WebclientWire
The WebclientWire class is the postMessage transport between a dashlet
iframe and the webclient host. It is the internal plumbing the facade
methods reuse; it is exported so consumers and tests can drive it directly.
1. Constructor
new WebclientWire(options: WebclientWireOptions): WebclientWire;
| Option | Meaning |
|---|---|
|
The window the wire listens on (structural |
|
Configured origin (never |
|
Response timeout in ms for |
|
Receives origin-validated host events: |
|
When |
2. Methods
start(): void; // attach the listener (if listen is true)
dispatch(event: MessageEventLike): void; // route an event in shared-listener mode
destroy(): void; // detach
get pendingCount(): number; // correlated calls awaiting a reply
call<T = unknown>(method: string, params: unknown = [], msgId?: string): Promise<T>;
call posts [method, params, { msgId }] on the wire and correlates the
reply by msgId. The id is unguessable: crypto.getRandomValues produces
dmsg- + 32 hex characters, with a sequential dashlet-msg-N fallback
where the API is absent. If the bound elapses without a reply, the pending
call rejects with a TimeoutError (a late reply is ignored); a host
{ error } payload rejects with the host error (see
error model).
3. Origin validation and outbound posts
Inbound: every message is validated against the configured origin (strict)
or the learned anchor (learning, after the first onInit); non-matching
messages are dropped. Origin comparison is
originMatches — the file-origin
group (including the desktop-app "null" serialization) matches
bidirectionally.
Outbound: posts target the last accepted origin, with one exception — a
host whose origin is a file-origin-group member is addressed as "*",
the only target token guaranteed delivery to it. With no trusted origin at
all, calls never post (and reject on the bounded timeout instead).