@@ -305,26 +305,26 @@ function getApiKeyResult(apiKey: string): {
305305 const type = isPublicApiKey ( apiKey )
306306 ? "PUBLIC"
307307 : isSecretApiKey ( apiKey )
308- ? "PRIVATE"
309- : isPublicJWT ( apiKey )
310- ? "PUBLIC_JWT"
311- : "PRIVATE" ; // Fallback to private key
308+ ? "PRIVATE"
309+ : isPublicJWT ( apiKey )
310+ ? "PUBLIC_JWT"
311+ : "PRIVATE" ; // Fallback to private key
312312 return { apiKey, type } ;
313313}
314314
315315export type AuthenticationResult =
316316 | {
317- type : "personalAccessToken" ;
318- result : PersonalAccessTokenAuthenticationResult ;
319- }
317+ type : "personalAccessToken" ;
318+ result : PersonalAccessTokenAuthenticationResult ;
319+ }
320320 | {
321- type : "organizationAccessToken" ;
322- result : OrganizationAccessTokenAuthenticationResult ;
323- }
321+ type : "organizationAccessToken" ;
322+ result : OrganizationAccessTokenAuthenticationResult ;
323+ }
324324 | {
325- type : "apiKey" ;
326- result : ApiAuthenticationResult ;
327- } ;
325+ type : "apiKey" ;
326+ result : ApiAuthenticationResult ;
327+ } ;
328328
329329type AuthenticationMethod = "personalAccessToken" | "organizationAccessToken" | "apiKey" ;
330330
@@ -341,11 +341,11 @@ type FilteredAuthenticationResult<
341341 T extends AllowedAuthenticationMethods = AllowedAuthenticationMethods
342342> =
343343 | ( T [ "personalAccessToken" ] extends true
344- ? Extract < AuthenticationResult , { type : "personalAccessToken" } >
345- : never )
344+ ? Extract < AuthenticationResult , { type : "personalAccessToken" } >
345+ : never )
346346 | ( T [ "organizationAccessToken" ] extends true
347- ? Extract < AuthenticationResult , { type : "organizationAccessToken" } >
348- : never )
347+ ? Extract < AuthenticationResult , { type : "organizationAccessToken" } >
348+ : never )
349349 | ( T [ "apiKey" ] extends true ? Extract < AuthenticationResult , { type : "apiKey" } > : never ) ;
350350
351351/**
@@ -501,10 +501,10 @@ export async function authenticatedEnvironmentForAuthentication(
501501 slug : slug ,
502502 ...( slug === "dev"
503503 ? {
504- orgMember : {
505- userId : user . id ,
506- } ,
507- }
504+ orgMember : {
505+ userId : user . id ,
506+ } ,
507+ }
508508 : { } ) ,
509509 } ,
510510 include : authIncludeBase ,
@@ -520,7 +520,9 @@ export async function authenticatedEnvironmentForAuthentication(
520520 const environment = await $replica . runtimeEnvironment . findFirst ( {
521521 where : {
522522 projectId : project . id ,
523- type : "PREVIEW" ,
523+ type : {
524+ in : [ "PREVIEW" , "DEVELOPMENT" ] ,
525+ } ,
524526 branchName : sanitizedBranch ,
525527 archivedAt : null ,
526528 } ,
@@ -532,10 +534,10 @@ export async function authenticatedEnvironmentForAuthentication(
532534 }
533535
534536 if ( ! environment . parentEnvironment ) {
535- throw json ( { error : "Branch not associated with a preview environment" } , { status : 400 } ) ;
537+ throw json ( { error : "Branch not associated with a parent environment" } , { status : 400 } ) ;
536538 }
537539
538- // PREVIEW envs reuse the parent's apiKey for downstream auth flows
540+ // PREVIEW envs (and DEVELOPMENT branches) reuse the parent's apiKey for downstream auth flows
539541 // (signed JWTs, internal-fetch helpers). Override before mapping so
540542 // the slim shape carries the parent's key.
541543 return toAuthenticated ( {
@@ -586,7 +588,9 @@ export async function authenticatedEnvironmentForAuthentication(
586588 const environment = await $replica . runtimeEnvironment . findFirst ( {
587589 where : {
588590 projectId : project . id ,
589- type : "PREVIEW" ,
591+ type : {
592+ in : [ "PREVIEW" , "DEVELOPMENT" ] ,
593+ } ,
590594 branchName : sanitizedBranch ,
591595 archivedAt : null ,
592596 } ,
0 commit comments