openrtc 2.0.0-rc.3 → 2.0.0-rc.5
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/dist/DelegatingRuntimeAdapter-BLNigcS4.d.ts +134 -0
- package/dist/{OpenRTCShared-ZQPu5LqL.d.ts → OpenRTCShared-BswnbjpG.d.ts} +3 -4
- package/dist/{WasmBridge-2A22U7RU.js → WasmBridge-227YXBG7.js} +1 -1
- package/dist/{chunk-A3IAG6EL.js → chunk-6KCPRIB5.js} +1 -1
- package/dist/chunk-C5YSVLNT.js +2 -0
- package/dist/{chunk-5LRLWIT5.js → chunk-CA6HLY7T.js} +1 -1
- package/dist/chunk-JUHDH6K4.js +2 -0
- package/dist/{chunk-7H2JPCBN.js → chunk-LBRXS637.js} +1 -1
- package/dist/{chunk-F2XGNLXL.js → chunk-NRO64VRR.js} +1 -1
- package/dist/chunk-PEBFQ4CL.js +1 -0
- package/dist/{chunk-3USHQ7QW.js → chunk-QHWMILLL.js} +3 -3
- package/dist/chunk-UNDCN2UF.js +2 -0
- package/dist/chunk-VGMSLZH5.js +1 -0
- package/dist/chunk-XDYCWI5Z.js +1 -0
- package/dist/factories-JWIRMXCV.js +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/ipcFactory-UAVK2YED.js +1 -0
- package/dist/native.d.ts +5 -5
- package/dist/native.js +1 -1
- package/dist/openrtc_bg.wasm +0 -0
- package/dist/runtime/WasmRuntimeAdapter.d.ts +3 -3
- package/dist/runtime/WasmRuntimeAdapter.js +1 -1
- package/dist/runtime/device-status.d.ts +2 -2
- package/dist/runtime/index.d.ts +10 -25
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/legacy.d.ts +3 -3
- package/dist/runtime/legacy.js +1 -1
- package/dist/runtime/tauri.d.ts +4 -4
- package/dist/runtime/tauri.js +1 -1
- package/dist/{tauri-Cz9n17g8.d.ts → tauri-BgLgJoQA.d.ts} +2 -2
- package/dist/testing.d.ts +4 -4
- package/dist/testing.js +1 -1
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-BVJr065k.d.ts → types-BHePJWbM.d.ts} +1 -1
- package/dist/{types-DkgaCyqS.d.ts → types-D0pqNSOf.d.ts} +1 -1
- package/dist/{types-DNl4KHHY.d.ts → types-ZdRrnIRw.d.ts} +36 -4
- package/package.json +1 -1
- package/dist/DelegatingRuntimeAdapter-DqfHkjLy.d.ts +0 -373
- package/dist/chunk-6TAVJ46R.js +0 -1
- package/dist/chunk-GW7P3D54.js +0 -1
- package/dist/chunk-PODAMIL6.js +0 -2
- package/dist/chunk-PRVFZI2T.js +0 -1
- package/dist/chunk-UEYM6WTT.js +0 -2
- package/dist/chunk-YBXGNKM7.js +0 -2
- package/dist/factories-LI53SFLH.js +0 -1
- package/dist/ipcFactory-QY44OIKA.js +0 -1
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
import { D as Device, n as DiscoveryMode, o as AuthMode, p as SignalingMode, i as ClientOptions, E as ExplicitFileDataSendParams, q as ISignalingBackend, j as RoomMember, R as RuntimeIdentity, r as SignalingEnvelope, h as DeviceStatusSnapshot, m as PeerSessionSnapshot, s as BackendPeerBiStream, t as BackendPeerUniStream, u as ManagedConnectionRecord, v as ResolvedPeerIdentity, w as DeviceEvent, x as DesiredPeerProjection, y as CoreClientBridgeHost, N as NativeConnectParams, z as NativeConnectResult, S as SignalingSession, F as SessionEvent, B as BackendConnectionState, L as LocalDeviceInfo, G as NativeManagedSessionStartResult, H as GrantScope } from './types-BVJr065k.js';
|
|
2
|
-
import { R as RuntimeCapabilities } from './capabilities-YSskrE8H.js';
|
|
3
|
-
import { A as AuthContext } from './IEngineBridge-BbsT8hof.js';
|
|
4
|
-
|
|
5
|
-
interface NativeTrustToken {
|
|
6
|
-
token: string;
|
|
7
|
-
expiresAtMs: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/** Internal-only gateway record before normalization; includes namespace fields omitted from the public Device type. */
|
|
11
|
-
type RawDeviceDoc = Device & {
|
|
12
|
-
appTag?: string;
|
|
13
|
-
tag?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
interface WasmBridgeOptions {
|
|
17
|
-
apiKey?: string;
|
|
18
|
-
discoveryMode?: DiscoveryMode;
|
|
19
|
-
space?: string;
|
|
20
|
-
spaceKey?: string;
|
|
21
|
-
authMode?: AuthMode;
|
|
22
|
-
signalingMode?: SignalingMode;
|
|
23
|
-
projectId?: string;
|
|
24
|
-
coordinationGateway?: ClientOptions['coordinationGateway'];
|
|
25
|
-
coordinationAvenueOverride?: ClientOptions['coordinationAvenueOverride'];
|
|
26
|
-
platformAttestationTokenProvider?: ClientOptions['platformAttestationTokenProvider'];
|
|
27
|
-
/** Internal host hint used by the provider-neutral gateway projection. */
|
|
28
|
-
coordinationPlatformType?: 'web' | 'desktop' | 'mobile';
|
|
29
|
-
storagePrefix?: string;
|
|
30
|
-
deviceIdPersistence?: 'persistent' | 'ephemeral';
|
|
31
|
-
endpointIdPersistence?: 'persistent' | 'ephemeral';
|
|
32
|
-
nodeIdPersistence?: 'persistent' | 'ephemeral';
|
|
33
|
-
localDeviceId?: string;
|
|
34
|
-
deviceName?: string;
|
|
35
|
-
turnCredentialsProvider?: () => Promise<{
|
|
36
|
-
iceServers?: RTCIceServer[];
|
|
37
|
-
} | null | undefined>;
|
|
38
|
-
applicationCrypto?: ExplicitFileDataSendParams['applicationCrypto'];
|
|
39
|
-
spaceAuth?: 'scoped-token';
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* WasmBridge is the browser host wrapper over the Rust/WASM runtime.
|
|
43
|
-
*
|
|
44
|
-
* Allowed:
|
|
45
|
-
* - normalize JS/WASM binding shapes
|
|
46
|
-
* - forward auth, discovery, signaling, and lifecycle calls into Rust
|
|
47
|
-
* - expose typed browser-facing results
|
|
48
|
-
*
|
|
49
|
-
* Not allowed:
|
|
50
|
-
* - become a second lifecycle engine
|
|
51
|
-
* - invent peer identity or connect policy that is not backed by Rust
|
|
52
|
-
* - normalize app-specific payload protocols into runtime behavior
|
|
53
|
-
*
|
|
54
|
-
* Source of truth:
|
|
55
|
-
* - Rust/WASM owns transport/runtime connection state and lifecycle primitives
|
|
56
|
-
* - The selected coordination provider owns browser delivery projections
|
|
57
|
-
* - RuntimeClient owns app-facing orchestration across those surfaces
|
|
58
|
-
*/
|
|
59
|
-
declare class WasmBridge implements ISignalingBackend {
|
|
60
|
-
private static readonly EXPLICIT_FILE_PROTOCOL_TYPE;
|
|
61
|
-
private static readonly EXPLICIT_FILE_CHUNK_SIZE_BYTES;
|
|
62
|
-
private static readonly MAX_EXPLICIT_TRANSFER_HEADER_BYTES;
|
|
63
|
-
private static readonly FALLBACK_EXPLICIT_FILE_NAME;
|
|
64
|
-
private static readonly MAX_EXPLICIT_FILE_NAME_CHARS;
|
|
65
|
-
private static readonly FALLBACK_EXPLICIT_MIME_TYPE;
|
|
66
|
-
private static readonly MAX_EXPLICIT_MIME_TYPE_CHARS;
|
|
67
|
-
app: any | null;
|
|
68
|
-
auth: any | null;
|
|
69
|
-
private readonly appTag;
|
|
70
|
-
protected options: {
|
|
71
|
-
appTag: string;
|
|
72
|
-
apiKey?: string;
|
|
73
|
-
discoveryMode?: DiscoveryMode;
|
|
74
|
-
space?: string;
|
|
75
|
-
spaceKey?: string;
|
|
76
|
-
authMode: AuthMode;
|
|
77
|
-
signalingMode?: SignalingMode;
|
|
78
|
-
projectId: string;
|
|
79
|
-
coordinationGateway?: ClientOptions['coordinationGateway'];
|
|
80
|
-
coordinationAvenueOverride?: ClientOptions['coordinationAvenueOverride'];
|
|
81
|
-
platformAttestationTokenProvider?: ClientOptions['platformAttestationTokenProvider'];
|
|
82
|
-
coordinationPlatformType?: 'web' | 'desktop' | 'mobile';
|
|
83
|
-
storagePrefix?: string;
|
|
84
|
-
deviceIdPersistence?: 'persistent' | 'ephemeral';
|
|
85
|
-
endpointIdPersistence?: 'persistent' | 'ephemeral';
|
|
86
|
-
nodeIdPersistence?: 'persistent' | 'ephemeral';
|
|
87
|
-
localDeviceId?: string;
|
|
88
|
-
deviceName?: string;
|
|
89
|
-
strictMode?: boolean;
|
|
90
|
-
turnCredentialsProvider?: () => Promise<{
|
|
91
|
-
iceServers?: RTCIceServer[];
|
|
92
|
-
} | null | undefined>;
|
|
93
|
-
applicationCrypto?: ExplicitFileDataSendParams['applicationCrypto'];
|
|
94
|
-
spaceTokenProvider?: ClientOptions['spaceTokenProvider'];
|
|
95
|
-
spaceAuth?: 'scoped-token';
|
|
96
|
-
};
|
|
97
|
-
private spaceNamespaceIdPromise;
|
|
98
|
-
private cachedSpaceNamespaceId;
|
|
99
|
-
private authListeners;
|
|
100
|
-
private persistenceReady;
|
|
101
|
-
wasmClient: any;
|
|
102
|
-
private readonly createdAtMs;
|
|
103
|
-
private missingWasmWarnings;
|
|
104
|
-
private readonly wasmReadyWarningDelayMs;
|
|
105
|
-
private browserCoordinationSignaling;
|
|
106
|
-
private readonly nativeTrustTokens;
|
|
107
|
-
private lastObservedFirebaseUserId;
|
|
108
|
-
private sessionReaders;
|
|
109
|
-
protected authContext: {
|
|
110
|
-
userId: string;
|
|
111
|
-
token?: string | null;
|
|
112
|
-
refreshToken?: string | null;
|
|
113
|
-
customToken?: string | null;
|
|
114
|
-
tokenProvider?: (forceRefresh?: boolean) => Promise<string | null>;
|
|
115
|
-
appCheckTokenProvider?: (forceRefresh?: boolean) => Promise<string | null>;
|
|
116
|
-
expiresAtMs?: number | null;
|
|
117
|
-
} | null;
|
|
118
|
-
private injectedBrowserAuthSessionActive;
|
|
119
|
-
private readonly presenceManager;
|
|
120
|
-
private hasSyncedAuthToWasmClient;
|
|
121
|
-
private lastWasmAuthUserId;
|
|
122
|
-
private lastWasmAuthToken;
|
|
123
|
-
private lastDeliveredConnectionStates;
|
|
124
|
-
private authScopedRuntimeGeneration;
|
|
125
|
-
private coreClient;
|
|
126
|
-
private readonly applicationRouteEscalations;
|
|
127
|
-
private applicationRouteEscalationUnsubscribe;
|
|
128
|
-
private applicationRouteEscalationSubscriptionGeneration;
|
|
129
|
-
private applicationRouteEscalationSubscriptionEpoch;
|
|
130
|
-
constructor(options: WasmBridgeOptions);
|
|
131
|
-
get tag(): string;
|
|
132
|
-
getRuntimeCapabilities(): RuntimeCapabilities;
|
|
133
|
-
private static readonly WEB_DEVICE_ID_STORAGE_PREFIX;
|
|
134
|
-
private static readonly EPHEMERAL_DEVICE_ID_TTL_MS;
|
|
135
|
-
private getDeviceIdentityStorageKey;
|
|
136
|
-
private getDeviceIdPersistenceMode;
|
|
137
|
-
private isTicketOnlyMode;
|
|
138
|
-
private usesProviderNeutralGrant;
|
|
139
|
-
private createRandomDeviceId;
|
|
140
|
-
protected resolveWebLogicalDeviceId(): string;
|
|
141
|
-
private getDefaultBrowserDeviceName;
|
|
142
|
-
private getCoordinationSignaling;
|
|
143
|
-
usesCoordinationGateway(): boolean;
|
|
144
|
-
/** Restore the existing gateway delivery subscription after a native host resumes. */
|
|
145
|
-
reconnectCoordinationAfterHostResume(): Promise<void>;
|
|
146
|
-
getCoordinationNativeTrustToken(forceRefresh?: boolean): Promise<NativeTrustToken>;
|
|
147
|
-
invalidateCoordinationNativeTrustToken(): void;
|
|
148
|
-
subscribeCoordinationNativeTrustToken(listener: (token: NativeTrustToken | null) => void, options?: {
|
|
149
|
-
emitCurrent?: boolean;
|
|
150
|
-
}): () => void;
|
|
151
|
-
setCoordinationLocalDeviceId(deviceId: string): void;
|
|
152
|
-
/** Internal native-host hint for provider-neutral roster presentation. */
|
|
153
|
-
setCoordinationPlatformType(platformType: 'desktop' | 'mobile'): void;
|
|
154
|
-
setCoordinationExcludedPeers(excludedPeers: string[]): Promise<void>;
|
|
155
|
-
joinCoordinationRoom(roomId: string, nodeId: string, ticket: string): Promise<void>;
|
|
156
|
-
leaveCoordinationRoom(roomId: string): Promise<void>;
|
|
157
|
-
getCoordinationRoomMembers(roomId: string): Promise<RoomMember[]>;
|
|
158
|
-
watchCoordinationRoomMembers(roomId: string, callback: (members: RoomMember[]) => void): () => void;
|
|
159
|
-
private withWebPresenceMetadata;
|
|
160
|
-
setAuthContext(context: {
|
|
161
|
-
userId: string;
|
|
162
|
-
token?: string | null;
|
|
163
|
-
refreshToken?: string | null;
|
|
164
|
-
customToken?: string | null;
|
|
165
|
-
tokenProvider?: (forceRefresh?: boolean) => Promise<string | null>;
|
|
166
|
-
appCheckTokenProvider?: (forceRefresh?: boolean) => Promise<string | null>;
|
|
167
|
-
expiresAtMs?: number | null;
|
|
168
|
-
} | null): Promise<void>;
|
|
169
|
-
private ensureBrowserPlatformAuth;
|
|
170
|
-
private syncWasmAuthToken;
|
|
171
|
-
private toRuntimeIdentity;
|
|
172
|
-
protected getCurrentUserId(): string | null;
|
|
173
|
-
getCurrentUserIdForScope(): string | null;
|
|
174
|
-
getAuthContext(): Readonly<typeof this.authContext> | null;
|
|
175
|
-
protected isSpaceMode(): boolean;
|
|
176
|
-
getResolvedOptions(): Readonly<typeof this.options>;
|
|
177
|
-
protected getDiscoveryScopeId(): string | null;
|
|
178
|
-
protected matchesTag(device: Pick<RawDeviceDoc, 'tag' | 'appTag'>): boolean;
|
|
179
|
-
matchesLegacyOrCurrentTag(device: Pick<RawDeviceDoc, 'tag' | 'appTag'>): boolean;
|
|
180
|
-
private stopSessionSubscriptions;
|
|
181
|
-
private stopRuntimeAuthScopedLoops;
|
|
182
|
-
stopAuthScopedActivity(options?: {
|
|
183
|
-
userId?: string | null;
|
|
184
|
-
}): Promise<void>;
|
|
185
|
-
setWasmClient(client: any): void;
|
|
186
|
-
private warnMissingWasmOnce;
|
|
187
|
-
private waitForWasmClient;
|
|
188
|
-
protected normalizeDevice(raw: Record<string, any>, fallbackId?: string): Device;
|
|
189
|
-
normalizeDeviceRecord(raw: Record<string, any>, fallbackId?: string): Device;
|
|
190
|
-
getResolvedWebLogicalDeviceId(): string;
|
|
191
|
-
private normalizeDeviceStatusSnapshot;
|
|
192
|
-
private normalizePeerSessionSnapshot;
|
|
193
|
-
private toBackendConnectionStateFromPeerSession;
|
|
194
|
-
private normalizeConnectionStateSnapshot;
|
|
195
|
-
private stabilizeConnectionState;
|
|
196
|
-
private sameConnectionState;
|
|
197
|
-
private deliverConnectionState;
|
|
198
|
-
private get browserPresenceLoopState();
|
|
199
|
-
private set browserPresenceLoopState(value);
|
|
200
|
-
get currentUser(): RuntimeIdentity | null;
|
|
201
|
-
onAuthChange(callback: (user: RuntimeIdentity | null) => void): () => void;
|
|
202
|
-
checkForSSOToken(): Promise<void>;
|
|
203
|
-
waitForAuth(): Promise<void>;
|
|
204
|
-
signInAnonymously(): Promise<void>;
|
|
205
|
-
signInWithPluto(): Promise<void>;
|
|
206
|
-
signOut(): Promise<void>;
|
|
207
|
-
getTurnCredentials(): Promise<any>;
|
|
208
|
-
updatePresence(localNodeId: string, ticketStr: string, isOnline?: boolean, ttlMs?: number, metadata?: string, deviceNameOverride?: string): Promise<void>;
|
|
209
|
-
refreshLivePresence(localNodeId: string, ticketStr: string, metadata?: string, deviceNameOverride?: string): Promise<void>;
|
|
210
|
-
setOffline(localNodeId: string): Promise<void>;
|
|
211
|
-
updateDevice(deviceId: string, updates: {
|
|
212
|
-
deviceName?: string;
|
|
213
|
-
capabilities?: Device['capabilities'];
|
|
214
|
-
metadata?: string;
|
|
215
|
-
excludedPeers?: string[];
|
|
216
|
-
}): Promise<void>;
|
|
217
|
-
deleteDevice(deviceId: string): Promise<void>;
|
|
218
|
-
cleanupStaleDevices(): Promise<void>;
|
|
219
|
-
sendMessage(targetId: string, payload: string, state?: string, replyPayload?: string): Promise<string>;
|
|
220
|
-
pollMessages(targetId: string): Promise<SignalingEnvelope[]>;
|
|
221
|
-
searchDevices(excludeNodeId?: string): Promise<Device[]>;
|
|
222
|
-
listDevicesWithStatus(): Promise<DeviceStatusSnapshot[]>;
|
|
223
|
-
getPeerSession(id: string): Promise<PeerSessionSnapshot | null>;
|
|
224
|
-
listPeerSessions(): Promise<PeerSessionSnapshot[]>;
|
|
225
|
-
waitForSettledPeer(id: string, timeoutMs?: number): Promise<PeerSessionSnapshot | null>;
|
|
226
|
-
openPeerBi(id: string, timeoutMs?: number): Promise<BackendPeerBiStream>;
|
|
227
|
-
openPeerNativeBi(id: string, label: string, timeoutMs?: number): Promise<BackendPeerBiStream>;
|
|
228
|
-
openPeerBiTransportOnly(id: string, timeoutMs?: number): Promise<BackendPeerBiStream>;
|
|
229
|
-
openPeerUni(id: string, timeoutMs?: number): Promise<BackendPeerUniStream>;
|
|
230
|
-
resolvePeerConnectionRecords(id: string): Promise<ManagedConnectionRecord[]>;
|
|
231
|
-
resolvePeerIdentity(id: string): Promise<ResolvedPeerIdentity>;
|
|
232
|
-
onDevicesChange(callback: (devices: Device[]) => void, excludeNodeId?: string): () => void;
|
|
233
|
-
subscribeDevices(userId: string): Promise<ReadableStream<DeviceEvent[]>>;
|
|
234
|
-
startAutoConnect(userId: string, localDeviceId: string): Promise<void>;
|
|
235
|
-
startAutoConnectOnce(userId: string, localDeviceId: string): Promise<void>;
|
|
236
|
-
notifyDisconnectRequested(remoteNodeId: string): void;
|
|
237
|
-
setAutoConnectExcluded(deviceId: string, excluded: boolean): Promise<void>;
|
|
238
|
-
disconnectDevice(deviceId: string): Promise<void>;
|
|
239
|
-
submitDesiredPeerProjection(revision: number, peers: DesiredPeerProjection[]): Promise<void>;
|
|
240
|
-
setCoreClient(client: CoreClientBridgeHost | null): void;
|
|
241
|
-
private startApplicationRouteEscalationSubscription;
|
|
242
|
-
private stopApplicationRouteEscalationSubscription;
|
|
243
|
-
private retryManagedApplicationRouteEscalations;
|
|
244
|
-
private escalateManagedApplicationRoute;
|
|
245
|
-
connectToDevice(params: NativeConnectParams): Promise<NativeConnectResult>;
|
|
246
|
-
forceReconnectSnapshot(): void;
|
|
247
|
-
startPresenceLoop(userId: string, localNodeId: string, deviceName: string, ticket: string, metadata?: string): void;
|
|
248
|
-
private ensureSpaceNamespaceIdPromise;
|
|
249
|
-
createSession(session: SignalingSession): Promise<void>;
|
|
250
|
-
updateSession(sessionId: string, updateData: any): Promise<void>;
|
|
251
|
-
subscribeSessions(localDeviceId: string): Promise<ReadableStream<SessionEvent[]>>;
|
|
252
|
-
getLocalDeviceId(): Promise<string | null>;
|
|
253
|
-
isConnected(node_id: string): Promise<boolean>;
|
|
254
|
-
private hasConnectedIndependentPeerRoute;
|
|
255
|
-
getConnectionStates(): Promise<BackendConnectionState[]>;
|
|
256
|
-
onConnectionStateChange(callback: (state: BackendConnectionState) => void): Promise<() => void> | (() => void);
|
|
257
|
-
sendExplicitFilePath(connectionId: string, filePath: string, transferId?: string): Promise<string>;
|
|
258
|
-
private sanitizeExplicitFileName;
|
|
259
|
-
private sanitizeExplicitMimeType;
|
|
260
|
-
private assertExplicitTransferHeaderSize;
|
|
261
|
-
private createWebRTCExplicitTransferId;
|
|
262
|
-
private createWebRTCExplicitTransferFrame;
|
|
263
|
-
sendExplicitFileData(params: ExplicitFileDataSendParams): Promise<void>;
|
|
264
|
-
getTransferHistory(limit?: number): Promise<Array<[string, unknown]>>;
|
|
265
|
-
deleteTransferJob(jobId: string): Promise<void>;
|
|
266
|
-
watchFriendDevices(friendUserIds: string[], callback: (friendDevices: Map<string, any[]>) => void): () => void;
|
|
267
|
-
updateFriendTicket(friendTicket: string | null): Promise<void>;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
declare abstract class DelegatingRuntimeAdapter implements ISignalingBackend {
|
|
271
|
-
protected readonly backend: ISignalingBackend;
|
|
272
|
-
protected constructor(backend: ISignalingBackend);
|
|
273
|
-
get currentUser(): RuntimeIdentity | null;
|
|
274
|
-
setAuthContext(context: AuthContext | null): Promise<void> | void;
|
|
275
|
-
signInAnonymously(): Promise<void>;
|
|
276
|
-
signInWithPluto(): Promise<void>;
|
|
277
|
-
signOut(): Promise<void>;
|
|
278
|
-
stopAuthScopedActivity(): Promise<void>;
|
|
279
|
-
usesCoordinationGateway(): boolean;
|
|
280
|
-
joinCoordinationRoom(roomId: string, nodeId: string, ticket: string): Promise<void>;
|
|
281
|
-
leaveCoordinationRoom(roomId: string): Promise<void>;
|
|
282
|
-
getCoordinationRoomMembers(roomId: string): Promise<RoomMember[]>;
|
|
283
|
-
watchCoordinationRoomMembers(roomId: string, callback: (members: RoomMember[]) => void): () => void;
|
|
284
|
-
getTurnCredentials(): Promise<any>;
|
|
285
|
-
updatePresence(localNodeId: string, ticketStr: string, isOnline: boolean, ttlMs: number, metadata?: string): Promise<void>;
|
|
286
|
-
refreshLivePresence(localNodeId: string, ticketStr: string, metadata?: string): Promise<void>;
|
|
287
|
-
setOffline(localNodeId: string): Promise<void>;
|
|
288
|
-
cleanupStaleDevices(): Promise<void>;
|
|
289
|
-
searchDevices(excludeNodeId?: string): Promise<Device[]>;
|
|
290
|
-
listDevicesWithStatus(): Promise<DeviceStatusSnapshot[]>;
|
|
291
|
-
getPeerSession(id: string): Promise<PeerSessionSnapshot | null>;
|
|
292
|
-
listPeerSessions(): Promise<PeerSessionSnapshot[]>;
|
|
293
|
-
waitForSettledPeer(id: string, timeoutMs?: number): Promise<PeerSessionSnapshot | null>;
|
|
294
|
-
resolvePeerIdentity(id: string): Promise<ResolvedPeerIdentity>;
|
|
295
|
-
resolvePeerConnectionRecords(id: string): Promise<ManagedConnectionRecord[]>;
|
|
296
|
-
updateDevice(deviceId: string, updates: {
|
|
297
|
-
deviceName?: string;
|
|
298
|
-
capabilities?: Device['capabilities'];
|
|
299
|
-
metadata?: string;
|
|
300
|
-
}): Promise<void>;
|
|
301
|
-
deleteDevice(deviceId: string): Promise<void>;
|
|
302
|
-
onDevicesChange(callback: (devices: Device[]) => void, excludeNodeId?: string): () => void;
|
|
303
|
-
onAuthChange(callback: (user: RuntimeIdentity | null) => void): () => void;
|
|
304
|
-
checkForSSOToken(): Promise<void>;
|
|
305
|
-
waitForAuth(): Promise<void>;
|
|
306
|
-
sendMessage(targetId: string, payload: string, state?: string, replyPayload?: string): Promise<string>;
|
|
307
|
-
pollMessages(targetId: string): Promise<SignalingEnvelope[]>;
|
|
308
|
-
watchFriendDevices(friendUserIds: string[], callback: (friendDevices: Map<string, Device[]>) => void): () => void;
|
|
309
|
-
updateFriendTicket(friendTicket: string | null): Promise<void>;
|
|
310
|
-
subscribeDevices(userId: string): Promise<ReadableStream<DeviceEvent[]>>;
|
|
311
|
-
startAutoConnect(userId: string, localDeviceId: string): void;
|
|
312
|
-
submitDesiredPeerProjection(revision: number, peers: DesiredPeerProjection[]): Promise<void>;
|
|
313
|
-
startPresenceLoop(userId: string, localNodeId: string, deviceName: string, ticket: string, metadata?: string): void;
|
|
314
|
-
createSession(session: SignalingSession): Promise<void>;
|
|
315
|
-
updateSession(sessionId: string, updateData: any): Promise<void>;
|
|
316
|
-
subscribeSessions(localDeviceId: string): Promise<ReadableStream<SessionEvent[]>>;
|
|
317
|
-
forceReconnectSnapshot(): void;
|
|
318
|
-
getLocalDeviceId(): Promise<string | null>;
|
|
319
|
-
getLocalDeviceInfo(): Promise<LocalDeviceInfo | null>;
|
|
320
|
-
updateLocalDeviceName(deviceName: string): Promise<LocalDeviceInfo | null>;
|
|
321
|
-
startManagedSessionNative(options: {
|
|
322
|
-
userId: string;
|
|
323
|
-
deviceName?: string;
|
|
324
|
-
localDeviceId?: string | null;
|
|
325
|
-
metadata?: string;
|
|
326
|
-
autoConnect?: boolean;
|
|
327
|
-
presence?: boolean;
|
|
328
|
-
}): Promise<NativeManagedSessionStartResult>;
|
|
329
|
-
notifyNetworkChange(options?: {
|
|
330
|
-
reason?: string;
|
|
331
|
-
}): Promise<unknown>;
|
|
332
|
-
getManagedNodeId(options?: {
|
|
333
|
-
initializeIfMissing?: boolean;
|
|
334
|
-
}): Promise<string | null>;
|
|
335
|
-
startPresenceLoopOnce(userId: string, localNodeId: string, deviceName: string, ticket: string, metadata?: string): Promise<void>;
|
|
336
|
-
startAutoConnectOnce(userId: string, localDeviceId: string): Promise<void>;
|
|
337
|
-
getEndpointTicket(): Promise<string>;
|
|
338
|
-
getEndpointTicketWithToken(scope: GrantScope, maxConnections: number): Promise<string | null>;
|
|
339
|
-
registerSessionToken(token: string, scope: GrantScope, maxConnections: number): Promise<void>;
|
|
340
|
-
revokeSessionTokensByScope(scope: GrantScope): Promise<string[]>;
|
|
341
|
-
openPeerBi(id: string, timeoutMs?: number): Promise<BackendPeerBiStream>;
|
|
342
|
-
incoming_streams(): Promise<ReadableStream<unknown>>;
|
|
343
|
-
is_current_transport_stable_id(endpointId: string, transportStableId: bigint): Promise<boolean>;
|
|
344
|
-
openPeerNativeBi(id: string, label: string, timeoutMs?: number): Promise<BackendPeerBiStream>;
|
|
345
|
-
openPeerBiTransportOnly(id: string, timeoutMs?: number): Promise<BackendPeerBiStream>;
|
|
346
|
-
openPeerUni(id: string, timeoutMs?: number): Promise<BackendPeerUniStream>;
|
|
347
|
-
connectToDevice(params: NativeConnectParams): Promise<NativeConnectResult>;
|
|
348
|
-
disconnectDevice(deviceId: string): Promise<void>;
|
|
349
|
-
setAutoConnectExcluded(deviceId: string, excluded: boolean): Promise<void>;
|
|
350
|
-
isConnected(nodeId: string): Promise<boolean>;
|
|
351
|
-
getConnectionStates(): Promise<BackendConnectionState[]>;
|
|
352
|
-
onConnectionStateChange(callback: (state: BackendConnectionState) => void): Promise<() => void> | (() => void);
|
|
353
|
-
/** @deprecated Use named channels or `openrtc-file-transfer`. */
|
|
354
|
-
sendExplicitFilePath(connectionId: string, filePath: string, transferId?: string): Promise<string>;
|
|
355
|
-
/** @deprecated Use named channels or `openrtc-file-transfer`. */
|
|
356
|
-
sendExplicitFileData(params: ExplicitFileDataSendParams): Promise<void>;
|
|
357
|
-
/** @deprecated Transfer history belongs to the consumer application. */
|
|
358
|
-
getTransferHistory(limit?: number): Promise<Array<[string, unknown]>>;
|
|
359
|
-
/** @deprecated Transfer history belongs to the consumer application. */
|
|
360
|
-
deleteTransferJob(jobId: string): Promise<void>;
|
|
361
|
-
getRuntimeCapabilities(): RuntimeCapabilities;
|
|
362
|
-
onIncomingNativeMessage(callback: (connectionId: string, remoteNodeId: string | null, message: any) => void): Promise<() => void>;
|
|
363
|
-
unwrap(): ISignalingBackend;
|
|
364
|
-
/**
|
|
365
|
-
* Forward setCoreClient() to the inner backend if it implements it. This
|
|
366
|
-
* lets the core Client inject a reference into backends (e.g. WasmBridge)
|
|
367
|
-
* that need to escalate transport-level dials into full Client.connect()
|
|
368
|
-
* handshakes.
|
|
369
|
-
*/
|
|
370
|
-
setCoreClient(client: unknown): void;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
export { DelegatingRuntimeAdapter as D, type WasmBridgeOptions as W, WasmBridge as a };
|
package/dist/chunk-6TAVJ46R.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {u}from'./chunk-3USHQ7QW.js';import {f}from'./chunk-F2XGNLXL.js';import {c}from'./chunk-RD3JEGGF.js';function s(i,r){let t=c(i);return u(t,new f({...t,bridge:r}))}export{s as a};
|
package/dist/chunk-GW7P3D54.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-A3IAG6EL.js';import {w}from'./chunk-YBXGNKM7.js';var n=class extends a{constructor(e){super(new w(e));}setWasmClient(e){this.unwrap().setWasmClient(e);}};export{n as a};
|
package/dist/chunk-PODAMIL6.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var E=new Map;function O(a){let e=new Uint8Array(a),t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function j(a){let e=JSON.stringify({crv:a.crv,kty:a.kty,x:a.x});return O(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e)))}function G(){return O(crypto.getRandomValues(new Uint8Array(24)).buffer)}async function K(){return typeof indexedDB>"u"?null:new Promise((a,e)=>{let t=indexedDB.open("openrtc-v2-device-keys",1);t.onupgradeneeded=()=>{t.result.objectStoreNames.contains("keys")||t.result.createObjectStore("keys");},t.onsuccess=()=>a(t.result),t.onerror=()=>e(t.error);})}async function H(a){let e=await K().catch(()=>null);if(!e)return E.get(a)??null;try{return await new Promise((t,n)=>{let i=e.transaction("keys","readonly").objectStore("keys").get(a);i.onsuccess=()=>t(i.result??null),i.onerror=()=>n(i.error);})}finally{e.close();}}async function L(a,e){let t=await K().catch(()=>null);if(!t){E.set(a,e);return}try{await new Promise((n,i)=>{let r=t.transaction("keys","readwrite").objectStore("keys").put(e,a);r.onsuccess=()=>n(),r.onerror=()=>i(r.error);});}finally{t.close();}}async function V(a){let e=await H(a);if(e)return e;let t=await crypto.subtle.generateKey({name:"Ed25519"},false,["sign","verify"]);return await L(a,t),t}var _={async getOrCreate(a){let e=await V(a),t=await crypto.subtle.exportKey("jwk",e.publicKey),n=await j(t);return {publicKeyJwk:t,thumbprint:n,async proof(i){let r=G(),s=Math.floor(Date.now()/1e3),o=await crypto.subtle.sign({name:"Ed25519"},e.privateKey,new TextEncoder().encode(i(r,s)));return {publicKeyJwk:t,signature:O(o),nonce:r,issuedAt:s}}}}};var M={"identity.assertion.exchange":25692e-8,"identity.monthly-active-principal":110352e-9,"capability.issue":212346e-9,"device.enroll":218946e-9,"gateway.grant.issue":202146e-9,"gateway.grant.refresh":200346e-9,"security.attestation.verify":29694e-8,"room.create":388056e-9,"room.join":209946e-9,"room.leave":200346e-9,"coordination.connection.open":274614e-9,"coordination.credential.refresh":259662e-9,"coordination.presence.offline":253638e-9,"coordination.signal.send":259638e-9,"coordination.session.put":259638e-9,"coordination.session.delete":253638e-9,"coordination.usage.ingest":197088e-9};var R={controlPlane:"https://api.openrtc.app",gateway:"https://gateway.openrtc.app"},N=1440*6e4,g=class extends Error{constructor(t,n){super(t);this.status=n;this.name="OpenRTCV2HttpError";}};function U(a,e,t){return `openrtc:v2:device-certificate:${a}:${e}:${t}`}function J(a,e,t,n){try{let i=globalThis.localStorage?.getItem(U(a,e,t));if(!i)return null;let r=JSON.parse(i);if(typeof r.token!="string"||typeof r.expiresAtMs!="number"||r.expiresAtMs<=Date.now()+N)return null;let s=h(r.token);return s.typ!=="device-certificate"||s.appTag!==a||s.principalId!==e||s.deviceId!==t||s.deviceKeyThumbprint!==n||Number(s.exp)*1e3!==r.expiresAtMs?null:{token:r.token,expiresAtMs:r.expiresAtMs}}catch{return null}}function q(a,e,t,n){try{globalThis.localStorage?.setItem(U(a,e,t),JSON.stringify(n));}catch{}}function W(a){return `${a}_${crypto.randomUUID()}`}async function B(a,e){let t=new TextEncoder().encode(`${a}:${e}`);return [...new Uint8Array(await crypto.subtle.digest("SHA-256",t))].map(i=>i.toString(16).padStart(2,"0")).join("")}function h(a){let e=a.split(".")[1];if(!e)throw new Error("OpenRTC returned a malformed credential.");let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return JSON.parse(atob(n))}var C=class{constructor(e,t,n,i,r={},s){this.apiKey=e;this.endpoints=t;this.keyProvider=n;this.attestation=i;this.events=r;this.botVerification=s;this.keyPromise=null;this.authEpochs=new Map;this.appTag=`app_${e.slice(-16)}`;}record(e){this.events.onLogicalOperation?.(e);}before(e){this.events.beforeLogicalOperation?.(e);}authEpoch(e){let t=this.authEpochs.get(e);if(t)return t;let n={generation:0,devices:new Map};return this.authEpochs.set(e,n),e.subscribe&&(n.unsubscribe=e.subscribe(()=>{n.generation+=1,n.devices.clear(),this.events.onAuthEpochChanged?.(e);})),n}dispose(){for(let e of this.authEpochs.values())e.unsubscribe?.();this.authEpochs.clear();}key(){return this.keyPromise??(this.keyPromise=this.keyProvider.getOrCreate(this.appTag))}async post(e,t){let n=W("request"),i=JSON.stringify({apiKey:this.apiKey,...t}),r=null;for(let s=0;s<2;s+=1)try{let o=await fetch(`${this.endpoints.controlPlane}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-OpenRTC-Idempotency-Key":n},body:i,signal:AbortSignal.timeout(15e3)});if(o.ok)return o.json();let c=`OpenRTC request failed (${o.status}).`;try{let l=await o.json();typeof l.error=="string"&&(c=l.error.slice(0,256));}catch{}let d=new g(c,o.status);if(r=d,s===0&&[502,503,504].includes(o.status))continue;throw d}catch(o){if(r=o,s===0&&o instanceof TypeError)continue;throw o}throw r instanceof Error?r:new Error("OpenRTC request failed.")}async capability(e,t,n,i=false){this.before("capability.issue");let r=e==="space"?await B(this.apiKey,t):t,o=await(await this.key()).proof((u,p)=>["openrtc:v2:capability",this.apiKey,e,r,u,p].join(":")),c=this.botVerification?await this.botVerification.getToken({action:"openrtc_capability",apiKey:this.apiKey}):void 0,d=await this.post("/v2/capabilities",{avenue:{kind:e,id:r},deviceProof:o,...n?{maxPeers:n}:{},...i?{advancedFanout:true}:{},...c?{turnstileToken:c}:{}});this.record("capability.issue");let l={type:"capability",token:d.capability,avenue:e==="ticket"?{kind:"session",id:r}:d.avenue,expiresAtMs:d.expiresAt*1e3};return l.renew=()=>this.capability(e,t,n,i),l}async deviceCertificate(e,t,n){let i=this.authEpoch(e),r=i.devices.get(t)??{};if(i.devices.set(t,r),r.current&&r.current.expiresAtMs>Date.now()+N)return this.deviceCertificateResult(e,t,n,{...r.current,enrolled:false});if(!r.inFlight){let o=i.generation;r.inFlight=this.enrollAuthenticatedDevice(e,t).then(c=>{if(i.generation!==o)throw new Error("The OpenRTC authentication identity changed during enrollment.");return r.current=c,c}).finally(()=>{r.inFlight=void 0;});}let s=await r.inFlight;return this.deviceCertificateResult(e,t,n,s)}deviceCertificateResult(e,t,n,i){let r={type:"device-certificate",token:i.token,avenue:n??{kind:"user",id:i.principalId},expiresAtMs:i.expiresAtMs};return r.renew=async()=>(await this.deviceCertificate(e,t,n)).source,{principalId:i.principalId,source:r,enrolled:i.enrolled}}async enrollAuthenticatedDevice(e,t){this.before("identity.assertion.exchange"),this.before("identity.monthly-active-principal");let n=async u=>{let p=await e.getAssertion({audience:"https://api.openrtc.app/v2/assertions/exchange",forceRefresh:u});if(!p)throw new Error("The OpenRTC auth provider returned no assertion.");return this.post("/v2/assertions/exchange",{assertion:p,...e.providerId?{providerId:e.providerId}:{}})},i;try{i=await n(!1);}catch(u){if(!(u instanceof g)||u.status!==401)throw u;i=await n(true);}this.record("identity.assertion.exchange"),this.record("identity.monthly-active-principal");let r=await this.key(),s=J(this.appTag,i.principalId,t,r.thumbprint);if(s)return {...s,principalId:i.principalId,enrolled:false};this.before("device.enroll"),this.attestation&&this.before("security.attestation.verify");let o=await r.proof((u,p)=>["openrtc:v2:device-enroll",this.appTag,i.principalId,t,u,p].join(":")),c=this.attestation?{kind:this.attestation.kind,...await this.attestation.getEvidence({challenge:`openrtc:v2:attestation:${this.appTag}:${i.principalId}:${t}:${o.nonce}`,apiKey:this.apiKey})}:void 0,d=await this.post("/v2/devices/enroll",{identitySession:i.identitySession,deviceId:t,deviceProof:o,...c?{attestation:c}:{}});this.record("device.enroll"),c&&this.record("security.attestation.verify");let l={principalId:i.principalId,token:d.deviceCertificate,expiresAtMs:d.expiresAt*1e3,enrolled:true};return q(this.appTag,i.principalId,t,{token:l.token,expiresAtMs:l.expiresAtMs}),l}async durableRoomMembership(e,t,n){if(e.type!=="device-certificate")throw new Error("Durable rooms require a device certificate.");this.before(n==="join"?"room.join":"room.leave");let i=h(e.token),r=String(i.jti??""),o=await(await this.key()).proof((c,d)=>["openrtc:v2:room-membership",r,n,t,c,d].join(":"));await this.post("/v2/rooms/memberships",{action:n,roomId:t,deviceCertificate:e.token,deviceProof:o}),this.record(n==="join"?"room.join":"room.leave");}grantProvider(e,t={}){let n=null,i=e;return async r=>{if(n)return n;let s=(async()=>{let o=false;i.expiresAtMs<=Date.now()+5*6e4&&i.renew&&(i=await i.renew(),o=true);let c=r.refreshGrant?"gateway.grant.refresh":"gateway.grant.issue";this.before(c),r.refreshGrant&&this.before("coordination.credential.refresh");let d=h(i.token),l=String(d.jti??""),p=await(await this.key()).proof((v,b)=>["openrtc:v2:gateway-grant",l,r.avenue.kind,r.avenue.id,r.runtimeInstanceId,v,b].join(":")),f=await this.post("/v2/gateway/grants",{credentialType:i.type,credential:i.token,avenue:r.avenue,runtimeInstanceId:r.runtimeInstanceId,ticketFingerprint:r.ticketFingerprint,deviceProof:p,...r.refreshGrant?{refreshGrant:r.refreshGrant}:{},...t.maxPeers?{maxPeers:t.maxPeers}:{},...t.features?{features:t.features}:{}});return this.record(c),r.refreshGrant&&this.record("coordination.credential.refresh"),o&&await t.onSourceRenewed?.({token:i.token,expiresAtMs:i.expiresAtMs}),f})();n=s;try{return await s}finally{n===s&&(n=null);}}}};var P=new WeakMap;function oe(a){let e=P.get(a);if(!e)throw new Error("[OpenRTC] Capability runtime is unavailable or already closed.");return e}function z(a){let e=a?.trim()??"";if(!/^pk_(?:live|test)_[0-9a-f]{40}$/.test(e))throw new Error("[OpenRTC] apiKey must be a public pk_live_ or pk_test_ key.");return e}function y(a){let e=a?.trim()??"";if(!e||e.length>160||!/^[A-Za-z0-9_.:@-]+$/.test(e))throw new Error("[OpenRTC] Capability id is invalid.");return e}function Z(a){let e=a?.trim();if(e){if(new TextEncoder().encode(e).byteLength>4*1024)throw new Error("[OpenRTC] Device profile metadata must not exceed 4 KiB.");return e}}var F=/^[A-Za-z0-9_.:@-]{1,160}$/,X=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function $(a){let e=typeof a=="string"?a.trim():"";if(!F.test(e))return null;let t=e.startsWith("device_")?e.slice(7):"";return X.test(t)?t:e}function Q(a,e){try{let t=a.getItem(`pluto_rtc_web_device_identity_${e}`);if(!t)return null;let n=JSON.parse(t);return $(n?.deviceId)}catch{return null}}function Y(a){let e=`openrtc:v2:device-id:${a}`,t=`pluto_rtc_web_device_identity_${a}`,n,i=(()=>{try{return n=globalThis.localStorage,n&&Q(n,a)||$(n?.getItem(e))||crypto.randomUUID()}catch{return crypto.randomUUID()}})();try{n?.setItem(e,i),n?.setItem(t,JSON.stringify({deviceId:i}));}catch{}return i}function ee(a){let e=typeof a=="string"?a.trim():"";if(!F.test(e))throw new Error("[OpenRTC] The native host returned an invalid durable device ID.");return e}function T(a){let e=h(a.token),t=typeof e.deviceKeyThumbprint=="string"?e.deviceKeyThumbprint.trim():"";if(!/^[A-Za-z0-9_-]{43}$/.test(t))throw new Error("[OpenRTC] Anonymous capability is missing its device-key binding.");return `anon_${t.slice(0,32)}`}var k=class{constructor(){this.descriptors=new Map;this.targets=new Map;}register(e){if(!e?.id?.trim())throw new Error("[OpenRTC] Channel id is required.");this.descriptors.set(e.id,{...e});for(let[t,n]of this.targets)t.channels.register({...e,delivery:e.delivery??n});return ()=>{this.descriptors.delete(e.id);for(let t of this.targets.keys())t.channels.unregister(e.id);}}list(){return [...this.descriptors.values()].map(e=>({...e}))}attach(e,t){this.targets.set(e,t);for(let n of this.descriptors.values())e.channels.register({...n,delivery:n.delivery??t});}detach(e){this.targets.delete(e);}},I=class{constructor(e){this.options=e;this.total=0;this.warned=false;}get sessionCreditsUsd(){return this.total}estimate(e){let t=Math.max(0,Math.floor(e.units??1));return {creditsUsd:(M[e.operation]??0)*t,estimated:true}}assertCanSpend(e,t=1){let n=this.options?.maxSessionCreditsUsd;if(n===void 0||this.total+this.estimate({operation:e,units:t}).creditsUsd<=n)return;let r={sessionCreditsUsd:this.total,operation:e,estimated:true,thresholdCreditsUsd:n,kind:"session-limit"};throw this.options?.onWarning?.(r),new Error("[OpenRTC] The client-side session credit limit was reached.")}record(e,t=1){let n=this.estimate({operation:e,units:t}).creditsUsd;this.total+=n;let i={sessionCreditsUsd:this.total,operation:e,estimated:true};this.options?.onUsage?.(i);let r=this.options?.warnAtSessionCreditsUsd;!this.warned&&r!==void 0&&this.total>=r&&(this.warned=true,this.options?.onWarning?.({...i,thresholdCreditsUsd:r,kind:"warning"}));}},m=class{constructor(e,t,n,i){this.kind=e;this.id=t;this.client=n;this.onClosed=i;this.closed=false;P.set(this,n);}get peers(){return this.client.peers}get channels(){return this.client.channels}get diagnostics(){return this.client.diagnostics}async close(){if(!this.closed){this.closed=true;try{await this.client.advanced.runtime.shutdown();}finally{P.delete(this),this.onClosed();}}}},x=class extends m{constructor(t,n,i){super("devices",t,n,i);this.kind="devices";this.localId=()=>this.client.devices.localId();this.localInfo=()=>this.client.devices.localInfo();this.list=()=>this.client.devices.list();this.listWithStatus=()=>this.client.devices.listWithStatus();this.watch=this.client.devices.watch;this.connect=this.client.devices.connect;this.disconnect=this.client.devices.disconnect;}},A=class extends m{constructor(t,n,i,r){super("space",t,n,i);this.delivery=r;this.kind="space";this.leave=()=>this.close();}},w=class extends m{constructor(t,n,i,r,s){super("room",t,n,i);this.membership=r;this.onLeave=s;this.kind="room";this.left=false;}async leave(){this.left||(this.left=true,await this.onLeave?.()),await this.close();}},S=class extends m{constructor(t,n,i,r){super("ticket",t,n,i);this.token=r;this.kind="ticket";}},D=class{constructor(e,t){this.options=e;this.internals=t;this.channels=new k;this.handles=new Set;this.activations=new Map;this.closed=false;this.devices={start:(e={})=>{let t=e.auth??this.options.auth;return this.activateOnce("devices",JSON.stringify({autoConnect:e.autoConnect??"online",maxPeers:e.maxPeers??null,advancedFanout:e.advancedFanout===true,profile:e.profile??null}),t,()=>this.startDevices(e))}};this.spaces={join:(e,t={})=>this.activateOnce(`space:${y(e)}`,JSON.stringify({payload:t.payload??"reliable",maxPeers:t.maxPeers??null,advancedFanout:t.advancedFanout===true}),void 0,()=>this.joinSpace(e,t))};this.rooms={join:(e,t={})=>{let n=t.access??"capability";return this.activateOnce(`room:${y(e)}`,JSON.stringify({access:n,membership:t.membership??"ephemeral",maxPeers:t.maxPeers??null,advancedFanout:t.advancedFanout===true}),n==="authenticated"?t.auth??this.options.auth:void 0,()=>this.joinRoom(e,t))}};this.tickets={issue:(e,t={})=>this.activateOnce(`ticket:${y(e)}`,JSON.stringify({maxPeers:t.maxPeers??null,advancedFanout:t.advancedFanout===true}),void 0,()=>this.issueTicket(e,t))};this.onClosed=e=>{this.handles.delete(e);for(let[t,n]of this.activations)n.handle===e&&this.activations.delete(t);};this.apiKey=z(e.apiKey),this.usage=new I(e.usage),this.controlPlane=new C(this.apiKey,t.endpoints??R,t.deviceKeyProvider??_,e.trust?.attestation,{beforeLogicalOperation:n=>this.usage.assertCanSpend(n),onLogicalOperation:n=>this.usage.record(n),onAuthEpochChanged:n=>this.retireAuthCapabilities(n)},e.trust?.botVerification);}assertOpen(){if(this.closed)throw new Error("[OpenRTC] Client is closed.")}activateOnce(e,t,n,i){this.assertOpen();let r=this.activations.get(e);if(r){if(r.fingerprint!==t||r.auth!==n)throw new Error(`[OpenRTC] ${e} is already active with different options.`);return r.promise}let s={fingerprint:t,auth:n},o=i().then(c=>(s.handle=c,c)).catch(c=>{throw this.activations.get(e)===s&&this.activations.delete(e),c});return s.promise=o,this.activations.set(e,s),o}retireAuthCapabilities(e){for(let t of this.activations.values())t.auth===e&&t.promise.then(n=>n.close()).catch(()=>{});}async deviceId(){let e=this.internals.deviceIdProvider?await this.internals.deviceIdProvider(this.controlPlane.appTag):Y(this.controlPlane.appTag);return ee(e)}runtimeOptions(e){let t=this.options.transports,n=t?.privacy==="relay-only";if(n&&t?.relay!==true)throw new Error("[OpenRTC] transports.privacy: relay-only requires transports.relay: true.");return {apiKey:this.apiKey,authMode:"external",discoveryMode:e.avenue?.kind==="user"?"user-scoped":"space",space:e.avenue?.id,localDeviceId:e.deviceId,deviceIdPersistence:"persistent",endpointIdPersistence:this.internals.platform==="native"?"persistent":"ephemeral",deviceName:e.deviceName?.trim()||void 0,nativeApplicationStreamConsumer:this.internals.platform==="native"&&t?.nativeHostProtocols===true?"host":"runtime",coordinationAvenueOverride:e.avenue,coordinationGateway:{endpoint:(this.internals.endpoints??R).gateway,environment:"production",grantProvider:e.grantProvider,testingAllowInsecureLoopback:this.internals.testingAllowInsecureLoopback},transports:{iroh:n?{relayOnly:true,localDiscovery:false,persistenceMode:this.internals.platform==="native"?"persistent":"ephemeral",...this.internals.irohTestRelayUrl?{testRelayUrl:this.internals.irohTestRelayUrl}:{}}:this.internals.irohTestRelayUrl?{testRelayUrl:this.internals.irohTestRelayUrl,persistenceMode:this.internals.platform==="native"?"persistent":"ephemeral"}:t?.iroh??true,webrtc:t?.webrtc===true?n?{privacyMode:true,useTurn:true,useDefaultIceServers:false}:true:false,ble:t?.ble??false,moq:t?.moq??false},transportPriority:t?.priority}}async activate(e){let t={relay:this.options.transports?.relay===true,moq:this.options.transports?.moq===true,ble:this.options.transports?.ble===true,advancedFanout:e.advancedFanout===true,durableMembership:e.durableMembership===true},n=e.source,i=null,r=()=>({userId:e.principalId,token:n.token,tokenProvider:async()=>n.token,expiresAtMs:n.expiresAtMs}),s=this.runtimeOptions({avenue:e.source.avenue,grantProvider:this.controlPlane.grantProvider(e.source,{maxPeers:e.maxPeers,features:t,onSourceRenewed:async d=>{n={...n,...d},await i?.setAuth(r());}}),deviceId:e.deviceId,userId:e.principalId,deviceName:e.deviceName}),[o,{wrapAssembly:c}]=await Promise.all([this.internals.runtimeFactory(s),import('./OpenRTCShared-TKAQLONA.js')]);i=c(o,this.internals.platform==="native"?"native":"web"),await i.setAuth(r()),this.channels.attach(i,e.defaultDelivery??"reliable");try{this.usage.assertCanSpend("coordination.connection.open"),await i.devices.startSession({sessionKind:e.kind==="devices"?"app-user-device":"scoped-guest",scope:`v2:${e.kind}:${e.id}`,userId:e.principalId,localDeviceId:e.deviceId,metadata:e.deviceMetadata,autoConnectPolicy:e.autoConnect?"enabled":"disabled",presencePolicy:"online"});}catch(d){throw this.channels.detach(i),await i.advanced.runtime.shutdown().catch(()=>{}),d}return this.usage.record("coordination.connection.open"),i}async startDevices(e={}){this.assertOpen();let t=e.auth??this.options.auth;if(!t)throw new Error("[OpenRTC] devices.start() requires an auth provider.");let n=await this.deviceId(),i=await this.controlPlane.deviceCertificate(t,n),r=await this.activate({kind:"devices",id:i.principalId,source:i.source,principalId:i.principalId,deviceId:n,maxPeers:e.maxPeers,autoConnect:e.autoConnect!=="none",advancedFanout:e.advancedFanout,deviceName:e.profile?.name,deviceMetadata:Z(e.profile?.metadata)}),s;return s=new x(i.principalId,r,()=>{this.channels.detach(r),this.onClosed(s);}),this.handles.add(s),s}async joinSpace(e,t={}){this.assertOpen();let n=y(e),i=await this.controlPlane.capability("space",n,t.maxPeers,t.advancedFanout),r=String(h(i.token).principalId),s=await this.activate({kind:"space",id:n,source:i,principalId:r,deviceId:T(i),maxPeers:t.maxPeers,autoConnect:true,defaultDelivery:t.payload??"reliable",advancedFanout:t.advancedFanout}),o;return o=new A(n,s,()=>{this.channels.detach(s),this.onClosed(o);},t.payload??"reliable"),this.handles.add(o),o}async joinRoom(e,t={}){this.assertOpen();let n=y(e),i=t.membership??"ephemeral",r=t.access??"capability";if(i==="durable"&&r!=="authenticated")throw new Error("[OpenRTC] Durable room membership requires access: authenticated.");if(r==="authenticated"){let l=t.auth??this.options.auth;if(!l)throw new Error("[OpenRTC] Authenticated rooms require an auth provider.");let u=await this.deviceId(),p=await this.controlPlane.deviceCertificate(l,u,{kind:"room",id:n});i==="durable"&&await this.controlPlane.durableRoomMembership(p.source,n,"join");let f;try{f=await this.activate({kind:"room",id:n,source:p.source,principalId:p.principalId,deviceId:u,maxPeers:t.maxPeers,autoConnect:!0,durableMembership:i==="durable",advancedFanout:t.advancedFanout});}catch(b){throw i==="durable"&&await this.controlPlane.durableRoomMembership(p.source,n,"leave").catch(()=>{}),b}let v;return v=new w(n,f,()=>{this.channels.detach(f),this.onClosed(v);},i,i==="durable"?async()=>{await this.controlPlane.durableRoomMembership(p.source,n,"leave");}:void 0),this.handles.add(v),v}let s=await this.controlPlane.capability("room",n,t.maxPeers,t.advancedFanout),o=String(h(s.token).principalId),c=await this.activate({kind:"room",id:n,source:s,principalId:o,deviceId:T(s),maxPeers:t.maxPeers,autoConnect:true,advancedFanout:t.advancedFanout}),d;return d=new w(n,c,()=>{this.channels.detach(c),this.onClosed(d);},"ephemeral"),this.handles.add(d),d}async issueTicket(e,t={}){this.assertOpen();let n=y(e),i=await this.controlPlane.capability("ticket",n,t.maxPeers,t.advancedFanout),r=String(h(i.token).principalId),s=await this.activate({kind:"ticket",id:n,source:i,principalId:r,deviceId:T(i),maxPeers:t.maxPeers,autoConnect:false,advancedFanout:t.advancedFanout}),o;return o=new S(n,s,()=>{this.channels.detach(s),this.onClosed(o);},i.token),this.handles.add(o),o}async close(){if(!this.closed){this.closed=true;try{await Promise.all([...this.handles].map(e=>e.close()));}finally{this.controlPlane.dispose(),this.activations.clear();}}}};function ce(a,e){return new D(a,e)}
|
|
2
|
-
export{j as a,oe as b,ce as c};
|
package/dist/chunk-PRVFZI2T.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {u,a as a$1}from'./chunk-3USHQ7QW.js';import {f}from'./chunk-F2XGNLXL.js';import {c}from'./chunk-RD3JEGGF.js';var s=false;function a(){s||(s=true,a$1(async()=>{let t=await import('./openrtc-UU4BBJLG.js');return {initWasm:t.default,WasmClient:t.WasmClient,start:t.start}}));}async function d(t){a();let e=c(t),{WasmBridge:i}=await import('./WasmBridge-2A22U7RU.js');return u(e,new i(e))}function y(t,e){let i=c(t);return u(i,new f({...i,bridge:e}))}export{d as a,y as b};
|
package/dist/chunk-UEYM6WTT.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-PODAMIL6.js';function s(){let t=crypto.getRandomValues(new Uint8Array(24)),e="";for(let r of t)e+=String.fromCharCode(r);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function u(t){if(!t||typeof t!="object")throw new Error("[OpenRTC] Native host returned no device public key.");let e=t;if(e.kty!=="OKP"||e.crv!=="Ed25519"||typeof e.x!="string"||!/^[A-Za-z0-9_-]{43}$/.test(e.x)||e.d!==void 0)throw new Error("[OpenRTC] Native host returned an invalid Ed25519 public key.");return {kty:"OKP",crv:"Ed25519",x:e.x}}function y(t){return {async getOrCreate(e){let r=u(await t.invoke("openrtc_v2_device_public_key",{appTag:e})),a$1=await a(r);return {publicKeyJwk:r,thumbprint:a$1,async proof(p){let n=s(),o=Math.floor(Date.now()/1e3),i=await t.invoke("openrtc_v2_sign_device_proof",{appTag:e,challenge:p(n,o)});if(!/^[A-Za-z0-9_-]{80,128}$/.test(i))throw new Error("[OpenRTC] Native host returned an invalid device proof.");return {publicKeyJwk:r,signature:i,nonce:n,issuedAt:o}}}}}}
|
|
2
|
-
export{y as a};
|