Skip to content

Commit 22cb853

Browse files
authored
Merge pull request #67 from Navigraph/fix/broken-token-expiry-check
2 parents 9a123cb + 693d01f commit 22cb853

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/nice-eyes-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@navigraph/auth": patch
3+
---
4+
5+
Fixed token expiry check. Previously, a token would be considered expired 3 minutes **after** it expired, but the intention was to treat it as expired 3 minutes **before** its real expiry.

packages/auth/src/util/isExpiredToken.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export default function isExpiredToken(accessToken?: string, threshold = EXPIRY_
1111
if (!accessToken) return true;
1212
const decodedToken = decodeAccessToken(accessToken);
1313
if (!decodedToken) return true;
14-
return decodedToken.exp * 1000 < Date.now() - threshold;
14+
return decodedToken.exp * 1000 < Date.now() + threshold;
1515
}

0 commit comments

Comments
 (0)