Skip to content

Commit 93e9748

Browse files
Validate expiresIn value in refreshToken to ensure proper numeric conversion and error handling
1 parent 0fbf449 commit 93e9748

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/nextjs/src/server/actions/refreshToken.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ const refreshToken = async (): Promise<RefreshResult> => {
9191
logger.warn('[refreshToken] Could not write session cookie — called from SSR rendering context.');
9292
}
9393

94-
const expiresInSeconds: number = parseInt(result.tokenResponse.expiresIn, 10);
94+
const rawExpiresIn: string | undefined = result.tokenResponse.expiresIn;
95+
const expiresInSeconds: number = parseInt(rawExpiresIn ?? '', 10);
96+
if (isNaN(expiresInSeconds)) {
97+
throw new Error(`[refreshToken] Invalid expiresIn value received: ${rawExpiresIn}`);
98+
}
9599
const expiresAt: number = Math.floor(Date.now() / 1000) + expiresInSeconds;
96100

97101
logger.debug('[refreshToken] Token refresh succeeded.');

0 commit comments

Comments
 (0)