accounts
Version:
Tempo Accounts SDK
76 lines • 3.15 kB
TypeScript
/**
* Wallet-window mounts for the postMessage adapter — the UI half of a wata
* postMessage session.
*
* A mount owns where the wallet page lives (hidden overlay iframe or popup
* window) and how it surfaces: the adapter drives `show`/`hide` from its
* request queue, and the wata transport acquires and releases the window
* handle through `target`/`close`. Mirrors the bespoke `Dialog.iframe` /
* `Dialog.popup` UX without the bespoke messenger coupling.
*/
/** Mounted wallet-window UI driven by the adapter's request queue. */
export type Mount = {
/** Tears down the session's window handle (wata transport close). */
close: (handle: Window | MessagePort) => void;
/** Removes all mounted DOM. */
destroy: () => void;
/** Puts the UI away once the request queue drains. */
hide: () => void;
/** Mode the wallet page renders its approval chrome in. */
mode: 'iframe' | 'popup';
/** Surfaces and focuses the UI for a pending request. */
show: () => void;
/** Acquires the window handle for the wata session, mounting UI as needed. */
target: () => Window | null;
};
/** Creates a {@link Mount} bound to the wallet page URL. */
export type Factory = ((parameters: Factory.Parameters) => Mount) & {
/** Mode advertised to the wallet page (`?mode=`), known pre-instantiation. */
mode: 'iframe' | 'popup';
};
export declare namespace Factory {
/** Parameters for a mount factory. */
type Parameters = {
/** Wallet page URL (already origin- and mode-tagged). */
host: string;
/** Called when the user dismisses the UI without answering. */
onDismiss: () => void;
/**
* Called when the mounted wallet page was reloaded out from under the
* session (e.g. React hydration re-appending the iframe) and the
* session must re-handshake.
*/
onInvalidate: () => void;
};
}
/**
* Picks the default mount: an overlay iframe unless the context can't
* support one — insecure contexts lack WebAuthn in iframes, and without
* IntersectionObserver v2 an untrusted host can't run its occlusion
* defense.
*/
export declare function auto(options?: auto.Options): Factory;
export declare namespace auto {
/** Options for {@link auto}. */
type Options = {
/** Wallet hostname used for bundled and same-site trusted-host matching. */
source?: string | undefined;
/** Hostnames trusted to render the wallet in an iframe without IO v2. */
trustedHosts?: readonly string[] | undefined;
};
}
/** Mounts the wallet page in a hidden full-viewport overlay iframe. */
export declare function iframe(): Factory;
/** Opens the wallet page in a centered popup window per request burst. */
export declare function popup(options?: popup.Options): Factory;
export declare namespace popup {
/** Options for {@link popup}. */
type Options = {
/** Popup window dimensions. @default `{ width: 404, height: 600 }` */
size?: {
width: number;
height: number;
} | undefined;
};
}
//# sourceMappingURL=mount.d.ts.map