@@ -5,7 +5,10 @@ var __importDefault =
55 return mod && mod . __esModule ? mod : { default : mod } ;
66 } ;
77Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
8- exports . getActualClientIdFromDevelopmentClientId = exports . isUsingDevelopmentClientId = exports . DEV_OAUTH_REDIRECT_URL = void 0 ;
8+ exports . DEV_OAUTH_REDIRECT_URL = void 0 ;
9+ exports . isUsingDevelopmentClientId = isUsingDevelopmentClientId ;
10+ exports . getActualClientIdFromDevelopmentClientId = getActualClientIdFromDevelopmentClientId ;
11+ exports . default = NewProvider ;
912const thirdpartyUtils_1 = require ( "../../../thirdpartyUtils" ) ;
1013const utils_1 = require ( "../../../utils" ) ;
1114const pkce_challenge_1 = __importDefault ( require ( "pkce-challenge" ) ) ;
@@ -16,21 +19,19 @@ const DEV_OAUTH_AUTHORIZATION_URL = "https://supertokens.io/dev/oauth/redirect-t
1619exports . DEV_OAUTH_REDIRECT_URL = "https://supertokens.io/dev/oauth/redirect-to-app" ;
1720// If Third Party login is used with one of the following development keys, then the dev authorization url and the redirect url will be used.
1821const DEV_OAUTH_CLIENT_IDS = [
19- "1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com" ,
22+ "1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com" , // google
2023 "467101b197249757c71f" , // github
2124] ;
2225const DEV_KEY_IDENTIFIER = "4398792-" ;
2326function isUsingDevelopmentClientId ( client_id ) {
2427 return client_id . startsWith ( DEV_KEY_IDENTIFIER ) || DEV_OAUTH_CLIENT_IDS . includes ( client_id ) ;
2528}
26- exports . isUsingDevelopmentClientId = isUsingDevelopmentClientId ;
2729function getActualClientIdFromDevelopmentClientId ( client_id ) {
2830 if ( client_id . startsWith ( DEV_KEY_IDENTIFIER ) ) {
2931 return client_id . split ( DEV_KEY_IDENTIFIER ) [ 1 ] ;
3032 }
3133 return client_id ;
3234}
33- exports . getActualClientIdFromDevelopmentClientId = getActualClientIdFromDevelopmentClientId ;
3435function accessField ( obj , key ) {
3536 const keyParts = key . split ( "." ) ;
3637 for ( const k of keyParts ) {
@@ -166,12 +167,12 @@ function NewProvider(input) {
166167 if ( input . config . clients === undefined || input . config . clients . length !== 1 ) {
167168 throw new Error ( "please provide exactly one client config or pass clientType or tenantId" ) ;
168169 }
169- return configUtils_1 . getProviderConfigForClient ( input . config , input . config . clients [ 0 ] ) ;
170+ return ( 0 , configUtils_1 . getProviderConfigForClient ) ( input . config , input . config . clients [ 0 ] ) ;
170171 }
171172 if ( input . config . clients !== undefined ) {
172173 for ( const client of input . config . clients ) {
173174 if ( client . clientType === clientType ) {
174- return configUtils_1 . getProviderConfigForClient ( input . config , client ) ;
175+ return ( 0 , configUtils_1 . getProviderConfigForClient ) ( input . config , client ) ;
175176 }
176177 }
177178 }
@@ -199,7 +200,7 @@ function NewProvider(input) {
199200 ? void 0
200201 : _a . includes ( "S256" ) ;
201202 if ( impl . config . clientSecret === undefined || impl . config . forcePKCE || isS256MethodSupported ) {
202- const { code_challenge, code_verifier } = pkce_challenge_1 . default ( 64 ) ; // According to https://www.rfc-editor.org/rfc/rfc7636, length must be between 43 and 128
203+ const { code_challenge, code_verifier } = ( 0 , pkce_challenge_1 . default ) ( 64 ) ; // According to https://www.rfc-editor.org/rfc/rfc7636, length must be between 43 and 128
203204 queryParams [ "code_challenge" ] = code_challenge ;
204205 queryParams [ "code_challenge_method" ] = "S256" ;
205206 pkceCodeVerifier = code_verifier ;
@@ -263,9 +264,9 @@ function NewProvider(input) {
263264 accessTokenAPIParams [ "redirect_uri" ] = exports . DEV_OAUTH_REDIRECT_URL ;
264265 }
265266 /* Transformation needed for dev keys END */
266- const tokenResponse = await thirdpartyUtils_1 . doPostRequest ( tokenAPIURL , accessTokenAPIParams ) ;
267+ const tokenResponse = await ( 0 , thirdpartyUtils_1 . doPostRequest ) ( tokenAPIURL , accessTokenAPIParams ) ;
267268 if ( tokenResponse . status >= 400 ) {
268- logger_1 . logDebugMessage (
269+ ( 0 , logger_1 . logDebugMessage ) (
269270 `Received response with status ${ tokenResponse . status } and body ${ tokenResponse . stringResponse } `
270271 ) ;
271272 throw new Error (
@@ -283,28 +284,25 @@ function NewProvider(input) {
283284 } ;
284285 if ( idToken && impl . config . jwksURI !== undefined ) {
285286 if ( jwks === undefined ) {
286- jwks = jose_1 . createRemoteJWKSet ( new URL ( impl . config . jwksURI ) ) ;
287+ jwks = ( 0 , jose_1 . createRemoteJWKSet ) ( new URL ( impl . config . jwksURI ) ) ;
287288 }
288- rawUserInfoFromProvider . fromIdTokenPayload = await thirdpartyUtils_1 . verifyIdTokenFromJWKSEndpointAndGetPayload (
289- idToken ,
290- jwks ,
291- {
292- audience : getActualClientIdFromDevelopmentClientId ( impl . config . clientId ) ,
293- }
294- ) ;
289+ rawUserInfoFromProvider . fromIdTokenPayload = await ( 0 ,
290+ thirdpartyUtils_1 . verifyIdTokenFromJWKSEndpointAndGetPayload ) ( idToken , jwks , {
291+ audience : getActualClientIdFromDevelopmentClientId ( impl . config . clientId ) ,
292+ } ) ;
295293 if ( impl . config . validateIdTokenPayload !== undefined ) {
296294 await impl . config . validateIdTokenPayload ( {
297295 idTokenPayload : rawUserInfoFromProvider . fromIdTokenPayload ,
298296 clientConfig : impl . config ,
299- userContext : utils_1 . getUserContext ( userContext ) ,
297+ userContext : ( 0 , utils_1 . getUserContext ) ( userContext ) ,
300298 } ) ;
301299 }
302300 }
303301 if ( impl . config . validateAccessToken !== undefined && accessToken !== undefined ) {
304302 await impl . config . validateAccessToken ( {
305303 accessToken : accessToken ,
306304 clientConfig : impl . config ,
307- userContext : utils_1 . getUserContext ( userContext ) ,
305+ userContext : ( 0 , utils_1 . getUserContext ) ( userContext ) ,
308306 } ) ;
309307 }
310308 if ( accessToken && impl . config . userInfoEndpoint !== undefined ) {
@@ -330,13 +328,13 @@ function NewProvider(input) {
330328 }
331329 }
332330 }
333- const userInfoFromAccessToken = await thirdpartyUtils_1 . doGetRequest (
331+ const userInfoFromAccessToken = await ( 0 , thirdpartyUtils_1 . doGetRequest ) (
334332 impl . config . userInfoEndpoint ,
335333 queryParams ,
336334 headers
337335 ) ;
338336 if ( userInfoFromAccessToken . status >= 400 ) {
339- logger_1 . logDebugMessage (
337+ ( 0 , logger_1 . logDebugMessage ) (
340338 `Received response with status ${ userInfoFromAccessToken . status } and body ${ userInfoFromAccessToken . stringResponse } `
341339 ) ;
342340 throw new Error (
@@ -360,4 +358,3 @@ function NewProvider(input) {
360358 }
361359 return impl ;
362360}
363- exports . default = NewProvider ;
0 commit comments