UNPKG

@slide-computer/signer-web

Version:

JavaScript and TypeScript library to communicate with web signers on the Internet Computer

63 lines (62 loc) 2 kB
import { type Transport } from "@slide-computer/signer"; import { PostMessageChannel } from "./postMessageChannel"; export declare class PostMessageTransportError extends Error { constructor(message: string); } export interface PostMessageTransportOptions { /** * Signer RPC url to send and receive messages from */ url: string; /** * Signer window feature config string * @example "toolbar=0,location=0,menubar=0,width=500,height=500,left=100,top=100" */ windowOpenerFeatures?: string; /** * Relying party window, used to listen for incoming message events * @default globalThis.window */ window?: Window; /** * Reasonable time in milliseconds in which the communication channel needs to be established * TODO: Lower this value once "not available, try again later" error is standardized and implemented * @default 120000 */ establishTimeout?: number; /** * Time in milliseconds of not receiving heartbeat responses after which the communication channel is disconnected * @default 2000 */ disconnectTimeout?: number; /** * Status polling rate in ms * @default 300 */ statusPollingRate?: number; /** * Get random uuid implementation for status messages * @default globalThis.crypto */ crypto?: Pick<Crypto, "randomUUID">; /** * Manage focus between relying party and signer window * @default true */ manageFocus?: boolean; /** * Close signer window on communication channel establish timeout * @default true */ closeOnEstablishTimeout?: boolean; /** * Detect attempts to establish channel outside of click handler * @default true */ detectNonClickEstablishment?: boolean; } export declare class PostMessageTransport implements Transport { #private; constructor(options: PostMessageTransportOptions); establishChannel(): Promise<PostMessageChannel>; }