openrtc 2.3.0 → 2.4.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 (68) hide show
  1. package/dist/{ITransport-CjxCQ6q7.d.ts → Connection-DZ5eP5hL.d.ts} +445 -94
  2. package/dist/DelegatingRuntimeAdapter-4cgiIWMN.d.ts +150 -0
  3. package/dist/IpcRuntimeAdapter-Dduaxscj.d.ts +80 -0
  4. package/dist/WasmBridge-3W2HHADU.js +1 -0
  5. package/dist/{assembly-Bmi65-tK.d.ts → assembly-By3UBQsE.d.ts} +36 -19
  6. package/dist/{capabilities-BPuynml5.d.ts → capabilities-B2mHv_H7.d.ts} +2 -6
  7. package/dist/chunk-2GX6GB6L.js +1 -0
  8. package/dist/chunk-2LATKLCC.js +118 -0
  9. package/dist/{chunk-KRJECX7X.js → chunk-5XOLKH66.js} +1 -1
  10. package/dist/chunk-6OFAKLDB.js +2 -0
  11. package/dist/chunk-72NEEJQG.js +1 -0
  12. package/dist/chunk-BCGCJGIV.js +2 -0
  13. package/dist/chunk-GNW63SM6.js +2 -0
  14. package/dist/chunk-JPBW67B3.js +1 -0
  15. package/dist/chunk-MI3ZMVPK.js +2 -0
  16. package/dist/chunk-OT7IPLZE.js +1 -0
  17. package/dist/chunk-OWKAJPOI.js +1 -0
  18. package/dist/chunk-P2SHJMS3.js +1 -0
  19. package/dist/chunk-TYZS5LXQ.js +2 -0
  20. package/dist/chunk-WB66633N.js +1 -0
  21. package/dist/chunk-XEHBTMJQ.js +1 -0
  22. package/dist/chunk-YYI6AY6W.js +2 -0
  23. package/dist/{controlPlane-KVFZ7BR5.js → controlPlane-7E6KGQPP.js} +1 -1
  24. package/dist/coreClient.d.ts +3 -4
  25. package/dist/coreClient.js +1 -1
  26. package/dist/{deviceEnrollment-VACC64CQ.js → deviceEnrollment-CBJYXZ43.js} +2 -2
  27. package/dist/index.d.ts +6 -7
  28. package/dist/index.js +1 -1
  29. package/dist/{ipc-CPnNwv6f.d.ts → ipc-DgzKqHH3.d.ts} +3 -0
  30. package/dist/ipcFactory-4PCGKZIN.js +1 -0
  31. package/dist/native.d.ts +21 -0
  32. package/dist/native.js +1 -0
  33. package/dist/openrtc-5HAYVDHT.js +2 -0
  34. package/dist/openrtc_bg.wasm +0 -0
  35. package/dist/protocol-BSBjMb7p.d.ts +6 -0
  36. package/dist/runtime/WasmRuntimeAdapter.d.ts +4 -5
  37. package/dist/runtime/WasmRuntimeAdapter.js +1 -1
  38. package/dist/runtime/device-status.d.ts +1 -2
  39. package/dist/runtime/factories.d.ts +283 -8
  40. package/dist/runtime/factories.js +1 -1
  41. package/dist/runtime/index.d.ts +13 -160
  42. package/dist/runtime/index.js +1 -1
  43. package/dist/testing/native.d.ts +11 -0
  44. package/dist/testing/native.js +1 -0
  45. package/dist/testing.d.ts +13 -19
  46. package/dist/testing.js +1 -1
  47. package/dist/transport/index.d.ts +7 -18
  48. package/dist/transport/index.js +1 -1
  49. package/dist/{types--jQzenZR.d.ts → types-BArEthJr.d.ts} +178 -10
  50. package/package.json +11 -2
  51. package/dist/DelegatingRuntimeAdapter-DE4LTGAJ.d.ts +0 -399
  52. package/dist/IpcRuntimeAdapter-CE0va9Tr.d.ts +0 -19
  53. package/dist/WasmBridge-75F6GKHG.js +0 -1
  54. package/dist/chunk-2L6ULC32.js +0 -1
  55. package/dist/chunk-2SUSPEC4.js +0 -1
  56. package/dist/chunk-7BJKDBLP.js +0 -2
  57. package/dist/chunk-DUY34MGT.js +0 -1
  58. package/dist/chunk-HEAJ7ZUR.js +0 -1
  59. package/dist/chunk-HUG5AX7R.js +0 -1
  60. package/dist/chunk-Q6KXVTSH.js +0 -2
  61. package/dist/chunk-R35AWMNY.js +0 -1
  62. package/dist/chunk-UILOGUOU.js +0 -1
  63. package/dist/chunk-WA434EWD.js +0 -2
  64. package/dist/chunk-XAL4T6TB.js +0 -3
  65. package/dist/chunk-Z2IS6NH2.js +0 -2
  66. package/dist/ipcFactory-32R47AVK.js +0 -1
  67. package/dist/openrtc-4EZPCHWM.js +0 -2
  68. package/dist/types-DDhMQkK8.d.ts +0 -621
