Repository navigation
Conversation
The `date` parameter was never read; the wall clock was used instead. The tolerance was applied past `exp`, keeping a token valid for 60 seconds after it expired. It now marks a token invalid once it is within the tolerance of `exp`, matching the JavaScript and Swift SDKs. The two tests named "IsInvalid" asserted true and only passed because `date` was ignored. They now assert false, and two new tests pin the tolerance window at 30 and 90 seconds before `exp`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
davidliu
requested review from
MaxHeimbrock and
xianshijing-lk
as code owners
October 30, 2026 08:12
🦋 Changeset detectedLatest commit: 5b78c5e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
Diffuse output: AARJAR |
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
TokenSourceResponse.hasValidToken(tolerance, date)had two problems:datewas never read. A freshDate()was used for every comparison.tolerancewas applied pastexp, so a cached token stayed valid for 60 seconds after it expired and was handed toRoom.connect, which the server rejects.The tolerance is now a refresh margin: a token within
toleranceofexpis reported invalid so the caching source fetches a fresh one. This matchesisResponseTokenValidin client-sdk-js andhasValidToken(withTolerance:)in client-sdk-swift, both of which have always subtracted the margin.Tests
tokenBeforeNbfIsInvalidandtokenAfterExpIsInvalidassertedtrueand only passed becausedatewas ignored. They now assertfalse.expis invalid, 90 seconds before is valid.CachingTokenSourceTestpasses (9 tests),spotlessCheckpasses.Behaviour change
The default validator used by
cached()now refetches tokens with under 60 seconds left instead of serving them from cache. Apps that passed their owndatewill now see it honoured.🤖 Generated with Claude Code