• Checks if the user is currently authenticated

    Verifies whether valid authentication tokens exist and are not expired. Dynamically imports the token module to avoid circular dependencies.

    This function:

    • Checks for the existence of both access and refresh tokens
    • Validates that the access token has not expired
    • Handles edge cases (missing tokens, invalid expiry)
    • Works correctly even after application restart

    Returns Promise<boolean>

    Promise resolving to authentication status

    // Check auth before making API request
    if (await isAuthenticated()) {
    // User is authenticated, proceed with operation
    const userData = await fetchUserProfile();
    displayUserData(userData);
    } else {
    // User is not authenticated, show login
    showLoginButton();
    hideUserContent();
    }
    export async function isAuthenticated(): Promise<boolean> {
    const mod = await import("./storage/token-operations");
    return mod.isAuthenticated();
    }