@@ -1,3 +1,299 @@
1
+ type AuthContext = {
2
+ userId: string;
3
+ token?: string | null;
4
+ refreshToken?: string | null;
5
+ customToken?: string | null;
6
+ tokenProvider?: (forceRefresh?: boolean) => Promise<string | null>;
7
+ /**
8
+ * Supplies the platform attestation token required by the configured
9
+ * control plane. Firebase-backed hosted deployments use App Check today;
10
+ * keeping acquisition on the auth context prevents coordination code from
11
+ * owning a second Firebase app or assuming one global project.
12
+ */
13
+ appCheckTokenProvider?: (forceRefresh?: boolean) => Promise<string | null>;
14
+ expiresAtMs?: number | null;
15
+ };
16
+
17
+ /**
18
+ * App-facing options intentionally hide transport node identifiers from callbacks.
19
+ */
20
+ type RuntimeClientOptions = Omit<ClientOptions, 'onDevices' | 'onAutoConnect' | 'onIncomingSession' | 'coordinationAvenueOverride' | 'coordinationRoomGossipFanout' | 'coordinationPlatformType'> & {
21
+ onDevices?: (devices: RuntimeDevice[]) => void;
22
+ onAutoConnect?: (devices: RuntimeDevice[]) => void;
23
+ onIncomingSession?: (session: RuntimeSession) => Promise<void>;
24
+ };
25
+ /**
26
+ * App-facing device model. Runtime transport identifiers stay internal.
27
+ */
28
+ type RuntimeDevice = Omit<Device, 'nodeId'>;
29
+ /**
30
+ * App-facing session model. Node identifiers are runtime-internal metadata.
31
+ */
32
+ type RuntimeSession = Omit<SignalingSession, 'initiatorNodeId' | 'targetNodeId' | 'appTag'>;
33
+ type RuntimeAuthIdentity = RuntimeIdentity;
34
+ type RuntimeAuthContext = AuthContext;
35
+ /**
36
+ * App-facing peer state model. Runtime transport identifiers stay internal.
37
+ */
38
+ type RuntimePeerState = Omit<PeerState, 'nodeId'>;
39
+ type RuntimePeerHealth = PeerHealth;
40
+ type PeerLifecycleStatus$1 = PeerLifecycleStatus;
41
+ type RuntimePeerScope = PeerScope;
42
+ /**
43
+ * App-facing peer session snapshot model. Runtime transport identifiers stay internal.
44
+ */
45
+ type PeerSessionSnapshot$1 = Omit<PeerSessionSnapshot, 'nodeId'>;
46
+ type LocalDeviceInfo$1 = LocalDeviceInfo;
47
+ type RuntimeRoomMember = RoomMember;
48
+ type DeviceConnectOptions = ManagedDeviceConnectOptions;
49
+ type JoinRoomOptions$1 = JoinRoomOptions;
50
+ type ChannelDescriptor$1 = ChannelDescriptor;
51
+ interface ConnectionTarget {
52
+ ticket: string;
53
+ timeoutMs?: number;
54
+ }
55
+ /**
56
+ * Durable browser storage used by the optional upstream Iroh docs, blobs, and
57
+ * gossip protocols. Implementations normally map these atomic operations to
58
+ * IndexedDB; OpenRTC deliberately does not own a second browser database.
59
+ */
60
+ interface BrowserProtocolStore {
61
+ loadIdentity(): Promise<{
62
+ defaultAuthor: Uint8Array;
63
+ } | null>;
64
+ exportSnapshot(): Promise<{
65
+ authors: unknown[];
66
+ namespaces: unknown[];
67
+ entries: unknown[];
68
+ }>;
69
+ importAuthor(authorId: string, author: Uint8Array): Promise<void>;
70
+ importNamespace(capability: unknown): Promise<void>;
71
+ deleteNamespace(namespaceId: string): Promise<void>;
72
+ applyEntry(mutation: unknown): Promise<void>;
73
+ acknowledgeOutbox(operationId: string): Promise<void>;
74
+ listBlobManifests(): Promise<unknown[]>;
75
+ getBlobResumeState(contentHash: string): Promise<unknown | null>;
76
+ readBlobRange(contentHash: string, offset: number, length: number): Promise<Uint8Array | null>;
77
+ writeBlobRange(contentHash: string, size: number, chunkBytes: number, offset: number, bytes: Uint8Array): Promise<void>;
78
+ finalizeBlob(contentHash: string): Promise<boolean>;
79
+ readBlobOutboardNode(contentHash: string, nodeId: string): Promise<Uint8Array | null>;
80
+ writeOutboard(contentHash: string, nodeId: string, pair: Uint8Array): Promise<void>;
81
+ markBlobBaoReady(contentHash: string): Promise<void>;
82
+ writeStagingChunk(sessionId: string, chunkIndex: number, bytes: Uint8Array): Promise<void>;
83
+ finalizeBlobStaging(sessionId: string, contentHash: string, size: number, chunkBytes: number): Promise<void>;
84
+ abortBlobStaging(sessionId: string): Promise<void>;
85
+ deleteBlob(contentHash: string, force: boolean): Promise<boolean>;
86
+ beginBlobImport(contentHash: string, size: number, chunkBytes: number): Promise<void>;
87
+ writeBlobChunk(contentHash: string, size: number, chunkBytes: number, chunkIndex: number, bytes: Uint8Array): Promise<void>;
88
+ finalizeBlobImport(contentHash: string, size: number, chunkBytes: number): Promise<void>;
89
+ flush(): Promise<void>;
90
+ }
91
+ interface NamespaceDescriptor {
92
+ namespaceId: string;
93
+ capabilityKind: 'read' | 'write';
94
+ capability: Uint8Array;
95
+ }
96
+ interface IrohMutationReceipt {
97
+ contentHash: string;
98
+ operationId: string;
99
+ }
100
+ interface IrohDocEntry {
101
+ namespaceId: string;
102
+ authorId: string;
103
+ key: Uint8Array;
104
+ timestamp: number;
105
+ contentHash: string;
106
+ contentLength: number;
107
+ }
108
+ interface PeerConnectOptions {
109
+ deviceId?: string;
110
+ ticket?: string;
111
+ scope?: RuntimePeerScope;
112
+ channelId?: string;
113
+ /** Total wall-clock budget for dial, admission, and peer settlement. */
114
+ timeoutMs?: number;
115
+ /**
116
+ * When true, automatic/observer dials fail fast if the peer has a sticky
117
+ * manual-disconnect projection for this app session. User-initiated manual
118
+ * reconnects should leave this unset and clear the exclusion explicitly.
119
+ */
120
+ keepManualDisconnect?: boolean;
121
+ }
122
+ interface PeerStreamOptions {
123
+ ticket?: string;
124
+ scope?: RuntimePeerScope;
125
+ channelId?: string;
126
+ /** Internal channel metadata written inside the protected stream envelope. */
127
+ channelMetadata?: Record<string, unknown> | null;
128
+ timeoutMs?: number;
129
+ }
130
+ interface PortableMediaChunk {
131
+ publicationId: string;
132
+ mediaGeneration: number;
133
+ sequence: number;
134
+ timestampUs: number;
135
+ durationUs: number;
136
+ kind: 'audio' | 'video' | 'screen' | 'data';
137
+ codec: 'opus' | 'h264' | 'vp8' | 'vp9' | 'av1' | 'pcm' | 'opaque';
138
+ keyframe: boolean;
139
+ discardable: boolean;
140
+ payload: Uint8Array;
141
+ }
142
+ interface PortableMediaPublish {
143
+ publicationId: string;
144
+ mediaGeneration: number;
145
+ kind: 'audio' | 'video';
146
+ codec: PortableMediaChunk['codec'];
147
+ clockRate: number;
148
+ codedWidth?: number;
149
+ codedHeight?: number;
150
+ channels?: number;
151
+ }
152
+ interface PortableMediaPublicationStart {
153
+ publicationId: string;
154
+ mediaGeneration: number;
155
+ control: Uint8Array;
156
+ }
157
+ interface PortableMediaSample {
158
+ publicationId: string;
159
+ timestampUs: number;
160
+ durationUs: number;
161
+ keyframe: boolean;
162
+ discardable: boolean;
163
+ payload: Uint8Array;
164
+ }
165
+ type PortableMediaControl = {
166
+ type: 'publish';
167
+ publicationId: string;
168
+ mediaGeneration: number;
169
+ kind: PortableMediaPublish['kind'];
170
+ codec: PortableMediaPublish['codec'];
171
+ clockRate: number;
172
+ codedWidth?: number;
173
+ codedHeight?: number;
174
+ channels?: number;
175
+ } | {
176
+ type: 'set-enabled' | 'request-keyframe' | 'stop';
177
+ publicationId: string;
178
+ mediaGeneration: number;
179
+ [key: string]: unknown;
180
+ };
181
+ type ChannelFraming = 'raw' | 'u32be';
182
+ interface ScopedChannelOptions {
183
+ peerId?: string;
184
+ peerNodeId?: string;
185
+ deviceId?: string | null;
186
+ ticket?: string;
187
+ scope: RuntimePeerScope;
188
+ channelId: string;
189
+ timeoutMs?: number;
190
+ keepManualDisconnect?: boolean;
191
+ /**
192
+ * Reuse an application-ready route owned by an active capability and fail
193
+ * if none exists. Protocol packages use this to open a named channel
194
+ * without gaining authority to dial, repair, or add an admission avenue.
195
+ */
196
+ existingRouteOnly?: boolean;
197
+ framing?: ChannelFraming;
198
+ }
199
+ interface ScopedLogicalChannel {
200
+ channelId: string;
201
+ peerId: string;
202
+ connection: Connection;
203
+ send(payload: Uint8Array): Promise<void>;
204
+ onMessage(callback: (payload: Uint8Array) => void): () => void;
205
+ close(): Promise<void>;
206
+ diagnostics(): {
207
+ connectionId: string | null;
208
+ remoteNodeId: string | null;
209
+ transports: string[];
210
+ hasSendOnWebRTC?: boolean;
211
+ hasWebRTCTransport?: boolean;
212
+ lastSendTransport?: ProtocolName | 'stream' | null;
213
+ framing: ChannelFraming;
214
+ delivery: 'reliable' | 'latest-state';
215
+ };
216
+ }
217
+ /**
218
+ * App-facing device status snapshot model. Runtime transport identifiers stay internal.
219
+ */
220
+ type DeviceStatus = Omit<DeviceStatusSnapshot, 'nodeId'>;
221
+ type DevicePresence = DevicePresenceStatus;
222
+ type IncomingStream = {
223
+ type: 'bi' | 'uni';
224
+ stream: any;
225
+ /** Native Rust logical connection identity used for internal demux. */
226
+ connectionId?: string;
227
+ remoteNodeId: string;
228
+ protocolHint?: 'control' | 'explicit' | 'native-main' | 'unknown';
229
+ channel?: ChannelMetadata | null;
230
+ };
231
+ type ConnectionEvent = {
232
+ type: 'connected' | 'disconnected';
233
+ connectionId: string;
234
+ localNodeId: string;
235
+ remoteNodeId: string;
236
+ transport: ProtocolName;
237
+ };
238
+ type RawConnection = {
239
+ connectionId: string;
240
+ localNodeId: string;
241
+ remoteNodeId: string;
242
+ };
243
+ type PresenceLoopOptions = {
244
+ deviceName?: string;
245
+ ticket?: string;
246
+ metadata?: string;
247
+ };
248
+ type SessionPlatform = 'native' | 'web';
249
+ type SessionKind = 'app-user-device' | 'share-anonymous' | 'drive-grant-guest' | 'scoped-guest' | (string & {});
250
+ type AutoConnectPolicy = 'enabled' | 'disabled' | 'scoped-only';
251
+ type PresencePolicy = 'online' | 'disabled';
252
+ type ConnectionState = BackendConnectionState;
253
+ type ReadinessOptions = ApplicationPayloadReadinessOptions;
254
+ type PayloadRouteOptions = ApplicationPayloadRouteOptions;
255
+ type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'failed';
256
+ interface PeerReadiness {
257
+ requestedId: string;
258
+ connected: boolean;
259
+ settledReady: boolean;
260
+ status: ConnectionStatus;
261
+ health: RuntimePeerHealth | 'unknown';
262
+ deviceId?: string | null;
263
+ deviceIdHint?: string | null;
264
+ activeConnectionId?: string | null;
265
+ readinessState?: string;
266
+ readinessReason?: string;
267
+ scopes: string[];
268
+ }
269
+ interface DeviceProfile {
270
+ deviceId: string | null;
271
+ deviceName: string;
272
+ platformType: string;
273
+ userId: string | null;
274
+ capabilities: NonNullable<LocalDeviceInfo$1['capabilities']>;
275
+ lastSeenAt: string;
276
+ localNodeId?: string | null;
277
+ }
278
+ interface ManagedOptions {
279
+ platform: SessionPlatform;
280
+ sessionKind?: SessionKind;
281
+ scope?: string | null;
282
+ autoConnectPolicy?: AutoConnectPolicy;
283
+ presencePolicy?: PresencePolicy;
284
+ userId?: string | null;
285
+ deviceName?: string;
286
+ localDeviceId?: string | null;
287
+ metadata?: string;
288
+ autoConnect?: boolean;
289
+ presence?: boolean;
290
+ }
291
+ interface ManagedSession {
292
+ mode: SessionPlatform;
293
+ device: DeviceProfile;
294
+ stop: () => Promise<void>;
295
+ }
296
+
1
297
  interface CoordinationGatewayOptions {
2
298
  /**
3
299
  * Provider-neutral coordination gateway endpoint.
@@ -117,10 +413,9 @@ type EndpointKind = 'device' | 'ephemeral';
117
413
  type PeerLifecycleStatus = 'disconnected' | 'connecting' | 'connected' | 'failed' | 'closed';
118
414
  type PeerHealth = 'unknown' | 'healthy' | 'suspect' | 'stale';
119
415
  type DevicePresenceStatus = 'online' | 'idle' | 'offline';
120
- type PeerLifecycleStage = 'discovered' | 'dialing' | 'base-connected' | 'admitted' | 'protocol-ready' | 'upgrading' | 'webrtc-ready' | 'degraded' | 'reconnecting' | 'closed';
416
+ type PeerLifecycleStage = 'discovered' | 'dialing' | 'base-connected' | 'admitted' | 'protocol-ready' | 'degraded' | 'reconnecting' | 'closed';
121
417
  type PeerBaseTransportState = 'unknown' | 'connecting' | 'connected' | 'degraded' | 'closed';
122
418
  type PeerAdmissionState = 'unknown' | 'pending' | 'admitted' | 'rejected' | 'expired';
123
- type PeerWebRtcState = 'unknown' | 'disabled' | 'connecting' | 'transport-open' | 'route-probing' | 'ready' | 'failed' | 'closed';
124
419
  /**
125
420
  * Lifecycle label attached to a projected peer while the runtime tracks local ownership.
126
421
  *
@@ -154,13 +449,13 @@ interface ChannelDescriptor {
154
449
  delivery?: 'reliable' | 'latest-state';
155
450
  description?: string;
156
451
  }
157
- type ProtocolName = 'iroh' | 'iroh-quic' | 'iroh-relay' | 'iroh-lan' | 'iroh-webrtc' | 'iroh-moq' | 'ble' | 'webrtc' | 'webrtc-lan' | 'webrtc-turn' | 'moq';
452
+ type ProtocolName = 'iroh' | 'iroh-quic' | 'iroh-relay' | 'iroh-lan' | 'ble' | 'webrtc' | 'moq';
158
453
  type ProtocolMaturity = 'stable' | 'experimental' | 'unsupported';
159
454
  type TransportPrivacy = 'direct' | 'relay-only';
160
455
  type RouteOptimization = 'balanced' | 'lowest-latency';
161
456
  type ProtocolBaseName = 'iroh' | 'webrtc' | 'moq';
162
- type RouteFamily = 'iroh-path' | 'iroh-physical' | 'optional-route';
163
- type RouteKind = 'core' | 'host-installed' | 'carrier-adapter' | 'route-adapter' | 'path-label';
457
+ type RouteFamily = 'iroh-path' | 'iroh-physical';
458
+ type RouteKind = 'core' | 'host-installed' | 'carrier-adapter' | 'path-label';
164
459
  /**
165
460
  * Public compatibility type. `native` and `plugin` are legacy capability
166
461
  * labels; generated route descriptors use `RouteKind`.
@@ -177,7 +472,6 @@ interface RouteDescriptor {
177
472
  defaultRank: number;
178
473
  browser: boolean;
179
474
  native: boolean;
180
- independent: boolean;
181
475
  }
182
476
  interface ProtocolCapability {
183
477
  /** Canonical descriptor id; additive to the legacy capability shape. */
@@ -190,16 +484,14 @@ interface ProtocolCapability {
190
484
  implementation: ProtocolImplementationKind;
191
485
  locality: ProtocolLocality;
192
486
  maturity: ProtocolMaturity;
193
- /** Canonical descriptor rank; additive to the legacy capability shape. */
194
- defaultRank?: number;
487
+ /** Canonical descriptor rank and the sole public ordering metadata. */
488
+ defaultRank: number;
489
+ /** @deprecated Read-only 2.x compatibility alias; removed in 3.0.0. */
490
+ preferredRank: number;
195
491
  /** Canonical implementation taxonomy; `implementation` retains legacy values. */
196
492
  routeImplementation?: RouteKind;
197
- /** Compatibility alias for `defaultRank`. */
198
- preferredRank: number;
199
493
  browser: boolean;
200
494
  native: boolean;
201
- /** Canonical descriptor flag; additive to the legacy capability shape. */
202
- independent?: boolean;
203
495
  configured?: boolean;
204
496
  available: boolean;
205
497
  reason?: string;
@@ -293,15 +585,6 @@ interface ClientOptions {
293
585
  nodeIdPersistence?: 'persistent' | 'ephemeral';
294
586
  secretKey?: string;
295
587
  strictMode?: boolean;
296
- /**
297
- * Selects the sole consumer of admitted native application streams.
298
- *
299
- * `runtime` (default) routes named OpenRTC channels through the TypeScript
300
- * runtime. `host` is for native products that install one process-level
301
- * Rust protocol dispatcher. A native host must never enable both consumers:
302
- * the underlying stream queue is ordered and each raw stream has one owner.
303
- */
304
- nativeStreamConsumer?: 'runtime' | 'host';
305
588
  /**
306
589
  * Optional application-provided TURN credential loader.
307
590
  *
@@ -316,7 +599,10 @@ interface ClientOptions {
316
599
  onAutoConnect?: (devices: Device[]) => void;
317
600
  onIncomingSession?: (session: SignalingSession) => Promise<void>;
318
601
  transports?: {
319
- /** Allow Iroh, TURN, and MoQ relay routes. Defaults to true. */
602
+ /**
603
+ * Consumer relay intent. Authenticated Iroh-relay and managed-TURN
604
+ * availability are separate runtime facts.
605
+ */
320
606
  relay?: boolean;
321
607
  iroh?: boolean | PlutoIrohConfiguration;
322
608
  webrtc?: boolean | PlutoRTCConfiguration;
@@ -401,7 +687,6 @@ interface PeerState {
401
687
  settledReady?: boolean;
402
688
  readinessState?: string;
403
689
  readinessReason?: string;
404
- webrtcState?: PeerWebRtcState;
405
690
  routable?: boolean;
406
691
  transportStableId?: number | null;
407
692
  transportGeneration?: number;
@@ -454,6 +739,16 @@ interface BackendConnectionState {
454
739
  createdAt?: number;
455
740
  updatedAt?: number;
456
741
  }
742
+ /** Generation-fenced application message emitted by the native Rust owner. */
743
+ interface NativePeerDataEvent {
744
+ connectionId: string;
745
+ remoteNodeId?: string | null;
746
+ transport: ProtocolName;
747
+ transportStableId: number;
748
+ transportGeneration: number;
749
+ routeGeneration: number;
750
+ payload: number[];
751
+ }
457
752
  interface NativeConnectResult {
458
753
  connectionId: string;
459
754
  deviceId?: string | null;
@@ -646,13 +941,9 @@ interface DeviceStatusSnapshot extends Device {
646
941
  }
647
942
  interface LatencySnapshot {
648
943
  webrtc?: number | null;
649
- webrtcLan?: number | null;
650
- webrtcTurn?: number | null;
651
944
  iroh?: number | null;
652
945
  irohLan?: number | null;
653
946
  irohRelay?: number | null;
654
- irohWebrtc?: number | null;
655
- irohMoq?: number | null;
656
947
  ble?: number | null;
657
948
  moq?: number | null;
658
949
  }
@@ -768,13 +1059,6 @@ interface ExplicitFileDataSendParams {
768
1059
  deviceId?: string;
769
1060
  remoteNodeId?: string;
770
1061
  requireApplicationCrypto?: boolean;
771
- getUpgradeState?: () => string;
772
- isWebRtcApplicationRouteReady?: () => boolean;
773
- sendOnWebRTC?: (data: Uint8Array) => Promise<void>;
774
- getWebRTCTransport?: () => {
775
- getBufferedAmount?: () => number;
776
- waitForDrain?: (lowWaterMark: number) => Promise<void>;
777
- } | null;
778
1062
  };
779
1063
  remoteNodeId?: string;
780
1064
  file: File;
@@ -799,8 +1083,15 @@ interface DesiredPeerProjection {
799
1083
  sessionId?: string | null;
800
1084
  excludedPeers?: string[];
801
1085
  }
1086
+ /** Browser-only Rust/WASM module supplied by the browser signaling adapter. */
1087
+ interface BrowserWasmRuntimeModule {
1088
+ initWasm(moduleOrPath?: unknown): Promise<unknown>;
1089
+ WasmClient: new (apiKey: string) => any;
1090
+ start(): void;
1091
+ }
802
1092
  interface ISignalingBackend {
803
1093
  currentUser: RuntimeIdentity | null;
1094
+ loadBrowserWasmRuntime?(): Promise<BrowserWasmRuntimeModule>;
804
1095
  signInAnonymously(): Promise<void>;
805
1096
  signInWithPluto?(): Promise<void>;
806
1097
  signOut(): Promise<void>;
@@ -866,13 +1157,20 @@ interface ISignalingBackend {
866
1157
  notifyNetworkChange?(options?: {
867
1158
  reason?: string;
868
1159
  }): Promise<unknown>;
1160
+ setTransportPriority?(priority: ProtocolName[]): Promise<void>;
869
1161
  getManagedNodeId?(options?: {
870
1162
  initializeIfMissing?: boolean;
871
1163
  }): Promise<string | null>;
872
1164
  getEndpointTicket?(): Promise<string>;
873
1165
  openPeerBi?(id: string, timeoutMs?: number): Promise<BackendPeerBiStream>;
874
- openPeerNativeBi?(id: string, label: string, timeoutMs?: number): Promise<BackendPeerBiStream>;
875
1166
  openPeerUni?(id: string, timeoutMs?: number): Promise<BackendPeerUniStream>;
1167
+ beginOpenRtcMediaPublication?(input: Omit<PortableMediaPublish, 'mediaGeneration'>): PortableMediaPublicationStart | Promise<PortableMediaPublicationStart>;
1168
+ encodeOpenRtcMediaSample?(input: PortableMediaSample): Uint8Array | Promise<Uint8Array>;
1169
+ pauseOpenRtcMediaPublication?(publicationId: string): void | Promise<void>;
1170
+ retireOpenRtcMediaPublication?(publicationId: string): void | Promise<void>;
1171
+ retireOpenRtcMediaReceiver?(publicationId: string, mediaGeneration: number): void | Promise<void>;
1172
+ decodeOpenRtcMediaChunk?(encoded: Uint8Array): PortableMediaChunk | Promise<PortableMediaChunk>;
1173
+ decodeOpenRtcMediaControl?(encoded: Uint8Array): PortableMediaControl | Promise<PortableMediaControl>;
876
1174
  connectToDevice?(params: {
877
1175
  deviceId?: string | null;
878
1176
  endpointTicket: string;
@@ -888,6 +1186,10 @@ interface ISignalingBackend {
888
1186
  isConnected(nodeId: string): Promise<boolean>;
889
1187
  getConnectionStates?(): Promise<BackendConnectionState[]>;
890
1188
  onStateChange?(callback: (state: BackendConnectionState) => void): Promise<() => void> | (() => void);
1189
+ /** Native-only protected logical message surface; browser uses its WASM connection. */
1190
+ sendPeerMessage?(id: string, payload: Uint8Array): Promise<void>;
1191
+ /** Native-only generation-fenced logical message projection. */
1192
+ onPeerMessage?(callback: (event: NativePeerDataEvent) => void): Promise<() => void> | (() => void);
891
1193
  /** @deprecated Implement file protocols over named channels, or use `openrtc-file-transfer`. */
892
1194
  sendExplicitFilePath?(connectionId: string, filePath: string, transferId?: string): Promise<string>;
893
1195
  /** @deprecated Implement file protocols over named channels, or use `openrtc-file-transfer`. */
@@ -898,15 +1200,7 @@ interface ISignalingBackend {
898
1200
  deleteTransferJob?(jobId: string): Promise<void>;
899
1201
  }
900
1202
  interface CoreClientBridgeHost {
901
- connect(ticket: string, timeoutMs?: number, expectedDeviceId?: string | null, channelId?: string, options?: {
902
- admissionAlreadyPresented?: boolean;
903
- approvedScope?: string | null;
904
- }): Promise<{
905
- id?: string | null;
906
- remoteNodeId?: string | null;
907
- deviceId?: string | null;
908
- } | unknown>;
909
- ensureManagedApplicationRoute?(options: ManagedApplicationRouteOptions): Promise<{
1203
+ ensureManagedApplicationRoute(options: ManagedApplicationRouteOptions): Promise<{
910
1204
  id?: string | null;
911
1205
  remoteNodeId?: string | null;
912
1206
  deviceId?: string | null;
@@ -932,9 +1226,6 @@ interface SignalingOptions {
932
1226
  nodeIdPersistence?: 'persistent' | 'ephemeral';
933
1227
  }
934
1228
  interface TransportContext {
935
- sendMoQ: (data: Uint8Array, options?: {
936
- alreadyProtected?: boolean;
937
- }) => Promise<void>;
938
1229
  /**
939
1230
  * Send one plaintext typed frame over a fresh runtime-owned Iroh application
940
1231
  * stream. The runtime applies the negotiated application-crypto stream
@@ -949,11 +1240,6 @@ interface TransportContext {
949
1240
  */
950
1241
  rankRoutes?: (candidates: ProtocolName[]) => ProtocolName[];
951
1242
  disableIrohFallback: boolean;
952
- isMoQReady: () => boolean;
953
- isMoQDataReady?: () => boolean;
954
- isMoQApplicationRouteProven?: () => boolean;
955
- requestMoQApplicationRouteProof?: () => void;
956
- clearMoQApplicationRouteProof?: () => void;
957
1243
  requestIrohCarrier?: () => void;
958
1244
  runtimeFlow?: 'default' | 'ticket-only';
959
1245
  readerCloseStrategy?: 'cancel' | 'release-lock';
@@ -1004,19 +1290,8 @@ interface ApplicationPayloadRouteOptions extends ApplicationPayloadReadinessOpti
1004
1290
  }
1005
1291
  interface ApplicationPayloadSendOptions extends ApplicationPayloadRouteOptions {
1006
1292
  }
1007
- interface ApplicationRouteReadyObservation {
1008
- connectionId: string;
1009
- remoteNodeId: string;
1010
- activeTransport: ProtocolName;
1011
- parallelTransport?: ProtocolName | null;
1012
- reason: 'webrtc-route-ready' | 'webrtc-heartbeat-healthy' | 'webrtc-application-send' | 'base-transport-loss-preserved';
1013
- transportStableId?: number;
1014
- transportGeneration?: number;
1015
- routeGeneration?: number;
1016
- }
1017
1293
  interface ConnectionOptions {
1018
1294
  reliable?: boolean;
1019
- rtcConfig?: PlutoRTCConfiguration;
1020
1295
  transportContext?: TransportContext;
1021
1296
  applicationCrypto?: PayloadCrypto;
1022
1297
  /**
@@ -1042,23 +1317,6 @@ interface ConnectionOptions {
1042
1317
  transportGeneration?: number;
1043
1318
  routeGeneration?: number;
1044
1319
  }) => boolean | void | Promise<boolean | void>;
1045
- /**
1046
- * Fired when a connection-owned application route has proven it can carry
1047
- * app traffic. Consumers should use this as a lifecycle signal for the same
1048
- * connection record, not as an independent projection source.
1049
- */
1050
- onApplicationRouteReady?: (event: ApplicationRouteReadyObservation) => void;
1051
- /**
1052
- * Fired when the WebRTC data plane has proven a ping/pong round trip but the
1053
- * mandatory application crypto route is not installed yet. Connection owns
1054
- * transport proof; Client owns the application-route handshake recovery.
1055
- */
1056
- onApplicationRouteMissing?: (event: {
1057
- connectionId: string;
1058
- remoteNodeId: string;
1059
- reason: 'webrtc-heartbeat-before-crypto';
1060
- negotiationId?: string | null;
1061
- }) => void;
1062
1320
  }
1063
1321
  interface JoinRequest {
1064
1322
  id: string;
@@ -1067,19 +1325,112 @@ interface JoinRequest {
1067
1325
  state: 'pending' | 'accepted' | 'rejected';
1068
1326
  }
1069
1327
 
1070
- interface ITransport {
1071
- readonly name: string;
1072
- readonly isReady: boolean;
1073
- init(localNodeId: string, remoteNodeId: string, options: any): Promise<void>;
1074
- send(data: Uint8Array): Promise<void>;
1075
- close(): void;
1076
- onMessage(callback: (data: Uint8Array) => void): void;
1077
- onStateChange(callback: (state: 'connecting' | 'connected' | 'failed' | 'disconnected') => void): void;
1078
- handleSignalingMessage?(msg: any): void;
1079
- getSignalingHandler?(): (msg: any) => Promise<void>;
1080
- getNativeTransport?(): any;
1081
- getNegotiationId?(): string | null;
1082
- getDataChannelReadyState?(): string | null;
1328
+ type ConnectionHealth = 'unknown' | 'healthy' | 'suspect' | 'stale';
1329
+
1330
+ type Message = string | object | ArrayBuffer | Uint8Array;
1331
+ /**
1332
+ * One logical admitted peer connection.
1333
+ *
1334
+ * This class owns application framing and callbacks on the logical Iroh stream
1335
+ * supplied by Rust. WebRTC and MoQ are packet carriers below that stream; this
1336
+ * class never constructs, negotiates, retries, or retains either carrier.
1337
+ * Authority inventory: `canonical-iroh-carriers` and
1338
+ * `logical-peer-streams-and-datagrams`.
1339
+ */
1340
+ declare class Connection {
1341
+ private static readonly decoder;
1342
+ private static readonly encoder;
1343
+ private static readonly MAX_PENDING_MESSAGES;
1344
+ private static readonly MAX_PENDING_ENCRYPTED_PAYLOADS;
1345
+ private static readonly DEFAULT_APPLICATION_CRYPTO_WAIT_MS;
1346
+ private writer;
1347
+ private reader;
1348
+ private options;
1349
+ private receiveBuffer;
1350
+ private writeMutex;
1351
+ private closed;
1352
+ private nativeSignalSender;
1353
+ private applicationKeyAgreementObservationEpoch;
1354
+ private lastApplicationPayloadTransport;
1355
+ private lastTransportStatusFingerprint;
1356
+ private lastBaseTransportGeneration;
1357
+ private lastBaseTransportStableId;
1358
+ private remoteDedicatedCarrierControl;
1359
+ private remoteDedicatedCarrierControlReady;
1360
+ private readonly listeners;
1361
+ private readonly closeListeners;
1362
+ private readonly irohHealthListeners;
1363
+ private readonly pendingMessages;
1364
+ private pendingEncryptedApplicationPayloads;
1365
+ private readonly applicationCryptoWaiters;
1366
+ readonly id: string;
1367
+ readonly remoteNodeId: string;
1368
+ /** @deprecated Use the admitted peer/device projection for device identity. */
1369
+ readonly deviceId: string;
1370
+ readonly localNodeId: string;
1371
+ constructor(id: string, localNodeId: string, remoteNodeId: string, writer: WritableStreamDefaultWriter<Uint8Array>, reader: ReadableStreamDefaultReader<Uint8Array>, options?: ConnectionOptions);
1372
+ get isClosed(): boolean;
1373
+ get transportType(): ProtocolName;
1374
+ setApplicationCrypto(applicationCrypto: PayloadCrypto | undefined): void;
1375
+ getKeyAgreementEpoch(): number;
1376
+ requireApplicationCrypto(): void;
1377
+ isApplicationCryptoRequired(): boolean;
1378
+ isPayloadReady(options?: ApplicationPayloadReadinessOptions): boolean;
1379
+ payloadTransports(options?: ApplicationPayloadRouteOptions): ProtocolName[];
1380
+ requestTransportRecovery(_reason: string): void;
1381
+ handleAppForeground(): void;
1382
+ handleBaseTransportAvailable(_source: string, proof: {
1383
+ transportState?: string | null;
1384
+ transportGeneration?: number | null;
1385
+ transportStableId?: number | null;
1386
+ }): void;
1387
+ getTransportDiagnostics(): Promise<any>;
1388
+ send(message: Message, options?: ApplicationPayloadSendOptions): Promise<void>;
1389
+ lastPayloadTransport(): ProtocolName | null;
1390
+ sendControl(message: Message): Promise<void>;
1391
+ sendRawIrohFrame(frame: Uint8Array): Promise<void>;
1392
+ getAvailableTransports(): ProtocolName[];
1393
+ disconnect(): Promise<void>;
1394
+ handleSessionAdmissionRejected(reason: string): void;
1395
+ onMessage(callback: (message: any) => void): void;
1396
+ onDisconnect(callback: () => void): void;
1397
+ injectData(chunk: Uint8Array): void;
1398
+ receiveFrameBody(body: Uint8Array): void;
1399
+ receiveMessage(message: unknown): void;
1400
+ receiveDataPayload(messageData: Uint8Array): void;
1401
+ onWebRtcHeartbeatHealth(_callback: (health: ConnectionHealth) => void): void;
1402
+ onIrohHeartbeatHealth(callback: (health: ConnectionHealth) => void): void;
1403
+ reportTransportStatusIfChanged(): void;
1404
+ getTransportStatus(): {
1405
+ activeTransport: ProtocolName;
1406
+ parallelTransport: ProtocolName | null;
1407
+ };
1408
+ getLatencySnapshot(): LatencySnapshot;
1409
+ setNativeSignalSender(sender: (envelope: any) => Promise<void>): void;
1410
+ getControlFrameMode(): NonNullable<ConnectionOptions['controlFrameMode']>;
1411
+ sendNativeControlEnvelope(envelope: unknown): Promise<boolean>;
1412
+ /** @deprecated Direct WebRTC/MoQ signal sessions were removed. */
1413
+ receiveInternalSignal(_content: unknown): void;
1414
+ private hasRequiredApplicationCrypto;
1415
+ private hasBaseApplicationRoute;
1416
+ private waitForRequiredApplicationCrypto;
1417
+ private resolveApplicationCryptoWaiters;
1418
+ private rejectApplicationCryptoWaiters;
1419
+ private encodePayload;
1420
+ private buildFrame;
1421
+ private sendTyped;
1422
+ private writeFrame;
1423
+ private openApplicationPayload;
1424
+ private openUntypedApplicationPayload;
1425
+ private isPlaintextBootstrapPayload;
1426
+ private queueEncryptedApplicationPayload;
1427
+ private flushPendingEncryptedApplicationPayloads;
1428
+ private readLoop;
1429
+ private handleData;
1430
+ private static isUntypedDataFrame;
1431
+ private processDataPayload;
1432
+ private emitMessage;
1433
+ private close;
1083
1434
  }
1084
1435
 
1085
- export type { RouteDescriptor as $, AuthMode as A, BackendPeerBiStream as B, ConnectDeviceResult as C, Device as D, ExplicitFileDataSendParams as E, ApplicationPayloadReadinessOptions as F, GrantScope as G, ApplicationPayloadRouteOptions as H, ISignalingBackend as I, ApplicationPayloadSendOptions as J, ITransport as K, LocalDeviceInfo as L, ManagedConnectionRecord as M, NativeConnectParams as N, LatencySnapshot as O, PlutoIrohConfiguration as P, PeerState as Q, RouteOptimization as R, SignalingMode as S, PeerScope as T, PeerHealth as U, ChannelDescriptor as V, ChannelMetadata as W, ManagedDeviceConnectOptions as X, JoinRoomOptions as Y, DevicePresenceStatus as Z, PeerLifecycleStatus as _, PlutoRTCConfiguration as a, ProtocolCapability as a0, ProtocolCapabilityMap as a1, CryptoStreams as a2, CryptoBiStream as a3, RouteFamily as a4, RouteKind as a5, AppLimits as a6, SignalingOptions as a7, RoomCreationMode as a8, ScanningLoopOptions as a9, ScanningLoopHandle as aa, RuntimeBootstrapOptions as ab, RuntimeBootstrapResult as ac, ManagedApplicationRouteOptions as ad, JoinRequest as ae, PlutoMoQConfiguration as b, ProtocolName as c, PeerSessionSnapshot as d, ResolvedPeerIdentity as e, ConnectDeviceHooks as f, ConnectDeviceOptions as g, ClientOptions as h, CoordinationGatewayGrantRequest as i, CoordinationGatewayGrant as j, DiscoveryMode as k, RoomMember as l, RuntimeIdentity as m, SignalingEnvelope as n, DeviceStatusSnapshot as o, BackendPeerUniStream as p, DeviceEvent as q, DesiredPeerProjection as r, CoreClientBridgeHost as s, NativeConnectResult as t, SignalingSession as u, SessionEvent as v, BackendConnectionState as w, NativeManagedSessionStartResult as x, ConnectionOptions as y, PayloadCrypto as z };
1436
+ export { type NativeManagedSessionStartResult as $, type AuthContext as A, type AuthMode as B, type ChannelDescriptor$1 as C, type DeviceStatus as D, type SignalingMode as E, type ClientOptions as F, type GrantScope as G, type ExplicitFileDataSendParams as H, type IncomingStream as I, type JoinRoomOptions$1 as J, type ISignalingBackend as K, type LocalDeviceInfo$1 as L, type ManagedOptions as M, type RuntimeIdentity as N, type RoomMember as O, type PlutoIrohConfiguration as P, type Device as Q, type RouteOptimization as R, type ScopedChannelOptions as S, type DeviceStatusSnapshot as T, type ManagedConnectionRecord as U, type SignalingEnvelope as V, type DeviceEvent as W, type DesiredPeerProjection as X, type SignalingSession as Y, type SessionEvent as Z, type LocalDeviceInfo as _, type PlutoRTCConfiguration as a, type BackendPeerBiStream as a0, type BackendPeerUniStream as a1, type PortableMediaPublish as a2, type PortableMediaPublicationStart as a3, type PortableMediaSample as a4, type PortableMediaChunk as a5, type PortableMediaControl as a6, type NativeConnectParams as a7, type NativeConnectResult as a8, type BackendConnectionState as a9, type ScanningLoopHandle as aA, type RuntimeBootstrapOptions as aB, type RuntimeBootstrapResult as aC, type ApplicationPayloadReadinessOptions as aD, type ManagedApplicationRouteOptions as aE, type PeerState as aF, type PeerScope as aG, type PeerHealth as aH, type ChannelDescriptor as aI, type JoinRequest as aJ, type AutoConnectPolicy as aK, type ChannelFraming as aL, type ConnectionStatus as aM, type DevicePresence as aN, type PayloadRouteOptions as aO, type PeerLifecycleStatus$1 as aP, type PeerSessionSnapshot$1 as aQ, type PresencePolicy as aR, type RuntimeAuthContext as aS, type RuntimePeerScope as aT, type SessionKind as aU, type SessionPlatform as aV, type NativePeerDataEvent as aa, type CoordinationGatewayGrantRequest as ab, type CoordinationGatewayGrant as ac, type BrowserWasmRuntimeModule as ad, type BrowserProtocolStore as ae, type NamespaceDescriptor as af, type IrohMutationReceipt as ag, type IrohDocEntry as ah, type CoreClientBridgeHost as ai, type RouteDescriptor as aj, type PayloadCrypto as ak, type CryptoStreams as al, type CryptoBiStream as am, type RouteFamily as an, type RouteKind as ao, type RuntimeAuthIdentity as ap, type RuntimeSession as aq, type AppLimits as ar, type ConnectionTarget as as, type PresenceLoopOptions as at, type SignalingOptions as au, type JoinRoomOptions as av, type ChannelMetadata as aw, type RoomCreationMode as ax, type ProtocolCapabilityMap as ay, type ScanningLoopOptions as az, type PlutoMoQConfiguration as b, type ProtocolName as c, type RuntimePeerState as d, type PeerConnectOptions as e, Connection as f, type PeerSessionSnapshot as g, type PeerReadiness as h, type RuntimePeerHealth as i, type ResolvedPeerIdentity as j, type PeerStreamOptions as k, type RuntimeDevice as l, type ScopedLogicalChannel as m, type ConnectionState as n, type ReadinessOptions as o, type ConnectionEvent as p, type ManagedSession as q, type DeviceConnectOptions as r, type ConnectDeviceResult as s, type ConnectDeviceHooks as t, type ConnectDeviceOptions as u, type DeviceProfile as v, type RawConnection as w, type RuntimeRoomMember as x, type RuntimeClientOptions as y, type DiscoveryMode as z };