Skip to content

fix: remove double token expiry buffer - #25

Merged
marcusolsson merged 1 commit into
mainfrom
fix/issue-5-double-buffer-wastes-token-lifetime
May 21, 2026
Merged

fix: remove double token expiry buffer#25
marcusolsson merged 1 commit into
mainfrom
fix/issue-5-double-buffer-wastes-token-lifetime

Conversation

@marcusolsson

Copy link
Copy Markdown
Contributor

Issue 5 from TODO.md

The token expiry buffer (ACCESS_TOKEN_EXPIRY_BUFFER_MS = 60s) was applied at both storage time and check time, creating a ~120s total headroom.

For a 300s token:

  • Before: stored expires = t0 + 240s, then accessTokenExpired() triggers at t0 + 180s40% waste
  • After: stored expires = t0 + 300s (raw), then accessTokenExpired() triggers at t0 + 240ssingle 60s buffer

Changes

  • pkce-flow.ts: Remove - ACCESS_TOKEN_EXPIRY_BUFFER_MS from exchangeCodeForTokens.
  • token.ts: Remove - ACCESS_TOKEN_EXPIRY_BUFFER_MS from refreshAccessTokenInternal.
  • auth.ts: No changeaccessTokenExpired() already correctly compares against now + BUFFER, which is the right single point for the buffer.
  • Cleans up unused imports of ACCESS_TOKEN_EXPIRY_BUFFER_MS.
  • Adds src/plugin/auth.test.ts with 5 tests for accessTokenExpired().

Refs: TODO.md Issue 5

@marcusolsson
marcusolsson merged commit fff3ca7 into main May 21, 2026
@marcusolsson
marcusolsson deleted the fix/issue-5-double-buffer-wastes-token-lifetime branch May 21, 2026 09:46
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.

1 participant