/** Parsed OAuth callback parameters from dxc-auth query parameter */ export interface OAuthCallbackParams { /** The Dexie Cloud authorization code */ code: string; /** The OAuth provider that was used */ provider: string; /** The state parameter */ state: string; } /** * Parses OAuth callback parameters from the dxc-auth query parameter. * * The dxc-auth parameter contains base64url-encoded JSON with the following structure: * - On success: { "code": "...", "provider": "...", "state": "..." } * - On error: { "error": "...", "provider": "...", "state": "..." } * * @param url - The URL to parse (defaults to window.location.href) * @returns OAuthCallbackParams if valid callback, null otherwise * @throws OAuthError if there's an error in the callback */ export declare function parseOAuthCallback(url?: string): OAuthCallbackParams | null; /** * Validates the OAuth state parameter against the stored state. * * @param receivedState - The state from the callback URL * @returns true if valid, false otherwise */ export declare function validateOAuthState(receivedState: string): boolean; /** * Cleans up the dxc-auth query parameter from the URL. * Call this after successfully handling the callback to clean up the browser URL. */ export declare function cleanupOAuthUrl(): void; /** * Complete handler for OAuth callback. * * Parses the dxc-auth query parameter, validates state, and returns the parameters * needed to complete the login flow. * * Note: For web SPAs using full page redirect, the dexie-cloud-addon automatically * detects and processes the dxc-auth parameter when db.cloud.configure() is called. * This function is primarily useful for Capacitor/native apps handling deep links. * * @param url - The callback URL (defaults to window.location.href) * @returns OAuthCallbackParams if valid callback, null otherwise * @throws OAuthError on validation failure or if callback contains an error * * @example * ```typescript * // Capacitor deep link handler: * App.addListener('appUrlOpen', async ({ url }) => { * const callback = handleOAuthCallback(url); * if (callback) { * await db.cloud.login({ oauthCode: callback.code, provider: callback.provider }); * } * }); * ``` */ export declare function handleOAuthCallback(url?: string): OAuthCallbackParams | null;