import { HostRuntime, type HostApiAccount } from "./host-runtime.js"; import { HostRuntimeRegistry } from "./host-runtime-registry.js"; import { type TrustedOriginMatcher } from "./scoped-frame.js"; import type { ChainStatus } from "./chain.js"; import type { RuntimeChainService } from "./runtime-chain-service.js"; import type { AccountCreateProofErrorKind, AccountRequestCredentialsErrorKind, HostApiOutcome, PaymentBalance, PaymentStatus } from "./types.js"; type HostRuntimeConstructorArg = ConstructorParameters[0]; type HostRuntimePort = MessagePort; export interface RemoteHostRuntimeSession { readonly productId: string; handleMessage(raw: Uint8Array): Promise; reset(): Promise; forgetRequest(requestId: string): Promise; isFollowRequest(requestId: string): Promise; encodeSignResponse(requestId: string, requestTag: number, signature: Uint8Array): Promise; encodeSignError(requestId: string, requestTag: number): Promise; encodeAccountGetResponse(requestId: string, publicKey: Uint8Array, name?: string | null): Promise; encodeAccountGetError(requestId: string, errorKind: AccountRequestCredentialsErrorKind, reason?: string | null): Promise; encodeAccountGetAliasResponse(requestId: string, context: Uint8Array, alias: Uint8Array): Promise; encodeAccountGetAliasError(requestId: string, errorKind: AccountRequestCredentialsErrorKind, reason?: string | null): Promise; encodeAccountCreateProofResponse(requestId: string, proof: Uint8Array): Promise; encodeAccountCreateProofError(requestId: string, errorKind: AccountCreateProofErrorKind, reason?: string | null): Promise; encodeDevicePermissionResponse(requestId: string, granted: boolean): Promise; encodeDevicePermissionError(requestId: string): Promise; encodeRemotePermissionResponse(requestId: string, granted: boolean): Promise; encodeRemotePermissionError(requestId: string): Promise; encodeCreateTransactionResponse(requestId: string, signedTxBytes: Uint8Array): Promise; encodeCreateTransactionError(requestId: string): Promise; encodeCreateTxNonProductResponse(requestId: string, signedTxBytes: Uint8Array): Promise; encodeCreateTxNonProductError(requestId: string): Promise; encodePaymentBalance(requestId: string, balance: PaymentBalance): Promise; encodePaymentBalanceInterrupt(requestId: string): Promise; encodePaymentTopUpResponse(requestId: string): Promise; encodePaymentTopUpError(requestId: string, reason: string): Promise; encodePaymentRequestResponse(requestId: string, receiptId: string): Promise; encodePaymentRequestError(requestId: string, reason: string): Promise; encodePaymentStatus(requestId: string, status: PaymentStatus): Promise; encodePaymentStatusInterrupt(requestId: string): Promise; encodeChainQueryResponse(requestId: string, jsonRpcResult: string): Promise; encodeChainQueryError(requestId: string): Promise; encodeChainRpcResponse(requestId: string, requestTag: number, jsonRpcMessage: string): Promise; encodeChainRpcError(requestId: string, requestTag: number, reason: string): Promise; encodeNavigateResponse(requestId: string): Promise; encodePushNotificationResponse(requestId: string): Promise; encodeChainFollowStop(requestId: string): Promise; encodeChainNotification(requestId: string, jsonRpcMessage: string): Promise; encodeStorageReadResponse(requestId: string, value: Uint8Array | null): Promise; encodeStorageWriteResponse(requestId: string): Promise; encodeStorageClearResponse(requestId: string): Promise; } export interface RemoteHostRuntime { setAccounts(accounts: readonly HostApiAccount[]): Promise; clearAccounts(): Promise; setSupportedChains(chains: readonly Uint8Array[]): Promise; session(productId: string): RemoteHostRuntimeSession; destroySession(productId: string): Promise; reset(): Promise; destroy(): void; } export interface RemoteRuntimeChainService { statuses(): Promise; connect(chainName: string): Promise; disconnect(chainName: string): Promise; refreshRouting(chainNames?: readonly string[]): Promise>; routingTable(): Promise>; supportedGenesisHashes(): Promise; routeChainByGenesisHash(genesisHash: Uint8Array): Promise; sendRpc(chainName: string, method: string, paramsJson: string): Promise; startSubscription(chainName: string, method: string, paramsJson: string, onMessage: (jsonRpc: string) => void, onAbort: (reason: string) => void): Promise<() => Promise>; destroy(): Promise; } /** * Serve a HostRuntime over a MessagePort-compatible transport. * * This is the runtime-frame side of the common-origin iframe pattern. */ export declare function serveHostRuntimePort(port: HostRuntimePort, runtime: HostRuntime, chainService?: RuntimeChainService | null): () => void; /** * Connect to a HostRuntime that is already exposed over a MessagePort. */ export declare function connectHostRuntimePort(port: HostRuntimePort): RemoteHostRuntime; export declare function connectHostRuntimeFramePort(port: HostRuntimePort, hasChainService: boolean): { runtime: RemoteHostRuntime; chainService: RemoteRuntimeChainService | null; }; export interface InstallHostRuntimeFrameOptions { sdk: HostRuntimeConstructorArg; scopeId?: string; registry?: HostRuntimeRegistry; trustedParentOrigin: TrustedOriginMatcher; createRuntime?: () => HostRuntime; createChainService?: () => RuntimeChainService | Promise | null> | null; } /** * Install the runtime-frame server inside a trusted common-origin iframe page. * * The host page should create the iframe, then call `mountHostRuntimeFrame()` * to transfer a MessagePort into it. Instantiate host-owned browser services * like SmoldotDriver in this page to keep cache/storage scoped to the shared * runtime origin. */ export declare function installHostRuntimeFrame(options: InstallHostRuntimeFrameOptions): () => void; export interface MountHostRuntimeFrameOptions { runtimeUrl: string; runtimeOrigin: string; parent?: HTMLElement; scopeId?: string; timeoutMs?: number; iframeAttributes?: Record; } export interface HostRuntimeFrameHandle { readonly iframe: HTMLIFrameElement; readonly runtime: RemoteHostRuntime; readonly chainService: RemoteRuntimeChainService | null; destroy(): void; } /** * Mount a hidden trusted runtime iframe and connect to its HostRuntime server. * * The iframe should be served from a common host-controlled origin, such as * `https://host.dot.li/runtime-frame.html`, so host-owned browser services can * live behind one trusted runtime boundary. Note that modern browsers may still * partition iframe storage by top-level site; hosts that need unpartitioned * durable cache reuse across pages must account for those browser policies. */ export declare function mountHostRuntimeFrame(options: MountHostRuntimeFrameOptions): Promise; export {}; //# sourceMappingURL=host-runtime-frame.d.ts.map