/** * IframeWallet — Wallet proxy that communicates with a web wallet loaded in an iframe. * * This mirrors {@link ExtensionWallet} from `@aztec/wallet-sdk/extension/provider` but uses * `window.postMessage` / `window.addEventListener('message')` instead of MessagePort. * * The wire protocol (encrypted {@link WalletMessage} / {@link WalletResponse}) is identical. */ import type { ChainInfo } from '@aztec/aztec.js/account'; import { type Wallet } from '@aztec/aztec.js/wallet'; import { type DisconnectCallback, type HeartbeatOptions, type WalletSdkLogger } from '../../types.js'; /** * A wallet implementation that communicates with a web wallet loaded in an iframe * using encrypted postMessage. * * Uses the same Proxy pattern as {@link ExtensionWallet}: intercepts property access, * checks if the property is a Wallet method via {@link WalletSchema}, and routes the * call through an encrypted postMessage channel. * * @example * ```typescript * const wallet = IframeWallet.create(walletId, sessionId, iframeWindow, walletOrigin, sharedKey, chainInfo, appId); * const accounts = await wallet.asWallet().getAccounts(); * ``` */ export declare class IframeWallet { private chainInfo; private appId; private walletId; private sessionId; private iframeWindow; private walletOrigin; private sharedKey; private inFlight; private disconnected; private disconnectCallbacks; private messageListener; private heartbeatTimer; private lastInboundAt; private log; private heartbeatIntervalMs; private heartbeatDeadAfterMs; private constructor(); /** * Creates a proxied IframeWallet that implements the {@link Wallet} interface. * * All Wallet method calls are intercepted by a Proxy, encrypted with the shared * AES-256-GCM key, sent via postMessage, and the response is decrypted and * validated against {@link WalletSchema}. * * @param walletId - Unique identifier of the remote wallet * @param sessionId - Session identifier from the key exchange * @param iframeWindow - The iframe's contentWindow to post messages to * @param walletOrigin - Origin of the wallet iframe (for postMessage targeting) * @param sharedKey - AES-256-GCM key derived from ECDH key exchange * @param chainInfo - Network information (chainId and version) * @param appId - Application identifier for the requesting dApp * @param logger - Optional logger; defaults to a no-op logger to keep extension/page bundles small * @param heartbeatOptions - Optional override for heartbeat tuning (mostly useful for tests) * @returns A proxied IframeWallet — call `.asWallet()` to get the typed `Wallet` */ static create(walletId: string, sessionId: string, iframeWindow: Window, walletOrigin: string, sharedKey: CryptoKey, chainInfo: ChainInfo, appId: string, logger?: WalletSdkLogger, heartbeatOptions?: HeartbeatOptions): IframeWallet; /** * Returns this wallet as a typed {@link Wallet} interface. * When accessed through the Proxy (via `create()`), returns the proxy itself. */ asWallet(): Wallet; private handleEncryptedResponse; private postMessage; /** * Start liveness probing while at least one request is in flight. PINGs are * unencrypted control messages — older wallet handlers that don't understand * them simply drop them, but any inbound traffic (PONG, encrypted response, * disconnect notice) resets the idle timer, so a slow-but-alive legacy wallet * never trips a false disconnect. */ private startHeartbeat; private maybeStopHeartbeat; private heartbeatTick; private handleDisconnect; onDisconnect(callback: DisconnectCallback): () => void; isDisconnected(): boolean; disconnect(): void; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWZyYW1lX3dhbGxldC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2lmcmFtZS9wcm92aWRlci9pZnJhbWVfd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7O0dBT0c7QUFDSCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN6RCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sd0JBQXdCLENBQUM7QUFPbkUsT0FBTyxFQUdMLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUssZ0JBQWdCLEVBS3JCLEtBQUssZUFBZSxFQUNyQixNQUFNLGdCQUFnQixDQUFDO0FBYXhCOzs7Ozs7Ozs7Ozs7O0dBYUc7QUFDSCxxQkFBYSxZQUFZO0lBWXJCLE9BQU8sQ0FBQyxTQUFTO0lBQ2pCLE9BQU8sQ0FBQyxLQUFLO0lBQ2IsT0FBTyxDQUFDLFFBQVE7SUFDaEIsT0FBTyxDQUFDLFNBQVM7SUFDakIsT0FBTyxDQUFDLFlBQVk7SUFDcEIsT0FBTyxDQUFDLFlBQVk7SUF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