File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ export async function findEnvironmentByApiKey(
6262 return environment ;
6363}
6464
65+ /** @deprecated We don't use public api keys anymore */
6566export async function findEnvironmentByPublicApiKey (
6667 apiKey : string ,
6768 branchName : string | undefined
@@ -85,7 +86,9 @@ export async function findEnvironmentByPublicApiKey(
8586 return environment ;
8687}
8788
88- export async function findEnvironmentById ( id : string ) : Promise < AuthenticatedEnvironment | null > {
89+ export async function findEnvironmentById (
90+ id : string
91+ ) : Promise < ( AuthenticatedEnvironment & { parentEnvironment : { apiKey : string } | null } ) | null > {
8992 const environment = await prisma . runtimeEnvironment . findFirst ( {
9093 where : {
9194 id,
@@ -94,6 +97,11 @@ export async function findEnvironmentById(id: string): Promise<AuthenticatedEnvi
9497 project : true ,
9598 organization : true ,
9699 orgMember : true ,
100+ parentEnvironment : {
101+ select : {
102+ apiKey : true ,
103+ } ,
104+ } ,
97105 } ,
98106 } ) ;
99107
Original file line number Diff line number Diff line change @@ -33,7 +33,10 @@ export async function validatePublicJwtKey(token: string): Promise<ValidatePubli
3333 return { ok : false , error : "Invalid Public Access Token, environment not found." } ;
3434 }
3535
36- const result = await validateJWT ( token , environment . apiKey ) ;
36+ const result = await validateJWT (
37+ token ,
38+ environment . parentEnvironment ?. apiKey ?? environment . apiKey
39+ ) ;
3740
3841 if ( ! result . ok ) {
3942 switch ( result . code ) {
You can’t perform that action at this time.
0 commit comments