openrtc 0.1.2 → 0.2.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 +26 -3
- package/dist/DelegatingRuntimeAdapter-CjHzBEBA.d.ts +180 -0
- package/dist/{IpcRuntimeAdapter-CT-W0Mtp.d.ts → IpcRuntimeAdapter-CtckyMol.d.ts} +2 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/internal.js +1 -1
- package/dist/chunk-3VTF5RKW.js +1 -0
- package/dist/chunk-JXGKO7SX.js +1 -0
- package/dist/chunk-MFT6SOZ6.js +3 -0
- package/dist/chunk-SGZWR63E.js +1 -0
- package/dist/chunk-VARALO7G.js +1 -0
- package/dist/chunk-WOHFM6DI.js +2 -0
- package/dist/chunk-YHJOXD46.js +2 -0
- package/dist/{factories-0TxDPMeu.d.ts → factories-CwZiIRg1.d.ts} +412 -226
- package/dist/index.d.ts +100 -6
- 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 +205 -391
- 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-DyCGvj9l.d.ts} +200 -170
- package/package.json +12 -10
- package/dist/chunk-4MH42GUI.js +0 -2
- package/dist/chunk-CQAKCS2S.js +0 -4
- 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,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
import {
|
|
1
|
+
import { R as RuntimeClientOptions, a as RuntimeClient, b as RuntimeDevice, c as RuntimeDeviceStatusSnapshot, d as RuntimeDeviceConnectOptions, e as RuntimeLocalDeviceInfo, f as RuntimeLocalDeviceProfile, g as RuntimePeerState, h as RuntimePeerConnectOptions, C as Connection, i as RuntimePeerReadinessSnapshot, j as RuntimePeerHealth, k as RuntimeChannelDescriptor, l as RuntimePeerStreamOptions, m as RuntimeIncomingStream, n as RuntimeScopedChannelOptions, o as RuntimeScopedLogicalChannel, p as RuntimePolicySnapshot, q as RuntimeConnectionStateSnapshot, r as RuntimeApplicationPayloadReadinessOptions, s as RuntimeConnectionEvent, P as PeerReconciliationStats, t as PlutoRuntimeAssembly, u as RuntimeRawConnection, I as ITransport } from './factories-CwZiIRg1.js';
|
|
2
|
+
export { v as ChannelDescriptor, w as ConnectionEvent, x as ConnectionTarget, D as DeviceProfile, y as IncomingStream, O as OPENRTC_RUNTIME_POLICY, z as PeerConnectOptions, A as PeerReadiness, B as PeerStreamOptions, E as PresenceLoopOptions, F as RawConnection, G as RuntimeAuthContext, H as RuntimeAuthIdentity, J as RuntimeAutoConnectPolicy, K as RuntimeConnectionTarget, L as RuntimeDeviceStatus, M as RuntimeJoinRoomOptions, N as RuntimeLogicalChannelFraming, Q as RuntimeManagedSession, S as RuntimeManagedSessionKind, T as RuntimeManagedSessionOptions, U as RuntimeManagedSessionPlatform, V as RuntimePeerLifecycleStatus, W as RuntimePeerScope, X as RuntimePeerSessionSnapshot, Y as RuntimePresenceLoopOptions, Z as RuntimePresencePolicy, _ as RuntimeRoomMember, $ as RuntimeSession, a0 as RuntimeUiConnectionStatus, a1 as ScopedChannelOptions, a2 as ScopedLogicalChannel, a3 as ScopedSession, a4 as Session, a5 as SessionOptions, a6 as getRuntimePolicy } from './factories-CwZiIRg1.js';
|
|
3
|
+
import { k as ConnectDeviceResult, l as ConnectDeviceHooks, m as ConnectDeviceOptions, P as PeerSessionSnapshot, c as ResolvedPeerIdentity, n as ProtocolName, o as ProtocolCapability, p as ProtocolCapabilityMap, q as ApplicationPayloadCrypto, r as ApplicationCryptoStreamTools, s as SpaceTokenProvider } from './types-DyCGvj9l.js';
|
|
4
|
+
export { t as AppLimits, u as ApplicationCryptoBiStream, v as ApplicationPayloadReadinessOptions, w as ApplicationPayloadRouteOptions, x as ApplicationPayloadSendOptions, A as AuthMode, D as DiscoveryMode, G as GrantScope, y as ProtocolBaseName, z as ProtocolImplementationKind, F as ProtocolLocality, S as SignalingMode, H as SpaceAuthMode } from './types-DyCGvj9l.js';
|
|
5
|
+
import { R as RuntimeCapabilities, a as RuntimeCapabilityProfile, A as AuthContext } from './DelegatingRuntimeAdapter-CjHzBEBA.js';
|
|
6
|
+
export { b as RuntimeAdapterKind } from './DelegatingRuntimeAdapter-CjHzBEBA.js';
|
|
7
|
+
import { P as PlutoIpcBridge } from './IpcRuntimeAdapter-CtckyMol.js';
|
|
8
|
+
export { TRANSPORT_LABELS, isDirectIrohTransportLabel, isIndependentTransportLabel, isIrohBaseTransportLabel, isOptionalTransportLabel, isWebRtcTransportLabel, normalizeTransportLabel } from './transport/index.js';
|
|
6
9
|
import './runtime/WasmRuntimeAdapter.js';
|
|
7
10
|
|
|
8
11
|
interface OpenRTCDeviceNamespace {
|
|
@@ -31,6 +34,7 @@ interface OpenRTCDeviceNamespace {
|
|
|
31
34
|
}
|
|
32
35
|
interface OpenRTCPeerNamespace {
|
|
33
36
|
watch(callback: (peers: RuntimePeerState[]) => void): () => void;
|
|
37
|
+
watchLifecycle(callback: (peers: RuntimePeerState[]) => void): () => void;
|
|
34
38
|
get(id: string): RuntimePeerState | undefined;
|
|
35
39
|
listConnected(): RuntimePeerState[];
|
|
36
40
|
connect(options: RuntimePeerConnectOptions): Promise<Connection>;
|
|
@@ -64,6 +68,7 @@ interface OpenRTCChannelNamespace {
|
|
|
64
68
|
onIncomingChannel(channelId: string, callback: (stream: RuntimeIncomingStream & {
|
|
65
69
|
channel: NonNullable<RuntimeIncomingStream['channel']>;
|
|
66
70
|
}) => boolean | void): () => void;
|
|
71
|
+
connectScoped(options: RuntimeScopedChannelOptions): Promise<RuntimeScopedLogicalChannel>;
|
|
67
72
|
}
|
|
68
73
|
interface OpenRTCDiagnosticsNamespace {
|
|
69
74
|
status(): Promise<{
|
|
@@ -74,13 +79,16 @@ interface OpenRTCDiagnosticsNamespace {
|
|
|
74
79
|
}>;
|
|
75
80
|
policy(): RuntimePolicySnapshot;
|
|
76
81
|
capabilities(): RuntimeCapabilities;
|
|
82
|
+
capabilityProfile(): RuntimeCapabilityProfile;
|
|
77
83
|
connectionStates(): Promise<RuntimeConnectionStateSnapshot[]>;
|
|
78
84
|
onConnectionStateChange(callback: (state: RuntimeConnectionStateSnapshot) => void): Promise<() => void> | (() => void);
|
|
79
85
|
connections(): Connection[];
|
|
86
|
+
applicationReadyConnections(options?: RuntimeApplicationPayloadReadinessOptions): Connection[];
|
|
80
87
|
onConnection(callback: (connection: Connection) => void): () => void;
|
|
81
88
|
onDisconnection(callback: (connection: Connection) => void): () => void;
|
|
82
89
|
onConnectionEvent(callback: (event: RuntimeConnectionEvent) => void): () => void;
|
|
83
90
|
forceReconnectSnapshot(): void;
|
|
91
|
+
peerReconciliation(): Readonly<PeerReconciliationStats>;
|
|
84
92
|
}
|
|
85
93
|
interface OpenRTCAdvancedNamespace {
|
|
86
94
|
readonly runtime: RuntimeClient;
|
|
@@ -154,7 +162,93 @@ declare namespace OpenRTC {
|
|
|
154
162
|
var native: (options: RuntimeClientOptions, bridge?: PlutoIpcBridge) => OpenRTCClient;
|
|
155
163
|
}
|
|
156
164
|
|
|
165
|
+
declare class TransportFactory {
|
|
166
|
+
private static readonly capabilityMap;
|
|
167
|
+
static createTransport(name: ProtocolName): ITransport;
|
|
168
|
+
static getProtocolCapability(name: ProtocolName): ProtocolCapability;
|
|
169
|
+
static getProtocolCapabilities(): ProtocolCapabilityMap;
|
|
170
|
+
static getPreferredProtocolOrder(options?: {
|
|
171
|
+
runtime?: 'browser' | 'native' | 'any';
|
|
172
|
+
includePathLabels?: boolean;
|
|
173
|
+
}): ProtocolName[];
|
|
174
|
+
static assertProtocolAvailable(name: ProtocolName): void;
|
|
175
|
+
}
|
|
176
|
+
declare function getPreferredProtocolOrder(options?: Parameters<typeof TransportFactory.getPreferredProtocolOrder>[0]): ProtocolName[];
|
|
177
|
+
|
|
178
|
+
declare function isApplicationEncryptedPayload(payload: Uint8Array): boolean;
|
|
179
|
+
declare function createSharedSecretApplicationCrypto(key: Uint8Array, options?: {
|
|
180
|
+
requireEncrypted?: boolean;
|
|
181
|
+
randomBytes?: (byteLength: number) => Uint8Array;
|
|
182
|
+
replayProtection?: boolean;
|
|
183
|
+
}): ApplicationPayloadCrypto;
|
|
184
|
+
declare function createApplicationCryptoStreamTools(crypto: ApplicationPayloadCrypto, options?: {
|
|
185
|
+
typeId?: number;
|
|
186
|
+
maxFrameBytes?: number;
|
|
187
|
+
}): ApplicationCryptoStreamTools;
|
|
188
|
+
|
|
189
|
+
declare const KEY_AGREEMENT_PUBLIC_KEY_BYTES = 32;
|
|
190
|
+
declare const KEY_AGREEMENT_ALGORITHM = "openrtc:x25519-hkdf:v1";
|
|
191
|
+
interface ApplicationKeyAgreementPayload {
|
|
192
|
+
algorithm: typeof KEY_AGREEMENT_ALGORITHM;
|
|
193
|
+
publicKey: string;
|
|
194
|
+
}
|
|
195
|
+
interface EphemeralKeyAgreement {
|
|
196
|
+
publicKey: Uint8Array;
|
|
197
|
+
secretKey: Uint8Array;
|
|
198
|
+
}
|
|
199
|
+
declare function generateEphemeralKeyAgreement(randomBytes?: (byteLength: number) => Uint8Array): EphemeralKeyAgreement;
|
|
200
|
+
declare function deriveApplicationCryptoKey(localSecretKey: Uint8Array, remotePublicKey: Uint8Array, localNodeId: string, remoteNodeId: string): Uint8Array;
|
|
201
|
+
declare function encodeApplicationKeyAgreementPayload(publicKey: Uint8Array): ApplicationKeyAgreementPayload;
|
|
202
|
+
|
|
203
|
+
type MintSpaceTokenRequest = {
|
|
204
|
+
spaceKey: string;
|
|
205
|
+
memberId?: string;
|
|
206
|
+
ttl?: number;
|
|
207
|
+
sandboxAppId?: string;
|
|
208
|
+
};
|
|
209
|
+
type MintSpaceTokenResponse = {
|
|
210
|
+
token: string;
|
|
211
|
+
expiresAt: number;
|
|
212
|
+
tokenLifetimeSeconds: number;
|
|
213
|
+
namespaceId: string;
|
|
214
|
+
spaceAppTag: string;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Mint a namespace-scoped Firebase custom token from your backend using the
|
|
218
|
+
* OpenRTC `POST /v1/spaces/tokens` endpoint. Never call this from browser code
|
|
219
|
+
* with a secret key — proxy through your server.
|
|
220
|
+
*/
|
|
221
|
+
type EnableSpaceAuthResponse = {
|
|
222
|
+
success: true;
|
|
223
|
+
space: {
|
|
224
|
+
namespaceId: string;
|
|
225
|
+
requireScopedAuth: boolean;
|
|
226
|
+
status: 'active' | 'revoked';
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Opt a provisioned space into scoped-auth mode (required for all spaces).
|
|
231
|
+
* Call from your backend with sk_live_... only.
|
|
232
|
+
*/
|
|
233
|
+
declare function enableSpaceAuth(endpointUrl: string, secretKey: string, namespaceId: string): Promise<EnableSpaceAuthResponse>;
|
|
234
|
+
declare function mintSpaceToken(endpointUrl: string, secretKey: string, request: MintSpaceTokenRequest): Promise<MintSpaceTokenResponse>;
|
|
235
|
+
/**
|
|
236
|
+
* Browser-safe space auth for static sites. Calls the rate-limited
|
|
237
|
+
* `v1SpacePublicTokens` endpoint (pk_live_ + spaceKey only).
|
|
238
|
+
*/
|
|
239
|
+
declare function createPublicSpaceTokenProvider(options: {
|
|
240
|
+
apiKey: string;
|
|
241
|
+
space?: string;
|
|
242
|
+
spaceKey?: string;
|
|
243
|
+
endpointUrl?: string;
|
|
244
|
+
memberIdStorageKey?: string;
|
|
245
|
+
sandboxAppId?: string;
|
|
246
|
+
}): SpaceTokenProvider;
|
|
247
|
+
declare function sandboxSpaceKey(spaceKey: string, sandboxAppId?: string): string;
|
|
248
|
+
declare const spaceToken: typeof createPublicSpaceTokenProvider;
|
|
249
|
+
declare const createSpaceTokenProvider: typeof createPublicSpaceTokenProvider;
|
|
250
|
+
|
|
157
251
|
type UpgradeState = 'none' | 'upgrading' | 'upgraded' | 'failed';
|
|
158
252
|
type OutboundMessage = string | object | ArrayBuffer | Uint8Array;
|
|
159
253
|
|
|
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 };
|
|
254
|
+
export { ApplicationCryptoStreamTools, type ApplicationKeyAgreementPayload, ApplicationPayloadCrypto, type EnableSpaceAuthResponse, KEY_AGREEMENT_ALGORITHM, KEY_AGREEMENT_PUBLIC_KEY_BYTES, type MintSpaceTokenRequest, type MintSpaceTokenResponse, OpenRTC, type OpenRTCClient, RuntimeClientOptions as OpenRTCOptions, type OutboundMessage, ProtocolCapability, ProtocolCapabilityMap, ProtocolName, RuntimeApplicationPayloadReadinessOptions, RuntimeCapabilities, RuntimeChannelDescriptor, RuntimeClientOptions, RuntimeConnectionEvent, RuntimeConnectionStateSnapshot, RuntimeDevice, RuntimeDeviceConnectOptions, RuntimeDeviceStatusSnapshot, RuntimeIncomingStream, RuntimeLocalDeviceInfo, RuntimeLocalDeviceProfile, RuntimePeerConnectOptions, RuntimePeerHealth, RuntimePeerReadinessSnapshot, RuntimePeerState, RuntimePeerStreamOptions, RuntimePolicySnapshot, RuntimeRawConnection, 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 {r,s}from'./chunk-MFT6SOZ6.js';export{c as KEY_AGREEMENT_ALGORITHM,b as KEY_AGREEMENT_PUBLIC_KEY_BYTES,g as ScopedSession,e as deriveApplicationCryptoKey,f as encodeApplicationKeyAgreementPayload,d as generateEphemeralKeyAgreement,a as getPreferredProtocolOrder}from'./chunk-MFT6SOZ6.js';import'./chunk-VARALO7G.js';import {b}from'./chunk-WOHFM6DI.js';export{q as OPENRTC_RUNTIME_POLICY,h as createApplicationCryptoStreamTools,g as createSharedSecretApplicationCrypto,r as getRuntimePolicy,f as isApplicationEncryptedPayload}from'./chunk-JXGKO7SX.js';import {m}from'./chunk-YHJOXD46.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-3VTF5RKW.js';function C(t){let n=m({...t});if("auth"in t&&!t.authMode){let o=t.auth;n.authMode=o==="none"?"anonymous":o;}if("identity"in t&&!t.nodeIdPersistence){let o=t.identity;n.nodeIdPersistence=o==="temporary"?"ephemeral":o;}return "namespace"in t&&!t.storagePrefix&&(n.storagePrefix=t.namespace),"privacy"in t&&t.strictMode===void 0&&(n.strictMode=!!t.privacy),n}function h(t){let n=t.runtime,o=Object.create(n),r=async e=>{if(typeof e!="string")return e;let s=(await n.listDevices()).find(b=>b.deviceId===e);if(!s)throw new Error(`OpenRTC device '${e}' is not currently discoverable.`);return s},a=async e=>({...e,localDeviceId:e?.localDeviceId??await n.getLocalDeviceId()??""}),c={list:()=>n.listDevices(),listWithStatus:()=>n.listDevicesWithStatus(),watch:e=>n.watchDevices(e),watchWithStatus:e=>n.watchDevicesWithStatus(e),connect:async(e,i)=>n.connectDevice(await r(e),await a(i)),connectWithRetry:async(e,i,s)=>n.connectDeviceWithRetry(await r(e),i,s),disconnect:e=>n.disconnectDevice(e),update:(e,i)=>n.updateDevice(e,i),delete:e=>n.deleteDevice(e),localId:()=>n.getLocalDeviceId(),localInfo:()=>n.getLocalDeviceInfo(),localProfile:e=>n.getLocalDeviceProfile(e),updateLocalName:e=>n.updateLocalDeviceName(e)},p={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,i)=>n.disconnectPeer(e,i),forceDisconnect:e=>n.forceDisconnectPeer(e),session:e=>n.getPeerSession(e),sessions:()=>n.listPeerSessions(),waitConnected:(e,i)=>n.waitForConnectedPeer(e,i),readiness:(e,i)=>n.getPeerReadiness(e,i),health:e=>n.getPeerHealth(e),identity:e=>n.resolvePeerIdentity(e),addScope:(e,i)=>n.addPeerScope(e,i),releaseScope:(e,i)=>n.releasePeerScope(e,i),scopes:e=>n.getPeerScopes(e),refresh:()=>n.refreshPeerSnapshot()},d={register:e=>n.registerChannel(e),unregister:e=>n.unregisterChannel(e),list:()=>n.listChannels(),openBi:(e,i,s)=>n.openPeerBi(e,{...s,channelId:i}),openUni:(e,i,s)=>n.openPeerUni(e,{...s,channelId:i}),onIncoming:e=>n.onIncomingStream(e),onIncomingChannel:(e,i)=>n.onIncomingChannelStream(e,s=>{if(s.channel)return i(s)}),connectScoped:e=>n.connectScopedChannel(e)},l={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()},m={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,i)=>n.setAutoConnectExcluded(e,i)};return Object.defineProperties(o,{devices:{get:()=>c,enumerable:true},peers:{get:()=>p,enumerable:true},channels:{get:()=>d,enumerable:true},diagnostics:{get:()=>l,enumerable:true},advanced:{get:()=>m,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}}),o}function v(t){let n=C(t),o=r(n);return h(o)}v.native=function(t,n){let o=C(t),r=n??b(),a=s(o,r);return h(a)};var z="https://api.openrtc.app";async function j(t,n,o){let r=t.replace(/\/$/,""),a=await fetch(`${r}/v1/spaces/${encodeURIComponent(o)}/scoped-auth`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:"{}"}),c=await a.json().catch(()=>({}));if(!a.ok){let p=typeof c?.error=="string"?c.error:`enableSpaceAuth failed (${a.status})`;throw new Error(p)}return c}async function H(t,n,o){let r=await fetch(t,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify(o)}),a=await r.json().catch(()=>({}));if(!r.ok){let c=typeof a?.error=="string"?a.error:`mintSpaceToken failed (${r.status})`;throw new Error(c)}if(typeof a?.token!="string"||!a.token.trim())throw new Error("mintSpaceToken response missing token");return a}function u(t){let n=t.apiKey.trim(),o=(t.spaceKey??t.space??"").trim(),r=S(t.sandboxAppId),a=(t.endpointUrl??z).replace(/\/$/,""),c=t.memberIdStorageKey??`openrtc:space-member:${o}${r?`:sandbox:${r}`:""}`;return async()=>{if(!n||!o)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 d=await fetch(`${a}/v1SpacePublicTokens`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:n,spaceKey:o,memberId:p,...r?{sandboxAppId:r}:{}})}),l=await d.json().catch(()=>({}));if(!d.ok){let e=typeof l?.error=="string"?l.error:`public space token mint failed (${d.status})`;throw new Error(e)}let m=typeof l?.token=="string"?l.token.trim():"";if(!m)throw new Error("public space token response missing token");return {customToken:m}}}function S(t){let n=t?.trim().toLowerCase()??"";if(!n)return "";if(!/^[a-z0-9][a-z0-9-]{0,47}$/.test(n))throw new Error("sandboxAppId must be 1-48 lowercase letters, numbers, or dashes.");return n}function q(t,n){let o=t.trim(),r=S(n);return r?`${o}::sandbox::${r}`:o}var F=u,G=u;
|
|
2
|
+
export{v as OpenRTC,u as createPublicSpaceTokenProvider,G as createSpaceTokenProvider,j as enableSpaceAuth,H as mintSpaceToken,q as sandboxSpaceKey,F 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-CjHzBEBA.js';
|
|
2
|
+
import '../types-DyCGvj9l.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-VARALO7G.js';import'../chunk-JXGKO7SX.js';import'../chunk-YHJOXD46.js';import'../chunk-3VTF5RKW.js';
|