openrtc 0.1.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +92 -0
- package/README.md +73 -9
- package/dist/DelegatingRuntimeAdapter-BxOcVIx_.d.ts +201 -0
- package/dist/{IpcRuntimeAdapter-CT-W0Mtp.d.ts → IpcRuntimeAdapter-U5AEH0jn.d.ts} +6 -2
- package/dist/auth/index.js +1 -1
- package/dist/auth/internal.js +1 -1
- package/dist/chunk-7DN33VUQ.js +1 -0
- package/dist/chunk-BLOEZIFJ.js +1 -0
- package/dist/chunk-FQETZQPW.js +2 -0
- package/dist/chunk-IUHUYHNZ.js +1 -0
- package/dist/chunk-UBEE42VU.js +2 -0
- package/dist/chunk-UPO23UMZ.js +3 -0
- package/dist/chunk-WNJE3MJF.js +1 -0
- package/dist/{factories-0TxDPMeu.d.ts → framing-lxzHEuSr.d.ts} +479 -226
- package/dist/index.d.ts +201 -7
- package/dist/index.js +2 -1
- package/dist/openrtc_bg.wasm +0 -0
- package/dist/runtime/WasmRuntimeAdapter.d.ts +2 -1
- package/dist/runtime/WasmRuntimeAdapter.js +1 -1
- package/dist/runtime/index.d.ts +213 -392
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/tauri.d.ts +5 -6
- package/dist/runtime/tauri.js +1 -1
- package/dist/transport/index.d.ts +11 -0
- package/dist/transport/index.js +1 -0
- package/dist/{DelegatingRuntimeAdapter-CW8d78dZ.d.ts → types-D0fRvUbN.d.ts} +222 -171
- package/env/index.d.ts +64 -0
- package/env/index.mjs +230 -0
- package/package.json +29 -18
- package/dist/chunk-26POO5PL.js +0 -4
- package/dist/chunk-4MH42GUI.js +0 -2
- package/dist/chunk-D54VGRRH.js +0 -1
- package/dist/chunk-DIQYFAGL.js +0 -2
- package/dist/chunk-PZ25OCVG.js +0 -2
- package/dist/chunk-UVASANPG.js +0 -1
- package/wasm/README.md +0 -64
- package/wasm/openrtc.d.ts +0 -320
- package/wasm/openrtc.js +0 -2290
- package/wasm/openrtc_bg.wasm +0 -0
- package/wasm/openrtc_bg.wasm.d.ts +0 -113
- package/wasm/package.json +0 -16
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
import {
|
|
1
|
+
import { R as RuntimeClientOptions, a as RuntimeClient, b as RuntimeManagedSessionOptions, c as RuntimeManagedSession, d as RuntimeDevice, e as RuntimeDeviceStatusSnapshot, f as RuntimeDeviceConnectOptions, g as RuntimeLocalDeviceInfo, h as RuntimeLocalDeviceProfile, i as RuntimePeerState, j as RuntimePeerConnectOptions, C as Connection, k as RuntimePeerReadinessSnapshot, l as RuntimePeerHealth, m as RuntimeChannelDescriptor, n as RuntimePeerStreamOptions, o as RuntimeIncomingStream, p as RuntimeScopedChannelOptions, q as RuntimeScopedLogicalChannel, r as RuntimeJoinRoomOptions, s as RuntimeRoomMember, t as RuntimePolicySnapshot, u as RuntimeConnectionStateSnapshot, v as RuntimeApplicationPayloadReadinessOptions, w as RuntimeConnectionEvent, P as PeerReconciliationStats, x as PlutoRuntimeAssembly, y as RuntimeRawConnection, I as ITransport } from './framing-lxzHEuSr.js';
|
|
2
|
+
export { z as ChannelDescriptor, A as ConnectionEvent, B as ConnectionTarget, D as DeviceProfile, E as IncomingStream, O as OPENRTC_RUNTIME_POLICY, F as PeerConnectOptions, G as PeerReadiness, H as PeerStreamOptions, J as PresenceLoopOptions, K as RawConnection, L as RuntimeAuthContext, M as RuntimeAuthIdentity, N as RuntimeAutoConnectPolicy, Q as RuntimeConnectionTarget, S as RuntimeDevicePresenceStatus, T as RuntimeDeviceStatus, U as RuntimeJsonFrameHandler, V as RuntimeLogicalChannelFraming, W as RuntimeManagedSessionKind, X as RuntimeManagedSessionPlatform, Y as RuntimePeerLifecycleStatus, Z as RuntimePeerScope, _ as RuntimePeerSessionSnapshot, $ as RuntimePresenceLoopOptions, a0 as RuntimePresencePolicy, a1 as RuntimeSession, a2 as RuntimeU32BEFrameHandler, a3 as RuntimeUiConnectionStatus, a4 as ScopedChannelOptions, a5 as ScopedLogicalChannel, a6 as ScopedSession, a7 as Session, a8 as SessionOptions, a9 as createRuntimeJsonFrameDecoder, aa as createRuntimeU32BEFrameDecoder, ab as decodeRuntimeJsonPayload, ac as encodeRuntimeJsonFrame, ad as encodeRuntimeJsonPayload, ae as encodeRuntimeU32BEFrame, af as getRuntimePolicy, ag as isRuntimeDeviceActive, ah as isRuntimeDeviceConnectable, ai as isRuntimeDeviceRoutable } from './framing-lxzHEuSr.js';
|
|
3
|
+
import { k as ConnectDeviceResult, l as ConnectDeviceHooks, m as ConnectDeviceOptions, P as PeerSessionSnapshot, c as ResolvedPeerIdentity, G as GrantScope, n as ProtocolName, o as ProtocolCapability, p as ProtocolCapabilityMap, q as ApplicationPayloadCrypto, r as ApplicationCryptoStreamTools, s as SpaceTokenProvider } from './types-D0fRvUbN.js';
|
|
4
|
+
export { t as AppLimits, u as ApplicationCryptoBiStream, v as ApplicationPayloadReadinessOptions, w as ApplicationPayloadRouteOptions, x as ApplicationPayloadSendOptions, A as AuthMode, y as DevicePresenceStatus, D as DiscoveryMode, z as ProtocolBaseName, F as ProtocolImplementationKind, H as ProtocolLocality, S as SignalingMode, J as SpaceAuthMode } from './types-D0fRvUbN.js';
|
|
5
|
+
import { R as RuntimeCapabilities, a as RuntimeCapabilityProfile, A as AuthContext } from './DelegatingRuntimeAdapter-BxOcVIx_.js';
|
|
6
|
+
export { b as RuntimeAdapterKind } from './DelegatingRuntimeAdapter-BxOcVIx_.js';
|
|
7
|
+
import { P as PlutoIpcBridge } from './IpcRuntimeAdapter-U5AEH0jn.js';
|
|
8
|
+
export { TRANSPORT_LABELS, isDirectIrohTransportLabel, isIndependentTransportLabel, isIrohBaseTransportLabel, isOptionalTransportLabel, isWebRtcTransportLabel, normalizeTransportLabel } from './transport/index.js';
|
|
6
9
|
import './runtime/WasmRuntimeAdapter.js';
|
|
7
10
|
|
|
11
|
+
type OpenRTCChannelConnectOptions = Omit<RuntimeScopedChannelOptions, 'scope' | 'deviceId' | 'ticket'> & {
|
|
12
|
+
/**
|
|
13
|
+
* Device selected from `client.devices.*`. Passing the device object lets
|
|
14
|
+
* OpenRTC reuse its current ticket for native and ticket-gated routes.
|
|
15
|
+
*/
|
|
16
|
+
device?: string | RuntimeDevice;
|
|
17
|
+
deviceId?: string | null;
|
|
18
|
+
ticket?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Logical channel lifecycle scope. Most app channels should use the default
|
|
21
|
+
* `session`; pass a custom scope only when you intentionally manage peer
|
|
22
|
+
* lifecycle separately from the channel.
|
|
23
|
+
*/
|
|
24
|
+
scope?: RuntimeScopedChannelOptions['scope'];
|
|
25
|
+
};
|
|
26
|
+
type OpenRTCDeviceSessionOptions = Omit<RuntimeManagedSessionOptions, 'platform'> & {
|
|
27
|
+
/**
|
|
28
|
+
* Runtime host for the managed user-device session. Normal apps can omit
|
|
29
|
+
* this: `OpenRTC(...)` defaults to `web`, and `OpenRTC.native(...)` defaults
|
|
30
|
+
* to `native`.
|
|
31
|
+
*/
|
|
32
|
+
platform?: RuntimeManagedSessionOptions['platform'];
|
|
33
|
+
};
|
|
8
34
|
interface OpenRTCDeviceNamespace {
|
|
35
|
+
startSession(options?: OpenRTCDeviceSessionOptions): Promise<RuntimeManagedSession>;
|
|
36
|
+
stopSession(options?: {
|
|
37
|
+
preserveBackendSession?: boolean;
|
|
38
|
+
}): Promise<void>;
|
|
9
39
|
list(): Promise<RuntimeDevice[]>;
|
|
10
40
|
listWithStatus(): Promise<RuntimeDeviceStatusSnapshot[]>;
|
|
11
41
|
watch(callback: (devices: RuntimeDevice[]) => void): () => void;
|
|
@@ -31,6 +61,7 @@ interface OpenRTCDeviceNamespace {
|
|
|
31
61
|
}
|
|
32
62
|
interface OpenRTCPeerNamespace {
|
|
33
63
|
watch(callback: (peers: RuntimePeerState[]) => void): () => void;
|
|
64
|
+
watchLifecycle(callback: (peers: RuntimePeerState[]) => void): () => void;
|
|
34
65
|
get(id: string): RuntimePeerState | undefined;
|
|
35
66
|
listConnected(): RuntimePeerState[];
|
|
36
67
|
connect(options: RuntimePeerConnectOptions): Promise<Connection>;
|
|
@@ -64,6 +95,25 @@ interface OpenRTCChannelNamespace {
|
|
|
64
95
|
onIncomingChannel(channelId: string, callback: (stream: RuntimeIncomingStream & {
|
|
65
96
|
channel: NonNullable<RuntimeIncomingStream['channel']>;
|
|
66
97
|
}) => boolean | void): () => void;
|
|
98
|
+
connect(options: OpenRTCChannelConnectOptions): Promise<RuntimeScopedLogicalChannel>;
|
|
99
|
+
connectScoped(options: RuntimeScopedChannelOptions): Promise<RuntimeScopedLogicalChannel>;
|
|
100
|
+
}
|
|
101
|
+
interface OpenRTCRoomNamespace {
|
|
102
|
+
create(roomId?: string): Promise<string>;
|
|
103
|
+
join(roomId: string, options?: RuntimeJoinRoomOptions): Promise<Connection[]>;
|
|
104
|
+
leave(roomId: string): Promise<void>;
|
|
105
|
+
watch(roomId: string, callback: (members: RuntimeRoomMember[]) => void): () => void;
|
|
106
|
+
members(roomId: string): Promise<RuntimeRoomMember[]>;
|
|
107
|
+
}
|
|
108
|
+
interface OpenRTCTicketNamespace {
|
|
109
|
+
raw(): Promise<string>;
|
|
110
|
+
share(options?: {
|
|
111
|
+
maxConnections?: number;
|
|
112
|
+
}): Promise<string>;
|
|
113
|
+
grant(scope: GrantScope, options?: {
|
|
114
|
+
maxConnections?: number;
|
|
115
|
+
}): Promise<string>;
|
|
116
|
+
revoke(scope: GrantScope): Promise<string[]>;
|
|
67
117
|
}
|
|
68
118
|
interface OpenRTCDiagnosticsNamespace {
|
|
69
119
|
status(): Promise<{
|
|
@@ -74,13 +124,16 @@ interface OpenRTCDiagnosticsNamespace {
|
|
|
74
124
|
}>;
|
|
75
125
|
policy(): RuntimePolicySnapshot;
|
|
76
126
|
capabilities(): RuntimeCapabilities;
|
|
127
|
+
capabilityProfile(): RuntimeCapabilityProfile;
|
|
77
128
|
connectionStates(): Promise<RuntimeConnectionStateSnapshot[]>;
|
|
78
129
|
onConnectionStateChange(callback: (state: RuntimeConnectionStateSnapshot) => void): Promise<() => void> | (() => void);
|
|
79
130
|
connections(): Connection[];
|
|
131
|
+
applicationReadyConnections(options?: RuntimeApplicationPayloadReadinessOptions): Connection[];
|
|
80
132
|
onConnection(callback: (connection: Connection) => void): () => void;
|
|
81
133
|
onDisconnection(callback: (connection: Connection) => void): () => void;
|
|
82
134
|
onConnectionEvent(callback: (event: RuntimeConnectionEvent) => void): () => void;
|
|
83
135
|
forceReconnectSnapshot(): void;
|
|
136
|
+
peerReconciliation(): Readonly<PeerReconciliationStats>;
|
|
84
137
|
}
|
|
85
138
|
interface OpenRTCAdvancedNamespace {
|
|
86
139
|
readonly runtime: RuntimeClient;
|
|
@@ -111,6 +164,8 @@ interface OpenRTCClient extends RuntimeClient {
|
|
|
111
164
|
readonly devices: OpenRTCDeviceNamespace;
|
|
112
165
|
readonly peers: OpenRTCPeerNamespace;
|
|
113
166
|
readonly channels: OpenRTCChannelNamespace;
|
|
167
|
+
readonly rooms: OpenRTCRoomNamespace;
|
|
168
|
+
readonly tickets: OpenRTCTicketNamespace;
|
|
114
169
|
readonly diagnostics: OpenRTCDiagnosticsNamespace;
|
|
115
170
|
readonly advanced: OpenRTCAdvancedNamespace;
|
|
116
171
|
/** @deprecated Use setAuth() instead */
|
|
@@ -128,6 +183,56 @@ interface OpenRTCClient extends RuntimeClient {
|
|
|
128
183
|
signIn(): Promise<void>;
|
|
129
184
|
/** Sign out and clear auth context */
|
|
130
185
|
signOut(): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* @deprecated Use `client.devices.startSession(...)` for the public
|
|
188
|
+
* user-device avenue lifecycle. This top-level method remains for
|
|
189
|
+
* RuntimeClient compatibility and advanced integrations.
|
|
190
|
+
*/
|
|
191
|
+
startManagedSession(options: RuntimeManagedSessionOptions): Promise<RuntimeManagedSession>;
|
|
192
|
+
/**
|
|
193
|
+
* @deprecated Use `client.devices.stopSession(...)` for the public
|
|
194
|
+
* user-device avenue lifecycle.
|
|
195
|
+
*/
|
|
196
|
+
stopManagedSession(options?: {
|
|
197
|
+
preserveBackendSession?: boolean;
|
|
198
|
+
}): Promise<void>;
|
|
199
|
+
/** @deprecated Use `client.rooms.create(...)`. */
|
|
200
|
+
createRoom(roomId?: string): Promise<string>;
|
|
201
|
+
/** @deprecated Use `client.rooms.join(...)`. */
|
|
202
|
+
joinRoom(roomId: string, options?: RuntimeJoinRoomOptions): Promise<Connection[]>;
|
|
203
|
+
/** @deprecated Use `client.rooms.leave(...)`. */
|
|
204
|
+
leaveRoom(roomId: string): Promise<void>;
|
|
205
|
+
/** @deprecated Use `client.rooms.watch(...)`. */
|
|
206
|
+
watchRoom(roomId: string, callback: (members: RuntimeRoomMember[]) => void): () => void;
|
|
207
|
+
/** @deprecated Use `client.rooms.members(...)`. */
|
|
208
|
+
getRoomMembers(roomId: string): Promise<RuntimeRoomMember[]>;
|
|
209
|
+
/** @deprecated Use `client.tickets.raw(...)`. */
|
|
210
|
+
getInvite(): Promise<string>;
|
|
211
|
+
/** @deprecated Use `client.tickets.raw(...)`. */
|
|
212
|
+
getTicket(): Promise<string>;
|
|
213
|
+
/** @deprecated Use `client.tickets.share(...)` or `client.tickets.grant(...)`. */
|
|
214
|
+
getTicketWithToken(scope: GrantScope, maxConnections?: number): Promise<string>;
|
|
215
|
+
/** @deprecated Use `client.tickets.revoke(...)`. */
|
|
216
|
+
revokeTokensByScope(scope: GrantScope): Promise<string[]>;
|
|
217
|
+
/** @deprecated Use `client.peers.connect(...)`. */
|
|
218
|
+
connectPeer(options: RuntimePeerConnectOptions): Promise<Connection>;
|
|
219
|
+
/** @deprecated Use `client.peers.connect(...)`. */
|
|
220
|
+
connectTo(options: RuntimePeerConnectOptions): Promise<Connection>;
|
|
221
|
+
/** @deprecated Use `client.peers.waitConnected(...)`. */
|
|
222
|
+
waitForConnectedPeer(id: string, timeoutMs?: number): Promise<PeerSessionSnapshot | null>;
|
|
223
|
+
/** @deprecated Use `client.channels.connect(...)`; use `client.channels.connectScoped(...)` only for custom lifecycle scopes. */
|
|
224
|
+
connectScopedChannel(options: RuntimeScopedChannelOptions): Promise<RuntimeScopedLogicalChannel>;
|
|
225
|
+
/** @deprecated Use `client.channels.openBi(...)`. */
|
|
226
|
+
openPeerBi(id: string, options?: RuntimePeerStreamOptions): Promise<{
|
|
227
|
+
connection: Connection;
|
|
228
|
+
readable: ReadableStream<Uint8Array>;
|
|
229
|
+
writable: WritableStream<Uint8Array>;
|
|
230
|
+
}>;
|
|
231
|
+
/** @deprecated Use `client.channels.openUni(...)`. */
|
|
232
|
+
openPeerUni(id: string, options?: RuntimePeerStreamOptions): Promise<{
|
|
233
|
+
connection: Connection;
|
|
234
|
+
writable: WritableStream<Uint8Array>;
|
|
235
|
+
}>;
|
|
131
236
|
/**
|
|
132
237
|
* Access to the underlying PlutoRuntimeAssembly for backward compatibility.
|
|
133
238
|
* @deprecated Access methods directly on the client instead.
|
|
@@ -145,7 +250,10 @@ interface OpenRTCClient extends RuntimeClient {
|
|
|
145
250
|
* @example
|
|
146
251
|
* ```typescript
|
|
147
252
|
* import { OpenRTC } from 'openrtc';
|
|
148
|
-
* const client = OpenRTC({
|
|
253
|
+
* const client = OpenRTC({
|
|
254
|
+
* apiKey: 'pk_live_...',
|
|
255
|
+
* authMode: 'anonymous',
|
|
256
|
+
* });
|
|
149
257
|
* await client.connect();
|
|
150
258
|
* ```
|
|
151
259
|
*/
|
|
@@ -154,7 +262,93 @@ declare namespace OpenRTC {
|
|
|
154
262
|
var native: (options: RuntimeClientOptions, bridge?: PlutoIpcBridge) => OpenRTCClient;
|
|
155
263
|
}
|
|
156
264
|
|
|
265
|
+
declare class TransportFactory {
|
|
266
|
+
private static readonly capabilityMap;
|
|
267
|
+
static createTransport(name: ProtocolName): ITransport;
|
|
268
|
+
static getProtocolCapability(name: ProtocolName): ProtocolCapability;
|
|
269
|
+
static getProtocolCapabilities(): ProtocolCapabilityMap;
|
|
270
|
+
static getPreferredProtocolOrder(options?: {
|
|
271
|
+
runtime?: 'browser' | 'native' | 'any';
|
|
272
|
+
includePathLabels?: boolean;
|
|
273
|
+
}): ProtocolName[];
|
|
274
|
+
static assertProtocolAvailable(name: ProtocolName): void;
|
|
275
|
+
}
|
|
276
|
+
declare function getPreferredProtocolOrder(options?: Parameters<typeof TransportFactory.getPreferredProtocolOrder>[0]): ProtocolName[];
|
|
277
|
+
|
|
278
|
+
declare function isApplicationEncryptedPayload(payload: Uint8Array): boolean;
|
|
279
|
+
declare function createSharedSecretApplicationCrypto(key: Uint8Array, options?: {
|
|
280
|
+
requireEncrypted?: boolean;
|
|
281
|
+
randomBytes?: (byteLength: number) => Uint8Array;
|
|
282
|
+
replayProtection?: boolean;
|
|
283
|
+
}): ApplicationPayloadCrypto;
|
|
284
|
+
declare function createApplicationCryptoStreamTools(crypto: ApplicationPayloadCrypto, options?: {
|
|
285
|
+
typeId?: number;
|
|
286
|
+
maxFrameBytes?: number;
|
|
287
|
+
}): ApplicationCryptoStreamTools;
|
|
288
|
+
|
|
289
|
+
declare const KEY_AGREEMENT_PUBLIC_KEY_BYTES = 32;
|
|
290
|
+
declare const KEY_AGREEMENT_ALGORITHM = "openrtc:x25519-hkdf:v1";
|
|
291
|
+
interface ApplicationKeyAgreementPayload {
|
|
292
|
+
algorithm: typeof KEY_AGREEMENT_ALGORITHM;
|
|
293
|
+
publicKey: string;
|
|
294
|
+
}
|
|
295
|
+
interface EphemeralKeyAgreement {
|
|
296
|
+
publicKey: Uint8Array;
|
|
297
|
+
secretKey: Uint8Array;
|
|
298
|
+
}
|
|
299
|
+
declare function generateEphemeralKeyAgreement(randomBytes?: (byteLength: number) => Uint8Array): EphemeralKeyAgreement;
|
|
300
|
+
declare function deriveApplicationCryptoKey(localSecretKey: Uint8Array, remotePublicKey: Uint8Array, localNodeId: string, remoteNodeId: string): Uint8Array;
|
|
301
|
+
declare function encodeApplicationKeyAgreementPayload(publicKey: Uint8Array): ApplicationKeyAgreementPayload;
|
|
302
|
+
|
|
303
|
+
type MintSpaceTokenRequest = {
|
|
304
|
+
spaceKey: string;
|
|
305
|
+
memberId?: string;
|
|
306
|
+
ttl?: number;
|
|
307
|
+
sandboxAppId?: string;
|
|
308
|
+
};
|
|
309
|
+
type MintSpaceTokenResponse = {
|
|
310
|
+
token: string;
|
|
311
|
+
expiresAt: number;
|
|
312
|
+
tokenLifetimeSeconds: number;
|
|
313
|
+
namespaceId: string;
|
|
314
|
+
spaceAppTag: string;
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* Mint a namespace-scoped Firebase custom token from your backend using the
|
|
318
|
+
* OpenRTC `POST /v1/spaces/tokens` endpoint. Never call this from browser code
|
|
319
|
+
* with a secret key — proxy through your server.
|
|
320
|
+
*/
|
|
321
|
+
type EnableSpaceAuthResponse = {
|
|
322
|
+
success: true;
|
|
323
|
+
space: {
|
|
324
|
+
namespaceId: string;
|
|
325
|
+
requireScopedAuth: boolean;
|
|
326
|
+
status: 'active' | 'revoked';
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Opt a provisioned space into scoped-auth mode (required for all spaces).
|
|
331
|
+
* Call from your backend with sk_live_... only.
|
|
332
|
+
*/
|
|
333
|
+
declare function enableSpaceAuth(endpointUrl: string, secretKey: string, namespaceId: string): Promise<EnableSpaceAuthResponse>;
|
|
334
|
+
declare function mintSpaceToken(endpointUrl: string, secretKey: string, request: MintSpaceTokenRequest): Promise<MintSpaceTokenResponse>;
|
|
335
|
+
/**
|
|
336
|
+
* Browser-safe space auth for static sites. Calls the rate-limited
|
|
337
|
+
* `v1SpacePublicTokens` endpoint (pk_live_ + spaceKey only).
|
|
338
|
+
*/
|
|
339
|
+
declare function createPublicSpaceTokenProvider(options: {
|
|
340
|
+
apiKey: string;
|
|
341
|
+
space?: string;
|
|
342
|
+
spaceKey?: string;
|
|
343
|
+
endpointUrl?: string;
|
|
344
|
+
memberIdStorageKey?: string;
|
|
345
|
+
sandboxAppId?: string;
|
|
346
|
+
}): SpaceTokenProvider;
|
|
347
|
+
declare function sandboxSpaceKey(spaceKey: string, sandboxAppId?: string): string;
|
|
348
|
+
declare const spaceToken: typeof createPublicSpaceTokenProvider;
|
|
349
|
+
declare const createSpaceTokenProvider: typeof createPublicSpaceTokenProvider;
|
|
350
|
+
|
|
157
351
|
type UpgradeState = 'none' | 'upgrading' | 'upgraded' | 'failed';
|
|
158
352
|
type OutboundMessage = string | object | ArrayBuffer | Uint8Array;
|
|
159
353
|
|
|
160
|
-
export { OpenRTC, type OpenRTCClient, RuntimeClientOptions as OpenRTCOptions, type OutboundMessage, RuntimeCapabilities, RuntimeChannelDescriptor, RuntimeClientOptions, RuntimeConnectionEvent, RuntimeConnectionStateSnapshot, RuntimeDevice, RuntimeDeviceConnectOptions, RuntimeDeviceStatusSnapshot, RuntimeIncomingStream, RuntimeLocalDeviceInfo, RuntimeLocalDeviceProfile, RuntimePeerConnectOptions, RuntimePeerHealth, RuntimePeerReadinessSnapshot, RuntimePeerState, RuntimePeerStreamOptions, RuntimePolicySnapshot, RuntimeRawConnection, type UpgradeState };
|
|
354
|
+
export { ApplicationCryptoStreamTools, type ApplicationKeyAgreementPayload, ApplicationPayloadCrypto, type EnableSpaceAuthResponse, GrantScope, KEY_AGREEMENT_ALGORITHM, KEY_AGREEMENT_PUBLIC_KEY_BYTES, type MintSpaceTokenRequest, type MintSpaceTokenResponse, OpenRTC, type OpenRTCChannelConnectOptions, type OpenRTCClient, type OpenRTCDeviceNamespace, type OpenRTCDeviceSessionOptions, RuntimeClientOptions as OpenRTCOptions, type OpenRTCRoomNamespace, type OpenRTCTicketNamespace, type OutboundMessage, ProtocolCapability, ProtocolCapabilityMap, ProtocolName, RuntimeApplicationPayloadReadinessOptions, RuntimeCapabilities, RuntimeChannelDescriptor, RuntimeClientOptions, RuntimeConnectionEvent, RuntimeConnectionStateSnapshot, RuntimeDevice, RuntimeDeviceConnectOptions, RuntimeDeviceStatusSnapshot, RuntimeIncomingStream, RuntimeJoinRoomOptions, RuntimeLocalDeviceInfo, RuntimeLocalDeviceProfile, RuntimeManagedSession, RuntimeManagedSessionOptions, RuntimePeerConnectOptions, RuntimePeerHealth, RuntimePeerReadinessSnapshot, RuntimePeerState, RuntimePeerStreamOptions, RuntimePolicySnapshot, RuntimeRawConnection, RuntimeRoomMember, RuntimeScopedChannelOptions, RuntimeScopedLogicalChannel, SpaceTokenProvider, type UpgradeState, createApplicationCryptoStreamTools, createPublicSpaceTokenProvider, createSharedSecretApplicationCrypto, createSpaceTokenProvider, deriveApplicationCryptoKey, enableSpaceAuth, encodeApplicationKeyAgreementPayload, generateEphemeralKeyAgreement, getPreferredProtocolOrder, isApplicationEncryptedPayload, mintSpaceToken, sandboxSpaceKey, spaceToken };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {z,A}from'./chunk-UPO23UMZ.js';export{c as KEY_AGREEMENT_ALGORITHM,b as KEY_AGREEMENT_PUBLIC_KEY_BYTES,g as ScopedSession,v as createRuntimeJsonFrameDecoder,r as createRuntimeU32BEFrameDecoder,t as decodeRuntimeJsonPayload,e as deriveApplicationCryptoKey,f as encodeApplicationKeyAgreementPayload,u as encodeRuntimeJsonFrame,s as encodeRuntimeJsonPayload,q as encodeRuntimeU32BEFrame,d as generateEphemeralKeyAgreement,a as getPreferredProtocolOrder,B as isRuntimeDeviceActive,D as isRuntimeDeviceConnectable,C as isRuntimeDeviceRoutable}from'./chunk-UPO23UMZ.js';import'./chunk-IUHUYHNZ.js';import {g}from'./chunk-UBEE42VU.js';export{q as OPENRTC_RUNTIME_POLICY,h as createApplicationCryptoStreamTools,g as createSharedSecretApplicationCrypto,r as getRuntimePolicy,f as isApplicationEncryptedPayload}from'./chunk-WNJE3MJF.js';import {m}from'./chunk-FQETZQPW.js';export{a as TRANSPORT_LABELS,d as isDirectIrohTransportLabel,g as isIndependentTransportLabel,c as isIrohBaseTransportLabel,e as isOptionalTransportLabel,f as isWebRtcTransportLabel,b as normalizeTransportLabel}from'./chunk-BLOEZIFJ.js';function O(t){let i=m({...t});if("auth"in t&&!t.authMode){let n=t.auth;i.authMode=n==="none"?"anonymous":n;}if("identity"in t&&!t.nodeIdPersistence){let n=t.identity;i.nodeIdPersistence=n==="temporary"?"ephemeral":n;}return "namespace"in t&&!t.storagePrefix&&(i.storagePrefix=t.namespace),"privacy"in t&&t.strictMode===void 0&&(i.strictMode=!!t.privacy),i}function T(t,i){let n=t.runtime,r=Object.create(n),s=async e=>{if(typeof e!="string")return e;let a=(await n.listDevices()).find(d=>d.deviceId===e);if(!a)throw new Error(`OpenRTC device '${e}' is not currently discoverable.`);return a},c=async e=>({...e,localDeviceId:e?.localDeviceId??await n.getLocalDeviceId()??""}),p=async e=>{let{device:o,scope:a,...d}=e,g=d.deviceId??(typeof o=="string"?o:o?.deviceId)??null,y=d.ticket??(typeof o=="string"?void 0:o?.ticket);g&&!y&&(y=(await s(g).catch(()=>null))?.ticket);let P={...d,scope:a??"session"};return g&&(P.deviceId=g),y&&(P.ticket=y),P},l={list:()=>n.listDevices(),startSession:(e={})=>n.startManagedSession({...e,platform:e.platform??i}),stopSession:e=>n.stopManagedSession(e),listWithStatus:()=>n.listDevicesWithStatus(),watch:e=>n.watchDevices(e),watchWithStatus:e=>n.watchDevicesWithStatus(e),connect:async(e,o)=>n.connectDevice(await s(e),await c(o)),connectWithRetry:async(e,o,a)=>n.connectDeviceWithRetry(await s(e),o,a),disconnect:e=>n.disconnectDevice(e),update:(e,o)=>n.updateDevice(e,o),delete:e=>n.deleteDevice(e),localId:()=>n.getLocalDeviceId(),localInfo:()=>n.getLocalDeviceInfo(),localProfile:e=>n.getLocalDeviceProfile(e),updateLocalName:e=>n.updateLocalDeviceName(e)},u={watch:e=>n.watchPeerStates(e),watchLifecycle:e=>n.watchPeerLifecycle(e),get:e=>n.getPeerState(e),listConnected:()=>n.listConnectedPeers(),connect:e=>n.connectPeer(e),disconnect:(e,o)=>n.disconnectPeer(e,o),forceDisconnect:e=>n.forceDisconnectPeer(e),session:e=>n.getPeerSession(e),sessions:()=>n.listPeerSessions(),waitConnected:(e,o)=>n.waitForConnectedPeer(e,o),readiness:(e,o)=>n.getPeerReadiness(e,o),health:e=>n.getPeerHealth(e),identity:e=>n.resolvePeerIdentity(e),addScope:(e,o)=>n.addPeerScope(e,o),releaseScope:(e,o)=>n.releasePeerScope(e,o),scopes:e=>n.getPeerScopes(e),refresh:()=>n.refreshPeerSnapshot()},m={register:e=>n.registerChannel(e),unregister:e=>n.unregisterChannel(e),list:()=>n.listChannels(),openBi:(e,o,a)=>n.openPeerBi(e,{...a,channelId:o}),openUni:(e,o,a)=>n.openPeerUni(e,{...a,channelId:o}),onIncoming:e=>n.onIncomingStream(e),onIncomingChannel:(e,o)=>n.onIncomingChannelStream(e,a=>{if(a.channel)return o(a)}),connect:async e=>n.connectScopedChannel(await p(e)),connectScoped:e=>n.connectScopedChannel(e)},R={create:e=>n.createRoom(e),join:(e,o)=>n.joinRoom(e,o),leave:e=>n.leaveRoom(e),watch:(e,o)=>n.watchRoom(e,o),members:e=>n.getRoomMembers(e)},C={raw:()=>n.getInvite(),share:e=>n.getTicketWithToken("share",e?.maxConnections??1),grant:(e,o)=>n.getTicketWithToken(e,o?.maxConnections??0),revoke:e=>n.revokeTokensByScope(e)},A={status:()=>n.getRuntimeStatus(),policy:()=>n.getRuntimePolicy(),capabilities:()=>n.getRuntimeCapabilities(),capabilityProfile:()=>n.getCapabilityProfile(),connectionStates:()=>n.getConnectionStates(),onConnectionStateChange:e=>n.onConnectionStateChange(e),connections:()=>n.getConnections(),applicationReadyConnections:e=>n.getApplicationReadyConnections(e),onConnection:e=>n.onConnection(e),onDisconnection:e=>n.onDisconnection(e),onConnectionEvent:e=>n.onConnectionEvent(e),forceReconnectSnapshot:()=>n.forceReconnectSnapshot(),peerReconciliation:()=>n.getPeerReconciliationStats()},x={runtime:n,assembly:t,nodeId:()=>n.getNodeId(),nodeIdFromTicket:e=>n.getNodeIdFromTicket(e),endpointTicket:()=>n.getEndpointTicket(),connectRaw:e=>n.connectRaw(e),openBi:e=>n.openBi(e),openUni:e=>n.openUni(e),isConnected:e=>n.isConnected(e),disconnectNode:e=>n.disconnectNode(e),setAutoConnectExcluded:(e,o)=>n.setAutoConnectExcluded(e,o)};return Object.defineProperties(r,{devices:{get:()=>l,enumerable:true},peers:{get:()=>u,enumerable:true},channels:{get:()=>m,enumerable:true},rooms:{get:()=>R,enumerable:true},tickets:{get:()=>C,enumerable:true},diagnostics:{get:()=>A,enumerable:true},advanced:{get:()=>x,enumerable:true},setAuth:{value:e=>t.setAuthContext(e),enumerable:true,writable:true,configurable:true},setAuthContext:{value:e=>t.setAuthContext(e),enumerable:true,writable:true,configurable:true},syncPlutoAuth:{value:e=>t.syncPlutoAuth(e),enumerable:true,writable:true,configurable:true},bindPlutoAuthHost:{value:()=>t.bindPlutoAuthHost(),enumerable:true,writable:true,configurable:true},signIn:{value:()=>t.signInWithPluto(),enumerable:true,writable:true,configurable:true},signOut:{value:()=>t.signOut(),enumerable:true,writable:true,configurable:true},runtime:{get:()=>n,enumerable:false},_assembly:{get:()=>t,enumerable:false}}),r}function I(t){let i=O(t),n=z(i);return T(n,"web")}I.native=function(t,i){let n=O(t),r=i??g(),s=A(n,r);return T(s,"native")};var ie="https://api.openrtc.app";async function re(t,i,n){let r=t.replace(/\/$/,""),s=await fetch(`${r}/v1/spaces/${encodeURIComponent(n)}/scoped-auth`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:"{}"}),c=await s.json().catch(()=>({}));if(!s.ok){let p=typeof c?.error=="string"?c.error:`enableSpaceAuth failed (${s.status})`;throw new Error(p)}return c}async function se(t,i,n){let r=await fetch(t,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),s=await r.json().catch(()=>({}));if(!r.ok){let c=typeof s?.error=="string"?s.error:`mintSpaceToken failed (${r.status})`;throw new Error(c)}if(typeof s?.token!="string"||!s.token.trim())throw new Error("mintSpaceToken response missing token");return s}function S(t){let i=t.apiKey.trim(),n=(t.spaceKey??t.space??"").trim(),r=k(t.sandboxAppId),s=(t.endpointUrl??ie).replace(/\/$/,""),c=t.memberIdStorageKey??`openrtc:space-member:${n}${r?`:sandbox:${r}`:""}`;return async()=>{if(!i||!n)throw new Error("spaceToken requires apiKey and space");let p=null;typeof sessionStorage<"u"?(p=sessionStorage.getItem(c),p||(p=globalThis.crypto?.randomUUID?.()??`member-${Date.now()}`,sessionStorage.setItem(c,p))):p=`member-${Date.now()}`;let l=await fetch(`${s}/v1SpacePublicTokens`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:i,spaceKey:n,memberId:p,...r?{sandboxAppId:r}:{}})}),{text:u,payload:m}=await ce(l);if(!l.ok){let C=typeof m?.error=="string"?m.error:u.trim()?u.trim().slice(0,240):`public space token mint failed (${l.status})`;throw new Error(C)}let R=typeof m?.token=="string"?m.token.trim():"";if(!R)throw new Error("public space token response missing token");return {customToken:R}}}function ae(t){if(!t.trim())return {};try{let i=JSON.parse(t);return i&&typeof i=="object"?i:{}}catch{return {}}}async function ce(t){let i=t.text;if(typeof i=="function"){let r=await i.call(t).catch(()=>"");return {text:r,payload:ae(r)}}let n=await t.json().catch(()=>({}));return {text:JSON.stringify(n),payload:n&&typeof n=="object"?n:{}}}function k(t){let i=t?.trim().toLowerCase()??"";if(!i)return "";if(!/^[a-z0-9][a-z0-9-]{0,47}$/.test(i))throw new Error("sandboxAppId must be 1-48 lowercase letters, numbers, or dashes.");return i}function pe(t,i){let n=t.trim(),r=k(i);return r?`${n}::sandbox::${r}`:n}var me=S,le=S;
|
|
2
|
+
export{I as OpenRTC,S as createPublicSpaceTokenProvider,le as createSpaceTokenProvider,re as enableSpaceAuth,se as mintSpaceToken,pe as sandboxSpaceKey,me as spaceToken};
|
package/dist/openrtc_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { D as DelegatingRuntimeAdapter, W as WasmBridgeOptions } from '../DelegatingRuntimeAdapter-
|
|
1
|
+
import { D as DelegatingRuntimeAdapter, W as WasmBridgeOptions } from '../DelegatingRuntimeAdapter-BxOcVIx_.js';
|
|
2
|
+
import '../types-D0fRvUbN.js';
|
|
2
3
|
|
|
3
4
|
declare class WasmRuntimeAdapter extends DelegatingRuntimeAdapter {
|
|
4
5
|
constructor(options: WasmBridgeOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as WasmRuntimeAdapter}from'../chunk-
|
|
1
|
+
export{a as WasmRuntimeAdapter}from'../chunk-IUHUYHNZ.js';import'../chunk-WNJE3MJF.js';import'../chunk-FQETZQPW.js';import'../chunk-BLOEZIFJ.js';
|