UNPKG

@gemini-wallet/core

Version:

Core SDK for Gemini Wallet integration with popup communication

39 lines 1.48 kB
import { AppMetadata, GeminiSdkMessage, GeminiSdkMessageResponse } from "./types"; type CommunicatorConfigParams = { appMetadata: AppMetadata; onDisconnectCallback?: () => void; }; /** * Handles communication between the SDK and the Gemini Wallet popup window * using the postMessage API for secure cross-origin communication. */ export declare class Communicator { private readonly appMetadata; private readonly url; private popup; private listeners; private onDisconnectCallback?; constructor({ appMetadata, onDisconnectCallback }: CommunicatorConfigParams); /** * Posts a message to the popup window */ postMessage(message: GeminiSdkMessage): Promise<void>; /** * Posts a request to the popup window and waits for a response */ postRequestAndWaitForResponse<M extends GeminiSdkMessage, R extends GeminiSdkMessageResponse>(request: GeminiSdkMessage): Promise<R>; /** * Listens for messages from the popup window that match a given predicate */ onMessage<M extends GeminiSdkMessage, R extends GeminiSdkMessageResponse>(predicate: (_: Partial<M>) => boolean): Promise<R>; /** * Closes the popup, rejects all pending requests and clears event listeners */ private onRequestCancelled; /** * Waits for the popup window to fully load and then sends app context */ waitForPopupLoaded(): Promise<Window>; } export {}; //# sourceMappingURL=communicator.d.ts.map