Module auth/storage/token-state

Token In-Memory State Management Module

Manages the ephemeral in-memory state of authentication tokens and related data for the application's authentication system, providing fast access to authentication information without requiring persistent storage lookups.

Features:

  • High-performance in-memory token storage for frequent access
  • Dual memory/storage architecture with persistent storage fallback
  • Refresh timer management for automatic token renewal
  • Token state getters and setters with consistent access patterns
  • Memory state cleanup during logout or token invalidation
  • Configurable token refresh safety margin
  • State initialization from persistent storage when needed

This module implements the memory-side of the dual memory/persistent storage architecture, optimizing token access performance by minimizing disk operations after initial loading. The state is synchronized with persistent storage when tokens change, ensuring data consistency and reliability.

Variables

REFRESH_MARGIN

Functions

getAccessTokenState
getRefreshTokenState
getTokenExpiryState
setAccessTokenState
setRefreshTokenState
setTokenExpiryState
getRefreshTimer
setRefreshTimer
clearRefreshTimer
clearTokenState