• Retrieves the stored refresh token

    Gets the currently stored refresh token used for obtaining new access tokens when they expire. Dynamically imports the token module to avoid circular dependencies.

    This function:

    • Attempts to retrieve token from memory state first
    • Falls back to secure storage if not in memory
    • Rehydrates memory state from storage when needed
    • Returns null if no valid refresh token exists
    • Handles all retrieval errors gracefully

    Returns Promise<null | string>

    Promise resolving to the refresh token or null if not authenticated

    // Check if we have a refresh token before attempting refresh
    const refreshToken = await getRefreshToken();
    if (refreshToken) {
    const success = await refreshAccessToken();
    if (success) {
    console.log("Successfully refreshed access token");
    }
    }
    export async function getRefreshToken(): Promise<string | null> {
    const mod = await import("./storage/token-operations");
    return mod.getRefreshToken();
    }