@net-mesh/browser 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +517 -0
  2. package/LICENSE-APACHE +190 -0
  3. package/LICENSE-MIT +21 -0
  4. package/README.md +666 -0
  5. package/dist/async-queue.d.ts +26 -0
  6. package/dist/async-queue.js +62 -0
  7. package/dist/credential.d.ts +70 -0
  8. package/dist/credential.js +95 -0
  9. package/dist/errors.d.ts +400 -0
  10. package/dist/errors.js +726 -0
  11. package/dist/events.d.ts +232 -0
  12. package/dist/events.js +298 -0
  13. package/dist/identity.d.ts +40 -0
  14. package/dist/identity.js +78 -0
  15. package/dist/index.bundle.js +2 -0
  16. package/dist/index.d.ts +38 -0
  17. package/dist/index.js +46 -0
  18. package/dist/leader/events.d.ts +111 -0
  19. package/dist/leader/events.js +116 -0
  20. package/dist/leader/index.d.ts +14 -0
  21. package/dist/leader/index.js +11 -0
  22. package/dist/leader/session.d.ts +539 -0
  23. package/dist/leader/session.js +770 -0
  24. package/dist/leader/wasm.d.ts +123 -0
  25. package/dist/leader/wasm.js +39 -0
  26. package/dist/lobby.d.ts +183 -0
  27. package/dist/lobby.js +504 -0
  28. package/dist/local.d.ts +80 -0
  29. package/dist/local.js +160 -0
  30. package/dist/net_leaf.d.ts +1494 -0
  31. package/dist/net_leaf.js +3753 -0
  32. package/dist/net_leaf_bg.wasm +0 -0
  33. package/dist/net_leaf_bg.wasm.d.ts +137 -0
  34. package/dist/netcode/client.d.ts +102 -0
  35. package/dist/netcode/client.js +296 -0
  36. package/dist/netcode/clock.d.ts +45 -0
  37. package/dist/netcode/clock.js +54 -0
  38. package/dist/netcode/host.d.ts +118 -0
  39. package/dist/netcode/host.js +276 -0
  40. package/dist/netcode/index.d.ts +19 -0
  41. package/dist/netcode/index.js +14 -0
  42. package/dist/netcode/interpolate.d.ts +50 -0
  43. package/dist/netcode/interpolate.js +100 -0
  44. package/dist/netcode/wire.d.ts +125 -0
  45. package/dist/netcode/wire.js +117 -0
  46. package/dist/node.d.ts +908 -0
  47. package/dist/node.js +1085 -0
  48. package/dist/org.d.ts +412 -0
  49. package/dist/org.js +567 -0
  50. package/dist/peer-driver.d.ts +117 -0
  51. package/dist/peer-driver.js +224 -0
  52. package/dist/store/assembly.d.ts +176 -0
  53. package/dist/store/assembly.js +325 -0
  54. package/dist/store/chunker.d.ts +83 -0
  55. package/dist/store/chunker.js +190 -0
  56. package/dist/store/core.d.ts +136 -0
  57. package/dist/store/core.js +477 -0
  58. package/dist/store/definition.d.ts +23 -0
  59. package/dist/store/definition.js +83 -0
  60. package/dist/store/errors.d.ts +77 -0
  61. package/dist/store/errors.js +94 -0
  62. package/dist/store/host.d.ts +247 -0
  63. package/dist/store/host.js +675 -0
  64. package/dist/store/index.d.ts +50 -0
  65. package/dist/store/index.js +40 -0
  66. package/dist/store/interest.d.ts +40 -0
  67. package/dist/store/interest.js +77 -0
  68. package/dist/store/inventory.d.ts +81 -0
  69. package/dist/store/inventory.js +140 -0
  70. package/dist/store/join.d.ts +118 -0
  71. package/dist/store/join.js +724 -0
  72. package/dist/store/json.d.ts +50 -0
  73. package/dist/store/json.js +283 -0
  74. package/dist/store/ledger.d.ts +187 -0
  75. package/dist/store/ledger.js +292 -0
  76. package/dist/store/owner.d.ts +616 -0
  77. package/dist/store/owner.js +1711 -0
  78. package/dist/store/patch.d.ts +70 -0
  79. package/dist/store/patch.js +166 -0
  80. package/dist/store/player.d.ts +65 -0
  81. package/dist/store/player.js +261 -0
  82. package/dist/store/replica.d.ts +187 -0
  83. package/dist/store/replica.js +740 -0
  84. package/dist/store/state.d.ts +42 -0
  85. package/dist/store/state.js +165 -0
  86. package/dist/store/types.d.ts +200 -0
  87. package/dist/store/types.js +25 -0
  88. package/dist/store/visibility.d.ts +118 -0
  89. package/dist/store/visibility.js +282 -0
  90. package/dist/store/wire.d.ts +309 -0
  91. package/dist/store/wire.js +834 -0
  92. package/dist/stream.d.ts +174 -0
  93. package/dist/stream.js +238 -0
  94. package/dist/three/index.d.ts +109 -0
  95. package/dist/three/index.js +130 -0
  96. package/dist/udp-probe.d.ts +159 -0
  97. package/dist/udp-probe.js +245 -0
  98. package/dist/wasm.d.ts +642 -0
  99. package/dist/wasm.js +98 -0
  100. package/dist/world/border.d.ts +84 -0
  101. package/dist/world/border.js +99 -0
  102. package/dist/world/handoff.d.ts +187 -0
  103. package/dist/world/handoff.js +222 -0
  104. package/dist/world/index.d.ts +13 -0
  105. package/dist/world/index.js +9 -0
  106. package/dist/world/link.d.ts +179 -0
  107. package/dist/world/link.js +476 -0
  108. package/dist/world/regions.d.ts +154 -0
  109. package/dist/world/regions.js +314 -0
  110. package/package.json +72 -0
