Module auth/storage/token-operations

Token Operations Service Module

Provides core token management operations including storage, retrieval, validation, and lifecycle management for Spotify authentication tokens.

Features:

  • Secure token storage in both memory and encrypted persistent storage
  • Token retrieval with memory/storage fallback strategy
  • Automatic token refresh scheduling
  • Token validity checking and expiration handling
  • Secure token clearing during logout
  • Coordination with Spotify API for token synchronization
  • Comprehensive error handling and logging
  • Circular dependency resolution through function injection

This module serves as the primary implementation for token-related operations that are exposed through the auth module's public API. It implements a dual storage strategy with memory state for performance and encrypted persistent storage for reliability across app restarts.

Functions

setScheduleTokenRefreshFunction
setTokens
clearTokens
getAccessToken
getRefreshToken
getTokenExpiry
isAuthenticated