Skip to content

Conversation

@ryanbonial
Copy link
Member

@ryanbonial ryanbonial commented Jan 29, 2026

Description

Added a createLoggedInAuthState helper function to properly initialize the lastTokenRefresh timestamp for stamped tokens. This prevents unnecessary token refreshes when the tab becomes visible after being hidden, as the system now tracks when tokens were last refreshed.

The implementation:

  • Automatically sets lastTokenRefresh for stamped tokens (containing -st)
  • Preserves existing timestamps when updating tokens
  • Doesn't set timestamps for non-stamped tokens
  • Moved auth state types to a dedicated file for better organization

What to review

  • The implementation of createLoggedInAuthState in utils.ts
  • Usage of the helper throughout the codebase where auth states are created
  • The comprehensive test cases that verify the behavior with different token types
  • The fix for visibility change handling that now respects the timestamp

Testing

Added extensive test coverage for the new functionality:

  • Tests for createLoggedInAuthState with various token types and parameters
  • Tests for visibility change behavior with recent and old timestamps
  • Tests that verify the fix prevents unnecessary refreshes

Fun gif

needed

@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sdk-docs Ready Ready Preview, Comment Jan 29, 2026 8:48pm
sdk-kitchensink-react Ready Ready Preview, Comment Jan 29, 2026 8:48pm

Request Review

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