/** * Auth to Fund Event Mapper * * This module provides utilities to map Connect Auth callbacks to Fund postMessage events * for backward compatibility. When using @connect-xyz/auth-react instead of Fund iframe, * we need to translate Auth's callback-based API into Fund's postMessage-based API. * * Mapping: * - Auth onLoaded() -> FUND_APP_LOADED * - Auth onClose() -> FUND_CLOSE_BUTTON_CLICKED * - Auth onDeposit() with success status -> FUND_COMPLETED * - Auth onDeposit() with failed status -> FUND_FAILED * - Auth onError() -> FUND_ERROR (new event) * - Auth onEvent('deposit.submitted') -> FUND_DEPOSIT_SUBMITTED (new event) */ /** * Auth callback types from @connect-xyz/auth-react */ export type AuthDepositPayload = { data: { depositId: string; status: { value: string; details: string; occurredAt: string; }; assetId: string; networkId: string; amount?: string; }; }; export type AuthErrorPayload = { errorCode: string; reason: string; }; export type AuthEvent = { type: string; data: { depositId: string; }; }; /** * Creates Auth callbacks that automatically emit Fund-compatible postMessages * to the parent window for backward compatibility. * * @param origin - The origin to send postMessages to (typically window.location.origin) * @returns Object with Auth callback functions */ export declare function createAuthToFundCallbacks(origin: string): { /** * Maps Auth onLoaded to FUND_APP_LOADED */ onLoaded: () => void; /** * Maps Auth onClose to FUND_CLOSE_BUTTON_CLICKED */ onClose: () => void; /** * Maps Auth onDeposit to FUND_COMPLETED or FUND_FAILED * based on the deposit status value. * Also sends FUND_CONNECT_DEPOSIT event for Connect-specific deposit handling. */ onDeposit: (deposit: AuthDepositPayload) => void; /** * Maps Auth onError to FUND_ERROR */ onError: (error: AuthErrorPayload) => void; /** * Maps Auth onEvent to appropriate Fund events * Handles 'deposit.submitted' -> FUND_DEPOSIT_SUBMITTED * All other events are caught by default case -> FUND_CONNECT_EVENT (catch-all) */ onEvent: (event: AuthEvent) => void; };