openrtc 0.2.0 → 1.0.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.
- package/LICENSE +92 -0
- package/README.md +100 -10
- package/dist/{DelegatingRuntimeAdapter-CjHzBEBA.d.ts → DelegatingRuntimeAdapter-By7pziBs.d.ts} +36 -15
- package/dist/IEngineBridge-C7OT2CRv.d.ts +10 -0
- package/dist/{IpcRuntimeAdapter-CtckyMol.d.ts → IpcRuntimeAdapter-DymXAsNU.d.ts} +6 -3
- package/dist/auth/index.js +1 -1
- package/dist/auth/internal.js +1 -1
- package/dist/chunk-3KDNLXT6.js +3 -0
- package/dist/chunk-5RXNKNPH.js +2 -0
- package/dist/chunk-6TIOSMVJ.js +1 -0
- package/dist/chunk-BLOEZIFJ.js +1 -0
- package/dist/chunk-CK6WQV7J.js +1 -0
- package/dist/chunk-KH227SE4.js +1 -0
- package/dist/chunk-KYDLXXNM.js +1 -0
- package/dist/chunk-W5JHUOK5.js +2 -0
- package/dist/device-status-nkXepu97.d.ts +560 -0
- package/dist/{factories-CwZiIRg1.d.ts → framing-BUtu0oZK.d.ts} +47 -520
- package/dist/index.d.ts +113 -9
- package/dist/index.js +2 -2
- package/dist/openrtc_bg.wasm +0 -0
- package/dist/runtime/WasmRuntimeAdapter.d.ts +3 -2
- package/dist/runtime/WasmRuntimeAdapter.js +1 -1
- package/dist/runtime/device-status.d.ts +3 -0
- package/dist/runtime/device-status.js +1 -0
- package/dist/runtime/index.d.ts +94 -84
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/tauri.d.ts +4 -3
- package/dist/runtime/tauri.js +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +1 -1
- package/dist/{types-DyCGvj9l.d.ts → types-CzIpGV9x.d.ts} +117 -14
- package/package.json +22 -10
- package/dist/chunk-3VTF5RKW.js +0 -1
- package/dist/chunk-JXGKO7SX.js +0 -1
- package/dist/chunk-MFT6SOZ6.js +0 -3
- package/dist/chunk-SGZWR63E.js +0 -1
- package/dist/chunk-VARALO7G.js +0 -1
- package/dist/chunk-WOHFM6DI.js +0 -2
- package/dist/chunk-YHJOXD46.js +0 -2
|
@@ -1,337 +1,10 @@
|
|
|
1
|
-
import { A as AuthContext
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { A as AuthContext } from './IEngineBridge-C7OT2CRv.js';
|
|
2
|
+
import { G as GrantScope, I as ISignalingBackend, m as ConnectDeviceHooks, n as ConnectDeviceOptions, l as ConnectDeviceResult, M as ManagedConnectionRecord, P as PeerSessionSnapshot, c as ResolvedPeerIdentity, u as AppLimits, i as NativeConnectParams, j as NativeConnectResult, E as ExplicitFileDataSendParams } from './types-CzIpGV9x.js';
|
|
3
|
+
import { h as RuntimePeerState, s as RuntimeConnectionStateSnapshot, j as RuntimePeerReadinessSnapshot, i as RuntimePeerConnectOptions, C as Connection, n as RuntimeIncomingStream, R as RuntimeClientOptions, H as RuntimeAuthIdentity, f as RuntimeLocalDeviceInfo, g as RuntimeLocalDeviceProfile, c as RuntimeDevice, a as RuntimeManagedSessionOptions, b as RuntimeManagedSession, d as RuntimeDeviceStatusSnapshot, e as RuntimeDeviceConnectOptions, X as RuntimeSession, q as RuntimeJoinRoomOptions, r as RuntimeRoomMember, K as RuntimeConnectionTarget, o as RuntimeScopedChannelOptions, p as RuntimeScopedLogicalChannel, m as RuntimePeerStreamOptions, v as RuntimeRawConnection, l as RuntimeChannelDescriptor, V as RuntimePresenceLoopOptions, k as RuntimePeerHealth, t as RuntimeApplicationPayloadReadinessOptions, u as RuntimeConnectionEvent } from './device-status-nkXepu97.js';
|
|
4
|
+
import { R as RuntimeCapabilities, a as RuntimeCapabilityProfile } from './DelegatingRuntimeAdapter-By7pziBs.js';
|
|
5
|
+
import { P as PlutoIpcBridge, I as IpcRuntimeAdapter } from './IpcRuntimeAdapter-DymXAsNU.js';
|
|
4
6
|
import { WasmRuntimeAdapter } from './runtime/WasmRuntimeAdapter.js';
|
|
5
7
|
|
|
6
|
-
interface ITransport {
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly isReady: boolean;
|
|
9
|
-
init(localNodeId: string, remoteNodeId: string, options: any): Promise<void>;
|
|
10
|
-
send(data: Uint8Array): Promise<void>;
|
|
11
|
-
close(): void;
|
|
12
|
-
onMessage(callback: (data: Uint8Array) => void): void;
|
|
13
|
-
onStateChange(callback: (state: 'connecting' | 'connected' | 'failed' | 'disconnected') => void): void;
|
|
14
|
-
handleSignalingMessage?(msg: any): void;
|
|
15
|
-
getSignalingHandler?(): (msg: any) => Promise<void>;
|
|
16
|
-
getNativeTransport?(): any;
|
|
17
|
-
getNegotiationId?(): string | null;
|
|
18
|
-
getDataChannelReadyState?(): string | null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type ConnectionHealth = 'unknown' | 'healthy' | 'suspect' | 'stale';
|
|
22
|
-
|
|
23
|
-
type UpgradeState = 'none' | 'upgrading' | 'upgraded' | 'failed';
|
|
24
|
-
declare class Connection {
|
|
25
|
-
private static readonly textDecoder;
|
|
26
|
-
private static readonly textEncoder;
|
|
27
|
-
private static readonly UPGRADE_RETRY_DELAY_MS;
|
|
28
|
-
private static readonly MAX_UPGRADE_RETRIES;
|
|
29
|
-
private static readonly MAX_UPGRADE_REDRIVES;
|
|
30
|
-
private static readonly UPGRADE_REDRIVE_DELAY_MS;
|
|
31
|
-
private static readonly WEBRTC_DISCONNECTED_GRACE_MS;
|
|
32
|
-
private static readonly MAX_PENDING_MESSAGES;
|
|
33
|
-
private static readonly DEFAULT_APPLICATION_CRYPTO_WAIT_MS;
|
|
34
|
-
/**
|
|
35
|
-
* Must exceed `WEBRTC_ICE_CONNECT_TIMEOUT_MS` in `WebRTCTransport`: the transport
|
|
36
|
-
* waits that long for ICE + DataChannel before `failed`. A shorter watchdog here
|
|
37
|
-
* tears the PC down early, burns `MAX_UPGRADE_RETRIES`, and stretches upgrades to ~60s+ under load.
|
|
38
|
-
*/
|
|
39
|
-
private static readonly WEBRTC_UPGRADE_ATTEMPT_TIMEOUT_MS;
|
|
40
|
-
private static readonly MAX_PENDING_ENCRYPTED_APPLICATION_PAYLOADS;
|
|
41
|
-
private listeners;
|
|
42
|
-
private pendingMessages;
|
|
43
|
-
private pendingEncryptedApplicationPayloads;
|
|
44
|
-
private webrtcBinaryHandlers;
|
|
45
|
-
private closeListeners;
|
|
46
|
-
private upgradeStateListeners;
|
|
47
|
-
private writer;
|
|
48
|
-
private reader;
|
|
49
|
-
private _isClosed;
|
|
50
|
-
get isClosed(): boolean;
|
|
51
|
-
private receiveBuffer;
|
|
52
|
-
readonly id: string;
|
|
53
|
-
readonly remoteNodeId: string;
|
|
54
|
-
/** @deprecated Compatibility alias for legacy consumers. This is the remote node id, not a device id. */
|
|
55
|
-
readonly deviceId: string;
|
|
56
|
-
readonly localNodeId: string;
|
|
57
|
-
private options;
|
|
58
|
-
private writeMutex;
|
|
59
|
-
private applicationCryptoWaiters;
|
|
60
|
-
private nativeSignalSender;
|
|
61
|
-
private webrtcTransport;
|
|
62
|
-
private webRtcApplicationRouteReadyTransport;
|
|
63
|
-
private webRtcApplicationRouteReadyNegotiationId;
|
|
64
|
-
private upgradeState;
|
|
65
|
-
private upgradeRequested;
|
|
66
|
-
private negotiationSwitchCount;
|
|
67
|
-
private upgradeAttemptActive;
|
|
68
|
-
private upgradeRetryCount;
|
|
69
|
-
private upgradeReDriveCount;
|
|
70
|
-
private upgradeReDriveTimer;
|
|
71
|
-
private upgradeRetryTimer;
|
|
72
|
-
private upgradeAttemptTimeoutTimer;
|
|
73
|
-
private lastReportedTransportStatus;
|
|
74
|
-
private applicationRouteMissingNotified;
|
|
75
|
-
private upgradeTerminalFailure;
|
|
76
|
-
private pendingSignals;
|
|
77
|
-
private activeNegotiationId;
|
|
78
|
-
private webrtcHeartbeat;
|
|
79
|
-
private webRtcHeartbeatProbeInFlight;
|
|
80
|
-
private webRtcApplicationRouteProbeInFlight;
|
|
81
|
-
private webRtcHeartbeatConsecutiveProbeFailures;
|
|
82
|
-
private irohHealthListeners;
|
|
83
|
-
private webrtcHealthListeners;
|
|
84
|
-
private lastWebRtcHeartbeatOkAt;
|
|
85
|
-
private lastWebRtcDataChannelOpenAt;
|
|
86
|
-
private static readonly WEBRTC_RENEGOTIATE_LIVENESS_WINDOW_MS;
|
|
87
|
-
private static readonly MAX_NEGOTIATION_SWITCHES;
|
|
88
|
-
private lastForegroundAt;
|
|
89
|
-
private webRtcDisconnectedGraceTimer;
|
|
90
|
-
private preferredWebRtcRole;
|
|
91
|
-
constructor(id: string, localNodeId: string, remoteNodeId: string, writer: WritableStreamDefaultWriter<Uint8Array>, reader: ReadableStreamDefaultReader<Uint8Array>, options?: ConnectionOptions);
|
|
92
|
-
setApplicationCrypto(applicationCrypto: ApplicationPayloadCrypto | undefined): void;
|
|
93
|
-
requireApplicationCrypto(): void;
|
|
94
|
-
isApplicationCryptoRequired(): boolean;
|
|
95
|
-
isReadyForApplicationPayload(options?: ApplicationPayloadReadinessOptions): boolean;
|
|
96
|
-
getApplicationPayloadTransports(options?: ApplicationPayloadRouteOptions): ProtocolName[];
|
|
97
|
-
private isTransportAvailableForApplicationPayload;
|
|
98
|
-
private resolveApplicationCryptoWaiters;
|
|
99
|
-
private rejectApplicationCryptoWaiters;
|
|
100
|
-
private waitForRequiredApplicationCrypto;
|
|
101
|
-
/**
|
|
102
|
-
* Starts WebRTC upgrade only when peer capability negotiation allows it.
|
|
103
|
-
* No-op when WebRTC is not configured or an upgrade already started.
|
|
104
|
-
*/
|
|
105
|
-
requestWebRTCUpgrade(reason?: string): void;
|
|
106
|
-
/**
|
|
107
|
-
* Whether the current WebRTC route is provably alive: an open data channel
|
|
108
|
-
* plus either a recent heartbeat round trip or a freshly opened channel. An
|
|
109
|
-
* `open` readyState alone is not proof — it lingers for many seconds after the
|
|
110
|
-
* remote vanishes (e.g. a page reload), so a dead-but-`open` channel reports
|
|
111
|
-
* not-live and can be replaced rather than trusted.
|
|
112
|
-
*/
|
|
113
|
-
private isWebRtcRouteHeartbeatLive;
|
|
114
|
-
requestTransportRecovery(reason: string, options?: {
|
|
115
|
-
forceRenegotiate?: boolean;
|
|
116
|
-
replaceExisting?: boolean;
|
|
117
|
-
}): void;
|
|
118
|
-
private static readonly FOREGROUND_PROBE_TIMEOUT_MS;
|
|
119
|
-
handleAppForeground(): void;
|
|
120
|
-
private beginWebRtcRecovery;
|
|
121
|
-
getUpgradeState(): UpgradeState;
|
|
122
|
-
updateRTCConfig(rtcConfig: ConnectionOptions['rtcConfig']): void;
|
|
123
|
-
onUpgradeStateChange(callback: (state: UpgradeState) => void): void;
|
|
124
|
-
/**
|
|
125
|
-
* Best-effort transport diagnostics for developer tooling.
|
|
126
|
-
*
|
|
127
|
-
* - `usesRelay=true` means the selected WebRTC candidate pair includes a relay candidate.
|
|
128
|
-
* - `usesRelay=false` means we found a selected pair and it is direct.
|
|
129
|
-
* - `usesRelay=null` means there is not enough data yet.
|
|
130
|
-
*/
|
|
131
|
-
getTransportDiagnostics(): Promise<{
|
|
132
|
-
activeTransport: ProtocolName;
|
|
133
|
-
parallelTransport: ProtocolName | null;
|
|
134
|
-
usesRelay: boolean | null;
|
|
135
|
-
relaySource: string | null;
|
|
136
|
-
webrtc: {
|
|
137
|
-
iceConnectionState: string | null;
|
|
138
|
-
iceGatheringState: string | null;
|
|
139
|
-
localCandidateType: string | null;
|
|
140
|
-
remoteCandidateType: string | null;
|
|
141
|
-
localProtocol: string | null;
|
|
142
|
-
remoteProtocol: string | null;
|
|
143
|
-
candidateTypeSummary: string | null;
|
|
144
|
-
} | null;
|
|
145
|
-
}>;
|
|
146
|
-
private lastWebRtcLocalCandidateType;
|
|
147
|
-
private lastWebRtcRemoteCandidateType;
|
|
148
|
-
get transportType(): ProtocolName;
|
|
149
|
-
private _peerMoQReady;
|
|
150
|
-
get peerMoQReady(): boolean;
|
|
151
|
-
set peerMoQReady(value: boolean);
|
|
152
|
-
private _remoteSupportsWebRTC;
|
|
153
|
-
get remoteSupportsWebRTC(): boolean;
|
|
154
|
-
set remoteSupportsWebRTC(value: boolean);
|
|
155
|
-
private mediaListeners;
|
|
156
|
-
/**
|
|
157
|
-
* Send a message to the other peer.
|
|
158
|
-
* Messages can be strings or objects (JSON stringified).
|
|
159
|
-
*/
|
|
160
|
-
send(message: string | object | ArrayBuffer | Uint8Array, options?: ApplicationPayloadSendOptions): Promise<void>;
|
|
161
|
-
/**
|
|
162
|
-
* Send media data (video/audio header + payload)
|
|
163
|
-
* Internal use for now.
|
|
164
|
-
*/
|
|
165
|
-
sendMedia(type: 'audio' | 'video', data: Uint8Array): Promise<void>;
|
|
166
|
-
/**
|
|
167
|
-
* Send a data message on a specific transport without fallback.
|
|
168
|
-
* Throws when the requested transport is unavailable.
|
|
169
|
-
*/
|
|
170
|
-
sendOnTransport(transport: ProtocolName, message: string | object | ArrayBuffer | Uint8Array): Promise<void>;
|
|
171
|
-
/**
|
|
172
|
-
* Send plaintext control traffic that is required to bootstrap application
|
|
173
|
-
* key agreement. This is intentionally separate from public app-data sends.
|
|
174
|
-
*/
|
|
175
|
-
sendControl(message: string | object | ArrayBuffer | Uint8Array): Promise<void>;
|
|
176
|
-
/**
|
|
177
|
-
* Write an already-framed payload directly on the underlying iroh control stream.
|
|
178
|
-
* Used by native-main signaling paths that must preserve protocol framing.
|
|
179
|
-
*/
|
|
180
|
-
sendRawIrohFrame(frame: Uint8Array): Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* Compatibility/diagnostic view of currently usable transports.
|
|
183
|
-
*
|
|
184
|
-
* Lifecycle projection and route selection must use getTransportStatus().
|
|
185
|
-
* This legacy list intentionally remains for older callers and tests that
|
|
186
|
-
* need a human-readable inventory, but it is not an authority for active
|
|
187
|
-
* versus fallback transport state.
|
|
188
|
-
*/
|
|
189
|
-
getAvailableTransports(): ProtocolName[];
|
|
190
|
-
onWebRTCBinaryMessage(handler: (data: Uint8Array) => boolean): void;
|
|
191
|
-
private dispatchWebRtcBinaryHandlers;
|
|
192
|
-
getWebRTCTransport(): ITransport | null;
|
|
193
|
-
sendOnWebRTC(data: Uint8Array): Promise<void>;
|
|
194
|
-
private encodePayload;
|
|
195
|
-
private protectApplicationPayload;
|
|
196
|
-
private openApplicationPayload;
|
|
197
|
-
private openUntypedApplicationPayload;
|
|
198
|
-
private queueEncryptedApplicationPayload;
|
|
199
|
-
private flushPendingEncryptedApplicationPayloads;
|
|
200
|
-
private buildFrame;
|
|
201
|
-
private sendOverIroh;
|
|
202
|
-
private sendUsingTransport;
|
|
203
|
-
private sendTypedOnTransport;
|
|
204
|
-
private sendTyped;
|
|
205
|
-
private getSendTransportPriorities;
|
|
206
|
-
/**
|
|
207
|
-
* Disconnect the connection
|
|
208
|
-
*/
|
|
209
|
-
disconnect(): Promise<void>;
|
|
210
|
-
/**
|
|
211
|
-
* Listen for incoming messages
|
|
212
|
-
*/
|
|
213
|
-
onMessage(callback: (message: any) => void): void;
|
|
214
|
-
/**
|
|
215
|
-
* Listen for incoming media
|
|
216
|
-
*/
|
|
217
|
-
onMedia(callback: (type: 'audio' | 'video', data: Uint8Array) => void): void;
|
|
218
|
-
/**
|
|
219
|
-
* Listen for disconnection
|
|
220
|
-
*/
|
|
221
|
-
onDisconnect(callback: () => void): void;
|
|
222
|
-
private close;
|
|
223
|
-
private preserveWebRtcConnectionAfterBaseTransportLoss;
|
|
224
|
-
private readLoop;
|
|
225
|
-
injectData(chunk: Uint8Array): void;
|
|
226
|
-
private handleData;
|
|
227
|
-
private tryHandlePlaintextNativeSignal;
|
|
228
|
-
private static isUntypedDataFrame;
|
|
229
|
-
private processDataPayload;
|
|
230
|
-
private isLikelyTextPayload;
|
|
231
|
-
private emitMedia;
|
|
232
|
-
private emitMessage;
|
|
233
|
-
receiveMessage(msg: any): void;
|
|
234
|
-
receiveDataPayload(messageData: Uint8Array): void;
|
|
235
|
-
private trackListeners;
|
|
236
|
-
private warnedSrtpApplicationCryptoBoundary;
|
|
237
|
-
private warnSrtpApplicationCryptoBoundary;
|
|
238
|
-
addTrack(track: MediaStreamTrack): RTCRtpSender | null;
|
|
239
|
-
addTransceiver(trackOrKind: MediaStreamTrack | string, init?: RTCRtpTransceiverInit): RTCRtpTransceiver | null;
|
|
240
|
-
onTrack(callback: (event: RTCTrackEvent) => void): void;
|
|
241
|
-
private hasRecoverableBasePath;
|
|
242
|
-
private isWebRtcDataChannelOpen;
|
|
243
|
-
private clearWebRtcDisconnectedGraceTimer;
|
|
244
|
-
private transportStillLikelyAlive;
|
|
245
|
-
private handleUnhealthyWebRtcTransportStateWithGrace;
|
|
246
|
-
private attemptUpgrade;
|
|
247
|
-
private setUpgradeState;
|
|
248
|
-
private handleUpgradeFailure;
|
|
249
|
-
private scheduleUpgradeReDrive;
|
|
250
|
-
private clearUpgradeReDriveTimer;
|
|
251
|
-
private shouldRetryUpgrade;
|
|
252
|
-
private scheduleUpgradeRetry;
|
|
253
|
-
private clearUpgradeRetryTimer;
|
|
254
|
-
private startUpgradeAttemptTimeout;
|
|
255
|
-
private clearUpgradeAttemptTimeoutTimer;
|
|
256
|
-
private teardownWebRTCTransport;
|
|
257
|
-
private startWebRtcHeartbeat;
|
|
258
|
-
private stopWebRtcHeartbeat;
|
|
259
|
-
private notifyWebRtcApplicationRouteMissing;
|
|
260
|
-
private startWebRtcApplicationRouteProbe;
|
|
261
|
-
private sendIrohHeartbeatPong;
|
|
262
|
-
/** Register a listener for WebRTC heartbeat health changes. */
|
|
263
|
-
onWebRtcHeartbeatHealth(cb: (health: ConnectionHealth) => void): void;
|
|
264
|
-
/** Register a listener for iroh heartbeat health changes (WASM path). */
|
|
265
|
-
onIrohHeartbeatHealth(cb: (health: ConnectionHealth) => void): void;
|
|
266
|
-
reportTransportStatusIfChanged(): void;
|
|
267
|
-
/**
|
|
268
|
-
* Single connection-owned transport snapshot for status reporting,
|
|
269
|
-
* lifecycle projection, and diagnostics. The active route is application
|
|
270
|
-
* ready; the parallel route is its usable fallback or candidate.
|
|
271
|
-
*/
|
|
272
|
-
getTransportStatus(): {
|
|
273
|
-
activeTransport: ProtocolName;
|
|
274
|
-
parallelTransport: ProtocolName | null;
|
|
275
|
-
};
|
|
276
|
-
private resolveParallelTransport;
|
|
277
|
-
setNativeSignalSender(sender: (envelope: any) => Promise<void>): void;
|
|
278
|
-
/**
|
|
279
|
-
* Structured connection-lifecycle log. One event per meaningful transition
|
|
280
|
-
* (upgrade requested/started/failed, route promoted, app route ready, …) with
|
|
281
|
-
* the connection's current lifecycle snapshot, so the whole connection flow
|
|
282
|
-
* can be reconstructed from logs. Emits both a human line and a JSON line.
|
|
283
|
-
*/
|
|
284
|
-
private traceLifecycle;
|
|
285
|
-
getControlFrameMode(): NonNullable<ConnectionOptions['controlFrameMode']>;
|
|
286
|
-
/**
|
|
287
|
-
* Send a control envelope over the native-main signal route. Returns false
|
|
288
|
-
* (without sending) unless this connection is in `native-main` control-frame
|
|
289
|
-
* mode and has a native signal sender, so a typed connection never
|
|
290
|
-
* accidentally routes control through the native sender.
|
|
291
|
-
*/
|
|
292
|
-
sendNativeControlEnvelope(envelope: any): Promise<boolean>;
|
|
293
|
-
/**
|
|
294
|
-
* Promote a connection to the native-main control plane: switch its
|
|
295
|
-
* control-frame mode to `native-main` and attach the native signal sender.
|
|
296
|
-
* Used when native-main evidence arrives for a connection that bootstrapped
|
|
297
|
-
* on a typed stream, so subsequent control traffic flows over the durable
|
|
298
|
-
* native-main route even if the bootstrap stream later closes.
|
|
299
|
-
*/
|
|
300
|
-
promoteToNativeMainControlRoute(sender: (envelope: any) => Promise<void>): void;
|
|
301
|
-
private hasRequiredApplicationCrypto;
|
|
302
|
-
private clearWebRtcApplicationRouteReady;
|
|
303
|
-
private isCurrentWebRtcTransportApplicationRouteReady;
|
|
304
|
-
private isWebRtcApplicationRouteReadyForTransport;
|
|
305
|
-
/**
|
|
306
|
-
* Mark the upgraded WebRTC data plane as carrying a proven application route
|
|
307
|
-
* (data channel open + required crypto present). Idempotent. Promotes the
|
|
308
|
-
* active transport projection to `webrtc` via reportTransportStatusIfChanged.
|
|
309
|
-
*/
|
|
310
|
-
private markWebRtcApplicationRouteReady;
|
|
311
|
-
/**
|
|
312
|
-
* True only when the WebRTC transport is upgraded AND its application route
|
|
313
|
-
* is proven (crypto present). The active route must not advertise `webrtc`
|
|
314
|
-
* until this holds, so a half-open data channel never looks routable.
|
|
315
|
-
*/
|
|
316
|
-
isWebRtcApplicationRouteReady(): boolean;
|
|
317
|
-
/**
|
|
318
|
-
* MoQ has a different data-plane shape than WebRTC: it is a shared relay
|
|
319
|
-
* session on the Client plus a peer capability/subscription bit on this
|
|
320
|
-
* Connection. Even so, it follows the same lifecycle invariant as every
|
|
321
|
-
* custom transport: do not advertise it as the active application route until
|
|
322
|
-
* the local transport is ready, the peer route is enabled, and the required
|
|
323
|
-
* application crypto is available. Future MoQ route probes should tighten
|
|
324
|
-
* this predicate, not bypass it.
|
|
325
|
-
*/
|
|
326
|
-
isMoQApplicationRouteReady(): boolean;
|
|
327
|
-
private sendInternalSignal;
|
|
328
|
-
receiveInternalSignal(content: any): void;
|
|
329
|
-
private handleInternalSignal;
|
|
330
|
-
private createNegotiationId;
|
|
331
|
-
private getDeterministicWebRtcRole;
|
|
332
|
-
private normalizeNegotiationId;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
8
|
/**
|
|
336
9
|
* Coalesced peer reconciliation scheduler and full reconcile orchestration.
|
|
337
10
|
*
|
|
@@ -348,186 +21,6 @@ type PeerReconciliationStats = {
|
|
|
348
21
|
orphanTsConnectionHealed: number;
|
|
349
22
|
};
|
|
350
23
|
|
|
351
|
-
/**
|
|
352
|
-
* App-facing options intentionally hide transport node identifiers from callbacks.
|
|
353
|
-
*/
|
|
354
|
-
type RuntimeClientOptions = Omit<ClientOptions, 'onDevices' | 'onAutoConnect' | 'onIncomingSession'> & {
|
|
355
|
-
onDevices?: (devices: RuntimeDevice[]) => void;
|
|
356
|
-
onAutoConnect?: (devices: RuntimeDevice[]) => void;
|
|
357
|
-
onIncomingSession?: (session: RuntimeSession) => Promise<void>;
|
|
358
|
-
};
|
|
359
|
-
/**
|
|
360
|
-
* App-facing device model. Runtime transport identifiers stay internal.
|
|
361
|
-
*/
|
|
362
|
-
type RuntimeDevice = Omit<Device, 'nodeId'>;
|
|
363
|
-
/**
|
|
364
|
-
* App-facing session model. Node identifiers are runtime-internal metadata.
|
|
365
|
-
*/
|
|
366
|
-
type RuntimeSession = Omit<SignalingSession, 'initiatorNodeId' | 'targetNodeId' | 'appTag'>;
|
|
367
|
-
type RuntimeAuthIdentity = RuntimeIdentity;
|
|
368
|
-
type RuntimeAuthContext = AuthContext;
|
|
369
|
-
/**
|
|
370
|
-
* App-facing peer state model. Runtime transport identifiers stay internal.
|
|
371
|
-
*/
|
|
372
|
-
type RuntimePeerState = Omit<PeerState, 'nodeId'>;
|
|
373
|
-
type RuntimePeerHealth = PeerHealth;
|
|
374
|
-
type RuntimePeerLifecycleStatus = PeerLifecycleStatus;
|
|
375
|
-
type RuntimePeerScope = PeerScope;
|
|
376
|
-
/**
|
|
377
|
-
* App-facing peer session snapshot model. Runtime transport identifiers stay internal.
|
|
378
|
-
*/
|
|
379
|
-
type RuntimePeerSessionSnapshot = Omit<PeerSessionSnapshot, 'nodeId'>;
|
|
380
|
-
type RuntimeLocalDeviceInfo = LocalDeviceInfo;
|
|
381
|
-
type RuntimeRoomMember = RoomMember;
|
|
382
|
-
type RuntimeDeviceConnectOptions = ManagedDeviceConnectOptions;
|
|
383
|
-
type RuntimeJoinRoomOptions = JoinRoomOptions;
|
|
384
|
-
type RuntimeChannelDescriptor = ChannelDescriptor$1;
|
|
385
|
-
interface RuntimeConnectionTarget {
|
|
386
|
-
ticket: string;
|
|
387
|
-
timeoutMs?: number;
|
|
388
|
-
}
|
|
389
|
-
interface RuntimePeerConnectOptions {
|
|
390
|
-
deviceId?: string;
|
|
391
|
-
ticket?: string;
|
|
392
|
-
scope?: RuntimePeerScope;
|
|
393
|
-
channelId?: string;
|
|
394
|
-
/**
|
|
395
|
-
* When true, automatic/observer dials fail fast if the peer has a sticky
|
|
396
|
-
* manual-disconnect projection for this app session. User-initiated manual
|
|
397
|
-
* reconnects should leave this unset and clear the exclusion explicitly.
|
|
398
|
-
*/
|
|
399
|
-
respectManualDisconnect?: boolean;
|
|
400
|
-
}
|
|
401
|
-
interface RuntimePeerStreamOptions {
|
|
402
|
-
ticket?: string;
|
|
403
|
-
scope?: RuntimePeerScope;
|
|
404
|
-
channelId?: string;
|
|
405
|
-
timeoutMs?: number;
|
|
406
|
-
}
|
|
407
|
-
type RuntimeLogicalChannelFraming = 'raw' | 'u32be';
|
|
408
|
-
interface RuntimeScopedChannelOptions {
|
|
409
|
-
peerId?: string;
|
|
410
|
-
peerNodeId?: string;
|
|
411
|
-
deviceId?: string | null;
|
|
412
|
-
ticket?: string;
|
|
413
|
-
scope: RuntimePeerScope;
|
|
414
|
-
channelId: string;
|
|
415
|
-
timeoutMs?: number;
|
|
416
|
-
respectManualDisconnect?: boolean;
|
|
417
|
-
/**
|
|
418
|
-
* Native product protocols such as Plutonium drive-view expect a plaintext
|
|
419
|
-
* stream label before payload frames. OpenRTC owns that handshake here so
|
|
420
|
-
* apps do not need to choose raw transport APIs.
|
|
421
|
-
*/
|
|
422
|
-
nativeLabel?: boolean;
|
|
423
|
-
framing?: RuntimeLogicalChannelFraming;
|
|
424
|
-
}
|
|
425
|
-
interface RuntimeScopedLogicalChannel {
|
|
426
|
-
channelId: string;
|
|
427
|
-
peerId: string;
|
|
428
|
-
connection: Connection;
|
|
429
|
-
send(payload: Uint8Array): Promise<void>;
|
|
430
|
-
onMessage(callback: (payload: Uint8Array) => void): () => void;
|
|
431
|
-
close(): Promise<void>;
|
|
432
|
-
diagnostics(): {
|
|
433
|
-
connectionId: string | null;
|
|
434
|
-
remoteNodeId: string | null;
|
|
435
|
-
transports: string[];
|
|
436
|
-
framing: RuntimeLogicalChannelFraming;
|
|
437
|
-
nativeLabel: boolean;
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* App-facing device status snapshot model. Runtime transport identifiers stay internal.
|
|
442
|
-
*/
|
|
443
|
-
type RuntimeDeviceStatusSnapshot = Omit<DeviceStatusSnapshot, 'nodeId'>;
|
|
444
|
-
type RuntimeDeviceStatus = RuntimeDeviceStatusSnapshot;
|
|
445
|
-
type RuntimeIncomingStream = {
|
|
446
|
-
type: 'bi' | 'uni';
|
|
447
|
-
stream: any;
|
|
448
|
-
remoteNodeId: string;
|
|
449
|
-
protocolHint?: 'control' | 'explicit' | 'native-main' | 'unknown';
|
|
450
|
-
channel?: IncomingStreamChannelMetadata | null;
|
|
451
|
-
};
|
|
452
|
-
type RuntimeConnectionEvent = {
|
|
453
|
-
type: 'connected' | 'disconnected';
|
|
454
|
-
connectionId: string;
|
|
455
|
-
localNodeId: string;
|
|
456
|
-
remoteNodeId: string;
|
|
457
|
-
transport: ProtocolName;
|
|
458
|
-
};
|
|
459
|
-
type RuntimeRawConnection = {
|
|
460
|
-
connectionId: string;
|
|
461
|
-
localNodeId: string;
|
|
462
|
-
remoteNodeId: string;
|
|
463
|
-
};
|
|
464
|
-
type RuntimePresenceLoopOptions = {
|
|
465
|
-
deviceName?: string;
|
|
466
|
-
ticket?: string;
|
|
467
|
-
metadata?: string;
|
|
468
|
-
};
|
|
469
|
-
type RuntimeManagedSessionPlatform = 'native' | 'web';
|
|
470
|
-
type RuntimeManagedSessionKind = 'app-user-device' | 'share-anonymous' | 'drive-grant-guest' | 'scoped-guest' | (string & {});
|
|
471
|
-
type RuntimeAutoConnectPolicy = 'enabled' | 'disabled' | 'scoped-only';
|
|
472
|
-
type RuntimePresencePolicy = 'online' | 'disabled';
|
|
473
|
-
type RuntimeConnectionStateSnapshot = BackendConnectionState;
|
|
474
|
-
type RuntimeApplicationPayloadReadinessOptions = ApplicationPayloadReadinessOptions;
|
|
475
|
-
type RuntimeUiConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'failed';
|
|
476
|
-
interface RuntimePeerReadinessSnapshot {
|
|
477
|
-
requestedId: string;
|
|
478
|
-
connected: boolean;
|
|
479
|
-
settledReady: boolean;
|
|
480
|
-
status: RuntimeUiConnectionStatus;
|
|
481
|
-
health: RuntimePeerHealth | 'unknown';
|
|
482
|
-
deviceId?: string | null;
|
|
483
|
-
deviceIdHint?: string | null;
|
|
484
|
-
activeConnectionId?: string | null;
|
|
485
|
-
readinessState?: string;
|
|
486
|
-
readinessReason?: string;
|
|
487
|
-
scopes: string[];
|
|
488
|
-
}
|
|
489
|
-
interface RuntimeLocalDeviceProfile {
|
|
490
|
-
deviceId: string | null;
|
|
491
|
-
deviceName: string;
|
|
492
|
-
platformType: string;
|
|
493
|
-
userId: string | null;
|
|
494
|
-
capabilities: NonNullable<RuntimeLocalDeviceInfo['capabilities']>;
|
|
495
|
-
lastSeenAt: string;
|
|
496
|
-
localNodeId?: string | null;
|
|
497
|
-
}
|
|
498
|
-
interface RuntimeManagedSessionOptions {
|
|
499
|
-
platform: RuntimeManagedSessionPlatform;
|
|
500
|
-
sessionKind?: RuntimeManagedSessionKind;
|
|
501
|
-
scope?: string | null;
|
|
502
|
-
autoConnectPolicy?: RuntimeAutoConnectPolicy;
|
|
503
|
-
presencePolicy?: RuntimePresencePolicy;
|
|
504
|
-
userId?: string | null;
|
|
505
|
-
deviceName?: string;
|
|
506
|
-
localDeviceId?: string | null;
|
|
507
|
-
metadata?: string;
|
|
508
|
-
autoConnect?: boolean;
|
|
509
|
-
presence?: boolean;
|
|
510
|
-
}
|
|
511
|
-
interface RuntimeManagedSession {
|
|
512
|
-
mode: RuntimeManagedSessionPlatform;
|
|
513
|
-
device: RuntimeLocalDeviceProfile;
|
|
514
|
-
stop: () => Promise<void>;
|
|
515
|
-
}
|
|
516
|
-
type ConnectionTarget = RuntimeConnectionTarget;
|
|
517
|
-
type PeerConnectOptions = RuntimePeerConnectOptions;
|
|
518
|
-
type PeerStreamOptions = RuntimePeerStreamOptions;
|
|
519
|
-
type ScopedChannelOptions = RuntimeScopedChannelOptions;
|
|
520
|
-
type ScopedLogicalChannel = RuntimeScopedLogicalChannel;
|
|
521
|
-
type IncomingStream = RuntimeIncomingStream;
|
|
522
|
-
type ConnectionEvent = RuntimeConnectionEvent;
|
|
523
|
-
type RawConnection = RuntimeRawConnection;
|
|
524
|
-
type PresenceLoopOptions = RuntimePresenceLoopOptions;
|
|
525
|
-
type PeerReadiness = RuntimePeerReadinessSnapshot;
|
|
526
|
-
type DeviceProfile = RuntimeLocalDeviceProfile;
|
|
527
|
-
type SessionOptions$1 = RuntimeManagedSessionOptions;
|
|
528
|
-
type Session$1 = RuntimeManagedSession;
|
|
529
|
-
type ChannelDescriptor = RuntimeChannelDescriptor;
|
|
530
|
-
|
|
531
24
|
interface SessionOptions {
|
|
532
25
|
/**
|
|
533
26
|
* Logical purpose of this session. Used as a peer-scope tag on all
|
|
@@ -776,8 +269,7 @@ interface RuntimePolicySnapshot {
|
|
|
776
269
|
};
|
|
777
270
|
nativeIpc: {
|
|
778
271
|
authRequiredWaitMs: number;
|
|
779
|
-
|
|
780
|
-
managedSessionIpcMaxAttempts: number;
|
|
272
|
+
defaultBoundedCommandTimeoutMs: number;
|
|
781
273
|
connectionEventSubscribeWindowMs: number;
|
|
782
274
|
connectionEventRetryMinDelayMs: number;
|
|
783
275
|
connectionEventRetryMaxDelayMs: number;
|
|
@@ -852,6 +344,7 @@ declare class RuntimeClient {
|
|
|
852
344
|
private fetchAndApplyAppLimits;
|
|
853
345
|
private resolvePeerStreamTarget;
|
|
854
346
|
private compatPeerConnectionFromTarget;
|
|
347
|
+
private isTransportOnlyStreamChannel;
|
|
855
348
|
private nextNativeStartRetryDelayMs;
|
|
856
349
|
private hasManagedSession;
|
|
857
350
|
private usesNativeIpcBackend;
|
|
@@ -860,10 +353,10 @@ declare class RuntimeClient {
|
|
|
860
353
|
private stopManagedReconciliation;
|
|
861
354
|
private notifyManagedReconciliation;
|
|
862
355
|
reconcileNativeManagedSession(reason?: string): Promise<void>;
|
|
356
|
+
notifyNetworkChange(reason?: string): Promise<void>;
|
|
863
357
|
private connectionStateSnapshotKey;
|
|
864
358
|
private runNativeStartLoop;
|
|
865
359
|
private isUnsupportedRuntimeAdapterError;
|
|
866
|
-
private isRecoverableNativeManagedSessionStartError;
|
|
867
360
|
onIdentityChange(callback: (identity: RuntimeAuthIdentity | null) => void): () => void;
|
|
868
361
|
signInAnonymously(): Promise<void>;
|
|
869
362
|
signInWithPluto(): Promise<void>;
|
|
@@ -1060,10 +553,8 @@ declare class RuntimeClient {
|
|
|
1060
553
|
connection: Connection;
|
|
1061
554
|
writable: WritableStream<Uint8Array>;
|
|
1062
555
|
}>;
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
endpointTicket: string;
|
|
1066
|
-
}): Promise<NativeConnectResult>;
|
|
556
|
+
private waitForBrowserApplicationCrypto;
|
|
557
|
+
connectToDevice(params: NativeConnectParams): Promise<NativeConnectResult>;
|
|
1067
558
|
connectRaw(target: RuntimeConnectionTarget): Promise<RuntimeRawConnection>;
|
|
1068
559
|
openBi(nodeId: string): Promise<{
|
|
1069
560
|
readable: ReadableStream<Uint8Array>;
|
|
@@ -1075,9 +566,13 @@ declare class RuntimeClient {
|
|
|
1075
566
|
unregisterChannel(channelId: string): void;
|
|
1076
567
|
listChannels(): RuntimeChannelDescriptor[];
|
|
1077
568
|
onIncomingChannelStream(channelId: string, callback: (stream: RuntimeIncomingStream) => boolean | void): () => void;
|
|
569
|
+
/** @deprecated Use named channels or the optional `openrtc-file-transfer` package. */
|
|
1078
570
|
sendExplicitFilePath(connectionId: string, filePath: string, transferId?: string): Promise<string>;
|
|
571
|
+
/** @deprecated Use named channels or the optional `openrtc-file-transfer` package. */
|
|
1079
572
|
sendExplicitFileData(params: ExplicitFileDataSendParams): Promise<void>;
|
|
573
|
+
/** @deprecated Transfer history belongs to the consumer application. */
|
|
1080
574
|
getTransferHistory(limit?: number): Promise<Array<[string, unknown]>>;
|
|
575
|
+
/** @deprecated Transfer history belongs to the consumer application. */
|
|
1081
576
|
deleteTransferJob(jobId: string): Promise<void>;
|
|
1082
577
|
startPresenceLoop(options?: RuntimePresenceLoopOptions): Promise<void>;
|
|
1083
578
|
updatePresence(options?: {
|
|
@@ -1086,6 +581,10 @@ declare class RuntimeClient {
|
|
|
1086
581
|
metadata?: string;
|
|
1087
582
|
ticket?: string;
|
|
1088
583
|
}): Promise<void>;
|
|
584
|
+
refreshLivePresence(options?: {
|
|
585
|
+
metadata?: string;
|
|
586
|
+
ticket?: string;
|
|
587
|
+
}): Promise<void>;
|
|
1089
588
|
setOffline(): Promise<void>;
|
|
1090
589
|
cleanupStaleDevices(): Promise<void>;
|
|
1091
590
|
startAutoConnect(localDeviceId?: string): Promise<void>;
|
|
@@ -1224,4 +723,32 @@ declare function createWasmClient(options: RuntimeFactoryOptions): PlutoRuntimeA
|
|
|
1224
723
|
*/
|
|
1225
724
|
declare function createIpcClient(options: RuntimeFactoryOptions, bridge: PlutoIpcBridge): PlutoRuntimeAssembly<IpcRuntimeAdapter>;
|
|
1226
725
|
|
|
1227
|
-
|
|
726
|
+
/**
|
|
727
|
+
* Pure byte / stream / timing helpers.
|
|
728
|
+
*
|
|
729
|
+
* Extracted from the `Client` god object (see
|
|
730
|
+
* `docs/plans/client-ts-decomposition.md` Phase 1). These functions are
|
|
731
|
+
* deliberately pure — no `Client` state, no `this`, no logging side effects — so
|
|
732
|
+
* the same helper is reused everywhere instead of being re-implemented inline
|
|
733
|
+
* (e.g. `concatBytes` previously existed both here and in `applicationCrypto.ts`,
|
|
734
|
+
* and three near-identical exponential-backoff helpers existed across the class).
|
|
735
|
+
*/
|
|
736
|
+
|
|
737
|
+
type ByteArray = Uint8Array<ArrayBuffer>;
|
|
738
|
+
type ByteArrayLike = Uint8Array<ArrayBufferLike>;
|
|
739
|
+
|
|
740
|
+
type RuntimeU32BEFrameHandler = (payload: ByteArray) => void;
|
|
741
|
+
type RuntimeJsonFrameHandler<T = unknown> = (value: T, payload: ByteArray) => void;
|
|
742
|
+
interface RuntimeJsonFrameDecoderOptions {
|
|
743
|
+
onInvalidJson?: (error: unknown, payload: ByteArray) => void;
|
|
744
|
+
}
|
|
745
|
+
declare function encodeRuntimeU32BEFrame(payload: ByteArrayLike): ByteArray;
|
|
746
|
+
declare function createRuntimeU32BEFrameDecoder(onFrame: RuntimeU32BEFrameHandler): (chunk: ByteArrayLike) => void;
|
|
747
|
+
declare function encodeRuntimeJsonPayload(value: unknown): ByteArray;
|
|
748
|
+
declare function decodeRuntimeJsonPayload<T = unknown>(payload: ByteArrayLike): T;
|
|
749
|
+
declare function encodeRuntimeJsonFrame(value: unknown): ByteArray;
|
|
750
|
+
declare function createRuntimeJsonFrameDecoder<T = unknown>(onValue: RuntimeJsonFrameHandler<T>, options?: RuntimeJsonFrameDecoderOptions): (chunk: ByteArrayLike) => void;
|
|
751
|
+
declare function concatRuntimeBytes(a: ByteArrayLike, b: ByteArrayLike): ByteArray;
|
|
752
|
+
declare function readRuntimeU32BE(bytes: ByteArrayLike, offset: number): number;
|
|
753
|
+
|
|
754
|
+
export { createIpcClient as A, createWasmClient as B, readRuntimeU32BE as C, DriveGrantActorError as D, driveGrantConnectionKey as E, driveGrantConnectionKeyToString as F, OPENRTC_RUNTIME_POLICY as O, type PeerReconciliationStats as P, RuntimeClient as R, ScopedSession as S, type RuntimePolicySnapshot as a, type PlutoRuntimeAssembly as b, type RuntimeJsonFrameHandler as c, type RuntimeU32BEFrameHandler as d, type Session as e, type SessionOptions as f, createRuntimeJsonFrameDecoder as g, createRuntimeU32BEFrameDecoder as h, decodeRuntimeJsonPayload as i, encodeRuntimeJsonFrame as j, encodeRuntimeJsonPayload as k, encodeRuntimeU32BEFrame as l, getRuntimePolicy as m, type RuntimeFactoryOptions as n, type RuntimeJsonFrameDecoderOptions as o, type DriveGrantActorErrorKind as p, DriveGrantActorHandle as q, type DriveGrantActorHandleOptions as r, DriveGrantActorRegistry as s, type DriveGrantActorState as t, type DriveGrantClose as u, type DriveGrantDial as v, type DriveGrantConnectionKey as w, type DriveGrantLogicalChannelHandle as x, type DriveGrantPreferredTransport as y, concatRuntimeBytes as z };
|