accounts
Version:
Tempo Accounts SDK
56 lines • 2.63 kB
TypeScript
import { PostMessage } from 'wata';
import type * as Adapter from '../../Adapter.js';
import * as Mount from './mount.js';
/**
* Creates a postMessage adapter that forwards wallet RPC through a Wata
* postMessage session.
*
* One provider holds one session to one wallet window. The wallet page
* mounts in a hidden overlay iframe by default (a popup where iframes
* can't work — see {@link Mount.auto}), surfaces while requests are
* pending, and is put away once the queue drains: the iframe hides, a
* popup closes. Dismissing the UI or closing the window rejects the
* in-flight request; `wallet_disconnect` tears the session down.
*
* Safari account requests use a temporary popup because Safari rejects
* WebAuthn creation inside cross-origin iframes. When the wallet detects its
* iframe is occluded it asks to continue in a popup; the adapter remounts and
* re-sends the in-flight request there.
*/
export declare function postMessage(options: postMessage.Options): Adapter.Adapter;
export declare namespace postMessage {
/** Options for {@link postMessage}. */
type Options = {
/**
* Cleanup for a `target`-acquired handle, called when the session
* closes. Only used with {@link Options.target}; mounts own their
* handle cleanup. @default `handle.close()`
*/
close?: ((handle: Window | MessagePort) => void | Promise<void>) | undefined;
/** URL of the wallet's post-message page. */
host: string;
/** Data URI of the provider icon, announced via EIP-6963. */
icon?: Adapter.Meta['icon'] | undefined;
/**
* Where the wallet page lives and how it surfaces for requests.
* @default `Mount.auto()` — an overlay iframe, or a popup where
* iframes can't work (insecure context, no IO v2 for untrusted hosts).
*/
mount?: Mount.Factory | undefined;
/** Provider display name. */
name: string;
/** Reverse-DNS provider identifier. */
rdns: string;
/**
* Low-level override for the session's window handle, bypassing
* mounts entirely (no UI is created). Receives the page URL and
* returns a `Window` or `MessagePort`. A nullish handle rejects the
* request with `PostMessage.PopupBlockedError`.
*/
target?: ((parameters: {
/** Wallet page URL to mount. */
host: string | undefined;
}) => PostMessage.Target | null | undefined | Promise<PostMessage.Target | null | undefined>) | undefined;
};
}
//# sourceMappingURL=postMessage.d.ts.map