import { Entity } from "./entity"; /** * Authentication module interface */ export interface AuthModule { /** * Get the current authenticated user * @returns Promise resolving to the user entity */ me(): Promise; /** * Update the current authenticated user * @param data Updated user data * @returns Promise resolving to the updated user entity */ updateMe(data: Record): Promise; /** * Redirect to the login page * @param nextUrl Optional URL to redirect to after successful login */ login(nextUrl?: string): void; /** * Log out the current user * @param redirectUrl Optional URL to redirect to after logout * @returns Promise that resolves when logout is complete */ logout(redirectUrl?: string): Promise; /** * Set the authentication token * @param token Authentication token * @param saveToStorage Whether to save the token to localStorage */ setToken(token: string, saveToStorage?: boolean): void; /** * Check if the user is authenticated * @returns Promise resolving to authentication status */ isAuthenticated(): Promise; } /** * Options for token management */ export interface TokenOptions { /** * Key to use for storing the token in localStorage * @default "b44_access_token" */ storageKey?: string; /** * Parameter name to look for in URL * @default "access_token" */ paramName?: string; /** * Whether to save the token to localStorage * @default true */ saveToStorage?: boolean; /** * Whether to remove the token from URL after retrieval * @default true */ removeFromUrl?: boolean; } /** * Options for constructing a login URL */ export interface LoginUrlOptions { /** * Base URL of the server */ serverUrl: string; /** * Application ID */ appId: string | number; /** * Path to the login endpoint * @default "/login" */ loginPath?: string; }