Skip to content

fix: accept cacheTTL: Infinity, keep rejecting NaN - #652

Merged
SociableSteve merged 2 commits into
masterfrom
copilot/cachettl-accept-infinity-again
Aug 4, 2026
Merged

fix: accept cacheTTL: Infinity, keep rejecting NaN#652
SociableSteve merged 2 commits into
masterfrom
copilot/cachettl-accept-infinity-again

Conversation

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

#640 inadvertently made cacheTTL: Infinity a breaking change by applying the same Number.isFinite guard used for the security fix on clockTimestamp/clockTolerance. Unlike those options, cacheTTL: Infinity is safe — the cache window is always clamped to the token's own exp, so no expired token is accepted.

Changes

  • src/verifier.js — relax cacheTTL guard from !Number.isFinite to Number.isNaN; clockTimestamp and clockTolerance keep their isFinite check
  • test/verifier.spec.js — remove the assertion that Infinity throws; add a test confirming an expired token is still rejected when cacheTTL: Infinity
  • README.md — note that Infinity is a valid value meaning "no cap beyond the token's own expiry"
// Before (#640 behaviour — unintended breaking change)
createVerifier({ key, cacheTTL: Infinity }) // throws

// After — works as pre-#640, expired tokens still rejected
createVerifier({ key, cacheTTL: Infinity }) // ok
createVerifier({ key, cacheTTL: NaN })      // still throws

Co-authored-by: SociableSteve <52213009+SociableSteve@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix cacheTTL to accept Infinity value again fix: accept cacheTTL: Infinity, keep rejecting NaN Aug 4, 2026
Copilot AI requested a review from SociableSteve August 4, 2026 08:11
@SociableSteve
SociableSteve marked this pull request as ready for review August 4, 2026 08:19
@SociableSteve SociableSteve removed their assignment Aug 4, 2026
@SociableSteve
SociableSteve self-requested a review August 4, 2026 08:20
@SociableSteve
SociableSteve merged commit e4cbab3 into master Aug 4, 2026
9 checks passed
@SociableSteve
SociableSteve deleted the copilot/cachettl-accept-infinity-again branch August 4, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cacheTTL should accept Infinity again (breaking change in #640 was not security-required)

3 participants