• Renews the access token using the refresh token

    Uses the stored refresh token to obtain a new access token when the current one expires. Dynamically imports the token refresh module to avoid circular dependencies.

    This function:

    • Retrieves the current refresh token
    • Makes a request to Spotify's token endpoint
    • Updates stored tokens with the new access token
    • Schedules the next refresh based on expiry
    • Handles API errors with appropriate logging

    Returns Promise<boolean>

    Promise resolving to refresh success status

    // Refresh the token before making an important API call
    const refreshSucceeded = await refreshAccessToken();
    if (refreshSucceeded) {
    // Token is fresh, proceed with API call
    const result = await performCriticalOperation();
    } else {
    // Refresh failed, re-authenticate
    showLoginPrompt("Your session has expired. Please log in again.");
    }
    export async function refreshAccessToken(): Promise<boolean> {
    const mod = await import("./storage/token-refresh");
    return mod.refreshAccessToken();
    }