@@ -300,28 +300,28 @@ const handleFetchEvent: FetchEventCallback<OIDCRuntimeContext> = async (request,
300
300
redirect_uri : `${ installationURL } /visitor-auth/response` ,
301
301
} ) ;
302
302
303
- const accessTokenResp = await fetch ( accessTokenEndpoint , {
303
+ const tokenResp = await fetch ( accessTokenEndpoint , {
304
304
method : 'POST' ,
305
305
headers : { 'content-type' : 'application/x-www-form-urlencoded' } ,
306
306
body : searchParams ,
307
307
} ) ;
308
308
309
- if ( ! accessTokenResp . ok ) {
309
+ if ( ! tokenResp . ok ) {
310
310
return new Response (
311
- 'Error: Could not fetch access token from your authentication provider' ,
311
+ 'Error: Could not fetch ID token from your authentication provider' ,
312
312
{
313
313
status : 401 ,
314
314
} ,
315
315
) ;
316
316
}
317
317
318
- const accessTokenData = await accessTokenResp . json < OIDCTokenResponseData > ( ) ;
319
- if ( ! accessTokenData . access_token ) {
320
- logger . debug ( JSON . stringify ( accessTokenResp , null , 2 ) ) ;
318
+ const tokenRespData = await tokenResp . json < OIDCTokenResponseData > ( ) ;
319
+ if ( ! tokenRespData . id_token ) {
320
+ logger . debug ( JSON . stringify ( tokenResp , null , 2 ) ) ;
321
321
logger . debug (
322
- `Did not receive access token. Error: ${ accessTokenResp && 'error' in accessTokenResp ? accessTokenResp . error : '' } ${
323
- accessTokenResp && 'error_description' in accessTokenResp
324
- ? accessTokenResp . error_description
322
+ `Did not receive access token. Error: ${ tokenResp && 'error' in tokenResp ? tokenResp . error : '' } ${
323
+ tokenResp && 'error_description' in tokenResp
324
+ ? tokenResp . error_description
325
325
: ''
326
326
} `,
327
327
) ;
@@ -334,7 +334,7 @@ const handleFetchEvent: FetchEventCallback<OIDCRuntimeContext> = async (request,
334
334
}
335
335
336
336
// TODO: verify token using JWKS and check audience (aud) claims
337
- const decodedAccessToken = await jwt . decode ( accessTokenData . access_token ) ;
337
+ const decodedIdToken = await jwt . decode ( tokenRespData . id_token ) ;
338
338
const privateKey = context . environment . signingSecrets . siteInstallation ;
339
339
if ( ! privateKey ) {
340
340
return new Response ( 'Error: Missing private key from site installation' , {
@@ -346,7 +346,7 @@ const handleFetchEvent: FetchEventCallback<OIDCRuntimeContext> = async (request,
346
346
try {
347
347
jwtToken = await jwt . sign (
348
348
{
349
- ...( decodedAccessToken . payload ?? { } ) ,
349
+ ...( decodedIdToken . payload ?? { } ) ,
350
350
exp : Math . floor ( Date . now ( ) / 1000 ) + 1 * ( 60 * 60 ) ,
351
351
} ,
352
352
privateKey ,
0 commit comments