openrtc 0.1.0 → 0.1.2
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/README.md +1 -2
- package/dist/{core/types.d.ts → DelegatingRuntimeAdapter-CW8d78dZ.d.ts} +275 -95
- package/dist/IpcRuntimeAdapter-CT-W0Mtp.d.ts +24 -0
- package/dist/auth/index.d.ts +75 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/internal.d.ts +3 -1
- package/dist/auth/internal.js +1 -1
- package/dist/chunk-4MH42GUI.js +2 -0
- package/dist/chunk-CQAKCS2S.js +4 -0
- package/dist/chunk-D54VGRRH.js +1 -0
- package/dist/chunk-DIQYFAGL.js +2 -0
- package/dist/chunk-PZ25OCVG.js +2 -0
- package/dist/chunk-UVASANPG.js +1 -0
- package/dist/factories-0TxDPMeu.d.ts +1041 -0
- package/dist/index.d.ts +160 -3
- package/dist/index.js +1 -3
- package/dist/openrtc_bg.wasm +0 -0
- package/dist/runtime/WasmRuntimeAdapter.d.ts +5 -3
- package/dist/runtime/WasmRuntimeAdapter.js +1 -11
- package/dist/runtime/index.d.ts +796 -6
- package/dist/runtime/index.js +1 -5
- package/dist/runtime/tauri.d.ts +12 -8
- package/dist/runtime/tauri.js +1 -22
- package/package.json +11 -7
- package/wasm/openrtc.d.ts +61 -25
- package/wasm/openrtc.js +417 -259
- package/wasm/openrtc_bg.wasm +0 -0
- package/wasm/openrtc_bg.wasm.d.ts +27 -24
- package/wasm/package.json +1 -1
- package/dist/OpenRTC.d.ts +0 -71
- package/dist/OpenRTC.js +0 -130
- package/dist/api/MediaTransport.d.ts +0 -7
- package/dist/api/MediaTransport.js +0 -262
- package/dist/api/PlutoPeerConnection.d.ts +0 -50
- package/dist/api/PlutoPeerConnection.js +0 -434
- package/dist/api/PlutoWebSocket.d.ts +0 -24
- package/dist/api/PlutoWebSocket.js +0 -113
- package/dist/api/PlutoWebTransport.d.ts +0 -29
- package/dist/api/PlutoWebTransport.js +0 -105
- package/dist/auth/host.d.ts +0 -73
- package/dist/auth/host.js +0 -513
- package/dist/compat/index.d.ts +0 -20
- package/dist/compat/index.js +0 -20
- package/dist/core/Client.d.ts +0 -352
- package/dist/core/Client.js +0 -3689
- package/dist/core/Connection.d.ts +0 -67
- package/dist/core/Connection.js +0 -404
- package/dist/core/IEngineBridge.d.ts +0 -18
- package/dist/core/IEngineBridge.js +0 -1
- package/dist/core/ISignalingTransport.d.ts +0 -13
- package/dist/core/ISignalingTransport.js +0 -1
- package/dist/core/PeerLifecycleManager.d.ts +0 -43
- package/dist/core/PeerLifecycleManager.js +0 -330
- package/dist/core/PeerProjectionStore.d.ts +0 -43
- package/dist/core/PeerProjectionStore.js +0 -327
- package/dist/core/PlutoRTC.d.ts +0 -13
- package/dist/core/PlutoRTC.js +0 -26
- package/dist/core/Room.d.ts +0 -47
- package/dist/core/Room.js +0 -376
- package/dist/core/Signaling.d.ts +0 -39
- package/dist/core/Signaling.js +0 -147
- package/dist/core/bridges/BridgeCodecs.d.ts +0 -19
- package/dist/core/bridges/BridgeCodecs.js +0 -317
- package/dist/core/bridges/BrowserFirestoreRooms.d.ts +0 -36
- package/dist/core/bridges/BrowserFirestoreRooms.js +0 -169
- package/dist/core/bridges/BrowserFirestoreSignaling.d.ts +0 -111
- package/dist/core/bridges/BrowserFirestoreSignaling.js +0 -1010
- package/dist/core/bridges/NativeIpcBridge.d.ts +0 -156
- package/dist/core/bridges/NativeIpcBridge.js +0 -1472
- package/dist/core/bridges/RtdbPresence.d.ts +0 -122
- package/dist/core/bridges/RtdbPresence.js +0 -201
- package/dist/core/bridges/TauriBridge.d.ts +0 -8
- package/dist/core/bridges/TauriBridge.js +0 -7
- package/dist/core/bridges/WasmBridge.d.ts +0 -233
- package/dist/core/bridges/WasmBridge.js +0 -1811
- package/dist/core/config.d.ts +0 -31
- package/dist/core/config.js +0 -138
- package/dist/core/transports/ITransport.d.ts +0 -12
- package/dist/core/transports/ITransport.js +0 -1
- package/dist/core/transports/LocalDaemonBridge.d.ts +0 -41
- package/dist/core/transports/LocalDaemonBridge.js +0 -227
- package/dist/core/transports/TauriSignaling.d.ts +0 -28
- package/dist/core/transports/TauriSignaling.js +0 -373
- package/dist/core/transports/TransportFactory.d.ts +0 -9
- package/dist/core/transports/TransportFactory.js +0 -59
- package/dist/core/transports/WasmSignaling.d.ts +0 -78
- package/dist/core/transports/WasmSignaling.js +0 -522
- package/dist/core/transports/WebRTCTransport.d.ts +0 -23
- package/dist/core/transports/WebRTCTransport.js +0 -132
- package/dist/core/trust.d.ts +0 -23
- package/dist/core/trust.js +0 -99
- package/dist/core/types.js +0 -19
- package/dist/moq/MoQMediaTransport.d.ts +0 -6
- package/dist/moq/MoQMediaTransport.js +0 -106
- package/dist/moq/MoQPublisher.d.ts +0 -22
- package/dist/moq/MoQPublisher.js +0 -179
- package/dist/moq/MoQSession.d.ts +0 -35
- package/dist/moq/MoQSession.js +0 -166
- package/dist/moq/MoQSubscriber.d.ts +0 -19
- package/dist/moq/MoQSubscriber.js +0 -235
- package/dist/moq/common.d.ts +0 -47
- package/dist/moq/common.js +0 -304
- package/dist/moq/messages.d.ts +0 -105
- package/dist/moq/messages.js +0 -367
- package/dist/presets/plutoHosted.d.ts +0 -13
- package/dist/presets/plutoHosted.js +0 -18
- package/dist/runtime/DelegatingRuntimeAdapter.d.ts +0 -68
- package/dist/runtime/DelegatingRuntimeAdapter.js +0 -250
- package/dist/runtime/IpcRuntimeAdapter.d.ts +0 -9
- package/dist/runtime/IpcRuntimeAdapter.js +0 -13
- package/dist/runtime/RuntimeClient.d.ts +0 -257
- package/dist/runtime/RuntimeClient.js +0 -1484
- package/dist/runtime/TauriRuntimeAdapter.d.ts +0 -1
- package/dist/runtime/TauriRuntimeAdapter.js +0 -1
- package/dist/runtime/factories.d.ts +0 -24
- package/dist/runtime/factories.js +0 -66
- package/dist/runtime/ipc.d.ts +0 -8
- package/dist/runtime/ipc.js +0 -65
- package/dist/runtime/ipcContract.d.ts +0 -46
- package/dist/runtime/ipcContract.js +0 -1
- package/dist/runtime/types.d.ts +0 -110
- package/dist/runtime/types.js +0 -1
- package/dist/transports/TauriTransport.d.ts +0 -17
- package/dist/transports/TauriTransport.js +0 -49
- package/dist/transports/WebTransport.d.ts +0 -23
- package/dist/transports/WebTransport.js +0 -71
- package/dist/utils/debug.d.ts +0 -4
- package/dist/utils/debug.js +0 -33
- package/dist/utils/runtime.d.ts +0 -1
- package/dist/utils/runtime.js +0 -10
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,6 +1,796 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export
|
|
1
|
+
import { C as Connection, E as RuntimeConnectionTarget, q as RuntimeRawConnection } from '../factories-0TxDPMeu.js';
|
|
2
|
+
export { r as ChannelDescriptor, s as ConnectionEvent, t as ConnectionTarget, D as DeviceProfile, $ as DriveGrantActorError, a0 as DriveGrantActorErrorKind, a1 as DriveGrantActorHandle, a2 as DriveGrantActorHandleOptions, a3 as DriveGrantActorRegistry, a4 as DriveGrantClose, a5 as DriveGrantConnectionKey, a6 as DriveGrantDial, a7 as DriveGrantLogicalChannelHandle, a8 as DriveGrantWebRtcState, I as IncomingStream, O as OPENRTC_RUNTIME_POLICY, u as PeerConnectOptions, v as PeerReadiness, w as PeerStreamOptions, P as PlutoRuntimeAssembly, x as PresenceLoopOptions, y as RawConnection, z as RuntimeAuthContext, A as RuntimeAuthIdentity, B as RuntimeAutoConnectPolicy, k as RuntimeChannelDescriptor, a as RuntimeClient, R as RuntimeClientOptions, p as RuntimeConnectionEvent, o as RuntimeConnectionStateSnapshot, b as RuntimeDevice, d as RuntimeDeviceConnectOptions, F as RuntimeDeviceStatus, c as RuntimeDeviceStatusSnapshot, a9 as RuntimeFactoryOptions, m as RuntimeIncomingStream, G as RuntimeJoinRoomOptions, e as RuntimeLocalDeviceInfo, f as RuntimeLocalDeviceProfile, H as RuntimeManagedSession, J as RuntimeManagedSessionKind, K as RuntimeManagedSessionOptions, L as RuntimeManagedSessionPlatform, h as RuntimePeerConnectOptions, j as RuntimePeerHealth, M as RuntimePeerLifecycleStatus, i as RuntimePeerReadinessSnapshot, N as RuntimePeerScope, Q as RuntimePeerSessionSnapshot, g as RuntimePeerState, l as RuntimePeerStreamOptions, n as RuntimePolicySnapshot, S as RuntimePresenceLoopOptions, T as RuntimePresencePolicy, U as RuntimeRoomMember, V as RuntimeSession, W as RuntimeUiConnectionStatus, $ as ScopedConnectionActorError, a0 as ScopedConnectionActorErrorKind, a1 as ScopedConnectionActorHandle, a2 as ScopedConnectionActorHandleOptions, a3 as ScopedConnectionActorRegistry, a4 as ScopedConnectionClose, a6 as ScopedConnectionDial, a5 as ScopedConnectionKey, a7 as ScopedLogicalChannelHandle, a8 as ScopedWebRtcState, aa as Session, ab as SessionOptions, ac as createIpcClient, ad as createWasmClient, ae as driveGrantConnectionKey, af as driveGrantConnectionKeyToString, _ as getRuntimePolicy, ae as scopedConnectionKey, af as scopedConnectionKeyToString } from '../factories-0TxDPMeu.js';
|
|
3
|
+
import { y as SignalingOptions, w as ISignalingBackend, o as RuntimeIdentity, z as SignalingEnvelope, n as SignalingSession, m as Device, B as BackendConnectionState, J as JoinRoomOptions, s as RoomMember, d as AppLimits, F as RoomCreationMode, k as ClientOptions, f as DiscoveryMode, h as ProtocolCapabilityMap, H as ScanningLoopOptions, K as ScanningLoopHandle, a as ConnectDeviceHooks, b as ConnectDeviceOptions, C as ConnectDeviceResult, O as RuntimeBootstrapOptions, Q as RuntimeBootstrapResult, q as PeerState, t as PeerScope, r as PeerHealth, G as GrantScope, I as IncomingStreamChannelMetadata, l as ChannelDescriptor, T as JoinRequest, N as NativeConnectResult } from '../DelegatingRuntimeAdapter-CW8d78dZ.js';
|
|
4
|
+
export { U as BROWSER_WASM_RUNTIME_CAPABILITIES, V as NATIVE_IPC_RUNTIME_CAPABILITIES, j as RuntimeAdapterKind, c as RuntimeCapabilities, X as cloneRuntimeCapabilities } from '../DelegatingRuntimeAdapter-CW8d78dZ.js';
|
|
5
|
+
import { FirebaseApp } from 'firebase/app';
|
|
6
|
+
export { I as IpcRuntimeAdapter, a as IpcRuntimeAdapterOptions, P as NativeBridge, P as PlutoIpcBridge, b as PlutoIpcUnlisten } from '../IpcRuntimeAdapter-CT-W0Mtp.js';
|
|
7
|
+
export { WasmRuntimeAdapter } from './WasmRuntimeAdapter.js';
|
|
8
|
+
export { TauriRuntimeAdapter, TauriRuntimeAdapterOptions, createTauriIpcBridge } from './tauri.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* RtdbPresence — Phase 1 RTDB-backed device presence.
|
|
12
|
+
*
|
|
13
|
+
* Replaces the 60-second Firestore heartbeat loop with Firebase Realtime
|
|
14
|
+
* Database `onDisconnect` hooks. When a client disconnects (tab close,
|
|
15
|
+
* crash, network loss), the RTDB server automatically writes the offline
|
|
16
|
+
* state — no cleanup polling needed.
|
|
17
|
+
*
|
|
18
|
+
* RTDB paths mirror the Firestore device collection paths:
|
|
19
|
+
*
|
|
20
|
+
* personal/spaceKey → presence/spaces/{namespaceId}/devices/{deviceId}
|
|
21
|
+
* user-scoped → presence/{appTag}/users/{userId}/devices/{deviceId}
|
|
22
|
+
*
|
|
23
|
+
* Ticket version invalidation:
|
|
24
|
+
* Each presence node stores a `ticketVersion` integer. WasmBridge bumps it
|
|
25
|
+
* whenever it writes a new Firestore ticket (network change, reconnect).
|
|
26
|
+
* Subscribers compare the received ticketVersion against their cached value;
|
|
27
|
+
* if it differs they re-fetch the full device doc from Firestore. This means
|
|
28
|
+
* other clients never hold a stale connection ticket for more than one RTDB
|
|
29
|
+
* heartbeat interval (~1 s), eliminating the P2P-failure→Firestore fallback.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
interface RtdbDevicePresence {
|
|
33
|
+
online: boolean;
|
|
34
|
+
ticketVersion: number;
|
|
35
|
+
}
|
|
36
|
+
type RtdbPresenceMap = Record<string, RtdbDevicePresence>;
|
|
37
|
+
type DiscoveryPresenceScope = {
|
|
38
|
+
kind: 'user-scoped';
|
|
39
|
+
appTag: string;
|
|
40
|
+
userId: string;
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'personal';
|
|
43
|
+
namespaceId: string;
|
|
44
|
+
};
|
|
45
|
+
interface RtdbMemberPresence {
|
|
46
|
+
online: boolean;
|
|
47
|
+
}
|
|
48
|
+
type RtdbRoomPresenceMap = Record<string, RtdbMemberPresence>;
|
|
49
|
+
declare class RtdbPresence {
|
|
50
|
+
private readonly db;
|
|
51
|
+
constructor(app: FirebaseApp);
|
|
52
|
+
/**
|
|
53
|
+
* Register this device as online in RTDB and set an onDisconnect handler
|
|
54
|
+
* so the server marks it offline automatically on connection loss.
|
|
55
|
+
*
|
|
56
|
+
* Should be called once per session, after a Firestore ticket has been
|
|
57
|
+
* written. Does not replace the Firestore device doc — that remains the
|
|
58
|
+
* source of truth for the connection ticket and metadata.
|
|
59
|
+
*/
|
|
60
|
+
registerDevice(scope: DiscoveryPresenceScope, deviceId: string, ticketVersion?: number): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Bump the ticketVersion for a device. Call this whenever a new Firestore
|
|
63
|
+
* ticket is written (e.g. on network change / node restart). Subscribers
|
|
64
|
+
* will see the version change and re-fetch the Firestore doc.
|
|
65
|
+
*/
|
|
66
|
+
bumpTicketVersion(scope: DiscoveryPresenceScope, deviceId: string, newVersion: number): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Explicitly mark a device offline (graceful disconnect / sign-out).
|
|
69
|
+
* The onDisconnect handler would eventually fire anyway, but calling this
|
|
70
|
+
* immediately on graceful shutdown gives instant feedback to other clients.
|
|
71
|
+
*/
|
|
72
|
+
markOffline(scope: DiscoveryPresenceScope, deviceId: string, ticketVersion?: number): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Register a room member as online and set an onDisconnect handler.
|
|
75
|
+
* Called immediately after the Firestore member doc is written (join).
|
|
76
|
+
*/
|
|
77
|
+
registerRoomMember(appTag: string, roomId: string, memberId: string): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Explicitly mark a room member offline (graceful leave).
|
|
80
|
+
* The onDisconnect would fire eventually, but calling this immediately
|
|
81
|
+
* gives instant feedback to other members in the room.
|
|
82
|
+
*/
|
|
83
|
+
markRoomMemberOffline(appTag: string, roomId: string, memberId: string): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Subscribe to all member presence states in a room.
|
|
86
|
+
* Returns an unsubscribe function. The callback receives a map of
|
|
87
|
+
* memberId → { online } whenever any member's liveness changes.
|
|
88
|
+
*
|
|
89
|
+
* Consumers (BrowserFirestoreRooms) overlay this onto the Firestore
|
|
90
|
+
* member roster to show which members are currently alive vs. ghost entries.
|
|
91
|
+
*/
|
|
92
|
+
onRoomPresenceChange(appTag: string, roomId: string, callback: (presenceMap: RtdbRoomPresenceMap) => void): () => void;
|
|
93
|
+
/**
|
|
94
|
+
* Subscribe to all device presence states in a discovery scope.
|
|
95
|
+
*
|
|
96
|
+
* Returns an unsubscribe function. The callback receives the full map of
|
|
97
|
+
* deviceId → { online, ticketVersion } whenever any device's presence
|
|
98
|
+
* changes. This replaces the `onSnapshot` on the Firestore device
|
|
99
|
+
* collection for the online/offline boolean overlay.
|
|
100
|
+
*
|
|
101
|
+
* The Firestore device collection remains as the source of truth for
|
|
102
|
+
* connection tickets and metadata; RTDB is only used for the live
|
|
103
|
+
* online boolean and ticket invalidation signal.
|
|
104
|
+
*/
|
|
105
|
+
onPresenceChange(scope: DiscoveryPresenceScope, callback: (presenceMap: RtdbPresenceMap) => void): () => void;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class Signaling {
|
|
109
|
+
private readonly appTag;
|
|
110
|
+
private backend;
|
|
111
|
+
constructor(options: SignalingOptions, backend: ISignalingBackend);
|
|
112
|
+
get tag(): string;
|
|
113
|
+
waitForAuth(): Promise<void>;
|
|
114
|
+
get currentUser(): RuntimeIdentity | null;
|
|
115
|
+
onAuthChange(callback: (user: RuntimeIdentity | null) => void): () => void;
|
|
116
|
+
signInAnonymously(): Promise<void>;
|
|
117
|
+
signInWithPluto(): Promise<void>;
|
|
118
|
+
signOut(): Promise<void>;
|
|
119
|
+
stopAuthScopedActivity(): Promise<void>;
|
|
120
|
+
getTurnCredentials(): Promise<any>;
|
|
121
|
+
updatePresence(localNodeId: string, ticketStr: string, isOnline?: boolean, ttlMs?: number, metadata?: string): Promise<void>;
|
|
122
|
+
setOffline(localNodeId: string): Promise<void>;
|
|
123
|
+
cleanupStaleDevices(): Promise<void>;
|
|
124
|
+
sendMessage(targetId: string, payload: string, state?: string, replyPayload?: string): Promise<string>;
|
|
125
|
+
pollMessages(targetId: string): Promise<SignalingEnvelope[]>;
|
|
126
|
+
subscribeSessions(localDeviceId: string, callback: (session: SignalingSession) => void): Promise<() => void>;
|
|
127
|
+
getLocalDeviceId(): Promise<string | null>;
|
|
128
|
+
searchDevices(excludeNodeId?: string): Promise<Device[]>;
|
|
129
|
+
updateDevice(deviceId: string, updates: {
|
|
130
|
+
deviceName?: string;
|
|
131
|
+
capabilities?: Device['capabilities'];
|
|
132
|
+
metadata?: string;
|
|
133
|
+
}): Promise<void>;
|
|
134
|
+
deleteDevice(deviceId: string): Promise<void>;
|
|
135
|
+
onDevicesChange(callback: (devices: Device[]) => void, excludeNodeId?: string): () => void;
|
|
136
|
+
startAutoConnect(userId: string, localDeviceId: string): void;
|
|
137
|
+
notifyDisconnectRequested(remoteNodeId: string): void;
|
|
138
|
+
startPresenceLoop(userId: string, localNodeId: string, deviceName: string, ticket: string, metadata?: string): void;
|
|
139
|
+
forceReconnectSnapshot(): void;
|
|
140
|
+
isConnected(nodeId: string): Promise<boolean>;
|
|
141
|
+
getConnectionStates(): Promise<BackendConnectionState[]>;
|
|
142
|
+
onConnectionStateChange(callback: (state: BackendConnectionState) => void): (() => void) | Promise<() => void>;
|
|
143
|
+
supportsRustPeerLifecycleProjection(): boolean;
|
|
144
|
+
setWasmClient(client: any): void;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare class RoomManager {
|
|
148
|
+
private signaling;
|
|
149
|
+
private client;
|
|
150
|
+
private readonly heartbeatStops;
|
|
151
|
+
private browserRooms;
|
|
152
|
+
private rtdbPresence;
|
|
153
|
+
constructor(client: Client, signaling: Signaling);
|
|
154
|
+
private getBrowserRooms;
|
|
155
|
+
/**
|
|
156
|
+
* Phase 2: called by the runtime after RTDB presence is initialised
|
|
157
|
+
* (same RtdbPresence instance used for device presence in Phase 1).
|
|
158
|
+
*/
|
|
159
|
+
setRtdbPresence(rtdbPresence: RtdbPresence): void;
|
|
160
|
+
private usesDirectRoomBackend;
|
|
161
|
+
private get roomBackendTag();
|
|
162
|
+
private get appTag();
|
|
163
|
+
private invokeRoomCallable;
|
|
164
|
+
private isAlreadyExistsError;
|
|
165
|
+
private getMembersInternal;
|
|
166
|
+
private parseMemberDocuments;
|
|
167
|
+
private parseRoomMemberDocument;
|
|
168
|
+
/**
|
|
169
|
+
* Creates a new room. When `requestedRoomId` is provided, the backend will
|
|
170
|
+
* try to create that exact room ID instead of generating a random one.
|
|
171
|
+
*/
|
|
172
|
+
createRoom(requestedRoomId?: string): Promise<string>;
|
|
173
|
+
/**
|
|
174
|
+
* Joins a room by ID.
|
|
175
|
+
*/
|
|
176
|
+
joinRoom(roomId: string, options?: JoinRoomOptions): Promise<Connection[]>;
|
|
177
|
+
leaveRoom(roomId: string): Promise<void>;
|
|
178
|
+
getRoomMembers(roomId: string): Promise<RoomMember[]>;
|
|
179
|
+
watchRoom(roomId: string, callback: (members: RoomMember[]) => void): () => void;
|
|
180
|
+
/**
|
|
181
|
+
* Register this device as an online room member in RTDB and store a
|
|
182
|
+
* cleanup callback in heartbeatStops (keyed by roomId) so that
|
|
183
|
+
* stopHeartbeat() / leaveRoom() can trigger graceful offline marking.
|
|
184
|
+
*/
|
|
185
|
+
private registerRtdbRoomMember;
|
|
186
|
+
private markRtdbRoomMemberOffline;
|
|
187
|
+
private startLegacyHeartbeat;
|
|
188
|
+
stopHeartbeat(roomId?: string): void;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
declare class MoQPublisher {
|
|
192
|
+
private session;
|
|
193
|
+
private tracks;
|
|
194
|
+
private activePublishers;
|
|
195
|
+
constructor(session: MoQSession);
|
|
196
|
+
private pendingAnnounces;
|
|
197
|
+
announce(namespace: string): Promise<void>;
|
|
198
|
+
onAnnounceResult(namespace: string, error?: {
|
|
199
|
+
code: number;
|
|
200
|
+
reason: string;
|
|
201
|
+
}): void;
|
|
202
|
+
onSubscribe(msg: any): void;
|
|
203
|
+
onUnsubscribe(subscribeId: number): void;
|
|
204
|
+
createTrack(namespace: string, name: string): Promise<any>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declare class MoQSubscriber {
|
|
208
|
+
private session;
|
|
209
|
+
private onObject;
|
|
210
|
+
constructor(session: MoQSession, onObject: (ns: string, name: string, obj: Uint8Array, meta: any) => void);
|
|
211
|
+
private aliasMap;
|
|
212
|
+
private nextAlias;
|
|
213
|
+
private nextSubscribeId;
|
|
214
|
+
private pendingSubscriptions;
|
|
215
|
+
private deliveryState;
|
|
216
|
+
private activeSubscriptions;
|
|
217
|
+
subscribe(namespace: string, name: string): Promise<void>;
|
|
218
|
+
onSubscribeOk(subscribeId: number): void;
|
|
219
|
+
onSubscribeError(subscribeId: number, code: number): Promise<void>;
|
|
220
|
+
onSubscribeDone(subscribeId: number, code: number, reason: string): void;
|
|
221
|
+
private wakeDelivery;
|
|
222
|
+
private runDeliveryLoop;
|
|
223
|
+
handleIncomingUniStream(stream: ReadableStream<Uint8Array>): Promise<void>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
interface TransportInterface {
|
|
227
|
+
createBidirectionalStream(): Promise<{
|
|
228
|
+
readable: ReadableStream<Uint8Array>;
|
|
229
|
+
writable: WritableStream<Uint8Array>;
|
|
230
|
+
}>;
|
|
231
|
+
createUnidirectionalStream(): Promise<WritableStream<Uint8Array>>;
|
|
232
|
+
incomingBidirectionalStreams: ReadableStream<any>;
|
|
233
|
+
incomingUnidirectionalStreams: ReadableStream<ReadableStream<Uint8Array>>;
|
|
234
|
+
close(): void;
|
|
235
|
+
ready: Promise<void>;
|
|
236
|
+
}
|
|
237
|
+
declare class MoQSession {
|
|
238
|
+
transport: TransportInterface;
|
|
239
|
+
private controlStreamWriter;
|
|
240
|
+
private controlStreamReader;
|
|
241
|
+
private uniStreamReader;
|
|
242
|
+
private closeListeners;
|
|
243
|
+
private closed;
|
|
244
|
+
private closeEmitted;
|
|
245
|
+
private resourcesClosed;
|
|
246
|
+
private role;
|
|
247
|
+
setupComplete: boolean;
|
|
248
|
+
private setupResolve;
|
|
249
|
+
private setupPromise;
|
|
250
|
+
maxSubscribeId: number;
|
|
251
|
+
private streamBuffer;
|
|
252
|
+
publisher: MoQPublisher;
|
|
253
|
+
subscriber: MoQSubscriber;
|
|
254
|
+
constructor(transport: TransportInterface, onObject?: (ns: string, name: string, obj: Uint8Array, meta: any) => void, role?: number);
|
|
255
|
+
/** Wait for handshake to complete before sending ANNOUNCE/SUBSCRIBE */
|
|
256
|
+
waitForSetup(): Promise<void>;
|
|
257
|
+
init(): Promise<void>;
|
|
258
|
+
onClose(callback: (reason?: unknown) => void): () => void;
|
|
259
|
+
close(): void;
|
|
260
|
+
private cleanupResources;
|
|
261
|
+
private emitClose;
|
|
262
|
+
private readUniStreams;
|
|
263
|
+
sendControlMessage(msg: any): Promise<void>;
|
|
264
|
+
private readLoop;
|
|
265
|
+
private processBuffer;
|
|
266
|
+
private handleControlMessage;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
type IncomingProtocolHint = 'control' | 'explicit' | 'native-main' | 'unknown';
|
|
270
|
+
type IncomingStreamListenerEvent = {
|
|
271
|
+
type: 'bi' | 'uni';
|
|
272
|
+
stream: any;
|
|
273
|
+
remoteNodeId: string;
|
|
274
|
+
traceId?: string;
|
|
275
|
+
protocolHint?: IncomingProtocolHint;
|
|
276
|
+
channel?: IncomingStreamChannelMetadata | null;
|
|
277
|
+
invalid?: boolean;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
declare class Client {
|
|
281
|
+
private static readonly CHANNEL_ENVELOPE_MAGIC;
|
|
282
|
+
private static readonly CHANNEL_ENVELOPE_VERSION;
|
|
283
|
+
private static readonly CHANNEL_ENVELOPE_HEADER_BYTES;
|
|
284
|
+
private static readonly EXPLICIT_PROTOCOL_BYTE;
|
|
285
|
+
private static readonly NATIVE_MAIN_PROTOCOL_BYTE;
|
|
286
|
+
private static readonly NATIVE_MAIN_LABEL;
|
|
287
|
+
private static readonly NATIVE_MAIN_MAX_LABEL_BYTES;
|
|
288
|
+
private static readonly NATIVE_MAIN_MAX_FRAME_BYTES;
|
|
289
|
+
private static readonly NATIVE_MAIN_PROTOCOL_VERSION;
|
|
290
|
+
private static readonly CONNECTION_STATE_CHANGED_EVENT;
|
|
291
|
+
private static readonly NATIVE_MAIN_MESSAGE_EVENT;
|
|
292
|
+
private static readonly INCOMING_STREAM_RETRY_MIN_DELAY_MS;
|
|
293
|
+
private static readonly INCOMING_STREAM_RETRY_MAX_DELAY_MS;
|
|
294
|
+
private static readonly DEFAULT_PEER_CHANNEL_ID;
|
|
295
|
+
private static readonly SHARE_FILE_CHANNEL_ID;
|
|
296
|
+
private static readonly SHARE_CONTROL_CHANNEL_ID;
|
|
297
|
+
private static readonly incomingStreamHubs;
|
|
298
|
+
signaling: Signaling;
|
|
299
|
+
rooms: RoomManager;
|
|
300
|
+
private wasmLoaded;
|
|
301
|
+
wasmClient: any;
|
|
302
|
+
private initPromise;
|
|
303
|
+
node: any;
|
|
304
|
+
private connections;
|
|
305
|
+
private connectionListeners;
|
|
306
|
+
private disconnectionListeners;
|
|
307
|
+
private messageListeners;
|
|
308
|
+
private roomRequestListeners;
|
|
309
|
+
private streamListeners;
|
|
310
|
+
private readonly channelStreamListeners;
|
|
311
|
+
private readonly registeredChannels;
|
|
312
|
+
private announcedConnections;
|
|
313
|
+
private readonly peerLifecycle;
|
|
314
|
+
private readonly peerLifecycleClient;
|
|
315
|
+
private readonly knownDevicesById;
|
|
316
|
+
private readonly knownDeviceIdsByNodeId;
|
|
317
|
+
private readonly connectionTrustStates;
|
|
318
|
+
private readonly connectionChannelIds;
|
|
319
|
+
private readonly pendingSessionTokenTrustApprovals;
|
|
320
|
+
/** Tracks the last rejection timestamp per remote node to debounce repeated stale-token retries. */
|
|
321
|
+
private readonly sessionTokenRejectionCooldowns;
|
|
322
|
+
/** Tracks the last trust-failure timestamp per remote node to suppress rapid connection-rebuild storms. */
|
|
323
|
+
private readonly trustFailureCooldowns;
|
|
324
|
+
/** Nodes that have passed at least one session-token approval — exempt from trust-failure cooldown. */
|
|
325
|
+
private readonly sessionTokenApprovedNodes;
|
|
326
|
+
/** Connection IDs that have been explicitly approved via session-token admission. */
|
|
327
|
+
private readonly sessionTokenApprovedConnectionIds;
|
|
328
|
+
/** Most recent inbound native-main BiStream writer per remote node (desktop -> web). */
|
|
329
|
+
private readonly inboundNativeMainWriters;
|
|
330
|
+
/** Per-node write mutex for inbound native-main writers. */
|
|
331
|
+
private readonly inboundNativeMainWriteMutex;
|
|
332
|
+
/** Lifecycle metadata for inbound native-main writers to debug stale-writer routing. */
|
|
333
|
+
private readonly inboundNativeMainWriterMeta;
|
|
334
|
+
/** Per-node cooldown to bypass missing/stale inbound writer probes. */
|
|
335
|
+
private readonly inboundNativeMainBypassUntilMs;
|
|
336
|
+
private inboundNativeMainWriterSeq;
|
|
337
|
+
private managedPresenceGrant;
|
|
338
|
+
/** Token extracted from a compound ticket during connect(), keyed by remote node ID. */
|
|
339
|
+
private readonly pendingTokenByNodeId;
|
|
340
|
+
private readonly pendingNativeMainConnections;
|
|
341
|
+
private readonly webrtcIncomingExplicitTransfers;
|
|
342
|
+
private localNodeId;
|
|
343
|
+
private listening;
|
|
344
|
+
private listenLoopTask;
|
|
345
|
+
private options;
|
|
346
|
+
private readonly runtimeSafetyProfile;
|
|
347
|
+
appLimits: AppLimits;
|
|
348
|
+
private pendingConnection;
|
|
349
|
+
private incomingTraceSequence;
|
|
350
|
+
private browserBackgrounded;
|
|
351
|
+
private authSyncUnsubscribe;
|
|
352
|
+
private backendConnectionStateUnsubscribe;
|
|
353
|
+
private authRefreshInterval;
|
|
354
|
+
private deviceId;
|
|
355
|
+
private lastWasmAuthSyncUserId;
|
|
356
|
+
private lastWasmAuthSyncToken;
|
|
357
|
+
private loggedNativeDiscoveryWasmSkip;
|
|
358
|
+
private static readonly CONNECTION_STABLE_WINDOW_MS;
|
|
359
|
+
private static readonly CONNECTION_STABLE_TIMEOUT_MS;
|
|
360
|
+
private static readonly CONNECTION_STABLE_POLL_MS;
|
|
361
|
+
private static readonly SESSION_TOKEN_TRUST_APPROVAL_TTL_MS;
|
|
362
|
+
private static readonly SESSION_TOKEN_UNKNOWN_RETRY_ATTEMPTS;
|
|
363
|
+
private static readonly SESSION_TOKEN_UNKNOWN_RETRY_DELAY_MS;
|
|
364
|
+
/** How long to suppress new Connection objects for a node after a trust failure (ms). */
|
|
365
|
+
private static readonly TRUST_FAILURE_COOLDOWN_MS;
|
|
366
|
+
private static readonly INBOUND_WRITER_RETRY_COOLDOWN_MS;
|
|
367
|
+
private static readonly MOQ_RECONNECT_INITIAL_DELAY_MS;
|
|
368
|
+
private static readonly MOQ_RECONNECT_MAX_DELAY_MS;
|
|
369
|
+
private presenceInterval;
|
|
370
|
+
private hostedAppSettingsLoaded;
|
|
371
|
+
private effectiveRoomBackendTag;
|
|
372
|
+
private _moqSession;
|
|
373
|
+
private _moqState;
|
|
374
|
+
private moqReadyListeners;
|
|
375
|
+
private moqFailedListeners;
|
|
376
|
+
private moqObjectListeners;
|
|
377
|
+
private moqReconnectTimer;
|
|
378
|
+
private moqReconnectAttempts;
|
|
379
|
+
private readonly moqPeerSubscriptions;
|
|
380
|
+
roomCreationMode: RoomCreationMode;
|
|
381
|
+
constructor(options: ClientOptions);
|
|
382
|
+
private sleep;
|
|
383
|
+
private installAppLifecycleListeners;
|
|
384
|
+
private handleAppBackgroundState;
|
|
385
|
+
private reconcileConnectionsAfterForeground;
|
|
386
|
+
get apiKey(): string | undefined;
|
|
387
|
+
get discoveryMode(): DiscoveryMode;
|
|
388
|
+
private usesTicketOnlySignalingMode;
|
|
389
|
+
usesDirectRoomBackend(): boolean;
|
|
390
|
+
getRoomBackendTag(): string;
|
|
391
|
+
refreshHostedAppSettings(force?: boolean): Promise<void>;
|
|
392
|
+
setSignalingBackend(backend: ISignalingBackend): void;
|
|
393
|
+
get currentUser(): RuntimeIdentity | null;
|
|
394
|
+
onAuthChange(callback: (user: any) => void): () => void;
|
|
395
|
+
signInAnonymously(): Promise<void>;
|
|
396
|
+
signInWithPluto(): Promise<void>;
|
|
397
|
+
signOut(): Promise<void>;
|
|
398
|
+
getSignalingTelemetry(): {
|
|
399
|
+
transport: string;
|
|
400
|
+
wasmLoaded: boolean;
|
|
401
|
+
};
|
|
402
|
+
getProtocolCapabilities(): ProtocolCapabilityMap;
|
|
403
|
+
getRuntimeStatus(): Promise<{
|
|
404
|
+
runtime: 'tauri' | 'browser' | 'unknown';
|
|
405
|
+
wasmLoaded: boolean;
|
|
406
|
+
localNodeId?: string;
|
|
407
|
+
userId?: string;
|
|
408
|
+
}>;
|
|
409
|
+
private ensureWasmRuntimeForP2P;
|
|
410
|
+
private usesNativeIpcRuntimeWithoutWasmFallback;
|
|
411
|
+
private nativeWasmInitForbiddenError;
|
|
412
|
+
private ensureSignalingReadyForDiscovery;
|
|
413
|
+
private requiresManagedTransportTrust;
|
|
414
|
+
private getRegisteredChannel;
|
|
415
|
+
private isChannelPromotionEligible;
|
|
416
|
+
private isTransportOnlyChannel;
|
|
417
|
+
private getConnectionChannelId;
|
|
418
|
+
private isTransportOnlyConnectionId;
|
|
419
|
+
private resolvePromotionEligibility;
|
|
420
|
+
private assignConnectionChannel;
|
|
421
|
+
private rememberKnownDevice;
|
|
422
|
+
private getKnownDevice;
|
|
423
|
+
private refreshKnownDeviceCache;
|
|
424
|
+
private initializeConnectionTrust;
|
|
425
|
+
private consumePendingSessionTokenTrustApproval;
|
|
426
|
+
private applySessionTokenTrustApproval;
|
|
427
|
+
private getConnectionTrustState;
|
|
428
|
+
private getConnectionTrustProjection;
|
|
429
|
+
private applyConnectionTrustProjection;
|
|
430
|
+
private getConnectionTransportProjectionState;
|
|
431
|
+
private buildLocalTransportTrustPayload;
|
|
432
|
+
private sendTransportHandshake;
|
|
433
|
+
private broadcastTransportCapabilityUpdate;
|
|
434
|
+
private verifyRemoteTransportTrust;
|
|
435
|
+
private enforceConnectionTrustFailure;
|
|
436
|
+
private markConnectionTrustVerified;
|
|
437
|
+
private bindConnectionDeviceIdInRust;
|
|
438
|
+
private retireSupersededConnections;
|
|
439
|
+
searchDevices(): Promise<Device[]>;
|
|
440
|
+
updateDevice(deviceId: string, updates: {
|
|
441
|
+
deviceName?: string;
|
|
442
|
+
capabilities?: Device['capabilities'];
|
|
443
|
+
metadata?: string;
|
|
444
|
+
}): Promise<void>;
|
|
445
|
+
deleteDevice(deviceId: string): Promise<void>;
|
|
446
|
+
cleanupStaleDevices(): Promise<void>;
|
|
447
|
+
onDevicesChange(callback: any): () => void;
|
|
448
|
+
subscribeSessions(localDeviceId: string, callback: (session: SignalingSession) => void): Promise<() => void>;
|
|
449
|
+
startScanningLoop(options: ScanningLoopOptions): Promise<ScanningLoopHandle>;
|
|
450
|
+
connectDeviceWithRetry(device: Device, hooks: ConnectDeviceHooks, options: ConnectDeviceOptions): Promise<ConnectDeviceResult>;
|
|
451
|
+
bootstrapRuntime(options: RuntimeBootstrapOptions): Promise<RuntimeBootstrapResult>;
|
|
452
|
+
updateTransportConfig(transports: ClientOptions['transports']): void;
|
|
453
|
+
private getTurnCredentialsForTransportConfig;
|
|
454
|
+
/**
|
|
455
|
+
* Bootstraps the WASM module and Rust signaling.
|
|
456
|
+
* Must be called before connect or createRoom.
|
|
457
|
+
*/
|
|
458
|
+
init(): Promise<void>;
|
|
459
|
+
ensureAuthenticated(reason: 'init' | 'room-op' | 'discovery'): Promise<void>;
|
|
460
|
+
private installAuthTokenSync;
|
|
461
|
+
private syncAuthTokenToWasm;
|
|
462
|
+
get moqState(): "none" | "failed" | "connecting" | "ready";
|
|
463
|
+
get moq(): {
|
|
464
|
+
session: MoQSession;
|
|
465
|
+
publisher: MoQPublisher;
|
|
466
|
+
subscriber: MoQSubscriber;
|
|
467
|
+
} | null;
|
|
468
|
+
onMoQReady(cb: () => void): void;
|
|
469
|
+
onMoQFailed(cb: () => void): void;
|
|
470
|
+
onMoQObject(callback: (ns: string, name: string, obj: Uint8Array, meta: any) => void): void;
|
|
471
|
+
private clearMoQReconnectTimer;
|
|
472
|
+
private closeMoQSession;
|
|
473
|
+
private handleMoQSessionClosed;
|
|
474
|
+
private scheduleMoQReconnect;
|
|
475
|
+
private enableMoQForConnection;
|
|
476
|
+
private subscribeMoQPeer;
|
|
477
|
+
private resubscribeMoQPeers;
|
|
478
|
+
private initMoQ;
|
|
479
|
+
connect(ticket: string, timeoutMs?: number, expectedDeviceId?: string | null, channelId?: string): Promise<Connection>;
|
|
480
|
+
/**
|
|
481
|
+
* Low-level dial helper.
|
|
482
|
+
* Ensures the ticket is connected and returns only connection identity metadata.
|
|
483
|
+
*/
|
|
484
|
+
connectRaw(ticket: string, timeoutMs?: number): Promise<{
|
|
485
|
+
connectionId: string;
|
|
486
|
+
localNodeId: string;
|
|
487
|
+
remoteNodeId: string;
|
|
488
|
+
}>;
|
|
489
|
+
/**
|
|
490
|
+
* Start core-managed auto-connect for the authenticated user.
|
|
491
|
+
* This is intentionally low-level: callers decide when to start/stop and
|
|
492
|
+
* what higher-level protocol to run on top of the resulting connection.
|
|
493
|
+
*/
|
|
494
|
+
startAutoConnect(localDeviceId?: string): Promise<void>;
|
|
495
|
+
openBi(peerId: string): Promise<{
|
|
496
|
+
readable: ReadableStream<Uint8Array>;
|
|
497
|
+
writable: WritableStream<Uint8Array>;
|
|
498
|
+
}>;
|
|
499
|
+
openUni(peerId: string): Promise<WritableStream<Uint8Array>>;
|
|
500
|
+
getConnections(): Connection[];
|
|
501
|
+
getConnectionForPeer(connectionId?: string, remoteNodeId?: string): Connection | null;
|
|
502
|
+
watchPeerStates(callback: (peers: PeerState[]) => void): () => void;
|
|
503
|
+
getPeerState(id: string): PeerState | undefined;
|
|
504
|
+
listConnectedPeers(): PeerState[];
|
|
505
|
+
isPeerPromotionEligible(identifiers: {
|
|
506
|
+
connectionId?: string | null;
|
|
507
|
+
deviceId?: string | null;
|
|
508
|
+
deviceIdHint?: string | null;
|
|
509
|
+
nodeId?: string | null;
|
|
510
|
+
}): boolean;
|
|
511
|
+
addPeerScope(id: string, scope?: PeerScope): PeerState | undefined;
|
|
512
|
+
releasePeerScope(id: string, scope?: PeerScope): PeerState | undefined;
|
|
513
|
+
getPeerScopes(id: string): PeerScope[];
|
|
514
|
+
isSamePeer(a: string, b: string): boolean;
|
|
515
|
+
refreshPeerSnapshot(): Promise<PeerState[]>;
|
|
516
|
+
connectPeer(options: {
|
|
517
|
+
deviceId?: string;
|
|
518
|
+
ticket?: string;
|
|
519
|
+
scope?: PeerScope;
|
|
520
|
+
channelId?: string;
|
|
521
|
+
}): Promise<Connection>;
|
|
522
|
+
clearManualDisconnectProjection(id: string): void;
|
|
523
|
+
disconnectPeer(id: string, scope?: PeerScope): Promise<void>;
|
|
524
|
+
forceDisconnectPeer(id: string): Promise<void>;
|
|
525
|
+
getPeerHealth(id: string): Promise<PeerHealth>;
|
|
526
|
+
private mapRustPeerStatus;
|
|
527
|
+
private mapRustPeerHealth;
|
|
528
|
+
getTicket(): Promise<string>;
|
|
529
|
+
getNodeId(): Promise<string>;
|
|
530
|
+
getNodeIdFromTicket(ticket: string): Promise<string | null>;
|
|
531
|
+
/**
|
|
532
|
+
* Generate a random session token, register it, and return a compound
|
|
533
|
+
* ticket string with the token suffix appended.
|
|
534
|
+
*
|
|
535
|
+
* @param grantScope Admission-grant label (e.g. "share"). Used for bulk revoke in Rust.
|
|
536
|
+
* This is distinct from `PeerScope`, which only tracks local peer lifecycle.
|
|
537
|
+
* @param maxConnections 0 = unlimited.
|
|
538
|
+
*/
|
|
539
|
+
getEndpointTicketWithToken(grantScope: GrantScope, maxConnections?: number): Promise<string>;
|
|
540
|
+
/**
|
|
541
|
+
* Build a compound ticket from an externally-provided iroh ticket string.
|
|
542
|
+
* Generates a session token, registers it with the Rust wasm client when available,
|
|
543
|
+
* and appends the token
|
|
544
|
+
* payload as a base64url suffix separated by `.`.
|
|
545
|
+
*
|
|
546
|
+
* Used by RuntimeClient.getTicketWithToken() on native desktop where the
|
|
547
|
+
* iroh ticket comes from the Rust backend (via Tauri IPC) rather than the
|
|
548
|
+
* WASM node running in the webview.
|
|
549
|
+
*/
|
|
550
|
+
buildCompoundTicketWithToken(irohTicket: string, grantScope: GrantScope, maxConnections?: number): string;
|
|
551
|
+
setManagedPresenceTicket(ticket: string | null): void;
|
|
552
|
+
clearManagedPresenceTicket(): void;
|
|
553
|
+
/** Register an externally-generated session token with the Rust wasm client. */
|
|
554
|
+
registerSessionToken(token: string, grantScope: GrantScope, maxConnections: number): void;
|
|
555
|
+
/** Revoke a specific session token. */
|
|
556
|
+
revokeSessionToken(token: string): void;
|
|
557
|
+
/** Revoke all tokens that match the given scope. */
|
|
558
|
+
revokeTokensByScope(grantScope: GrantScope): Promise<string[]>;
|
|
559
|
+
private static generateSessionToken;
|
|
560
|
+
private static encodeSessionTokenPayload;
|
|
561
|
+
private static buildCompoundTicketWithPayload;
|
|
562
|
+
clearSessionTokens(): Promise<void>;
|
|
563
|
+
private resolvePresenceTicket;
|
|
564
|
+
private refreshManagedPresenceTicketIfNeeded;
|
|
565
|
+
private validateIncomingSessionToken;
|
|
566
|
+
private validateIncomingSessionTokenWithRetry;
|
|
567
|
+
/**
|
|
568
|
+
* Start the signaling-backed presence loop owned by the Rust core.
|
|
569
|
+
* A ticket can be provided explicitly, otherwise the current endpoint ticket is used.
|
|
570
|
+
*/
|
|
571
|
+
startPresenceLoop(options?: {
|
|
572
|
+
deviceName?: string;
|
|
573
|
+
ticket?: string;
|
|
574
|
+
metadata?: string;
|
|
575
|
+
}): Promise<void>;
|
|
576
|
+
/**
|
|
577
|
+
* Mark local presence offline in the signaling backend.
|
|
578
|
+
*/
|
|
579
|
+
setOffline(): Promise<void>;
|
|
580
|
+
/**
|
|
581
|
+
* Check raw connectivity against a remote node id.
|
|
582
|
+
*/
|
|
583
|
+
isConnected(nodeId: string): Promise<boolean>;
|
|
584
|
+
/**
|
|
585
|
+
* Disconnect a remote node from the local connection manager.
|
|
586
|
+
*/
|
|
587
|
+
disconnectNode(nodeId: string): Promise<void>;
|
|
588
|
+
getLocalDeviceId(): Promise<string | null>;
|
|
589
|
+
/**
|
|
590
|
+
* Route a raw message received on a native iroh connection through token
|
|
591
|
+
* validation. Called by RuntimeClient when NativeIpcBridge fires an
|
|
592
|
+
* `iroh://message` event for an incoming native connection.
|
|
593
|
+
*
|
|
594
|
+
* If we have a TS Connection object for this peer (e.g. the client also
|
|
595
|
+
* called connect()), route through handleMessage. Otherwise, for connections
|
|
596
|
+
* that were accepted purely by the Rust protocol handler, perform token
|
|
597
|
+
* validation directly.
|
|
598
|
+
*
|
|
599
|
+
* @returns true if the connection should be rejected (caller should disconnect)
|
|
600
|
+
*/
|
|
601
|
+
acceptNativeMessage(connectionId: string | null, remoteNodeId: string | null, msg: any): Promise<boolean>;
|
|
602
|
+
startListening(): Promise<void>;
|
|
603
|
+
stopListening(): void;
|
|
604
|
+
private getSharedIncomingStreamHub;
|
|
605
|
+
private nextIncomingStreamRetryDelayMs;
|
|
606
|
+
private getRuntimeSafetyProfile;
|
|
607
|
+
private shouldVerboseIncomingDiagnostics;
|
|
608
|
+
private shouldUseTransportOnlyChannelConnection;
|
|
609
|
+
private createTransportOnlyChannelConnection;
|
|
610
|
+
private shouldInspectIncomingChannelEnvelope;
|
|
611
|
+
private createTransportContext;
|
|
612
|
+
private hasTransportOnlyConnectionForRemoteNode;
|
|
613
|
+
private shouldSkipIncomingBiProbeForRemoteNode;
|
|
614
|
+
private disconnectNodeTransport;
|
|
615
|
+
private nextIncomingTraceId;
|
|
616
|
+
private logIncomingDiagnostic;
|
|
617
|
+
private awaitConnectEventReady;
|
|
618
|
+
private safeReleaseReaderLock;
|
|
619
|
+
/**
|
|
620
|
+
* Force an immediate presence update and reconnect snapshot.
|
|
621
|
+
*/
|
|
622
|
+
forceReconnectSnapshot(): void;
|
|
623
|
+
private updatePresenceInternal;
|
|
624
|
+
private listenLoop;
|
|
625
|
+
private prependChunkToReadable;
|
|
626
|
+
private cancelUnhandledIncomingUniStream;
|
|
627
|
+
private prependBytesToReader;
|
|
628
|
+
private concatBytes;
|
|
629
|
+
private encodeChannelEnvelope;
|
|
630
|
+
wrapChannelWritable(writable: WritableStream<Uint8Array>, channelId: string, metadata?: Record<string, unknown> | null): WritableStream<Uint8Array>;
|
|
631
|
+
private extractIncomingChannelEnvelope;
|
|
632
|
+
private isBiStreamLike;
|
|
633
|
+
private materializeIncomingBiStream;
|
|
634
|
+
private rebuildBiIncomingStream;
|
|
635
|
+
private classifyBiIncomingStream;
|
|
636
|
+
private detectNativeMainStream;
|
|
637
|
+
private resolveLocalHandshakePayload;
|
|
638
|
+
private getDeterministicConnectionId;
|
|
639
|
+
private getNativeMainConnectionId;
|
|
640
|
+
private findManualDisconnectProjectionForNativeNode;
|
|
641
|
+
private hasKnownConnectionForRemoteNode;
|
|
642
|
+
private inferTicketFlowBiProtocolHint;
|
|
643
|
+
private hasRustPeerLifecycleProjection;
|
|
644
|
+
private shouldProjectNativeMainLifecycle;
|
|
645
|
+
private emitNativeMainConnectionState;
|
|
646
|
+
private applyBackendConnectionState;
|
|
647
|
+
private encodeNativeMainFrame;
|
|
648
|
+
private dispatchNativeMainMessage;
|
|
649
|
+
private writeNativeMainMessage;
|
|
650
|
+
private handleNativeHandshakeRequest;
|
|
651
|
+
private handleNativeSessionTokenRequest;
|
|
652
|
+
private isNativeSignalEnvelope;
|
|
653
|
+
private buildNativeMainPayload;
|
|
654
|
+
private buildFramedMessage;
|
|
655
|
+
private buildNativeMainLabelHeader;
|
|
656
|
+
private writeNativeMainLabelHeaderOnBiStream;
|
|
657
|
+
private registerInboundNativeMainWriter;
|
|
658
|
+
private clearInboundNativeMainWriter;
|
|
659
|
+
private sendNativeSignalViaInboundControlStream;
|
|
660
|
+
private sendNativeSignalViaDedicatedStream;
|
|
661
|
+
private sendNativeSignalEnvelope;
|
|
662
|
+
private ensureIncomingConnectionForRemoteNode;
|
|
663
|
+
private handleNativeMainStream;
|
|
664
|
+
private tryExtractNativeMainPayload;
|
|
665
|
+
private isCoreConnectionHealthy;
|
|
666
|
+
private waitForStableConnection;
|
|
667
|
+
private announceConnectionWhenStable;
|
|
668
|
+
private normalizeIncomingStreamEvent;
|
|
669
|
+
private hasIncomingChannelListener;
|
|
670
|
+
private hasAnyIncomingChannelListeners;
|
|
671
|
+
private dispatchIncomingChannelListeners;
|
|
672
|
+
private dispatchIncomingGenericListeners;
|
|
673
|
+
private shouldTreatIncomingStreamAsTransportOnly;
|
|
674
|
+
private handleUnhandledIncomingStreamEvent;
|
|
675
|
+
private isHandshakeMessage;
|
|
676
|
+
private handleIncomingStream;
|
|
677
|
+
private maybeHandleWebRTCExplicitFileEnvelope;
|
|
678
|
+
private reassembleWebRTCExplicitPayload;
|
|
679
|
+
private dispatchSyntheticExplicitIncomingStream;
|
|
680
|
+
private registerConnection;
|
|
681
|
+
private reportConnectionTransportStatus;
|
|
682
|
+
private syncConnectionPeerLifecycle;
|
|
683
|
+
private getPeerCandidates;
|
|
684
|
+
updatePresence(isOnline?: boolean, ttlMs?: number, metadata?: string, ticketOverride?: string): Promise<void>;
|
|
685
|
+
onConnection(callback: (conn: Connection) => void): () => void;
|
|
686
|
+
onDisconnection(callback: (conn: Connection) => void): () => void;
|
|
687
|
+
onMessage(callback: (conn: Connection, msg: any) => void): () => void;
|
|
688
|
+
onIncomingStream(callback: (stream: IncomingStreamListenerEvent) => boolean | void): () => void;
|
|
689
|
+
registerChannel(descriptor: ChannelDescriptor): void;
|
|
690
|
+
unregisterChannel(channelId: string): void;
|
|
691
|
+
listChannels(): ChannelDescriptor[];
|
|
692
|
+
onIncomingChannelStream(channelId: string, callback: (stream: IncomingStreamListenerEvent) => boolean | void): () => void;
|
|
693
|
+
onRoomJoinRequest(callback: (request: JoinRequest) => void): () => void;
|
|
694
|
+
private createMoQDataTracks;
|
|
695
|
+
/**
|
|
696
|
+
* Send data via MoQ.
|
|
697
|
+
* @param peerId Target Node ID (for 1:1) or null (for Broadcast)
|
|
698
|
+
* @param data Payload
|
|
699
|
+
*/
|
|
700
|
+
sendMoQData(peerId: string | null, data: Uint8Array): Promise<void>;
|
|
701
|
+
private handleMessage;
|
|
702
|
+
private isWebRTCTransportEnabled;
|
|
703
|
+
private getRTCConfig;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Owns low-level transport commands for RuntimeClient.
|
|
708
|
+
*
|
|
709
|
+
* This intentionally stays narrow: managed sessions, device discovery, peer
|
|
710
|
+
* readiness, and channel orchestration remain in their existing managers until
|
|
711
|
+
* those boundaries can be tightened independently.
|
|
712
|
+
*/
|
|
713
|
+
declare class RuntimeConnectionController {
|
|
714
|
+
private readonly client;
|
|
715
|
+
private readonly backend;
|
|
716
|
+
constructor(client: Client, backend: ISignalingBackend | null);
|
|
717
|
+
connectToDevice(params: {
|
|
718
|
+
deviceId?: string | null;
|
|
719
|
+
endpointTicket: string;
|
|
720
|
+
}): Promise<NativeConnectResult>;
|
|
721
|
+
connectRaw(target: RuntimeConnectionTarget): Promise<RuntimeRawConnection>;
|
|
722
|
+
openBi(nodeId: string): Promise<{
|
|
723
|
+
readable: ReadableStream<Uint8Array>;
|
|
724
|
+
writable: WritableStream<Uint8Array>;
|
|
725
|
+
}>;
|
|
726
|
+
openUni(nodeId: string): Promise<WritableStream<Uint8Array>>;
|
|
727
|
+
isConnected(nodeId: string): Promise<boolean>;
|
|
728
|
+
disconnectNode(nodeId: string): Promise<void>;
|
|
729
|
+
disconnectDevice(deviceId: string): Promise<void>;
|
|
730
|
+
setAutoConnectExcluded(deviceId: string, excluded: boolean): Promise<void>;
|
|
731
|
+
disconnectPeer(id: string, scope?: string): Promise<void>;
|
|
732
|
+
forceDisconnectPeer(id: string): Promise<void>;
|
|
733
|
+
private clearManualDisconnectProjection;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Phase 7 TS-side correlation logger. Mirror of
|
|
738
|
+
* `openrtc/crates/openrtc/src/client/correlation.rs`. Emits `console.log` lines in
|
|
739
|
+
* the exact `key=value` shape the Phase 0 parser
|
|
740
|
+
* (`tests/helpers/correlationLog.ts`) recognises.
|
|
741
|
+
*
|
|
742
|
+
* The TS half exists so observer-side state transitions (scoped-actor
|
|
743
|
+
* coalescing, upgrade observation, channel opens, shutdown) emit the same
|
|
744
|
+
* correlation chain the Rust core does — making cross-language log scans
|
|
745
|
+
* grep-friendly.
|
|
746
|
+
*
|
|
747
|
+
* ## Usage
|
|
748
|
+
*
|
|
749
|
+
* ```ts
|
|
750
|
+
* import { clog } from '@/openrtc/packages/openrtc/src/runtime/correlationLog';
|
|
751
|
+
* clog('[scoped-actor][dial]',
|
|
752
|
+
* { sessionKind: 'scoped-guest', scope: 'scoped:abc', peerNodeId: 'node-A' },
|
|
753
|
+
* 'ready_first');
|
|
754
|
+
* ```
|
|
755
|
+
*
|
|
756
|
+
* Empty/undefined fields are omitted so log lines stay short.
|
|
757
|
+
*/
|
|
758
|
+
interface CorrelationFields {
|
|
759
|
+
sessionKind?: string;
|
|
760
|
+
grantId?: string;
|
|
761
|
+
scope?: string;
|
|
762
|
+
peerNodeId?: string;
|
|
763
|
+
connectionId?: string;
|
|
764
|
+
transportEpoch?: string | number;
|
|
765
|
+
channel?: string;
|
|
766
|
+
tokenFp?: string;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Renders `fields` to `key=value key=value` (snake_case keys to match
|
|
770
|
+
* the Phase 0 parser's primary regex set). Empty fields are dropped.
|
|
771
|
+
* Exposed for tests.
|
|
772
|
+
*/
|
|
773
|
+
declare function renderCorrelationFields(fields: CorrelationFields): string;
|
|
774
|
+
/** @deprecated Use correlationForScope() */
|
|
775
|
+
declare function correlationForDriveGrantScope(scope: string, extra?: CorrelationFields): CorrelationFields;
|
|
776
|
+
/**
|
|
777
|
+
* Phase 7 structured-log call. Emits a single `console.log` line of the
|
|
778
|
+
* form `<tag> <fields> <message>` — the exact shape the Phase 0
|
|
779
|
+
* `correlationLog.ts` parser already understands.
|
|
780
|
+
*
|
|
781
|
+
* Tag is typically a bracket-prefix like `[drive-grant-actor][dial]`.
|
|
782
|
+
* Fields are rendered as `snake_case=value`. Pass an empty object for
|
|
783
|
+
* the fields if a context isn't applicable yet.
|
|
784
|
+
*/
|
|
785
|
+
declare function clog(tag: string, fields: CorrelationFields, message?: string, ...extra: unknown[]): void;
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Consistent logging for session teardown / revoke paths (user-device, share, etc.).
|
|
789
|
+
*
|
|
790
|
+
* Browser: set `localStorage.setItem('OPENRTC_TEARDOWN_TRACE', '1')`, reload, reproduce.
|
|
791
|
+
* Stack lines are tagged `[OpenRTC][teardown-trace:stack]`.
|
|
792
|
+
* Native / Tauri: run with `PLUTO_RTC_TEARDOWN_TRACE=1` to log matching Rust iroh disconnect lines to stderr.
|
|
793
|
+
*/
|
|
794
|
+
declare function logOpenRtcTeardownTrace(kind: string, details?: Record<string, unknown>): void;
|
|
795
|
+
|
|
796
|
+
export { type CorrelationFields, RuntimeConnectionController, RuntimeConnectionTarget, RuntimeRawConnection, clog, correlationForDriveGrantScope, logOpenRtcTeardownTrace, renderCorrelationFields };
|