/** * `ExtensionChannel` — the channel for the host-extension topology, where the * mini-app IS the top-level page and the host is a browser extension. * * The mini-app and a content-script relay share the page's `window`, so a * plain `ApnaMessage` posted to `window` can't tell "outbound to host" from * "inbound from host". This channel wraps every message in a tiny * direction-tagged `RelayEnvelope`: * * SDK --{ __apnaRelay: 'to-host', message }--> content-script relay --> extension background * SDK <--{ __apnaRelay: 'to-app', message }-- content-script relay <-- extension background * * No host-extension exists yet, so this is lightly exercised (a mock relay in * unit tests) — but it implements the exact same `Channel` interface as * `IframeChannel`, so the protocol/bridge layers run over it unchanged. */ import { ApnaMessage } from '../protocol'; import { Channel } from './index'; /** Direction tags the SDK and the content-script relay agree on. */ export declare const RELAY_TO_HOST: "apna-relay:to-host"; export declare const RELAY_TO_APP: "apna-relay:to-app"; export interface ExtensionChannelOptions { /** Window to post to / listen on. Default: `window`. */ window?: Window; /** Expected origin for validation. Default `'*'`. */ targetOrigin?: string; } export declare class ExtensionChannel implements Channel { private readonly win; private readonly targetOrigin; private readonly handlers; private listening; private disposed; constructor(options?: ExtensionChannelOptions); send(message: ApnaMessage): void; onMessage(handler: (message: ApnaMessage) => void): () => void; /** * Resolves immediately — the content-script relay is injected at * `document_start`, so it is present before the mini-app's SDK runs. Real * protocol readiness is established by the handshake at the bridge layer. */ ready(): Promise; dispose(): void; private readonly onWindowMessage; private ensureListening; private stopListening; }