Gets or initializes the token expiry timestamp from memory or storage
Retrieves the timestamp when the current access token expires using
a memory-first strategy:
Returns the in-memory timestamp if available for maximum performance
Falls back to loading from persistent storage if not in memory
The expiry timestamp is used to determine when to refresh tokens
and if the current token is still valid for API requests.
Returns null|number
The token expiry timestamp (milliseconds since epoch) or null if not available
Example
// Check if token needs immediate refresh constexpiry = getTokenExpiryState(); if (expiry && expiry - Date.now() < 60000) { // Token expires in less than a minute, refresh now refreshAccessToken(); }
Source
exportfunctiongetTokenExpiryState(): number | null { if (tokenExpiryTimestamp) { returntokenExpiryTimestamp; }
// Try to load from persistent storage returnretrieveTokenValue<number>(TOKEN_EXPIRY_KEY); }
Gets or initializes the token expiry timestamp from memory or storage
Retrieves the timestamp when the current access token expires using a memory-first strategy:
The expiry timestamp is used to determine when to refresh tokens and if the current token is still valid for API requests.