/** * Options for `createIframeHost`. */ export interface IframeHostOptions { /** URL of the product iframe. */ iframeUrl: string; /** Container element the iframe is appended to. */ container: HTMLElement; /** * Called with the host end of a MessageChannel for each product document. * Hosts typically pipe this into a `WireProvider` (e.g. via * `createMessagePortProvider` from `@parity/truapi`). * * The first call happens immediately, before the iframe loads. A product * that navigates its whole document connects again, and the host gets a * fresh port once the new document sends its first frame. The function it * returned for the previous port is then called, and that port is closed; * any other return value is ignored. Each port is a new product session, * so it needs a connection of its own. * * With an opaque sandbox (no `allow-same-origin`) every document reports * the origin `"null"`, so a page the frame navigates to cannot be told * from the product, and only the first document is connected. */ onPort: (port: MessagePort) => (() => void) | void | Promise; /** * Optional explicit allow-list origin. Defaults to the origin of * `iframeUrl`. Throws if it disagrees with the iframe URL's origin. */ allowedOrigin?: string; /** Optional iframe Permissions Policy allow attribute. */ allow?: string; /** Override the default iframe sandbox attribute. */ sandbox?: string; } /** * Handle returned by `createIframeHost`. */ export interface IframeHost { iframe: HTMLIFrameElement; dispose: () => void; } /** * Embed a product iframe and transfer a `MessagePort` into it. The host * keeps the other end and passes it to a `WireProvider` (typically via * `createMessagePortProvider`). All product traffic flows over the * MessageChannel. */ export declare function createIframeHost(options: IframeHostOptions): IframeHost; export type { WireProvider } from "@parity/truapi";