Skip to content

fix(auth): update token expiration buffer to 5 minutes - #10535

Open
macastelaz wants to merge 2 commits into
firebase:mainfrom
macastelaz:fix/auth-token-refresh-buffer
Open

macastelaz wants to merge 2 commits into
firebase:mainfrom
macastelaz:fix/auth-token-refresh-buffer

Conversation

@macastelaz

Copy link
Copy Markdown
Contributor

Summary

Updates Buffer.TOKEN_REFRESH in packages/auth/src/core/user/token_manager.ts from 30_000 (30 seconds) to 5 * 60 * 1000 (5 minutes) so that on-demand StsTokenManager.isExpired checks (user.getIdToken()) match:

  • The documented User.getIdToken() behavior ("Returns the current token if it has not expired or if it will not expire in the next five minutes").
  • The 5-minute Duration.OFFSET (5 * 1000 * 60) used by ProactiveRefresh (proactive_refresh.ts).
  • The 5-minute on-demand refresh buffer used across the other Firebase Auth SDKs (iOS, Android, C++).

Also updates unit test fixtures that previously used 100-second token lifetimes (100_000 ms) to account for the 5-minute expiration buffer while preserving existing test coverage.

Testing

  • yarn --cwd packages/auth test:node:unit (714 passing)
  • yarn --cwd packages/auth test:browser:unit (1,082 passing)
  • yarn format & yarn --cwd packages/auth lint

@macastelaz
macastelaz requested review from a team and sam-gc as code owners October 27, 2026 03:09
@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0c886e9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/auth Patch
@firebase/auth-compat Patch
firebase Patch

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the on-demand ID token expiration buffer (Buffer.TOKEN_REFRESH) from 30 seconds to 5 minutes to match the proactive refresh offset, updating relevant tests and mocks accordingly. Feedback highlights a critical issue in phone.test.ts where variable shadowing leads to a vacuous assertion, meaning the test passes without actually verifying the token update.

Comment thread packages/auth/src/platform_browser/strategies/phone.test.ts
@macastelaz
macastelaz requested a review from hsubox76 October 27, 2026 03:40

This branch has not been deployed

No deployments
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