Skip to content

Commit

Permalink
Fix expiration date unit
Browse files Browse the repository at this point in the history
  • Loading branch information
NSeydoux committed Jan 14, 2025
1 parent bf16c51 commit fe9012e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/browser/src/login/oidc/ClientRegistrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ export default class ClientRegistrar implements IClientRegistrar {
const expirationDate =
expiresAt !== undefined ? Number.parseInt(expiresAt, 10) : -1;
// Expiration is only applicable to confidential clients.
// Note that Date.now() is in milliseconds, and expirationDate in seconds.
const expired =
storedClientSecret !== undefined && Date.now() > expirationDate;
storedClientSecret !== undefined && Math.floor(Date.now() / 1000) > expirationDate;
if (storedClientId && isKnownClientType(storedClientType) && !expired) {
return storedClientSecret !== undefined
? {
Expand All @@ -97,6 +98,7 @@ export default class ClientRegistrar implements IClientRegistrar {
}

try {
console.log(`Registering a new client`);
const registeredClient = await registerClient(options, issuerConfig);
// Save info
const infoToSave: Record<string, string> = {
Expand Down
3 changes: 2 additions & 1 deletion packages/node/src/login/oidc/ClientRegistrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export default class ClientRegistrar implements IClientRegistrar {
const expired =
storedClientSecret !== undefined &&
storedClientType === "dynamic" &&
Date.now() > expirationDate;
// Note that Date.now() is in milliseconds, and expirationDate in seconds.
Math.floor(Date.now() / 1000) > expirationDate;
if (
storedClientId !== undefined &&
isKnownClientType(storedClientType) &&
Expand Down

0 comments on commit fe9012e

Please sign in to comment.