import type { ChainInfo } from '@aztec/aztec.js/account'; import { type ConnectedWalletInfo, type WalletInfo } from '../../types.js'; /** * A discovered wallet before key exchange. * Has basic info and MessagePort, but no shared key yet. * * Call {@link establishSecureChannel} to perform key exchange and get a connected wallet. */ export declare class DiscoveredWallet { /** Basic wallet information (id, name, icon, version) */ readonly info: WalletInfo; /** The MessagePort for private communication with the wallet */ readonly port: MessagePort; /** Request ID for correlation */ readonly requestId: string; constructor( /** Basic wallet information (id, name, icon, version) */ info: WalletInfo, /** The MessagePort for private communication with the wallet */ port: MessagePort, /** Request ID for correlation */ requestId: string); /** * Establishes a secure connection with this wallet. * * This method: * 1. Generates an ECDH key pair * 2. Sends public key to wallet over the MessagePort * 3. Receives wallet's public key * 4. Derives shared secret and computes verification hash locally * * **IMPORTANT**: Has a 2 second timeout for MITM defense. * Both parties must exchange keys relatively quickly. * * The verification hash is computed independently by both parties * and should be displayed to the user for visual comparison. * * @returns Connected wallet with shared key and verification hash * @throws Error if key exchange fails or times out */ establishSecureChannel(): Promise; } /** * A fully connected wallet with secure channel established. * Available after key exchange completes. */ export interface ConnectedWallet { /** Full wallet info including public key and verification hash */ info: ConnectedWalletInfo; /** The MessagePort for encrypted communication */ port: MessagePort; /** The derived AES-256-GCM shared key for encryption */ sharedKey: CryptoKey; } /** * Options for wallet discovery. */ export interface DiscoveryOptions { /** Application ID making the request */ appId: string; /** How long to wait for user approval (ms). Default: 60000 (60s) */ timeout?: number; /** * Callback invoked when a wallet is discovered. * Wallets are streamed as users approve them. */ onWalletDiscovered?: (wallet: DiscoveredWallet) => void; /** * AbortSignal for cancelling discovery early. * When aborted, cleanup happens immediately instead of waiting for timeout. */ signal?: AbortSignal; } /** * Provider for discovering Aztec wallet extensions. * * NOTE: Most users should use WalletManager instead of this class directly. * WalletManager provides a higher-level API with streaming support. * * The connection flow is split into two phases for security: * * 1. **Discovery Phase** ({@link discoverWallets}): * - Broadcasts a discovery request (NO public keys) * - Wallet shows pending request to user * - User must approve before wallet reveals itself * - Wallets are streamed via callback as they're approved * * 2. **Secure Channel Phase** ({@link DiscoveredWallet.establishSecureChannel}): * - Performs ECDH key exchange over private MessageChannel * - Both parties compute verification hash locally * - Has a 2s timeout for MITM defense * - Returns connected wallet with shared key and verification hash */ export declare class ExtensionProvider { /** * Discovers wallet extensions that user has approved. * * Wallets are streamed via the `onWalletDiscovered` callback as users approve them. * The promise resolves when the timeout expires or signal is aborted. * * @param chainInfo - Chain information to check if extensions support this network * @param options - Discovery options including appId, appName, timeout, and callback * @returns Promise that resolves when discovery completes */ static discoverWallets(chainInfo: ChainInfo, options: DiscoveryOptions): Promise; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0ZW5zaW9uX3Byb3ZpZGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZXh0ZW5zaW9uL3Byb3ZpZGVyL2V4dGVuc2lvbl9wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUt6RCxPQUFPLEVBQ0wsS0FBSyxtQkFBbUIsRUFLeEIsS0FBSyxVQUFVLEVBRWhCLE1BQU0sZ0JBQWdCLENBQUM7QUFReEI7Ozs7O0dBS0c7QUFDSCxxQkFBYSxnQkFBZ0I7SUFFekIseURBQXlEO2FBQ3pDLElBQUksRUFBRSxVQUFVO0lBQ2hDLGdFQUFnRTthQUNoRCxJQUFJLEVBQUUsV0FBVztJQUNqQyxpQ0FBaUM7YUFDakIsU0FBUyxFQUFFLE1BQU07SUFObkM7SUFDRSx5REFBeUQ7SUFDekMsSUFBSSxFQUFFLFVBQVU7SUFDaEMsZ0VBQWdFO0lBQ2hELElBQUksRUFBRSxXQUFXO0lBQ2pDLGlDQUFpQztJQUNqQixTQUFTLEVBQUUsTUFBTSxFQUMvQjtJQUVKOzs7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