@@ -10,6 +10,32 @@ const parseCookies = (req: IncomingMessage) => {
1010 return cookie . parse ( req . headers [ 'cookie' ] || '' ) ;
1111} ;
1212
13+ type ClerkClient = ReturnType < typeof Clerk > ;
14+
15+ export async function loadInterstitial ( {
16+ clerkClient,
17+ requestState,
18+ } : {
19+ clerkClient : ClerkClient ;
20+ requestState : RequestState ;
21+ } ) {
22+ /**
23+ * When publishable key or frontendApi is present utilize the localInterstitial method
24+ * and avoid the extra network call
25+ */
26+ if ( requestState . publishableKey || requestState . frontendApi ) {
27+ return clerkClient . localInterstitial ( {
28+ frontendApi : requestState . frontendApi ,
29+ publishableKey : requestState . publishableKey ,
30+ proxyUrl : requestState . proxyUrl ,
31+ signInUrl : requestState . signInUrl ,
32+ isSatellite : requestState . isSatellite ,
33+ domain : requestState . domain ,
34+ } ) ;
35+ }
36+ return await clerkClient . remotePrivateInterstitial ( ) ;
37+ }
38+
1339export const authenticateRequest = ( opts : {
1440 clerkClient : ReturnType < typeof Clerk > ;
1541 apiKey : string ;
@@ -116,6 +142,6 @@ const satelliteAndMissingProxyUrlAndDomain =
116142 'Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl' ;
117143const satelliteAndMissingSignInUrl = `
118144Invalid signInUrl. A satellite application requires a signInUrl for development instances.
119- Check if signInUrl is missing from your configuration or it is not a absolute URL.` ;
145+ Check if signInUrl is missing from your configuration or if it is not an absolute URL.` ;
120146const missingProto =
121- "Cannot determine the request protocol. Please make sure you've set the X-Forwarded-Proto header with the request protocol (http or https)." ;
147+ "Cannot determine the request protocol. Please ensure you've set the X-Forwarded-Proto header with the request protocol (http or https)." ;
0 commit comments