fix(sdk): check token expiry in isAuthenticated()#80
Closed
aarushisingh04 wants to merge 1 commit into
Closed
Conversation
danhill-stripe
approved these changes
May 7, 2026
Contributor
danhill-stripe
left a comment
There was a problem hiding this comment.
Good catch, thanks!
danhill-stripe
requested changes
May 7, 2026
Contributor
danhill-stripe
left a comment
There was a problem hiding this comment.
Actually, looking more closely. The expires_at is only when the refresh token is needed for a new access token, not when the user needs to re-authenticate.
Author
|
@danhill-stripe oh right, checked |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
identified and fixed a bug where
isAuthenticated()instorage.tsreturnedtruefor expired tokens. expired sessions were treated as valid until the next API call returned a 401 meaning that any auth-gated command would proceed assuming a valid token.changes made
isAuthenticated()in bothStorageandMemoryStorageto checkauth.expires_atagainstDate.now()returningfalseif the token has expired.packages/sdk/src/utils/__tests__/auth-expiry.test.tscovering: valid tokens, expired tokens, the exact expiry boundary (>=), pre-setexpires_attaking precedence overexpires_inand bothclearAuth()andclearAll()resetting authenticated state.MemoryStoragewarning thatwithComputedExpirystampsexpires_atat construction time, so tests usingvi.useFakeTimers()should callsetAuth()after installing fake timers rather than passinginitialAuthdirectly.testing
npx turbo run test --filter @stripe/link-sdk(all pass).biome check.