/** * Regweb Proxy Client * * A lightweight client for mobile apps to communicate with the serverless proxy. * This client handles token storage locally and sends them with each request. * * Key features: * - No SDK dependencies - just fetch calls * - Bearer token authentication with your API key * - Automatic token management * - Works with Expo, React Native, and web * * Token lifetimes: * - Access token: varies (typically 1 hour), returned in `expires_in` * - Refresh token: 14 days (1209600 seconds) from issuance * * @example * ```typescript * const client = new RegwebProxyClient({ * proxyUrl: 'https://regweb-auth-proxy.workers.dev', * apiKey: 'your-api-key', * }); * * await client.login('username', 'password'); * const user = await client.getUser(); * ``` */ export interface ProxyClientConfig { /** URL of the deployed proxy (e.g., https://your-worker.workers.dev) */ proxyUrl: string; /** API key for authenticating with the proxy */ apiKey: string; /** Optional timeout in milliseconds (default: 30000) */ timeout?: number; } export interface AuthResult { access_token: string; refresh_token: string; expires_in: number; token_type: string; scope: string; expiresAt: string; } export interface User { username: string; firstname: string; lastname: string; is_member: boolean; email: string; member?: Member; } export interface Member { id: number; firstname: string; lastname: string; email: string; [key: string]: unknown; } export interface Tokens { accessToken: string; refreshToken: string; /** Access token expiry (ISO string) */ expiresAt: string; /** Refresh token expiry (ISO string) - 14 days from issuance */ refreshTokenExpiresAt: string; } export declare class RegwebProxyClient { private config; private tokens; constructor(config: ProxyClientConfig); /** Internal method to make requests to the proxy */ private request; /** Authenticate with username and password */ login(username: string, password: string): Promise; /** Refresh the access token using the stored refresh token */ refreshToken(): Promise; /** Get the current user's data */ getUser(expandMember?: boolean): Promise; /** Get a member by ID */ getMember(id: number): Promise; /** Update a member's data */ updateMember(id: number, data: Partial): Promise<{ success: boolean; }>; /** Request a password reset email */ lostPassword(identification: string): Promise<{ success: boolean; }>; /** Clear local tokens (logout) */ logout(): void; /** Check if the user has a valid (non-expired) access token */ isLoggedIn(): boolean; /** Check if the refresh token is expired (14 day lifetime) */ isRefreshTokenExpired(): boolean; /** Get the current tokens (for persistence) */ getTokens(): Tokens | null; /** Restore tokens (e.g., from AsyncStorage) */ setTokens(tokens: Tokens): void; } export default RegwebProxyClient; //# sourceMappingURL=proxy-client.d.ts.map