openrtc 0.1.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/README.md +106 -0
- package/dist/OpenRTC.d.ts +71 -0
- package/dist/OpenRTC.js +130 -0
- package/dist/api/MediaTransport.d.ts +7 -0
- package/dist/api/MediaTransport.js +262 -0
- package/dist/api/PlutoPeerConnection.d.ts +50 -0
- package/dist/api/PlutoPeerConnection.js +434 -0
- package/dist/api/PlutoWebSocket.d.ts +24 -0
- package/dist/api/PlutoWebSocket.js +113 -0
- package/dist/api/PlutoWebTransport.d.ts +29 -0
- package/dist/api/PlutoWebTransport.js +105 -0
- package/dist/auth/host.d.ts +73 -0
- package/dist/auth/host.js +513 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js +1 -0
- package/dist/auth/internal.d.ts +1 -0
- package/dist/auth/internal.js +1 -0
- package/dist/compat/index.d.ts +20 -0
- package/dist/compat/index.js +20 -0
- package/dist/core/Client.d.ts +352 -0
- package/dist/core/Client.js +3689 -0
- package/dist/core/Connection.d.ts +67 -0
- package/dist/core/Connection.js +404 -0
- package/dist/core/IEngineBridge.d.ts +18 -0
- package/dist/core/IEngineBridge.js +1 -0
- package/dist/core/ISignalingTransport.d.ts +13 -0
- package/dist/core/ISignalingTransport.js +1 -0
- package/dist/core/PeerLifecycleManager.d.ts +43 -0
- package/dist/core/PeerLifecycleManager.js +330 -0
- package/dist/core/PeerProjectionStore.d.ts +43 -0
- package/dist/core/PeerProjectionStore.js +327 -0
- package/dist/core/PlutoRTC.d.ts +13 -0
- package/dist/core/PlutoRTC.js +26 -0
- package/dist/core/Room.d.ts +47 -0
- package/dist/core/Room.js +376 -0
- package/dist/core/Signaling.d.ts +39 -0
- package/dist/core/Signaling.js +147 -0
- package/dist/core/bridges/BridgeCodecs.d.ts +19 -0
- package/dist/core/bridges/BridgeCodecs.js +317 -0
- package/dist/core/bridges/BrowserFirestoreRooms.d.ts +36 -0
- package/dist/core/bridges/BrowserFirestoreRooms.js +169 -0
- package/dist/core/bridges/BrowserFirestoreSignaling.d.ts +111 -0
- package/dist/core/bridges/BrowserFirestoreSignaling.js +1010 -0
- package/dist/core/bridges/NativeIpcBridge.d.ts +156 -0
- package/dist/core/bridges/NativeIpcBridge.js +1472 -0
- package/dist/core/bridges/RtdbPresence.d.ts +122 -0
- package/dist/core/bridges/RtdbPresence.js +201 -0
- package/dist/core/bridges/TauriBridge.d.ts +8 -0
- package/dist/core/bridges/TauriBridge.js +7 -0
- package/dist/core/bridges/WasmBridge.d.ts +233 -0
- package/dist/core/bridges/WasmBridge.js +1811 -0
- package/dist/core/config.d.ts +31 -0
- package/dist/core/config.js +138 -0
- package/dist/core/transports/ITransport.d.ts +12 -0
- package/dist/core/transports/ITransport.js +1 -0
- package/dist/core/transports/LocalDaemonBridge.d.ts +41 -0
- package/dist/core/transports/LocalDaemonBridge.js +227 -0
- package/dist/core/transports/TauriSignaling.d.ts +28 -0
- package/dist/core/transports/TauriSignaling.js +373 -0
- package/dist/core/transports/TransportFactory.d.ts +9 -0
- package/dist/core/transports/TransportFactory.js +59 -0
- package/dist/core/transports/WasmSignaling.d.ts +78 -0
- package/dist/core/transports/WasmSignaling.js +522 -0
- package/dist/core/transports/WebRTCTransport.d.ts +23 -0
- package/dist/core/transports/WebRTCTransport.js +132 -0
- package/dist/core/trust.d.ts +23 -0
- package/dist/core/trust.js +99 -0
- package/dist/core/types.d.ts +559 -0
- package/dist/core/types.js +19 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/moq/MoQMediaTransport.d.ts +6 -0
- package/dist/moq/MoQMediaTransport.js +106 -0
- package/dist/moq/MoQPublisher.d.ts +22 -0
- package/dist/moq/MoQPublisher.js +179 -0
- package/dist/moq/MoQSession.d.ts +35 -0
- package/dist/moq/MoQSession.js +166 -0
- package/dist/moq/MoQSubscriber.d.ts +19 -0
- package/dist/moq/MoQSubscriber.js +235 -0
- package/dist/moq/common.d.ts +47 -0
- package/dist/moq/common.js +304 -0
- package/dist/moq/messages.d.ts +105 -0
- package/dist/moq/messages.js +367 -0
- package/dist/presets/plutoHosted.d.ts +13 -0
- package/dist/presets/plutoHosted.js +18 -0
- package/dist/runtime/DelegatingRuntimeAdapter.d.ts +68 -0
- package/dist/runtime/DelegatingRuntimeAdapter.js +250 -0
- package/dist/runtime/IpcRuntimeAdapter.d.ts +9 -0
- package/dist/runtime/IpcRuntimeAdapter.js +13 -0
- package/dist/runtime/RuntimeClient.d.ts +257 -0
- package/dist/runtime/RuntimeClient.js +1484 -0
- package/dist/runtime/TauriRuntimeAdapter.d.ts +1 -0
- package/dist/runtime/TauriRuntimeAdapter.js +1 -0
- package/dist/runtime/WasmRuntimeAdapter.d.ts +6 -0
- package/dist/runtime/WasmRuntimeAdapter.js +11 -0
- package/dist/runtime/factories.d.ts +24 -0
- package/dist/runtime/factories.js +66 -0
- package/dist/runtime/index.d.ts +6 -0
- package/dist/runtime/index.js +5 -0
- package/dist/runtime/ipc.d.ts +8 -0
- package/dist/runtime/ipc.js +65 -0
- package/dist/runtime/ipcContract.d.ts +46 -0
- package/dist/runtime/ipcContract.js +1 -0
- package/dist/runtime/tauri.d.ts +16 -0
- package/dist/runtime/tauri.js +22 -0
- package/dist/runtime/types.d.ts +110 -0
- package/dist/runtime/types.js +1 -0
- package/dist/transports/TauriTransport.d.ts +17 -0
- package/dist/transports/TauriTransport.js +49 -0
- package/dist/transports/WebTransport.d.ts +23 -0
- package/dist/transports/WebTransport.js +71 -0
- package/dist/utils/debug.d.ts +4 -0
- package/dist/utils/debug.js +33 -0
- package/dist/utils/runtime.d.ts +1 -0
- package/dist/utils/runtime.js +10 -0
- package/package.json +97 -0
- package/wasm/README.md +64 -0
- package/wasm/openrtc.d.ts +284 -0
- package/wasm/openrtc.js +2132 -0
- package/wasm/openrtc_bg.wasm +0 -0
- package/wasm/openrtc_bg.wasm.d.ts +110 -0
- package/wasm/package.json +16 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
export class DelegatingRuntimeAdapter {
|
|
2
|
+
constructor(backend) {
|
|
3
|
+
this.backend = backend;
|
|
4
|
+
}
|
|
5
|
+
get currentUser() {
|
|
6
|
+
return this.backend.currentUser;
|
|
7
|
+
}
|
|
8
|
+
setAuthContext(context) {
|
|
9
|
+
const backend = this.backend;
|
|
10
|
+
return backend.setAuthContext?.(context);
|
|
11
|
+
}
|
|
12
|
+
async signInAnonymously() {
|
|
13
|
+
return this.backend.signInAnonymously();
|
|
14
|
+
}
|
|
15
|
+
async signInWithPluto() {
|
|
16
|
+
if (typeof this.backend.signInWithPluto !== 'function') {
|
|
17
|
+
throw new Error('Selected runtime adapter does not support Pluto SSO.');
|
|
18
|
+
}
|
|
19
|
+
return this.backend.signInWithPluto();
|
|
20
|
+
}
|
|
21
|
+
async signOut() {
|
|
22
|
+
return this.backend.signOut();
|
|
23
|
+
}
|
|
24
|
+
async stopAuthScopedActivity() {
|
|
25
|
+
if (typeof this.backend.stopAuthScopedActivity === 'function') {
|
|
26
|
+
await this.backend.stopAuthScopedActivity();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async getTurnCredentials() {
|
|
30
|
+
return this.backend.getTurnCredentials();
|
|
31
|
+
}
|
|
32
|
+
async updatePresence(localNodeId, ticketStr, isOnline, ttlMs, metadata) {
|
|
33
|
+
return this.backend.updatePresence(localNodeId, ticketStr, isOnline, ttlMs, metadata);
|
|
34
|
+
}
|
|
35
|
+
async setOffline(localNodeId) {
|
|
36
|
+
return this.backend.setOffline(localNodeId);
|
|
37
|
+
}
|
|
38
|
+
async cleanupStaleDevices() {
|
|
39
|
+
return this.backend.cleanupStaleDevices();
|
|
40
|
+
}
|
|
41
|
+
async searchDevices(excludeNodeId) {
|
|
42
|
+
return this.backend.searchDevices(excludeNodeId);
|
|
43
|
+
}
|
|
44
|
+
async listDevicesWithStatus() {
|
|
45
|
+
if (typeof this.backend.listDevicesWithStatus !== 'function') {
|
|
46
|
+
throw new Error('Selected runtime adapter does not support listDevicesWithStatus().');
|
|
47
|
+
}
|
|
48
|
+
return this.backend.listDevicesWithStatus();
|
|
49
|
+
}
|
|
50
|
+
async getPeerSession(id) {
|
|
51
|
+
if (typeof this.backend.getPeerSession !== 'function') {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return this.backend.getPeerSession(id);
|
|
55
|
+
}
|
|
56
|
+
async listPeerSessions() {
|
|
57
|
+
if (typeof this.backend.listPeerSessions !== 'function') {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
return this.backend.listPeerSessions();
|
|
61
|
+
}
|
|
62
|
+
async waitForSettledPeer(id, timeoutMs) {
|
|
63
|
+
if (typeof this.backend.waitForSettledPeer !== 'function') {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return this.backend.waitForSettledPeer(id, timeoutMs);
|
|
67
|
+
}
|
|
68
|
+
async resolvePeerIdentity(id) {
|
|
69
|
+
if (typeof this.backend.resolvePeerIdentity !== 'function') {
|
|
70
|
+
return {
|
|
71
|
+
peerId: null,
|
|
72
|
+
deviceId: null,
|
|
73
|
+
deviceIdHint: null,
|
|
74
|
+
nodeId: null,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return this.backend.resolvePeerIdentity(id);
|
|
78
|
+
}
|
|
79
|
+
async resolvePeerConnectionRecords(id) {
|
|
80
|
+
if (typeof this.backend.resolvePeerConnectionRecords !== 'function') {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
return this.backend.resolvePeerConnectionRecords(id);
|
|
84
|
+
}
|
|
85
|
+
async updateDevice(deviceId, updates) {
|
|
86
|
+
return this.backend.updateDevice(deviceId, updates);
|
|
87
|
+
}
|
|
88
|
+
async deleteDevice(deviceId) {
|
|
89
|
+
return this.backend.deleteDevice(deviceId);
|
|
90
|
+
}
|
|
91
|
+
onDevicesChange(callback, excludeNodeId) {
|
|
92
|
+
return this.backend.onDevicesChange(callback, excludeNodeId);
|
|
93
|
+
}
|
|
94
|
+
onAuthChange(callback) {
|
|
95
|
+
return this.backend.onAuthChange(callback);
|
|
96
|
+
}
|
|
97
|
+
async checkForSSOToken() {
|
|
98
|
+
return this.backend.checkForSSOToken();
|
|
99
|
+
}
|
|
100
|
+
async waitForAuth() {
|
|
101
|
+
return this.backend.waitForAuth();
|
|
102
|
+
}
|
|
103
|
+
async sendMessage(targetId, payload, state, replyPayload) {
|
|
104
|
+
return this.backend.sendMessage(targetId, payload, state, replyPayload);
|
|
105
|
+
}
|
|
106
|
+
async pollMessages(targetId) {
|
|
107
|
+
return this.backend.pollMessages(targetId);
|
|
108
|
+
}
|
|
109
|
+
async subscribeDevices(userId) {
|
|
110
|
+
return this.backend.subscribeDevices(userId);
|
|
111
|
+
}
|
|
112
|
+
startAutoConnect(userId, localDeviceId) {
|
|
113
|
+
this.backend.startAutoConnect(userId, localDeviceId);
|
|
114
|
+
}
|
|
115
|
+
startPresenceLoop(userId, localNodeId, deviceName, ticket, metadata) {
|
|
116
|
+
this.backend.startPresenceLoop(userId, localNodeId, deviceName, ticket, metadata);
|
|
117
|
+
}
|
|
118
|
+
async createSession(session) {
|
|
119
|
+
return this.backend.createSession(session);
|
|
120
|
+
}
|
|
121
|
+
async updateSession(sessionId, updateData) {
|
|
122
|
+
return this.backend.updateSession(sessionId, updateData);
|
|
123
|
+
}
|
|
124
|
+
async subscribeSessions(localDeviceId) {
|
|
125
|
+
return this.backend.subscribeSessions(localDeviceId);
|
|
126
|
+
}
|
|
127
|
+
forceReconnectSnapshot() {
|
|
128
|
+
this.backend.forceReconnectSnapshot();
|
|
129
|
+
}
|
|
130
|
+
async getLocalDeviceId() {
|
|
131
|
+
if (typeof this.backend.getLocalDeviceId !== 'function') {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return this.backend.getLocalDeviceId();
|
|
135
|
+
}
|
|
136
|
+
async getLocalDeviceInfo() {
|
|
137
|
+
if (typeof this.backend.getLocalDeviceInfo !== 'function') {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return this.backend.getLocalDeviceInfo();
|
|
141
|
+
}
|
|
142
|
+
async updateLocalDeviceName(deviceName) {
|
|
143
|
+
if (typeof this.backend.updateLocalDeviceName !== 'function') {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return this.backend.updateLocalDeviceName(deviceName);
|
|
147
|
+
}
|
|
148
|
+
async getManagedNodeId(options) {
|
|
149
|
+
if (typeof this.backend.getManagedNodeId !== 'function') {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
return this.backend.getManagedNodeId(options);
|
|
153
|
+
}
|
|
154
|
+
async getEndpointTicket() {
|
|
155
|
+
if (typeof this.backend.getEndpointTicket !== 'function') {
|
|
156
|
+
throw new Error('Selected runtime adapter does not support getEndpointTicket().');
|
|
157
|
+
}
|
|
158
|
+
return this.backend.getEndpointTicket();
|
|
159
|
+
}
|
|
160
|
+
async getEndpointTicketWithToken(scope, maxConnections) {
|
|
161
|
+
const b = this.backend;
|
|
162
|
+
if (typeof b.getEndpointTicketWithToken !== 'function')
|
|
163
|
+
return null;
|
|
164
|
+
return b.getEndpointTicketWithToken(scope, maxConnections);
|
|
165
|
+
}
|
|
166
|
+
async registerSessionToken(token, scope, maxConnections) {
|
|
167
|
+
const b = this.backend;
|
|
168
|
+
if (typeof b.registerSessionToken === 'function') {
|
|
169
|
+
await b.registerSessionToken(token, scope, maxConnections);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async revokeSessionTokensByScope(scope) {
|
|
173
|
+
const b = this.backend;
|
|
174
|
+
if (typeof b.revokeSessionTokensByScope !== 'function')
|
|
175
|
+
return [];
|
|
176
|
+
return b.revokeSessionTokensByScope(scope);
|
|
177
|
+
}
|
|
178
|
+
async openPeerBi(id, timeoutMs) {
|
|
179
|
+
if (typeof this.backend.openPeerBi !== 'function') {
|
|
180
|
+
throw new Error('Selected runtime adapter does not support openPeerBi().');
|
|
181
|
+
}
|
|
182
|
+
return this.backend.openPeerBi(id, timeoutMs);
|
|
183
|
+
}
|
|
184
|
+
async openPeerUni(id, timeoutMs) {
|
|
185
|
+
if (typeof this.backend.openPeerUni !== 'function') {
|
|
186
|
+
throw new Error('Selected runtime adapter does not support openPeerUni().');
|
|
187
|
+
}
|
|
188
|
+
return this.backend.openPeerUni(id, timeoutMs);
|
|
189
|
+
}
|
|
190
|
+
async connectToDevice(params) {
|
|
191
|
+
if (typeof this.backend.connectToDevice !== 'function') {
|
|
192
|
+
throw new Error('Selected runtime adapter does not support connectToDevice().');
|
|
193
|
+
}
|
|
194
|
+
return this.backend.connectToDevice(params);
|
|
195
|
+
}
|
|
196
|
+
async disconnectDevice(deviceId) {
|
|
197
|
+
if (typeof this.backend.disconnectDevice !== 'function') {
|
|
198
|
+
throw new Error('Selected runtime adapter does not support disconnectDevice().');
|
|
199
|
+
}
|
|
200
|
+
return this.backend.disconnectDevice(deviceId);
|
|
201
|
+
}
|
|
202
|
+
async isConnected(nodeId) {
|
|
203
|
+
return this.backend.isConnected(nodeId);
|
|
204
|
+
}
|
|
205
|
+
async getConnectionStates() {
|
|
206
|
+
if (typeof this.backend.getConnectionStates !== 'function') {
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
return this.backend.getConnectionStates();
|
|
210
|
+
}
|
|
211
|
+
onConnectionStateChange(callback) {
|
|
212
|
+
if (typeof this.backend.onConnectionStateChange !== 'function') {
|
|
213
|
+
return () => { };
|
|
214
|
+
}
|
|
215
|
+
return this.backend.onConnectionStateChange(callback);
|
|
216
|
+
}
|
|
217
|
+
async sendExplicitFilePath(connectionId, filePath, transferId) {
|
|
218
|
+
if (typeof this.backend.sendExplicitFilePath !== 'function') {
|
|
219
|
+
throw new Error('Selected runtime adapter does not support sendExplicitFilePath().');
|
|
220
|
+
}
|
|
221
|
+
return this.backend.sendExplicitFilePath(connectionId, filePath, transferId);
|
|
222
|
+
}
|
|
223
|
+
async sendExplicitFileData(params) {
|
|
224
|
+
if (typeof this.backend.sendExplicitFileData !== 'function') {
|
|
225
|
+
throw new Error('Selected runtime adapter does not support sendExplicitFileData().');
|
|
226
|
+
}
|
|
227
|
+
return this.backend.sendExplicitFileData(params);
|
|
228
|
+
}
|
|
229
|
+
async getTransferHistory(limit) {
|
|
230
|
+
if (typeof this.backend.getTransferHistory !== 'function') {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
return this.backend.getTransferHistory(limit);
|
|
234
|
+
}
|
|
235
|
+
async deleteTransferJob(jobId) {
|
|
236
|
+
if (typeof this.backend.deleteTransferJob !== 'function') {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
return this.backend.deleteTransferJob(jobId);
|
|
240
|
+
}
|
|
241
|
+
async onIncomingNativeMessage(callback) {
|
|
242
|
+
const b = this.backend;
|
|
243
|
+
if (typeof b.onIncomingNativeMessage !== 'function')
|
|
244
|
+
return () => { };
|
|
245
|
+
return b.onIncomingNativeMessage(callback);
|
|
246
|
+
}
|
|
247
|
+
unwrap() {
|
|
248
|
+
return this.backend;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type NativeIpcBridgeOptions } from '../core/bridges/NativeIpcBridge';
|
|
2
|
+
import { DelegatingRuntimeAdapter } from './DelegatingRuntimeAdapter';
|
|
3
|
+
import { type PlutoIpcBridge } from './ipc';
|
|
4
|
+
export interface IpcRuntimeAdapterOptions extends NativeIpcBridgeOptions {
|
|
5
|
+
bridge: PlutoIpcBridge;
|
|
6
|
+
}
|
|
7
|
+
export declare class IpcRuntimeAdapter extends DelegatingRuntimeAdapter {
|
|
8
|
+
constructor(options: IpcRuntimeAdapterOptions);
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NativeIpcBridge } from '../core/bridges/NativeIpcBridge';
|
|
2
|
+
import { DelegatingRuntimeAdapter } from './DelegatingRuntimeAdapter';
|
|
3
|
+
import { assertValidIpcBridge } from './ipc';
|
|
4
|
+
export class IpcRuntimeAdapter extends DelegatingRuntimeAdapter {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
const bridge = assertValidIpcBridge(options.bridge, 'IpcRuntimeAdapter');
|
|
7
|
+
super(new NativeIpcBridge({
|
|
8
|
+
...options,
|
|
9
|
+
ipcBridge: bridge,
|
|
10
|
+
allowWasmFallback: options.allowWasmFallback ?? false,
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { Connection } from '../core/Connection';
|
|
2
|
+
import type { AuthContext } from '../core/IEngineBridge';
|
|
3
|
+
import type { AppLimits, ISignalingBackend, NativeConnectResult, ResolvedPeerIdentity } from '../core/types';
|
|
4
|
+
import type { RuntimeAuthIdentity, RuntimeClientOptions, RuntimeConnectionEvent, RuntimeConnectionTarget, RuntimeDeviceConnectOptions, RuntimeDevice, RuntimeDeviceStatusSnapshot, RuntimeIncomingStream, RuntimeLocalDeviceProfile, RuntimeLocalDeviceInfo, RuntimeManagedSession, RuntimeManagedSessionOptions, RuntimePeerReadinessSnapshot, RuntimePeerConnectOptions, RuntimePeerStreamOptions, RuntimePeerHealth, RuntimePeerState, RuntimePresenceLoopOptions, RuntimeRawConnection, RuntimeSession } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* RuntimeClient is the primary application-facing API.
|
|
7
|
+
* It owns host/runtime orchestration on top of the Rust core and should be the
|
|
8
|
+
* only high-level surface consumed by product code. App code should not rebuild
|
|
9
|
+
* lifecycle, discovery, or transfer-readiness policy above this layer.
|
|
10
|
+
*
|
|
11
|
+
* Allowed:
|
|
12
|
+
* - app-facing session startup/shutdown
|
|
13
|
+
* - typed device, peer, room, and transfer APIs
|
|
14
|
+
* - thin host/runtime coordination
|
|
15
|
+
*
|
|
16
|
+
* Not allowed:
|
|
17
|
+
* - teaching app code to depend on `advanced.unwrap*()`
|
|
18
|
+
* - treating `nodeId` as high-level peer identity
|
|
19
|
+
* - reimplementing Rust-owned lifecycle policy in product code
|
|
20
|
+
*
|
|
21
|
+
* Source of truth:
|
|
22
|
+
* - Rust core owns discovery, peer identity, presence, and transport lifecycle
|
|
23
|
+
* - RuntimeClient should converge toward thin wrappers over those core surfaces
|
|
24
|
+
*/
|
|
25
|
+
export declare class RuntimeClient {
|
|
26
|
+
private static readonly NATIVE_START_RETRY_WINDOW_MS;
|
|
27
|
+
private static readonly NATIVE_START_RETRY_MIN_DELAY_MS;
|
|
28
|
+
private static readonly NATIVE_START_RETRY_MAX_DELAY_MS;
|
|
29
|
+
private static readonly MANAGED_RECONCILIATION_INTERVAL_MS;
|
|
30
|
+
private static readonly DEVICE_STATUS_REFRESH_DEBOUNCE_MS;
|
|
31
|
+
private static readonly MANAGED_USER_DEVICE_SCOPE;
|
|
32
|
+
private static readonly MANAGED_USER_DEVICE_STORAGE_KEY_PREFIX;
|
|
33
|
+
private readonly client;
|
|
34
|
+
private readonly backend;
|
|
35
|
+
private managedSessionKey;
|
|
36
|
+
private managedSessionUserId;
|
|
37
|
+
private managedSessionOptions;
|
|
38
|
+
private readonly apiKey;
|
|
39
|
+
private readonly storageNamespace;
|
|
40
|
+
constructor(options: RuntimeClientOptions, backend?: ISignalingBackend | null);
|
|
41
|
+
get identity(): RuntimeAuthIdentity | null;
|
|
42
|
+
private sleep;
|
|
43
|
+
private fetchAndApplyAppLimits;
|
|
44
|
+
private normalizeUiConnectionStatus;
|
|
45
|
+
private managedUserDeviceStorageKey;
|
|
46
|
+
private static encodeManagedCompoundTicket;
|
|
47
|
+
private decodeManagedUserDeviceGrantFromTicket;
|
|
48
|
+
private loadPersistedManagedUserDeviceGrant;
|
|
49
|
+
private persistManagedUserDeviceGrant;
|
|
50
|
+
private persistManagedUserDeviceGrantFromTicket;
|
|
51
|
+
private clearPersistedManagedUserDeviceGrant;
|
|
52
|
+
private resolvePeerStreamTarget;
|
|
53
|
+
private compatPeerConnectionFromTarget;
|
|
54
|
+
private deviceStatusSnapshotKey;
|
|
55
|
+
private buildDeviceStatusLookup;
|
|
56
|
+
private overlayPeerSessionsOnDeviceSnapshots;
|
|
57
|
+
private overlayPeerStateOnDeviceSnapshots;
|
|
58
|
+
private runtimeDeviceToStatusSnapshot;
|
|
59
|
+
private uniqueLookupIds;
|
|
60
|
+
private matchSessionByLookupId;
|
|
61
|
+
private resolvePeerLookupIds;
|
|
62
|
+
private mergeWatchedDevicesIntoStatusSnapshots;
|
|
63
|
+
private nextNativeStartRetryDelayMs;
|
|
64
|
+
private hasManagedSession;
|
|
65
|
+
private startManagedReconciliation;
|
|
66
|
+
private connectionStateSnapshotKey;
|
|
67
|
+
private runNativeStartLoop;
|
|
68
|
+
onIdentityChange(callback: (identity: RuntimeAuthIdentity | null) => void): () => void;
|
|
69
|
+
signInAnonymously(): Promise<void>;
|
|
70
|
+
signInWithPluto(): Promise<void>;
|
|
71
|
+
setAuthContext(context: AuthContext | null): Promise<void>;
|
|
72
|
+
signOut(): Promise<void>;
|
|
73
|
+
initialize(): Promise<void>;
|
|
74
|
+
getRuntimeStatus(): Promise<{
|
|
75
|
+
runtime: 'tauri' | 'browser' | 'unknown';
|
|
76
|
+
wasmLoaded: boolean;
|
|
77
|
+
localNodeId?: string;
|
|
78
|
+
userId?: string;
|
|
79
|
+
}>;
|
|
80
|
+
start(options?: {
|
|
81
|
+
clearSessionTokens?: boolean;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
stop(): void;
|
|
84
|
+
getNodeId(): Promise<string>;
|
|
85
|
+
getNodeIdFromTicket(ticket: string): Promise<string | null>;
|
|
86
|
+
getLocalDeviceId(): Promise<string | null>;
|
|
87
|
+
getLocalDeviceInfo(): Promise<RuntimeLocalDeviceInfo | null>;
|
|
88
|
+
getLocalDeviceProfile(options?: {
|
|
89
|
+
deviceName?: string;
|
|
90
|
+
localDeviceId?: string | null;
|
|
91
|
+
platform?: 'native' | 'web';
|
|
92
|
+
userId?: string | null;
|
|
93
|
+
}): Promise<RuntimeLocalDeviceProfile>;
|
|
94
|
+
updateLocalDeviceName(deviceName: string): Promise<RuntimeLocalDeviceInfo | null>;
|
|
95
|
+
getManagedNodeId(options?: {
|
|
96
|
+
initializeIfMissing?: boolean;
|
|
97
|
+
}): Promise<string | null>;
|
|
98
|
+
getTicket(): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Generate a session-scoped endpoint ticket with an embedded random token.
|
|
101
|
+
* The token gates incoming connections: only clients that present the token
|
|
102
|
+
* in their handshake are accepted while the registry is non-empty.
|
|
103
|
+
*
|
|
104
|
+
* @param scope Logical label for bulk-revoke (e.g. "share").
|
|
105
|
+
* @param maxConnections 0 = unlimited.
|
|
106
|
+
*/
|
|
107
|
+
getTicketWithToken(grantScope: string, maxConnections?: number): Promise<string>;
|
|
108
|
+
/** Revoke all session tokens that match the given scope. */
|
|
109
|
+
revokeTokensByScope(grantScope: string): Promise<string[]>;
|
|
110
|
+
private revokeTokensByScopeInternal;
|
|
111
|
+
/** Revoke a single session token by its raw value. */
|
|
112
|
+
revokeSessionToken(token: string): void;
|
|
113
|
+
getEndpointTicket(): Promise<string>;
|
|
114
|
+
startManagedSession(options: RuntimeManagedSessionOptions): Promise<RuntimeManagedSession>;
|
|
115
|
+
stopManagedSession(options?: {
|
|
116
|
+
preserveBackendSession?: boolean;
|
|
117
|
+
}): Promise<void>;
|
|
118
|
+
private rotateManagedUserDeviceGrant;
|
|
119
|
+
listDevices(): Promise<RuntimeDevice[]>;
|
|
120
|
+
listDevicesWithStatus(): Promise<RuntimeDeviceStatusSnapshot[]>;
|
|
121
|
+
updateDevice(deviceId: string, updates: {
|
|
122
|
+
deviceName?: string;
|
|
123
|
+
capabilities?: RuntimeDevice['capabilities'];
|
|
124
|
+
metadata?: string;
|
|
125
|
+
}): Promise<void>;
|
|
126
|
+
deleteDevice(deviceId: string): Promise<void>;
|
|
127
|
+
watchDevices(callback: (devices: RuntimeDevice[]) => void): () => void;
|
|
128
|
+
watchDevicesWithStatus(callback: (devices: RuntimeDeviceStatusSnapshot[]) => void): () => void;
|
|
129
|
+
connectDeviceWithRetry(device: RuntimeDevice, hooks: import('../core/types').ConnectDeviceHooks, options: import('../core/types').ConnectDeviceOptions): Promise<import('../core/types').ConnectDeviceResult>;
|
|
130
|
+
/**
|
|
131
|
+
* Runtime-owned device connect flow used by product code.
|
|
132
|
+
* Rust owns the actual managed dial policy. This wrapper only:
|
|
133
|
+
* - validates the app-facing device/ticket input
|
|
134
|
+
* - forwards the request to the active runtime adapter
|
|
135
|
+
* - refreshes peer state and invokes optional app callbacks
|
|
136
|
+
*/
|
|
137
|
+
connectDevice(device: RuntimeDevice, options: RuntimeDeviceConnectOptions): Promise<import('../core/types').ConnectDeviceResult>;
|
|
138
|
+
watchPeerStates(callback: (peers: RuntimePeerState[]) => void): () => void;
|
|
139
|
+
getPeerState(id: string): RuntimePeerState | undefined;
|
|
140
|
+
resolvePeerConnectionRecords(id: string): Promise<import('../core/types').ManagedConnectionRecord[]>;
|
|
141
|
+
getPeerSession(id: string): Promise<import('../core/types').PeerSessionSnapshot | null>;
|
|
142
|
+
listPeerSessions(): Promise<import('../core/types').PeerSessionSnapshot[]>;
|
|
143
|
+
waitForConnectedPeer(id: string, timeoutMs?: number): Promise<import('../core/types').PeerSessionSnapshot | null>;
|
|
144
|
+
getPeerReadiness(id: string, timeoutMs?: number): Promise<RuntimePeerReadinessSnapshot>;
|
|
145
|
+
resolvePeerIdentity(id: string): Promise<ResolvedPeerIdentity>;
|
|
146
|
+
resolveIncomingStreamPeer(remoteNodeId: string): Promise<ResolvedPeerIdentity>;
|
|
147
|
+
listConnectedPeers(): RuntimePeerState[];
|
|
148
|
+
addPeerScope(id: string, scope?: string): RuntimePeerState | undefined;
|
|
149
|
+
releasePeerScope(id: string, scope?: string): RuntimePeerState | undefined;
|
|
150
|
+
getPeerScopes(id: string): string[];
|
|
151
|
+
isSamePeer(a: string, b: string): boolean;
|
|
152
|
+
refreshPeerSnapshot(): Promise<RuntimePeerState[]>;
|
|
153
|
+
subscribeSessions(localDeviceId: string, callback: (session: RuntimeSession) => void): Promise<() => void>;
|
|
154
|
+
getAppLimits(): AppLimits;
|
|
155
|
+
createRoom(): Promise<string>;
|
|
156
|
+
joinRoom(roomId: string, options?: import('./types').RuntimeJoinRoomOptions): Promise<Connection[]>;
|
|
157
|
+
leaveRoom(roomId: string): Promise<void>;
|
|
158
|
+
getRoomMembers(roomId: string): Promise<import('./types').RuntimeRoomMember[]>;
|
|
159
|
+
watchRoom(roomId: string, callback: (members: import('./types').RuntimeRoomMember[]) => void): () => void;
|
|
160
|
+
/** @deprecated Use connect() (no-arg) for lifecycle, or connectTo() for peer connections */
|
|
161
|
+
connectByTicket(target: RuntimeConnectionTarget): Promise<Connection>;
|
|
162
|
+
connectPeer(options: RuntimePeerConnectOptions): Promise<Connection>;
|
|
163
|
+
openPeerBi(id: string, options?: RuntimePeerStreamOptions): Promise<{
|
|
164
|
+
connection: Connection;
|
|
165
|
+
readable: ReadableStream<Uint8Array>;
|
|
166
|
+
writable: WritableStream<Uint8Array>;
|
|
167
|
+
}>;
|
|
168
|
+
openPeerUni(id: string, options?: RuntimePeerStreamOptions): Promise<{
|
|
169
|
+
connection: Connection;
|
|
170
|
+
writable: WritableStream<Uint8Array>;
|
|
171
|
+
}>;
|
|
172
|
+
connectToDevice(params: {
|
|
173
|
+
deviceId?: string | null;
|
|
174
|
+
endpointTicket: string;
|
|
175
|
+
}): Promise<NativeConnectResult>;
|
|
176
|
+
connectRaw(target: RuntimeConnectionTarget): Promise<RuntimeRawConnection>;
|
|
177
|
+
openBi(nodeId: string): Promise<{
|
|
178
|
+
readable: ReadableStream<Uint8Array>;
|
|
179
|
+
writable: WritableStream<Uint8Array>;
|
|
180
|
+
}>;
|
|
181
|
+
openUni(nodeId: string): Promise<WritableStream<Uint8Array>>;
|
|
182
|
+
onIncomingStream(callback: (stream: RuntimeIncomingStream) => boolean | void): () => void;
|
|
183
|
+
registerChannel(descriptor: import('./types').RuntimeChannelDescriptor): void;
|
|
184
|
+
unregisterChannel(channelId: string): void;
|
|
185
|
+
listChannels(): import('./types').RuntimeChannelDescriptor[];
|
|
186
|
+
onIncomingChannelStream(channelId: string, callback: (stream: RuntimeIncomingStream) => boolean | void): () => void;
|
|
187
|
+
sendExplicitFilePath(connectionId: string, filePath: string, transferId?: string): Promise<string>;
|
|
188
|
+
sendExplicitFileData(params: import('../core/types').ExplicitFileDataSendParams): Promise<void>;
|
|
189
|
+
getTransferHistory(limit?: number): Promise<Array<[string, unknown]>>;
|
|
190
|
+
deleteTransferJob(jobId: string): Promise<void>;
|
|
191
|
+
startPresenceLoop(options?: RuntimePresenceLoopOptions): Promise<void>;
|
|
192
|
+
updatePresence(options?: {
|
|
193
|
+
isOnline?: boolean;
|
|
194
|
+
ttlMs?: number;
|
|
195
|
+
metadata?: string;
|
|
196
|
+
ticket?: string;
|
|
197
|
+
}): Promise<void>;
|
|
198
|
+
setOffline(): Promise<void>;
|
|
199
|
+
startAutoConnect(localDeviceId?: string): Promise<void>;
|
|
200
|
+
isConnected(nodeId: string): Promise<boolean>;
|
|
201
|
+
disconnectNode(nodeId: string): Promise<void>;
|
|
202
|
+
disconnectDevice(deviceId: string): Promise<void>;
|
|
203
|
+
setAutoConnectExcluded(deviceId: string, excluded: boolean): Promise<void>;
|
|
204
|
+
disconnectPeer(id: string, scope?: string): Promise<void>;
|
|
205
|
+
forceDisconnectPeer(id: string): Promise<void>;
|
|
206
|
+
getPeerHealth(id: string): Promise<RuntimePeerHealth>;
|
|
207
|
+
getConnectionStates(): Promise<import('./types').RuntimeConnectionStateSnapshot[]>;
|
|
208
|
+
onConnectionStateChange(callback: (state: import('./types').RuntimeConnectionStateSnapshot) => void): Promise<() => void> | (() => void);
|
|
209
|
+
getConnections(): Connection[];
|
|
210
|
+
onConnection(callback: (connection: Connection) => void): () => void;
|
|
211
|
+
onDisconnection(callback: (connection: Connection) => void): () => void;
|
|
212
|
+
onConnectionEvent(callback: (event: RuntimeConnectionEvent) => void): () => void;
|
|
213
|
+
forceReconnectSnapshot(): void;
|
|
214
|
+
/** Single-call lifecycle: combines initialize() + start() */
|
|
215
|
+
connect(): Promise<void>;
|
|
216
|
+
/** Disconnect from the runtime (alias for stop()) */
|
|
217
|
+
disconnect(): void;
|
|
218
|
+
/** Alias for onIdentityChange */
|
|
219
|
+
onAuthChange(callback: (identity: RuntimeAuthIdentity | null) => void): () => void;
|
|
220
|
+
/** Alias for setAuthContext */
|
|
221
|
+
setAuth(context: AuthContext | null): Promise<void>;
|
|
222
|
+
/** Alias for signInWithPluto */
|
|
223
|
+
signIn(): Promise<void>;
|
|
224
|
+
/** Alias for listDevices */
|
|
225
|
+
getDevices(): Promise<RuntimeDevice[]>;
|
|
226
|
+
/** Device subscription with optional status enrichment */
|
|
227
|
+
onDevices(callback: (devices: RuntimeDevice[]) => void): () => void;
|
|
228
|
+
onDevices(callback: (devices: RuntimeDeviceStatusSnapshot[]) => void, options: {
|
|
229
|
+
status: true;
|
|
230
|
+
}): () => void;
|
|
231
|
+
/** Alias for getTicket — returns an invite/ticket string */
|
|
232
|
+
getInvite(): Promise<string>;
|
|
233
|
+
/** Connect to a peer by device ID or options */
|
|
234
|
+
connectTo(options: RuntimePeerConnectOptions): Promise<Connection>;
|
|
235
|
+
/** Alias for waitForConnectedPeer */
|
|
236
|
+
waitFor(id: string, timeoutMs?: number): Promise<import('../core/types').PeerSessionSnapshot | null>;
|
|
237
|
+
/** Open a stream to a peer (default: bidirectional) */
|
|
238
|
+
openStream(id: string, options?: RuntimePeerStreamOptions & {
|
|
239
|
+
direction?: 'bi' | 'send';
|
|
240
|
+
}): Promise<{
|
|
241
|
+
connection: Connection;
|
|
242
|
+
readable?: ReadableStream<Uint8Array>;
|
|
243
|
+
writable: WritableStream<Uint8Array>;
|
|
244
|
+
}>;
|
|
245
|
+
openChannelStream(channelId: string, id: string, options?: RuntimePeerStreamOptions & {
|
|
246
|
+
direction?: 'bi' | 'send';
|
|
247
|
+
}): Promise<{
|
|
248
|
+
connection: Connection;
|
|
249
|
+
readable?: ReadableStream<Uint8Array>;
|
|
250
|
+
writable: WritableStream<Uint8Array>;
|
|
251
|
+
}>;
|
|
252
|
+
/** Alias for onIncomingStream */
|
|
253
|
+
onStream(callback: (stream: RuntimeIncomingStream) => boolean | void): () => void;
|
|
254
|
+
onChannelStream(channelId: string, callback: (stream: RuntimeIncomingStream) => boolean | void): () => void;
|
|
255
|
+
/** Alias for watchRoom */
|
|
256
|
+
onRoomChange(roomId: string, callback: (members: import('./types').RuntimeRoomMember[]) => void): () => void;
|
|
257
|
+
}
|