• Gets or initializes the access token from memory or storage

    Retrieves the current access token using a memory-first strategy:

    1. Returns the in-memory token if available for maximum performance
    2. Falls back to loading from persistent storage if not in memory

    This dual approach balances performance with reliability, ensuring token availability across application restarts.

    Returns null | string

    The current access token or null if not available

    // Get access token for API request
    const token = getAccessTokenState();
    if (token) {
    headers.Authorization = `Bearer ${token}`;
    }
    export function getAccessTokenState(): string | null {
    if (currentAccessToken) {
    return currentAccessToken;
    }

    // Try to load from persistent storage
    return retrieveTokenValue<string>(ACCESS_TOKEN_KEY);
    }