@@ -0,0 +1,1494 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * A browser node.
6
+ */
7
+ export class LeafNode {
8
+ private constructor();
9
+ free(): void;
10
+ [Symbol.dispose](): void;
11
+ /**
12
+ * The anchor's node id, as 16 lowercase hex digits.
13
+ */
14
+ anchor_id_hex(): string;
15
+ /**
16
+ * Build, sign and publish this leaf's announcement.
17
+ *
18
+ * `capabilities` become tags alongside the mandatory `leaf` and
19
+ * `transport:rtc`; `reflex_addr` and `rtc_addr` stay absent.
20
+ */
21
+ announce(capabilities: string[]): Promise<void>;
22
+ /**
23
+ * Apply one signed revocation bundle from the control-plane
24
+ * feed, and say how many floors it raised.
25
+ *
26
+ * The landing point of the revocation feed: signed
27
+ * `OrgRevocationBundle` wire bytes, verified **in-leaf** by the
28
+ * node's own org authority before any floor moves. This is
29
+ * never a trust-the-JS setter — a forged bundle is refused here
30
+ * exactly as it is refused on the carrier's other paths — and
31
+ * the raise-only merge means an old but validly signed bundle
32
+ * can never roll floors back.
33
+ */
34
+ apply_org_revocation_bundle(bundle_hex: string): number;
35
+ /**
36
+ * Arm the network-change re-attempt trigger.
37
+ *
38
+ * Installs the window's `online` listener; the ICE
39
+ * `disconnected` → `failed` watcher is already on every peer
40
+ * connection this transport owns. From here, either
41
+ * observation files a trigger and
42
+ * [`crate::retry::RetryPolicy`] decides — once per network
43
+ * change, per peer.
44
+ *
45
+ * # Why a page has to ask
46
+ *
47
+ * Re-dialling is policy, and policy is the application's. A
48
+ * library that re-offered on its own would take that decision
49
+ * away from a page that has a reason not to: one that is
50
+ * deliberately holding a pair on the routed path, one tearing
51
+ * down, one whose user is on a metered link. §9 step 6 makes
52
+ * the routed session a supported disposition rather than a
53
+ * degraded one, so "the pair is relayed" is not a fault this
54
+ * leaf may assume it should fix.
55
+ *
56
+ * **Idempotent.** A second call adds no second listener,
57
+ * because two listeners for one `online` event are two triggers
58
+ * for one network change — and while the owner would coalesce
59
+ * them, a page that armed twice should not be relying on that.
60
+ *
61
+ * Only pairs this leaf took direct **as the offerer** are
62
+ * re-attempted: §9 step 4 gives the offerer the initiating
63
+ * role, and both sides re-offering one network change is two
64
+ * attempts per pair plus a supersession race.
65
+ */
66
+ arm_network_retry(): void;
67
+ /**
68
+ * Call `service` on the anchor.
69
+ *
70
+ * Resolves to the reply body, or rejects with the typed
71
+ * failure — `Timeout`, `SessionLost`, `Refused(status)`. Never
72
+ * a silent retry.
73
+ */
74
+ call(service: string, payload: Uint8Array, timeout_ms?: number | null): Promise<Uint8Array>;
75
+ /**
76
+ * One org-scoped unary call.
77
+ *
78
+ * The call runs the full admission (the org proof kinds and the
79
+ * session fence included) and resolves the response body.
80
+ * Opening refusal rejects `admission-denied` with its coarse
81
+ * reason (`rpc: refused (9): <coarse>`); a midstream revocation
82
+ * is the same denial as the terminal.
83
+ *
84
+ * The deadline is **absolute** and defaults to 300 s (`deadlineMs`
85
+ * absent is never "no deadline"); a frozen tab gets no lease
86
+ * extension and on wake an overdue call retires with its
87
+ * deadline terminal. Nothing here ever resumes a retired call —
88
+ * re-opening is a fresh call with a fresh proof and MAY repeat
89
+ * effects. Node or tab close retires ownership: pending calls
90
+ * fail typed.
91
+ */
92
+ call_org(service: string, payload: Uint8Array, opts: any): Promise<Uint8Array>;
93
+ /**
94
+ * One org-scoped client-streaming call. `send` pushes items,
95
+ * `finish` half-closes and resolves the response body. See
96
+ * [`Self::call_org`] for the deadline, suspension and closure
97
+ * contract.
98
+ */
99
+ call_org_client_stream(service: string, opts: any): Promise<OrgUploadCallHandle>;
100
+ /**
101
+ * One org-scoped duplex call. See [`Self::call_org`] for the
102
+ * deadline, suspension and closure contract.
103
+ */
104
+ call_org_duplex(service: string, opts: any): Promise<OrgDuplexCallHandle>;
105
+ /**
106
+ * One org-scoped server-streaming call. See [`Self::call_org`]
107
+ * for the deadline, suspension and closure contract — it holds
108
+ * for every shape. The typed terminal error arrives as the
109
+ * stream's final `next()` item, and dropping/cancelling the
110
+ * handle emits exactly one CANCEL.
111
+ */
112
+ call_org_streaming(service: string, payload: Uint8Array, opts: any): Promise<OrgByteStreamHandle>;
113
+ /**
114
+ * Close the node: every session, every channel, every pending
115
+ * call.
116
+ *
117
+ * Pending calls fail `RpcError::SessionLost` — typed, and not
118
+ * re-issued by anybody.
119
+ */
120
+ close(): void;
121
+ /**
122
+ * Bootstrap against an anchor and return a connected node.
123
+ *
124
+ * `opts`: `{ credentialB64, bootstrapUrl?, origin, iceServers? }`.
125
+ * `bootstrapUrl` overrides the credential's when present;
126
+ * everything else Layer 0 needs — the pinned anchor key, the
127
+ * PSK, the listener URL — comes from the credential itself.
128
+ *
129
+ * `iceServers` is optional and **defaults to the anchor's
130
+ * separately announced STUN endpoint** (the `stun_addr` field
131
+ * of `GET /rtc/anchor`), so the advertised configuration works
132
+ * without the page choosing a STUN service. An anchor that
133
+ * announced none leaves the connection with no ICE servers.
134
+ *
135
+ * A supplied `iceServers` is honoured verbatim, with one
136
+ * refusal: an entry naming this connection's peer RTC endpoint
137
+ * as its STUN server is
138
+ * [`LeafError::IceServerConflictsWithPeer`], returned before
139
+ * any ICE work. Detection is endpoint equality only; see
140
+ * [`crate::bootstrap::check_ice_servers_against_peer`].
141
+ */
142
+ static connect(opts: any): Promise<LeafNode>;
143
+ /**
144
+ * Every counter, as JSON. u64s are decimal strings.
145
+ */
146
+ counters_json(): string;
147
+ /**
148
+ * The ICE servers a `connect(opts)` with this options object
149
+ * would configure its `RTCPeerConnection` with, as JSON.
150
+ *
151
+ * Not a convenience: it is the only way for a caller — or a
152
+ * test — to see what the leaf made of the `RTCIceServer[]` it
153
+ * was handed *before* a connection attempt consumes it. Stage 5
154
+ * read those objects with `as_string`, so every one of them
155
+ * dropped and a page's STUN/TURN configuration was silently
156
+ * absent from the offer. Reads through exactly the parser
157
+ * [`Self::connect`] uses.
158
+ *
159
+ * Shape: `[{"urls":["stun:host:3478"],"username":"u",
160
+ * "credential":"c"}]`, `username`/`credential` present only
161
+ * when the entry carried them.
162
+ *
163
+ * It reports what the **caller** configured, so an options
164
+ * object with no `iceServers` reads `[]` here even though
165
+ * [`Self::connect`] will substitute the anchor's announced
166
+ * STUN endpoint: the substitute is not knowable without an
167
+ * anchor to ask, and inventing one would make this method lie
168
+ * about the only thing it can see.
169
+ */
170
+ static effective_ice_servers(opts: any): string;
171
+ /**
172
+ * What an `open_stream(opts)` with this options object would
173
+ * actually ask the node for, as JSON — the same read, without
174
+ * the stream.
175
+ *
176
+ * Shape: `{"reliability":"reliable","label":"app",
177
+ * "streamId":"0000000000000009","channelHash":7,
178
+ * "peer":"00366d403ce19dac"}`, with `streamId` `null` when the
179
+ * caller did not pin one (the node allocates), `channelHash`
180
+ * `null` when absent, and `peer` `null` when the stream
181
+ * addresses the anchor.
182
+ */
183
+ static effective_stream_options(opts: any): string;
184
+ /**
185
+ * Run the enrollment exchange against the anchor.
186
+ *
187
+ * [`Self::connect`] awaits this already, so a page never needs
188
+ * it; it is here because "still provisional" and "the anchor
189
+ * was slow" are the same symptom from the outside — an nRPC
190
+ * timeout — and a harness needs to be able to drive and
191
+ * observe the step that distinguishes them.
192
+ *
193
+ * A refusal is typed and final: the invite is single-use, so
194
+ * nothing here retries. Retrying would burn it and turn a
195
+ * legible refusal into an illegible replay.
196
+ */
197
+ enroll(): Promise<void>;
198
+ /**
199
+ * Whether the anchor has admitted this leaf.
200
+ *
201
+ * `false` after a successful handshake means the session is
202
+ * still provisional, which is the discriminator a harness needs
203
+ * when a call times out: §12 refused it, rather than the
204
+ * service being slow.
205
+ */
206
+ is_enrolled(): boolean;
207
+ /**
208
+ * How many callbacks are registered on this node right now.
209
+ *
210
+ * **Observable so the bound can be asserted rather than
211
+ * inferred**, exactly as `Reassembler::outstanding` is. The
212
+ * property that matters is that repeated stream open/close
213
+ * leaves this flat: a registration that close does not remove
214
+ * is retained for the life of the node, keeps being invoked
215
+ * for every event, and keeps its captured consumer wrapper
216
+ * alive. A number nobody can read is a bound nobody can test.
217
+ */
218
+ listener_count(): number;
219
+ /**
220
+ * The largest payload one packet carries, as the wire defines
221
+ * it: `MAX_PAYLOAD_SIZE` minus the event frame's length prefix.
222
+ *
223
+ * Published because an application that must keep a message
224
+ * inside one packet has no other way to learn the number, and
225
+ * the two wrong ways are both reachable: hardcoding 8 108
226
+ * treats the packet cap as available data bytes and overruns by
227
+ * the prefix, and hardcoding any figure freezes a wire constant
228
+ * into application code.
229
+ *
230
+ * A **static**, not a node method: it is a property of the wire,
231
+ * identical for every node, so reading it must not require a
232
+ * connection.
233
+ */
234
+ static maxEventBytes(): number;
235
+ /**
236
+ * This node's id, as 16 lowercase hex digits.
237
+ */
238
+ node_id_hex(): string;
239
+ /**
240
+ * Register an event listener. Each receives one JSON string per
241
+ * event.
242
+ *
243
+ * Returns the token that cancels it, the same currency
244
+ * [`LeafStream::on_message`] hands back. A node-wide listener
245
+ * lives as long as the node by default, which is what a page
246
+ * registering one at startup wants; a harness or a component
247
+ * that registers per episode needs to be able to give it back.
248
+ */
249
+ on_event(callback: Function): string;
250
+ /**
251
+ * Open an application stream.
252
+ *
253
+ * `opts`: `{ reliability: "reliable" | "fireAndForget",
254
+ * reliable?: boolean, label?, streamId?, channelHash?, peer? }`.
255
+ * `streamId` (a decimal or `0x`-hex **string**, because a `u64`
256
+ * never crosses as a JS number) and `channelHash` (a **number**
257
+ * in `0..=65535`) are used verbatim when present, so a stream
258
+ * can match a publish contract a native handler dispatches on.
259
+ *
260
+ * `peer` is **16 hex digits** — the spelling `node_id_hex()`
261
+ * hands out and the four §9 peer methods take — and names the
262
+ * node the stream addresses; absent, it is the anchor, which is
263
+ * what every caller before this option got and still gets. It
264
+ * is the page-facing half of §9: `connectPeer` installs a
265
+ * direct leaf ↔ leaf session and this is what puts application
266
+ * bytes on it. Nothing below it changes —
267
+ * `crate::node::LeafNode::open_stream` has always taken a peer
268
+ * and `route_outbound` has always decided routed vs direct, so
269
+ * a stream to a peer whose session is still ROUTED rides the
270
+ * anchor and needs no second call to start riding the
271
+ * DataChannel.
272
+ *
273
+ * **But the HANDLE does not survive the upgrade.** §9 step 4
274
+ * installs a *replacement* session, so the peer's incarnation
275
+ * changes, and a `StreamHandle` is fenced to the incarnation it
276
+ * was opened on
277
+ * (`LeafNode::check_handle` — the alias the
278
+ * native R12 fix closed): a handle opened while the pair was
279
+ * routed refuses with "stale stream handle … reopen the
280
+ * stream" once the direct session lands. The addressing is
281
+ * unchanged — same peer, same `streamId` if one was pinned —
282
+ * so reopening is one call and the far end sees the same
283
+ * stream; what is not true is that the old handle keeps
284
+ * working. A page driving a peer across the upgrade should
285
+ * reopen on that refusal.
286
+ *
287
+ * A peer with no session at all refuses typed from `send`,
288
+ * unchanged.
289
+ *
290
+ * Both are read by `stream_options`, which
291
+ * [`crate::leader_session::MeshSession::open_stream`] also
292
+ * calls: the direct and the proxied surface cannot read the
293
+ * same option object two ways. That surface now **carries**
294
+ * `peer` in its request rather than refusing it, so a follower
295
+ * addresses a peer exactly as this surface does.
296
+ */
297
+ open_stream(opts: any): LeafStream;
298
+ /**
299
+ * This node's **origin hash**, as 16 lowercase hex digits.
300
+ *
301
+ * Not the node id, and not interchangeable with it: the origin
302
+ * hash is derived from the entity key and is what rides every
303
+ * packet header this node seals, what names its nRPC reply
304
+ * channels (`<service>.replies.<origin>`), and what a receiver
305
+ * compares an event's `EventMeta.origin_hash` against — a
306
+ * direct peer whose packet origin and payload origin disagree
307
+ * has its frame dropped before admission, so anything that
308
+ * builds an event payload for this node to send MUST name this
309
+ * value.
310
+ */
311
+ origin_hash_hex(): string;
312
+ /**
313
+ * Answer the offer `peer` sent — the other half of §9 step 3.
314
+ *
315
+ * Resolves to the dialog id the offerer minted, which the page
316
+ * uses exactly as `peer_offer`'s caller does.
317
+ *
318
+ * The offer applied here is the one that arrived as a
319
+ * **verified** envelope: signature checked against the sender's
320
+ * signed announcement, inside its `not_after`, and unreplayed.
321
+ * The page passes no SDP, which is why an offer it never
322
+ * received cannot be answered and an offer it did receive
323
+ * cannot be altered.
324
+ *
325
+ * A second offer from the same peer supersedes the first: the
326
+ * old dialog is counted `ice_failed` and its id stops being the
327
+ * live one, which is what the page's next call sees.
328
+ */
329
+ peer_accept_offer(peer_hex: string): Promise<string>;
330
+ /**
331
+ * Service `peer`'s attempt once, and say where it stands.
332
+ *
333
+ * This is the trickle pump the page's drive loop calls. It does
334
+ * four things, all of them for one attempt:
335
+ *
336
+ * - applies the peer's `Answer` if one has arrived (an offerer
337
+ * only: an answerer already has the offer's description);
338
+ * - sends every candidate this browser has gathered for `peer`
339
+ * as a signed `Candidate` envelope;
340
+ * - applies every candidate the peer trickled;
341
+ * - evaluates the attempt's ICE deadline, and settles
342
+ * `udp_blocked` or `ice_relayed` when it has passed.
343
+ *
344
+ * Resolves to JSON: `{"dialog":"<16 hex>","state":"gathering"
345
+ * |"open"|"iceTimeout"|"udpBlocked","sent":<n>,"applied":<n>,
346
+ * "answered":<bool>,"remainingMs":"<decimal>"}`. `dialog` is
347
+ * the attempt that is CURRENTLY live for this peer, so a page
348
+ * whose dialog id no longer matches has been superseded — the
349
+ * one disposition this call cannot report for itself, because
350
+ * the attempt it would report about is gone.
351
+ *
352
+ * A candidate the browser rejects is not fatal to the attempt —
353
+ * the channel opening is what matters — but it is no longer
354
+ * SILENT. The engine's own error text rides back as
355
+ * `candidateError` (first one only, JSON-escaped) and is warned
356
+ * to the console. It was previously swallowed entirely: the
357
+ * success count rose or it did not, and nothing anywhere said
358
+ * why, which is the difference between "ICE is working on it"
359
+ * and "ICE has nothing to work with".
360
+ */
361
+ peer_candidate(peer_hex: string): Promise<string>;
362
+ /**
363
+ * [`Self::peer_candidate`], for a caller that names the dialog
364
+ * it is driving.
365
+ *
366
+ * The proxied form. A follower's request is served by another
367
+ * tab after crossing a channel, so the attempt it was issued for
368
+ * may already have been replaced — and servicing a *replacement*
369
+ * under a stale request is a mutation, not a misclassification.
370
+ * `attempt_for` refuses first.
371
+ */
372
+ peer_candidate_in(peer_hex: string, dialog_hex: string): Promise<string>;
373
+ /**
374
+ * The live attempt's dialog, 16 hex digits, when `peer` is
375
+ * **already a healthy direct pair** — session installed, no
376
+ * relay entry, transport open — and `null` otherwise.
377
+ *
378
+ * What makes `connectPeer` idempotent. A second offer to a
379
+ * healthy pair is not a no-op: its connection replaces the
380
+ * transport's link, which closes the working one under the other
381
+ * side, and the answerer never asked for a new attempt — so the
382
+ * pair ends up reading direct with a closed channel. A page (or a
383
+ * library, like netcode or a lobby) that calls `connectPeer` "to
384
+ * be sure" must get the pair it already has.
385
+ */
386
+ peer_direct_dialog(peer_hex: string): string | undefined;
387
+ /**
388
+ * Run the Noise handshake with `peer` over the direct
389
+ * DataChannel — §9 step 4.
390
+ *
391
+ * **Takes a peer id and nothing else.** A page that could
392
+ * supply a Noise key could supply *any* key, so the responder
393
+ * static this handshake authenticates comes from `peer`'s
394
+ * signature-verified announcement and the PSK from the
395
+ * credential `connect` was given. There is no parameter through
396
+ * which either can be substituted, which is the point.
397
+ *
398
+ * The offerer's role, per §9 step 4: the leaf that created the
399
+ * offer is the NKpsk0 initiator. The answerer never calls this
400
+ * — its half runs from the inbound packet, in
401
+ * `Inner::on_handshake`.
402
+ *
403
+ * On success the direct session is installed on this side and
404
+ * the relay entry for `peer` is gone, so the pair's traffic
405
+ * leaves on its own channel. The session replacement itself is
406
+ * the node's — `LeafNode::install_session`, the
407
+ * Stage 3/4a fence, unchanged and unreached from here.
408
+ */
409
+ peer_handshake(peer_hex: string): Promise<string>;
410
+ /**
411
+ * [`Self::peer_handshake`], for a caller that names the dialog
412
+ * it is driving.
413
+ *
414
+ * The proxied form, and the one where a stale request costs most:
415
+ * the Noise wait is the longest await on this surface, and the
416
+ * session it installs must belong to the attempt that negotiated
417
+ * the channel. A peer-only resolution would run a superseded
418
+ * request's handshake on the replacement.
419
+ */
420
+ peer_handshake_in(peer_hex: string, dialog_hex: string): Promise<string>;
421
+ /**
422
+ * Offer a direct connection to `peer` — §9 steps 2 and 3.
423
+ *
424
+ * Resolves to the dialog id, 16 hex digits, which is what the
425
+ * page correlates every later call on this attempt against.
426
+ *
427
+ * Three things happen, in this order:
428
+ *
429
+ * 1. **Discovery is required.** With no verified announcement
430
+ * for `peer` this refuses before anything is allocated:
431
+ * there is no key to handshake against and no authority to
432
+ * verify the peer's envelopes with, and guessing either is
433
+ * the failure mode this whole surface exists to prevent.
434
+ * 2. **The relayed session comes up** if there is not one
435
+ * already (§9 step 2): NKpsk0 over the anchor's blind
436
+ * forwarding, keys from the announcement. Failing here
437
+ * counts nothing — no offer was created, so there is no
438
+ * attempt to charge.
439
+ * 3. **The offer goes out** as a signed `Offer` envelope inside
440
+ * that session, and `ice_attempted` moves.
441
+ *
442
+ * The deadline the attempt runs under is
443
+ * [`PEER_ICE_DEADLINE_MS`] from now. The re-attempt owner calls
444
+ * `offer_peer` directly with the episode's deadline
445
+ * instead, which is how a repair and the window that absorbs
446
+ * its duplicate triggers end up being one absolute instant
447
+ * rather than two that nearly agree.
448
+ */
449
+ peer_offer(peer_hex: string): Promise<string>;
450
+ /**
451
+ * Publish `payload` on `channel`.
452
+ */
453
+ publish(channel: string, payload: Uint8Array): Promise<void>;
454
+ /**
455
+ * Answer a capability query from the announcements this leaf
456
+ * verified. A JSON array of
457
+ * `{ node_id, entity_id, capabilities, rtc_addr, noise_pubkey, version }`.
458
+ */
459
+ query(capability: string): Promise<string>;
460
+ /**
461
+ * Cancel the registration `token` names.
462
+ *
463
+ * `false` when it is already gone, which is the outcome a
464
+ * second cancellation wanted. An unparseable token is also
465
+ * `false`: it names no registration, and throwing for it would
466
+ * make a double-close harder to write than a leak.
467
+ */
468
+ remove_listener(token: string): boolean;
469
+ /**
470
+ * Retire the node because leadership moved off this tab, and say
471
+ * how many pending calls that failed.
472
+ *
473
+ * [`Self::close`] is the page saying "I am done with this node";
474
+ * this is the lifecycle saying "this node no longer holds the
475
+ * identity". The difference is the disposition of the pending
476
+ * calls, and it matters to the caller: a close is a
477
+ * `SessionLost`, and a stand-down is a `LeaderLost` naming the
478
+ * generation that owned the call, because "which leader did I
479
+ * lose" is the question a page asks next and this is the only
480
+ * place that knows the answer.
481
+ *
482
+ * `closed` is set **first**, so the pump the failure path runs
483
+ * through emits nothing, and everything after it is teardown.
484
+ */
485
+ retire(generation: bigint): number;
486
+ /**
487
+ * The re-attempt owner's ledger, as JSON.
488
+ *
489
+ * `{"armed":<bool>,"online":"<n>","iceFailed":"<n>",
490
+ * "triggers":"<n>","started":"<n>","coalesced":"<n>",
491
+ * "notEligible":"<n>","openEpisodes":<n>,"owned":<n>,
492
+ * "last":"<disposition>"|null}`.
493
+ *
494
+ * `started` is the number the witness asserts: one network
495
+ * change, one re-attempt, however many observations of it
496
+ * arrived. `triggers` is how many arrived, and `coalesced` is
497
+ * the difference the owner absorbed — reported rather than
498
+ * hidden, because "the trigger never fired" and "it fired and
499
+ * was absorbed" are different facts and only one of them is a
500
+ * defect.
501
+ *
502
+ * `owned` is how many pairs this leaf took direct as the
503
+ * offerer, i.e. the set a network change is evaluated against.
504
+ */
505
+ retry_report(): string;
506
+ /**
507
+ * `RtcStats` on the leaf — plan §10's telemetry surface, in the
508
+ * field names the NATIVE `RtcStats` uses.
509
+ *
510
+ * Page-facing as `node.rtcStats()` through
511
+ * `@net-mesh/browser`. `u64`s are decimal strings, the rule
512
+ * [`Self::counters_json`] follows.
513
+ *
514
+ * Two halves, one reading: the transport's own ledger
515
+ * (admission, writes, the buffered-amount high water) and the
516
+ * ICE attempt ledger the conformance matrix asserts on. Plus
517
+ * `not_applicable`, which names the 24 native fields a leaf has
518
+ * no meaning for **and says why** — see
519
+ * [`crate::counters::LeafCounters::rtc_stats_json`] for the
520
+ * reason that is a list of reasons rather than a wall of
521
+ * zeros.
522
+ */
523
+ rtc_stats_json(): string;
524
+ /**
525
+ * Serve one org-scoped unary service: `handler(caller, request)`
526
+ * resolves the response body.
527
+ *
528
+ * # The handler-drop contract (F-S3.1-2)
529
+ *
530
+ * The retire supervisor may drop the handler future without a
531
+ * final poll — cancellation is observed through the retirement
532
+ * observables (the terminal item, the sink's typed closed
533
+ * refusal, and `retired`), never assumed as a handler-side
534
+ * event; a detached observer holding `retired` observes the
535
+ * signal. After retirement the handler sees typed refusals and
536
+ * its return value is discarded — the terminal was already
537
+ * sent.
538
+ *
539
+ * Closing the returned handle retires this registration's live
540
+ * protected calls with their exact terminals and refuses new
541
+ * openings (C9's protected split).
542
+ */
543
+ serve_org(service: string, access: string, handler: Function, opts: any): OrgServeHandle;
544
+ /**
545
+ * Serve one org-scoped client-streaming service:
546
+ * `handler(caller, requests)` resolves the response body. See
547
+ * [`Self::serve_org`] for the handler-drop contract and the
548
+ * close semantics.
549
+ */
550
+ serve_org_client_stream(service: string, access: string, handler: Function, opts: any): OrgServeHandle;
551
+ /**
552
+ * Serve one org-scoped duplex service:
553
+ * `handler(caller, requests, sink)` pulls requests and pushes
554
+ * responses. See [`Self::serve_org`] for the handler-drop
555
+ * contract and the close semantics.
556
+ */
557
+ serve_org_duplex(service: string, access: string, handler: Function, opts: any): OrgServeHandle;
558
+ /**
559
+ * Serve one org-scoped server-streaming service:
560
+ * `handler(caller, request, sink)` pushes through `sink` and
561
+ * ends with `sink.close()` or by returning. See
562
+ * [`Self::serve_org`] for the handler-drop contract and the
563
+ * close semantics.
564
+ */
565
+ serve_org_streaming(service: string, access: string, handler: Function, opts: any): OrgServeHandle;
566
+ /**
567
+ * Sign a `0x0D02` signalling envelope for `peer` and hand it to
568
+ * the control plane — no session with `peer` needed.
569
+ *
570
+ * Through the boundary, not the data path. An envelope
571
+ * authenticates itself, so the carrier is untrusted and can be
572
+ * anything.
573
+ *
574
+ * **The v1 anchor carrier refuses** (R14). `AnchorControlPlane`
575
+ * does not carry envelopes: the Stage 4b listener reads one
576
+ * trickle frame type, `candidate`, and forwards nothing to a
577
+ * third party, so `signal` on a node connected to a real anchor
578
+ * returns `LeafError::ControlPlane` naming the peer it could not
579
+ * reach. That is deliberate — the first cut reported the local
580
+ * send as a delivery the anchor discarded. The carrier that does
581
+ * deliver today is the anchorless `MockControlPlane`; a
582
+ * forwarding anchor route is Stage 6's, and the trait's shape
583
+ * already admits it, which is why this takes a peer id and an
584
+ * envelope rather than a session.
585
+ */
586
+ signal(peer_hex: string, dialog_hex: string, kind: string, payload: Uint8Array): Promise<void>;
587
+ /**
588
+ * Subscribe to `channel` on the anchor.
589
+ */
590
+ subscribe(channel: string): Promise<void>;
591
+ /**
592
+ * Release membership of `channel` on the anchor.
593
+ *
594
+ * The direct surface's release is unconditional — this node is
595
+ * the only consumer it knows about. The last-consumer arithmetic
596
+ * belongs to the session surface, where several tabs share one
597
+ * node and one of them stopping is not all of them stopping.
598
+ */
599
+ unsubscribe(channel: string): Promise<void>;
600
+ }
601
+
602
+ /**
603
+ * One application stream.
604
+ */
605
+ export class LeafStream {
606
+ private constructor();
607
+ free(): void;
608
+ [Symbol.dispose](): void;
609
+ /**
610
+ * Stop using the stream. The session stays; a stream is
611
+ * per-stream state, not a connection.
612
+ *
613
+ * Nothing leaves the wire: one DataChannel carries every stream
614
+ * and there is no per-stream teardown frame. What it does do is
615
+ * release the node's own per-stream state — the receive cursor
616
+ * and the stream's classification — through the same fenced
617
+ * entry point a stale handle is refused by. It used to do
618
+ * literally nothing, which meant a proxied `StreamClose`
619
+ * removed the leader's handle and left the node holding the
620
+ * stream: a page that closed and reopened the same id got the
621
+ * old cursor.
622
+ *
623
+ * **Every registration this stream took is given back**, so
624
+ * repeated open/close leaves [`LeafNode::listener_count`] flat.
625
+ * A callback registered through [`Self::on_message`] lives on
626
+ * the node, not on this object, and it captures the consumer's
627
+ * own callback — so a close that removed only the node's stream
628
+ * state left the closure attached, still invoked for every
629
+ * event the node produced and still holding its consumer
630
+ * alive, for as long as the node lived.
631
+ *
632
+ * A refusal here is reported rather than returned: the handle is
633
+ * being discarded either way, and `close` is the one operation
634
+ * for which "it was already gone" is the outcome the caller
635
+ * wanted.
636
+ */
637
+ close(): void;
638
+ /**
639
+ * The incarnation of the session this stream was opened on,
640
+ * decimal — the spelling the event carries, so there is no
641
+ * conversion to get wrong.
642
+ *
643
+ * Provenance, not part of the filter key: see
644
+ * [`crate::node::LeafEvent::StreamData`].
645
+ */
646
+ incarnation(): string;
647
+ /**
648
+ * Whether this stream retransmits.
649
+ */
650
+ is_reliable(): boolean;
651
+ /**
652
+ * Listen for this stream's inbound payloads.
653
+ *
654
+ * **The callback receives the node's `stream_data` event JSON
655
+ * string**, not bytes — the same string
656
+ * [`LeafNode::on_event`] delivers, filtered to this stream's
657
+ * **peer and** id:
658
+ *
659
+ * ```text
660
+ * {"type":"stream_data","peer_node":"200","incarnation":"1","stream_id":"9","seq":"1","payload":"AQI="}
661
+ * ```
662
+ *
663
+ * Every `u64` is a decimal string and `payload` is standard
664
+ * padded base64. One contract, one direction: the leaf emits
665
+ * its canonical event JSON and the consumer decodes it.
666
+ * Emitting bytes here instead would mean a second encoding of
667
+ * an event that already exists, and would throw away `seq` and
668
+ * the rest of the event's provenance at the boundary.
669
+ * `@net-mesh/browser`'s `LeafStream` does that decode, which is
670
+ * why its `onMessage` and its async iterator yield
671
+ * `Uint8Array`; a host wiring this callback itself must parse
672
+ * the same way.
673
+ *
674
+ * **The peer is half of the key, not decoration.** A stream id
675
+ * comes from a label or from a publish contract and neither
676
+ * involves the peer, so one label opened to two peers is one id
677
+ * on two sessions — a supported composition. Filtering the
678
+ * node-wide event stream by the id alone made both wrappers
679
+ * accept whichever peer's payload arrived, delivering one
680
+ * peer's bytes into the other peer's inbox; a page that echoes
681
+ * then amplifies it. The incarnation rides the event as
682
+ * provenance and is deliberately **not** part of this key: see
683
+ * [`crate::node::LeafEvent::StreamData`].
684
+ *
685
+ * The callback runs with **no** borrow of the node held, so it
686
+ * may call straight back in: [`Self::send`], [`LeafNode::close`]
687
+ * and the rest are all reachable from here. That was not true
688
+ * before — the event was emitted from inside `flush`'s `&mut
689
+ * self` — so the advertised echo trapped instead of sending.
690
+ *
691
+ * **Returns the token that cancels the registration**, decimal.
692
+ * The closure is registered on the node and captures the
693
+ * consumer's callback, so a registration nothing names is
694
+ * retained for the node's whole life and keeps being invoked
695
+ * for every event it produces — which is what repeated
696
+ * open/close accumulated before the token existed.
697
+ * [`Self::close`] gives back every token this stream took, so
698
+ * an ordinary consumer never has to; [`Self::remove_listener`]
699
+ * is for one that wants to stop listening without closing.
700
+ */
701
+ on_message(callback: Function): string;
702
+ /**
703
+ * The peer this stream is with, 16 lowercase hex digits.
704
+ *
705
+ * **Spelled exactly like [`Self::stream_id_hex`], deliberately.**
706
+ * A stream is addressed by `(peer, stream_id)` and both halves
707
+ * of that key are read through the same accessor shape and
708
+ * reconciled against the event's decimal field by the same
709
+ * `BigInt` conversion, so a consumer has one idiom to get right
710
+ * rather than two. A peer-blind filter is the R4-10 defect: one
711
+ * label opened to two peers is one id on two sessions, and
712
+ * filtering the node-wide event stream by the id alone hands
713
+ * each wrapper whichever peer's payload arrived.
714
+ */
715
+ peer_node_hex(): string;
716
+ /**
717
+ * Cancel one registration [`Self::on_message`] returned.
718
+ *
719
+ * `false` when the token names no live registration of this
720
+ * stream — already cancelled, already closed, or never ours.
721
+ * Scoped to this stream on purpose: a token is the right to
722
+ * remove one subscription, and one stream must not be able to
723
+ * silence another's consumer by guessing a number.
724
+ */
725
+ remove_listener(token: string): boolean;
726
+ /**
727
+ * Send one payload. The bytes ride verbatim as one event in one
728
+ * packet — no leaf-added framing.
729
+ *
730
+ * Callable from [`Self::on_message`]: the borrow this takes is
731
+ * released before any listener runs, which is what makes
732
+ * `stream.onMessage(p => stream.send(p))` — the echo shape the
733
+ * TypeScript surface advertises — a supported operation rather
734
+ * than a `RefCell` trap.
735
+ */
736
+ send(payload: Uint8Array): void;
737
+ /**
738
+ * The stream id, 16 lowercase hex digits.
739
+ */
740
+ stream_id_hex(): string;
741
+ }
742
+
743
+ /**
744
+ * A Net node as a tab sees it, whether or not this tab runs it.
745
+ *
746
+ * ```text
747
+ * class MeshSession {
748
+ * static open(opts): Promise<MeshSession>
749
+ * role(): "leader" | "follower"
750
+ * generation(): string
751
+ * node_id_hex(): string | undefined
752
+ * fingerprint(): string
753
+ * scope(): string
754
+ * interruption_ms(): number | undefined
755
+ * call(service, payload, timeout_ms?): Promise<Uint8Array>
756
+ * subscribe(channel): Promise<void>
757
+ * publish(channel, payload): Promise<void>
758
+ * announce(capabilities): Promise<void>
759
+ * query(capability): Promise<string>
760
+ * counters_json(): Promise<string>
761
+ * signal(peer_hex, dialog, kind, payload): Promise<void>
762
+ * open_stream(opts): Promise<ProxyStream>
763
+ * on_event(cb): void
764
+ * close(): void
765
+ * }
766
+ * ```
767
+ *
768
+ * One honest difference from `crate::wasm::LeafNode`: `open_stream`
769
+ * returns a promise, because on a follower the stream is opened by
770
+ * another tab. Everything else has the same shape, and every
771
+ * operation carries the generation.
772
+ */
773
+ export class MeshSession {
774
+ private constructor();
775
+ free(): void;
776
+ [Symbol.dispose](): void;
777
+ /**
778
+ * Publish this node's capability announcement.
779
+ *
780
+ * Also records it as this tab's current intent, so a takeover
781
+ * re-publishes what the page last announced rather than what it
782
+ * opened with.
783
+ */
784
+ announce(capabilities: string[]): Promise<void>;
785
+ /**
786
+ * Call an nRPC service.
787
+ */
788
+ call(service: string, payload: Uint8Array, timeout_ms?: number | null): Promise<Uint8Array>;
789
+ /**
790
+ * One org-scoped unary call through the shared session.
791
+ *
792
+ * Identical contract to [`crate::wasm::LeafNode::call_org`] —
793
+ * the deadline is absolute, a frozen tab gets no lease
794
+ * extension, and nothing here ever resumes a retired call. On a
795
+ * follower the request crosses the proxy with the caller's
796
+ * proofs as opaque credential bytes (the leader's node mints the
797
+ * signed opening — the entity key never leaves a node); a
798
+ * generation move mid-call fails typed `LeaderLost` and is never
799
+ * resumed, and a retained handle from an older generation
800
+ * refuses rather than addressing a successor's call.
801
+ */
802
+ call_org(service: string, payload: Uint8Array, opts: any): Promise<Uint8Array>;
803
+ /**
804
+ * One org-scoped client-streaming call through the shared
805
+ * session. See [`Self::call_org`] for the contract.
806
+ */
807
+ call_org_client_stream(service: string, opts: any): Promise<OrgUploadCallHandle>;
808
+ /**
809
+ * One org-scoped duplex call through the shared session. See
810
+ * [`Self::call_org`] for the contract.
811
+ */
812
+ call_org_duplex(service: string, opts: any): Promise<OrgDuplexCallHandle>;
813
+ /**
814
+ * One org-scoped server-streaming call through the shared
815
+ * session. See [`Self::call_org`] for the deadline, suspension
816
+ * and closure contract. An opening denial REJECTS this promise;
817
+ * the typed terminal error arrives as the stream's final
818
+ * `next()` item.
819
+ */
820
+ call_org_streaming(service: string, payload: Uint8Array, opts: any): Promise<OrgByteStreamHandle>;
821
+ /**
822
+ * Stand down and release the lock.
823
+ */
824
+ close(): void;
825
+ /**
826
+ * Every leaf counter as JSON; `u64`s are decimal strings.
827
+ */
828
+ counters_json(): Promise<string>;
829
+ /**
830
+ * Run the enrollment exchange if the node is not enrolled.
831
+ *
832
+ * Proxied, so a follower's `enroll()` works: one node per origin
833
+ * means one enrollment per origin, and the follower is asking
834
+ * the only session there is. Idempotent on the leader's side —
835
+ * an already-enrolled node answers immediately.
836
+ */
837
+ enroll(): Promise<void>;
838
+ /**
839
+ * The identity fingerprint the lock is named after.
840
+ */
841
+ fingerprint(): string;
842
+ /**
843
+ * The generation in force, as a decimal string.
844
+ */
845
+ generation(): string;
846
+ /**
847
+ * The measured interruption, in milliseconds, for a tab that was
848
+ * promoted. `undefined` on the first leader.
849
+ */
850
+ interruption_ms(): number | undefined;
851
+ /**
852
+ * Whether the node has completed enrollment.
853
+ *
854
+ * A promise, where [`crate::wasm::LeafNode::is_enrolled`] is
855
+ * synchronous: on a follower the answer lives in another tab.
856
+ */
857
+ is_enrolled(): Promise<boolean>;
858
+ /**
859
+ * The node's id, 16 lowercase hex digits, once one is known.
860
+ */
861
+ node_id_hex(): string | undefined;
862
+ /**
863
+ * Register an event listener. One JSON string per event.
864
+ *
865
+ * Beyond [`crate::node::LeafEvent`]'s tags, a session emits
866
+ * `leader_changed`, `subscription_restored`, `leader_lost`,
867
+ * `generation_fenced`, `not_leader` and
868
+ * `serve_registration_refused` — the lifecycle made observable,
869
+ * because a page that cannot see a leader change cannot explain
870
+ * one, and a page that cannot see a permanent serve-registration
871
+ * refusal cannot explain why its service never dispatches
872
+ * (LEAF-14: the typed message a local `org_serve` would have
873
+ * thrown, exactly once, with no retry storm behind it).
874
+ */
875
+ on_event(callback: Function): void;
876
+ /**
877
+ * Resolve the identity, contend for the origin's lock, and return
878
+ * this tab's session.
879
+ *
880
+ * `opts` is everything `LeafNode.connect` takes — `credentialB64`,
881
+ * `origin`, `bootstrapUrl?`, `iceServers?`, `entitySecretHex?`,
882
+ * `noiseSecretHex?` — plus `capabilities?`, `subscriptions?`,
883
+ * `dbName?` and `lockScope?`.
884
+ *
885
+ * With no `entitySecretHex` the identity comes from IndexedDB
886
+ * under a non-extractable AES-GCM key, generated there on first
887
+ * run. With one, the host holds custody and nothing is stored.
888
+ * Both paths produce the same value and take the same route in.
889
+ */
890
+ static open(opts: any): Promise<MeshSession>;
891
+ /**
892
+ * Open an application stream, wherever the node is.
893
+ */
894
+ open_stream(opts: any): Promise<ProxyStream>;
895
+ /**
896
+ * Answer the offer `peer_hex` filed.
897
+ */
898
+ peer_accept_offer(peer_hex: string): Promise<string>;
899
+ /**
900
+ * Service one polling step of the attempt `dialog_hex`.
901
+ *
902
+ * The dialog is required, not optional. A proxied poll that
903
+ * named only the peer would be applied to whatever attempt is
904
+ * live when the leader gets to it, which is how a superseded
905
+ * request drives its replacement.
906
+ */
907
+ peer_candidate(peer_hex: string, dialog_hex: string): Promise<string>;
908
+ /**
909
+ * The live attempt's dialog when `peer_hex` is already a healthy
910
+ * direct pair on the leader, or `undefined` — what makes a follower's
911
+ * `connectPeer` idempotent, as `LeafNode::peer_direct_dialog` makes
912
+ * the leader's.
913
+ */
914
+ peer_direct_dialog(peer_hex: string): Promise<string | undefined>;
915
+ /**
916
+ * Run the Noise handshake for the attempt `dialog_hex`.
917
+ */
918
+ peer_handshake(peer_hex: string, dialog_hex: string): Promise<string>;
919
+ /**
920
+ * Mint an offer and start an attempt with `peer_hex` (§9).
921
+ *
922
+ * The four peer methods below are the primitives a **shared**
923
+ * TypeScript driver calls. The drive loop and its classification
924
+ * live once, in the package, and are used by `BrowserNode` and
925
+ * by this session alike — a second implementation of that loop
926
+ * here would be two spellings of one contract.
927
+ */
928
+ peer_offer(peer_hex: string): Promise<string>;
929
+ /**
930
+ * Publish one payload to a channel.
931
+ */
932
+ publish(channel: string, payload: Uint8Array): Promise<void>;
933
+ /**
934
+ * Find the nodes offering a capability.
935
+ */
936
+ query(capability: string): Promise<string>;
937
+ /**
938
+ * `"leader"` or `"follower"`.
939
+ */
940
+ role(): string;
941
+ /**
942
+ * The lock and channel name.
943
+ */
944
+ scope(): string;
945
+ /**
946
+ * Serve one org-scoped unary service through the shared
947
+ * session: `handler(caller, request)` resolves the response
948
+ * body. The registration rides the proxy registry and its
949
+ * inbound calls dispatch to THIS follower's handle and no other.
950
+ *
951
+ * # The handler-drop contract (F-S3.1-2)
952
+ *
953
+ * The retire supervisor may drop the handler future without a
954
+ * final poll — cancellation is observed through the retirement
955
+ * observables (the terminal item, the sink's typed closed
956
+ * refusal, and `retired`), never assumed as a handler-side
957
+ * event; a detached observer holding `retired` observes the
958
+ * signal. After retirement the handler sees typed refusals and
959
+ * its return value is discarded — the terminal was already
960
+ * sent. Closing the returned handle retires this registration's
961
+ * live protected calls with their exact terminals and refuses
962
+ * new openings (C9's protected split).
963
+ */
964
+ serve_org(service: string, access: string, handler: Function, opts: any): OrgServeHandle;
965
+ /**
966
+ * Serve one org-scoped client-streaming service through the
967
+ * shared session. See [`Self::serve_org`] for the handler-drop
968
+ * contract and the close semantics.
969
+ */
970
+ serve_org_client_stream(service: string, access: string, handler: Function, opts: any): OrgServeHandle;
971
+ /**
972
+ * Serve one org-scoped duplex service through the shared
973
+ * session. See [`Self::serve_org`] for the handler-drop
974
+ * contract and the close semantics.
975
+ */
976
+ serve_org_duplex(service: string, access: string, handler: Function, opts: any): OrgServeHandle;
977
+ /**
978
+ * Serve one org-scoped server-streaming service through the
979
+ * shared session. See [`Self::serve_org`] for the handler-drop
980
+ * contract and the close semantics.
981
+ */
982
+ serve_org_streaming(service: string, access: string, handler: Function, opts: any): OrgServeHandle;
983
+ /**
984
+ * Sign and send a session-independent signalling envelope.
985
+ */
986
+ signal(peer_hex: string, dialog_hex: string, kind: string, payload: Uint8Array): Promise<void>;
987
+ /**
988
+ * Subscribe to a channel.
989
+ *
990
+ * Recorded as this tab's own declaration, which is what a
991
+ * successor restores and what an attach carries to a new leader.
992
+ */
993
+ subscribe(channel: string): Promise<void>;
994
+ /**
995
+ * Release this tab's claim on a channel.
996
+ *
997
+ * The membership itself is given up only when no other tab still
998
+ * declares the channel: the origin runs one node, and one tab
999
+ * closing a subscription is not every tab closing it.
1000
+ */
1001
+ unsubscribe(channel: string): Promise<void>;
1002
+ }
1003
+
1004
+ /**
1005
+ * One org-scoped response stream as JavaScript sees it.
1006
+ *
1007
+ * `next()` resolves `{ done: false, value }`, `{ done: true }` (or
1008
+ * `{ done: true, value }` when the terminal carries a final body),
1009
+ * or `{ done: true, error }` with the typed terminal error — which
1010
+ * the TypeScript wrapper throws at the terminal item, so `for
1011
+ * await` sees a typed rejection. `cancel()` emits exactly one
1012
+ * CANCEL. Deadlines are absolute: a frozen tab gets no lease
1013
+ * extension and an overdue call retires with its deadline terminal;
1014
+ * nothing here ever resumes a retired call.
1015
+ */
1016
+ export class OrgByteStreamHandle {
1017
+ private constructor();
1018
+ free(): void;
1019
+ [Symbol.dispose](): void;
1020
+ /**
1021
+ * Cancel the call. Exactly one CANCEL reaches the provider, and
1022
+ * the terminal is latched locally — dropping this handle later
1023
+ * emits nothing (the exactly-once guard already fired).
1024
+ */
1025
+ cancel(): void;
1026
+ /**
1027
+ * The next item, the end of the stream, or the typed terminal
1028
+ * error item.
1029
+ */
1030
+ next(): Promise<any>;
1031
+ }
1032
+
1033
+ /**
1034
+ * One org-scoped duplex call as JavaScript sees it: an inline
1035
+ * upload sink and a response stream over the same call.
1036
+ */
1037
+ export class OrgDuplexCallHandle {
1038
+ private constructor();
1039
+ free(): void;
1040
+ [Symbol.dispose](): void;
1041
+ /**
1042
+ * Cancel the call (one CANCEL, terminal latched).
1043
+ */
1044
+ cancel(): void;
1045
+ /**
1046
+ * Half-close the upload direction. The response side stays
1047
+ * open — this is `finishSending`, not a completion.
1048
+ */
1049
+ finish_sending(): Promise<void>;
1050
+ /**
1051
+ * Push one upload item.
1052
+ */
1053
+ send(payload: Uint8Array): Promise<void>;
1054
+ /**
1055
+ * The response half of this call.
1056
+ *
1057
+ * Every handle this mints shares the call's latched terminal:
1058
+ * each consumer observes the real typed terminal (a
1059
+ * `Retired { Revoked }`, an `AdmissionDenied`, a refusal), never
1060
+ * a fabricated clean completion left for whoever polls second.
1061
+ */
1062
+ stream(): OrgByteStreamHandle;
1063
+ }
1064
+
1065
+ /**
1066
+ * The handler-facing request stream of a client-streaming or duplex
1067
+ * serve.
1068
+ *
1069
+ * # The handler-drop contract (F-S3.1-2)
1070
+ *
1071
+ * The retire supervisor may drop the handler future without a final
1072
+ * poll — cancellation is observed through the retirement
1073
+ * observables (the terminal item, the sink's typed closed refusal,
1074
+ * and `retired`), never assumed as a handler-side event; a detached
1075
+ * observer holding `retired` observes the signal. After retirement
1076
+ * `next` yields nothing more and the handler's return value is
1077
+ * discarded — the terminal was already sent.
1078
+ */
1079
+ export class OrgRequestStreamHandle {
1080
+ private constructor();
1081
+ free(): void;
1082
+ [Symbol.dispose](): void;
1083
+ /**
1084
+ * The next request item, or `{ done: true }` at the end of the
1085
+ * upload. There is no error arm: a terminated call is observed
1086
+ * through `retired`, and an ended upload is a clean `done`. A
1087
+ * retired call reports `done` — the pull never hangs the
1088
+ * handler (the F-S3.1-2 level).
1089
+ */
1090
+ next(): Promise<any>;
1091
+ /**
1092
+ * The retirement signal — same contract and vocabulary as
1093
+ * [`OrgResponseSinkHandle::retired`].
1094
+ */
1095
+ retired(): Promise<any>;
1096
+ }
1097
+
1098
+ /**
1099
+ * The handler-facing response sink of a streaming or duplex serve.
1100
+ *
1101
+ * # The handler-drop contract (F-S3.1-2)
1102
+ *
1103
+ * The retire supervisor may drop the handler future without a final
1104
+ * poll — cancellation is observed through the retirement
1105
+ * observables (the terminal item, the sink's typed closed refusal
1106
+ * below, and `retired`), never assumed as a handler-side event; a
1107
+ * detached observer holding `retired` observes the signal. After
1108
+ * retirement `send` and `close` refuse with the typed closed text
1109
+ * and the handler's return value is discarded — the terminal was
1110
+ * already sent.
1111
+ */
1112
+ export class OrgResponseSinkHandle {
1113
+ private constructor();
1114
+ free(): void;
1115
+ [Symbol.dispose](): void;
1116
+ /**
1117
+ * End the response side successfully. Idempotent: the terminal
1118
+ * frame is sent exactly once whether the handler closed the sink
1119
+ * or simply returned. After retirement this SETTLES with the
1120
+ * typed closed refusal (the F-S3.1-2 level: the promise never
1121
+ * hangs the handler — the terminal was already sent and the
1122
+ * handler's return is discarded).
1123
+ */
1124
+ close(): Promise<void>;
1125
+ /**
1126
+ * The retirement signal: resolves with one of `timeout`,
1127
+ * `cancelled`, `revoked`, `session-lost`, `leader-lost`,
1128
+ * `node-closed`, `replaced` exactly when the call retires. A
1129
+ * call that completes normally never retires, so this promise
1130
+ * stays pending — it is the retirement observable, not a
1131
+ * completion signal.
1132
+ */
1133
+ retired(): Promise<any>;
1134
+ /**
1135
+ * Push one response item. Refuses (typed) after retirement, and
1136
+ * parks (retries) while the response window has no credit — the
1137
+ * same permit semantics as the caller-side sinks.
1138
+ *
1139
+ * # Settling (the F-S3.1-2 level)
1140
+ *
1141
+ * Once `retired` resolves this promise SETTLES with the typed
1142
+ * closed refusal — a post-retirement `send` never hangs the
1143
+ * handler: it refuses, the handler resolves (or rejects), and
1144
+ * its return value is discarded because the terminal was
1145
+ * already sent.
1146
+ */
1147
+ send(payload: Uint8Array): Promise<void>;
1148
+ }
1149
+
1150
+ /**
1151
+ * A registration of one org service.
1152
+ */
1153
+ export class OrgServeHandle {
1154
+ private constructor();
1155
+ free(): void;
1156
+ [Symbol.dispose](): void;
1157
+ /**
1158
+ * Close the registration.
1159
+ *
1160
+ * **The protected-path split (C9):** closing an ORG serve
1161
+ * handle retires its live protected calls — each with its exact
1162
+ * retirement terminal — and refuses new openings. This is NOT
1163
+ * the public-path "let existing calls finish" behaviour.
1164
+ */
1165
+ close(): void;
1166
+ /**
1167
+ * The service name.
1168
+ */
1169
+ service(): string;
1170
+ }
1171
+
1172
+ /**
1173
+ * One org-scoped client-streaming call as JavaScript sees it.
1174
+ */
1175
+ export class OrgUploadCallHandle {
1176
+ private constructor();
1177
+ free(): void;
1178
+ [Symbol.dispose](): void;
1179
+ /**
1180
+ * Cancel the call (one CANCEL, terminal latched).
1181
+ */
1182
+ cancel(): void;
1183
+ /**
1184
+ * Half-close the upload and await the response body.
1185
+ *
1186
+ * Resolves the terminal body; rejects with the typed terminal
1187
+ * error's `Display` text (an admission denial is
1188
+ * `rpc: refused (9): <coarse>`).
1189
+ */
1190
+ finish(): Promise<Uint8Array>;
1191
+ /**
1192
+ * Push one upload item.
1193
+ */
1194
+ send(payload: Uint8Array): Promise<void>;
1195
+ }
1196
+
1197
+ /**
1198
+ * One application stream, on whichever tab runs the node.
1199
+ *
1200
+ * # Why it remembers its generation
1201
+ *
1202
+ * A stream id names per-session state, and leadership moving means a
1203
+ * new node with a new and independently allocated stream table. A
1204
+ * handle that carried only the id would therefore address *whatever*
1205
+ * stream the successor happened to open with that id — so a retained
1206
+ * object's `send` could push a payload into a stranger's stream and
1207
+ * its `close` could tear that stream down. Carrying the opening
1208
+ * generation makes the handle refuse instead, and the refusal is
1209
+ * typed, because "the leader changed" is an answer a page can act on
1210
+ * and silence is not.
1211
+ *
1212
+ * # Why it remembers a handle *and* an id
1213
+ *
1214
+ * The same argument one level down. Two opens to two peers under one
1215
+ * label share a wire stream id, so the id does not name an open
1216
+ * either: addressing the backend by it let one handle's `send` reach
1217
+ * another peer's stream. The `handle` names the open; the
1218
+ * `stream_id` is what the application filters on; and
1219
+ * [`Self::peer_node_hex`] is what makes that filter a peer filter
1220
+ * rather than a peer-blind one.
1221
+ */
1222
+ export class ProxyStream {
1223
+ private constructor();
1224
+ free(): void;
1225
+ [Symbol.dispose](): void;
1226
+ /**
1227
+ * Stop using the stream.
1228
+ *
1229
+ * Not a resurrection point: D2 is explicit that a stream is
1230
+ * session-scoped and is **not** restored across a leader change.
1231
+ * A page whose leader went away opens a new stream — and this
1232
+ * handle refuses to close anything on a successor, because the
1233
+ * stream it named is already gone with the node that owned it.
1234
+ *
1235
+ * The generation is checked twice, and the second one is the one
1236
+ * that matters. This method is synchronous and the request is
1237
+ * not, so the admission check below happens in the caller's turn
1238
+ * while the request is dispatched in a later one: a handoff in
1239
+ * between would have stamped the close as *current* and torn
1240
+ * down whatever stream the successor had opened with this id.
1241
+ * The check at admission stays because it is the one that makes a
1242
+ * stale close cost no task at all.
1243
+ */
1244
+ close(): void;
1245
+ /**
1246
+ * The generation that opened this stream, as a decimal string.
1247
+ */
1248
+ generation(): string;
1249
+ /**
1250
+ * The incarnation of the session this stream was opened on,
1251
+ * decimal — the spelling the event carries.
1252
+ */
1253
+ incarnation(): string;
1254
+ /**
1255
+ * Whether this stream retransmits.
1256
+ */
1257
+ is_reliable(): boolean;
1258
+ /**
1259
+ * Listen for inbound payloads on this stream.
1260
+ *
1261
+ * Filtered from the session's event stream by **both halves of
1262
+ * the key** — the peer and the stream id — which is the same
1263
+ * mechanism and the same event spelling a leader-local stream
1264
+ * uses ([`crate::wasm::LeafStream::on_message`]), so a
1265
+ * follower's stream and a leader's deliver through one path;
1266
+ * **and** by the generation that opened it, so a stale handle's
1267
+ * consumer stops receiving rather than starts receiving a
1268
+ * successor's bytes.
1269
+ *
1270
+ * The peer half was missing here, and the id alone is not the
1271
+ * identity of a stream: two peers under one label share it, so a
1272
+ * proxied consumer received whichever peer's payload arrived.
1273
+ * That is R4-10, on the proxied path.
1274
+ */
1275
+ on_message(callback: Function): void;
1276
+ /**
1277
+ * The peer this stream is with, 16 lowercase hex digits.
1278
+ *
1279
+ * **Spelled exactly like [`crate::wasm::LeafStream::peer_node_hex`]**
1280
+ * because a consumer must not need to know whether its stream is
1281
+ * direct or proxied to filter by peer. Its absence here was the
1282
+ * R4-10 cross-peer admixture, still open on every proxied handle
1283
+ * — including the leader tab's own `MeshSession`, which wraps the
1284
+ * same `ProxyStream`.
1285
+ */
1286
+ peer_node_hex(): string;
1287
+ /**
1288
+ * Send one payload.
1289
+ *
1290
+ * Refused, typed, once leadership has moved: see the type's own
1291
+ * documentation for why this is not merely an optimisation.
1292
+ *
1293
+ * # What resolving means, and what it does not
1294
+ *
1295
+ * Three dispositions are distinct and only the first is this
1296
+ * promise's:
1297
+ *
1298
+ * 1. **Admission.** Resolving says the node that owns the stream
1299
+ * accepted the bytes and enqueued them — a reliable stream has
1300
+ * taken ownership of them for retransmission, a
1301
+ * fire-and-forget one has queued one packet. That is the
1302
+ * contract, and it is the same one `LeafStream.send` has on
1303
+ * the direct surface.
1304
+ * 2. **Transport refusal.** A DataChannel that refuses the
1305
+ * packet at the flush boundary is reported there
1306
+ * (`crate::wasm::Inner::flush`) and does *not* reject this
1307
+ * promise: the flush happens after admission, on the node's
1308
+ * own pump, and a reliable stream's retransmission is what
1309
+ * answers for it.
1310
+ * 3. **Acknowledgement.** Nothing here waits for one. A reliable
1311
+ * stream's delivery is observable through its peer, not
1312
+ * through the resolution of this call; an unacknowledged
1313
+ * payload is retransmitted, and a stream that exhausts its
1314
+ * retries fails the stream rather than this send.
1315
+ *
1316
+ * A page that needs end-to-end confirmation asks for one in its
1317
+ * own protocol — an nRPC call, or a reply on the stream. Making
1318
+ * this promise wait for an ACK would turn every send into a round
1319
+ * trip and still could not speak for a fire-and-forget stream.
1320
+ */
1321
+ send(payload: Uint8Array): Promise<void>;
1322
+ /**
1323
+ * The stream id, 16 lowercase hex digits.
1324
+ */
1325
+ stream_id_hex(): string;
1326
+ }
1327
+
1328
+ /**
1329
+ * Route panics to `console.error`, so a wasm surprise is legible in
1330
+ * the browser log instead of an opaque `unreachable`.
1331
+ */
1332
+ export function start(): void;
1333
+
1334
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
1335
+
1336
+ export interface InitOutput {
1337
+ readonly memory: WebAssembly.Memory;
1338
+ readonly __wbg_leafnode_free: (a: number, b: number) => void;
1339
+ readonly __wbg_leafstream_free: (a: number, b: number) => void;
1340
+ readonly __wbg_meshsession_free: (a: number, b: number) => void;
1341
+ readonly __wbg_orgbytestreamhandle_free: (a: number, b: number) => void;
1342
+ readonly __wbg_orgduplexcallhandle_free: (a: number, b: number) => void;
1343
+ readonly __wbg_orgrequeststreamhandle_free: (a: number, b: number) => void;
1344
+ readonly __wbg_orgresponsesinkhandle_free: (a: number, b: number) => void;
1345
+ readonly __wbg_orgservehandle_free: (a: number, b: number) => void;
1346
+ readonly __wbg_orguploadcallhandle_free: (a: number, b: number) => void;
1347
+ readonly __wbg_proxystream_free: (a: number, b: number) => void;
1348
+ readonly leafnode_anchor_id_hex: (a: number, b: number) => void;
1349
+ readonly leafnode_announce: (a: number, b: number, c: number) => number;
1350
+ readonly leafnode_apply_org_revocation_bundle: (a: number, b: number, c: number, d: number) => void;
1351
+ readonly leafnode_arm_network_retry: (a: number, b: number) => void;
1352
+ readonly leafnode_call: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
1353
+ readonly leafnode_call_org: (a: number, b: number, c: number, d: number, e: number) => number;
1354
+ readonly leafnode_call_org_client_stream: (a: number, b: number, c: number, d: number) => number;
1355
+ readonly leafnode_call_org_duplex: (a: number, b: number, c: number, d: number) => number;
1356
+ readonly leafnode_call_org_streaming: (a: number, b: number, c: number, d: number, e: number) => number;
1357
+ readonly leafnode_close: (a: number) => void;
1358
+ readonly leafnode_connect: (a: number) => number;
1359
+ readonly leafnode_counters_json: (a: number, b: number) => void;
1360
+ readonly leafnode_effective_ice_servers: (a: number, b: number) => void;
1361
+ readonly leafnode_effective_stream_options: (a: number, b: number) => void;
1362
+ readonly leafnode_enroll: (a: number) => number;
1363
+ readonly leafnode_is_enrolled: (a: number) => number;
1364
+ readonly leafnode_listener_count: (a: number) => number;
1365
+ readonly leafnode_maxEventBytes: () => number;
1366
+ readonly leafnode_node_id_hex: (a: number, b: number) => void;
1367
+ readonly leafnode_on_event: (a: number, b: number, c: number) => void;
1368
+ readonly leafnode_open_stream: (a: number, b: number, c: number) => void;
1369
+ readonly leafnode_origin_hash_hex: (a: number, b: number) => void;
1370
+ readonly leafnode_peer_accept_offer: (a: number, b: number, c: number) => number;
1371
+ readonly leafnode_peer_candidate: (a: number, b: number, c: number) => number;
1372
+ readonly leafnode_peer_candidate_in: (a: number, b: number, c: number, d: number, e: number) => number;
1373
+ readonly leafnode_peer_direct_dialog: (a: number, b: number, c: number, d: number) => void;
1374
+ readonly leafnode_peer_handshake: (a: number, b: number, c: number) => number;
1375
+ readonly leafnode_peer_handshake_in: (a: number, b: number, c: number, d: number, e: number) => number;
1376
+ readonly leafnode_peer_offer: (a: number, b: number, c: number) => number;
1377
+ readonly leafnode_publish: (a: number, b: number, c: number, d: number) => number;
1378
+ readonly leafnode_query: (a: number, b: number, c: number) => number;
1379
+ readonly leafnode_remove_listener: (a: number, b: number, c: number) => number;
1380
+ readonly leafnode_retire: (a: number, b: bigint) => number;
1381
+ readonly leafnode_retry_report: (a: number, b: number) => void;
1382
+ readonly leafnode_rtc_stats_json: (a: number, b: number) => void;
1383
+ readonly leafnode_serve_org: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
1384
+ readonly leafnode_serve_org_client_stream: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
1385
+ readonly leafnode_serve_org_duplex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
1386
+ readonly leafnode_serve_org_streaming: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
1387
+ readonly leafnode_signal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
1388
+ readonly leafnode_subscribe: (a: number, b: number, c: number) => number;
1389
+ readonly leafnode_unsubscribe: (a: number, b: number, c: number) => number;
1390
+ readonly leafstream_close: (a: number) => void;
1391
+ readonly leafstream_incarnation: (a: number, b: number) => void;
1392
+ readonly leafstream_is_reliable: (a: number) => number;
1393
+ readonly leafstream_on_message: (a: number, b: number, c: number) => void;
1394
+ readonly leafstream_peer_node_hex: (a: number, b: number) => void;
1395
+ readonly leafstream_remove_listener: (a: number, b: number, c: number) => number;
1396
+ readonly leafstream_send: (a: number, b: number, c: number) => void;
1397
+ readonly leafstream_stream_id_hex: (a: number, b: number) => void;
1398
+ readonly meshsession_announce: (a: number, b: number, c: number) => number;
1399
+ readonly meshsession_call: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
1400
+ readonly meshsession_call_org: (a: number, b: number, c: number, d: number, e: number) => number;
1401
+ readonly meshsession_call_org_client_stream: (a: number, b: number, c: number, d: number) => number;
1402
+ readonly meshsession_call_org_duplex: (a: number, b: number, c: number, d: number) => number;
1403
+ readonly meshsession_call_org_streaming: (a: number, b: number, c: number, d: number, e: number) => number;
1404
+ readonly meshsession_close: (a: number) => void;
1405
+ readonly meshsession_counters_json: (a: number) => number;
1406
+ readonly meshsession_enroll: (a: number) => number;
1407
+ readonly meshsession_fingerprint: (a: number, b: number) => void;
1408
+ readonly meshsession_generation: (a: number, b: number) => void;
1409
+ readonly meshsession_interruption_ms: (a: number, b: number) => void;
1410
+ readonly meshsession_is_enrolled: (a: number) => number;
1411
+ readonly meshsession_node_id_hex: (a: number, b: number) => void;
1412
+ readonly meshsession_on_event: (a: number, b: number) => void;
1413
+ readonly meshsession_open: (a: number) => number;
1414
+ readonly meshsession_open_stream: (a: number, b: number) => number;
1415
+ readonly meshsession_peer_accept_offer: (a: number, b: number, c: number) => number;
1416
+ readonly meshsession_peer_candidate: (a: number, b: number, c: number, d: number, e: number) => number;
1417
+ readonly meshsession_peer_direct_dialog: (a: number, b: number, c: number) => number;
1418
+ readonly meshsession_peer_handshake: (a: number, b: number, c: number, d: number, e: number) => number;
1419
+ readonly meshsession_peer_offer: (a: number, b: number, c: number) => number;
1420
+ readonly meshsession_publish: (a: number, b: number, c: number, d: number) => number;
1421
+ readonly meshsession_query: (a: number, b: number, c: number) => number;
1422
+ readonly meshsession_role: (a: number, b: number) => void;
1423
+ readonly meshsession_scope: (a: number, b: number) => void;
1424
+ readonly meshsession_serve_org: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
1425
+ readonly meshsession_serve_org_client_stream: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
1426
+ readonly meshsession_serve_org_duplex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
1427
+ readonly meshsession_serve_org_streaming: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
1428
+ readonly meshsession_signal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
1429
+ readonly meshsession_subscribe: (a: number, b: number, c: number) => number;
1430
+ readonly meshsession_unsubscribe: (a: number, b: number, c: number) => number;
1431
+ readonly orgbytestreamhandle_cancel: (a: number) => void;
1432
+ readonly orgbytestreamhandle_next: (a: number) => number;
1433
+ readonly orgduplexcallhandle_cancel: (a: number) => void;
1434
+ readonly orgduplexcallhandle_finish_sending: (a: number) => number;
1435
+ readonly orgduplexcallhandle_send: (a: number, b: number) => number;
1436
+ readonly orgduplexcallhandle_stream: (a: number) => number;
1437
+ readonly orgrequeststreamhandle_next: (a: number) => number;
1438
+ readonly orgrequeststreamhandle_retired: (a: number) => number;
1439
+ readonly orgresponsesinkhandle_close: (a: number) => number;
1440
+ readonly orgresponsesinkhandle_retired: (a: number) => number;
1441
+ readonly orgresponsesinkhandle_send: (a: number, b: number) => number;
1442
+ readonly orgservehandle_close: (a: number) => void;
1443
+ readonly orgservehandle_service: (a: number, b: number) => void;
1444
+ readonly orguploadcallhandle_cancel: (a: number) => void;
1445
+ readonly orguploadcallhandle_finish: (a: number) => number;
1446
+ readonly orguploadcallhandle_send: (a: number, b: number) => number;
1447
+ readonly proxystream_close: (a: number) => void;
1448
+ readonly proxystream_generation: (a: number, b: number) => void;
1449
+ readonly proxystream_incarnation: (a: number, b: number) => void;
1450
+ readonly proxystream_is_reliable: (a: number) => number;
1451
+ readonly proxystream_on_message: (a: number, b: number) => void;
1452
+ readonly proxystream_peer_node_hex: (a: number, b: number) => void;
1453
+ readonly proxystream_send: (a: number, b: number) => number;
1454
+ readonly proxystream_stream_id_hex: (a: number, b: number) => void;
1455
+ readonly start: () => void;
1456
+ readonly __wasm_bindgen_func_elem_6504: (a: number, b: number, c: number, d: number) => void;
1457
+ readonly __wasm_bindgen_func_elem_6506: (a: number, b: number, c: number, d: number) => void;
1458
+ readonly __wasm_bindgen_func_elem_2355: (a: number, b: number, c: number) => number;
1459
+ readonly __wasm_bindgen_func_elem_2356: (a: number, b: number, c: number) => void;
1460
+ readonly __wasm_bindgen_func_elem_2356_112: (a: number, b: number, c: number) => void;
1461
+ readonly __wasm_bindgen_func_elem_2356_113: (a: number, b: number, c: number) => void;
1462
+ readonly __wasm_bindgen_func_elem_2356_114: (a: number, b: number, c: number) => void;
1463
+ readonly __wasm_bindgen_func_elem_2356_115: (a: number, b: number, c: number) => void;
1464
+ readonly __wasm_bindgen_func_elem_2356_116: (a: number, b: number, c: number) => void;
1465
+ readonly __wbindgen_export: (a: number, b: number) => number;
1466
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
1467
+ readonly __wbindgen_export3: (a: number) => void;
1468
+ readonly __wbindgen_export4: (a: number, b: number) => void;
1469
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
1470
+ readonly __wbindgen_export5: (a: number, b: number, c: number) => void;
1471
+ readonly __wbindgen_start: () => void;
1472
+ }
1473
+
1474
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
1475
+
1476
+ /**
1477
+ * Instantiates the given `module`, which can either be bytes or
1478
+ * a precompiled `WebAssembly.Module`.
1479
+ *
1480
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
1481
+ *
1482
+ * @returns {InitOutput}
1483
+ */
1484
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
1485
+
1486
+ /**
1487
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
1488
+ * for everything else, calls `WebAssembly.instantiate` directly.
1489
+ *
1490
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
1491
+ *
1492
+ * @returns {Promise<InitOutput>}
1493
+ */
1494
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;