Skip to content

Commit

Permalink
fix: add debug logs for experimental feature
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogrodzki committed Sep 6, 2024
1 parent 0635aef commit 41ef1df
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,26 @@ export async function handleExpiredToken<T>(
switch ((e as AuthError)?.code) {
case AuthErrorCode.NO_MATCHING_KID:
if (shouldExpireOnNoMatchingKidError) {
return handleVerifyTokenError(e, onExpired, onError);
return handleVerifyTokenError(
e,
async (e) => {
const result = await onExpired(e);

debug(
'experimental_refresh_on_expired_kid: Successfully refreshed token after kid has expired'
);

return result;
},
(e) => {
debug(
'experimental_refresh_on_expired_kid: Error when trying to refresh token after kid has expired',
{message: (e as Error)?.message, stack: (e as Error)?.stack}
);

return onError(e);
}
);
}

return onError(e);
Expand Down

0 comments on commit 41ef1df

Please sign in to comment.