openrtc 1.0.5 → 1.0.7

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.
@@ -1,4 +1,4 @@
1
- import { D as DiscoveryMode, A as AuthMode, S as SignalingMode, E as ExplicitFileDataSendParams, I as ISignalingBackend, c as RuntimeIdentity, d as Device, e as DeviceStatusSnapshot, P as PeerSessionSnapshot, R as ResolvedPeerIdentity, M as ManagedConnectionRecord, f as SignalingEnvelope, g as DeviceEvent, h as SignalingSession, i as SessionEvent, L as LocalDeviceInfo, N as NativeManagedSessionStartResult, G as GrantScope, B as BackendPeerBiStream, j as BackendPeerUniStream, k as NativeConnectParams, l as NativeConnectResult, m as BackendConnectionState } from './types-BCkKK8dy.js';
1
+ import { D as DiscoveryMode, A as AuthMode, d as SignalingMode, E as ExplicitFileDataSendParams, I as ISignalingBackend, e as RuntimeIdentity, f as Device, g as DeviceStatusSnapshot, P as PeerSessionSnapshot, R as ResolvedPeerIdentity, M as ManagedConnectionRecord, h as SignalingEnvelope, i as DeviceEvent, j as SignalingSession, k as SessionEvent, L as LocalDeviceInfo, N as NativeManagedSessionStartResult, G as GrantScope, B as BackendPeerBiStream, l as BackendPeerUniStream, m as NativeConnectParams, n as NativeConnectResult, o as BackendConnectionState } from './types-ZDsZknDI.js';
2
2
  import { A as AuthContext } from './IEngineBridge-C7OT2CRv.js';
3
3
  import { R as RuntimeCapabilities } from './capabilities-C4Dqs_pB.js';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import { A as AuthContext } from './IEngineBridge-C7OT2CRv.js';
2
- import { G as GrantScope, I as ISignalingBackend, a as ConnectDeviceHooks, b as ConnectDeviceOptions, C as ConnectDeviceResult, M as ManagedConnectionRecord, P as PeerSessionSnapshot, R as ResolvedPeerIdentity, W as AppLimits, k as NativeConnectParams, l as NativeConnectResult, E as ExplicitFileDataSendParams } from './types-BCkKK8dy.js';
3
- import { h as RuntimePeerState, s as RuntimeConnectionStateSnapshot, j as RuntimePeerReadinessSnapshot, i as RuntimePeerConnectOptions, C as Connection, n as RuntimeIncomingStream, R as RuntimeClientOptions, H as RuntimeAuthIdentity, f as RuntimeLocalDeviceInfo, g as RuntimeLocalDeviceProfile, c as RuntimeDevice, a as RuntimeManagedSessionOptions, b as RuntimeManagedSession, d as RuntimeDeviceStatusSnapshot, e as RuntimeDeviceConnectOptions, X as RuntimeSession, q as RuntimeJoinRoomOptions, r as RuntimeRoomMember, K as RuntimeConnectionTarget, o as RuntimeScopedChannelOptions, p as RuntimeScopedLogicalChannel, m as RuntimePeerStreamOptions, v as RuntimeRawConnection, l as RuntimeChannelDescriptor, V as RuntimePresenceLoopOptions, k as RuntimePeerHealth, t as RuntimeApplicationPayloadReadinessOptions, u as RuntimeConnectionEvent } from './types-QMj23Nvm.js';
2
+ import { G as GrantScope, I as ISignalingBackend, b as ConnectDeviceHooks, c as ConnectDeviceOptions, C as ConnectDeviceResult, M as ManagedConnectionRecord, P as PeerSessionSnapshot, R as ResolvedPeerIdentity, X as AppLimits, m as NativeConnectParams, n as NativeConnectResult, E as ExplicitFileDataSendParams } from './types-ZDsZknDI.js';
3
+ import { h as RuntimePeerState, s as RuntimeConnectionStateSnapshot, j as RuntimePeerReadinessSnapshot, i as RuntimePeerConnectOptions, C as Connection, n as RuntimeIncomingStream, R as RuntimeClientOptions, H as RuntimeAuthIdentity, f as RuntimeLocalDeviceInfo, g as RuntimeLocalDeviceProfile, c as RuntimeDevice, a as RuntimeManagedSessionOptions, b as RuntimeManagedSession, d as RuntimeDeviceStatusSnapshot, e as RuntimeDeviceConnectOptions, X as RuntimeSession, q as RuntimeJoinRoomOptions, r as RuntimeRoomMember, K as RuntimeConnectionTarget, o as RuntimeScopedChannelOptions, p as RuntimeScopedLogicalChannel, m as RuntimePeerStreamOptions, v as RuntimeRawConnection, l as RuntimeChannelDescriptor, V as RuntimePresenceLoopOptions, k as RuntimePeerHealth, t as RuntimeApplicationPayloadReadinessOptions, u as RuntimeConnectionEvent } from './types-N9s66nF8.js';
4
4
  import { R as RuntimeCapabilities, a as RuntimeCapabilityProfile } from './capabilities-C4Dqs_pB.js';
5
5
 
6
6
  /**
@@ -0,0 +1,2 @@
1
+ import {o}from'./chunk-HVTYSEU7.js';function D(t){let i=o({...t});if("auth"in t&&!t.authMode){let n=t.auth;i.authMode=n==="none"?"anonymous":n;}if("identity"in t){let n=t.identity,s=n==="temporary"?"ephemeral":n;!t.deviceIdPersistence&&!t.nodeIdPersistence&&(i.deviceIdPersistence=s),!t.endpointIdPersistence&&!t.nodeIdPersistence&&(i.endpointIdPersistence=s);}return "namespace"in t&&!t.storagePrefix&&(i.storagePrefix=t.namespace),"privacy"in t&&t.strictMode===void 0&&(i.strictMode=!!t.privacy),i}function x(t,i){let n=t.runtime,s=Object.create(n),r=async e=>{if(typeof e!="string")return e;let a=(await n.listDevices()).find(l=>l.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()??""}),m=async e=>{let{device:o,scope:a,...l}=e,R=l.deviceId??(typeof o=="string"?o:o?.deviceId)??null,P=l.ticket??(typeof o=="string"?void 0:o?.ticket);R&&!P&&(P=(await r(R).catch(()=>null))?.ticket);let h={...l,scope:a??"session"};return R&&(h.deviceId=R),P&&(h.ticket=P),h},d={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 r(e),await c(o)),connectWithRetry:async(e,o,a)=>n.connectDeviceWithRetry(await r(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()},p={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 m(e)),connectScoped:e=>n.connectScopedChannel(e)},g={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)},v={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)},b={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()},f={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),notifyNetworkChange:e=>n.notifyNetworkChange(e)};return Object.defineProperties(s,{devices:{get:()=>d,enumerable:true},peers:{get:()=>u,enumerable:true},channels:{get:()=>p,enumerable:true},rooms:{get:()=>g,enumerable:true},tickets:{get:()=>v,enumerable:true},diagnostics:{get:()=>b,enumerable:true},advanced:{get:()=>f,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}}),s}var I="https://api.openrtc.app";async function N(t,i,n){let s=t.replace(/\/$/,""),r=await fetch(`${s}/v1/spaces/${encodeURIComponent(n)}/scoped-auth`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:"{}"}),c=await r.json().catch(()=>({}));if(!r.ok){let m=typeof c?.error=="string"?c.error:`enableSpaceAuth failed (${r.status})`;throw new Error(m)}return c}async function M(t,i,n){let s=await fetch(t,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),r=await s.json().catch(()=>({}));if(!s.ok){let c=typeof r?.error=="string"?r.error:`mintSpaceToken failed (${s.status})`;throw new Error(c)}if(typeof r?.token!="string"||!r.token.trim())throw new Error("mintSpaceToken response missing token");return r}function S(t){let i=t.apiKey.trim(),n=(t.spaceKey??t.space??"").trim(),s=y(t.sandboxAppId),r=(t.endpointUrl??I).replace(/\/$/,""),c=t.memberIdStorageKey??`openrtc:space-member:${n}${s?`:sandbox:${s}`:""}`;return async()=>{if(!i||!n)throw new Error("spaceToken requires apiKey and space");let m=null;typeof sessionStorage<"u"?(m=sessionStorage.getItem(c),m||(m=globalThis.crypto?.randomUUID?.()??`member-${Date.now()}`,sessionStorage.setItem(c,m))):m=`member-${Date.now()}`;let d=await fetch(`${r}/v1SpacePublicTokens`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:i,spaceKey:n,memberId:m,...s?{sandboxAppId:s}:{}})}),{text:u,payload:p}=await k(d);if(!d.ok){let v=typeof p?.error=="string"?p.error:u.trim()?u.trim().slice(0,240):`public space token mint failed (${d.status})`;throw new Error(v)}let g=typeof p?.token=="string"?p.token.trim():"";if(!g)throw new Error("public space token response missing token");return {customToken:g}}}function O(t){if(!t.trim())return {};try{let i=JSON.parse(t);return i&&typeof i=="object"?i:{}}catch{return {}}}async function k(t){let i=t.text;if(typeof i=="function"){let s=await i.call(t).catch(()=>"");return {text:s,payload:O(s)}}let n=await t.json().catch(()=>({}));return {text:JSON.stringify(n),payload:n&&typeof n=="object"?n:{}}}function y(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 E(t,i){let n=t.trim(),s=y(i);return s?`${n}::sandbox::${s}`:n}var L=S,U=S;
2
+ export{D as a,x as b,N as c,M as d,S as e,E as f,L as g,U as h};
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { R as RuntimeClientOptions, I as ITransport } from './types-QMj23Nvm.js';
2
- export { w as ChannelDescriptor, x as ConnectionEvent, y as ConnectionTarget, D as DeviceProfile, z as IncomingStream, P as PeerConnectOptions, A as PeerReadiness, B as PeerStreamOptions, E as PresenceLoopOptions, F as RawConnection, t as RuntimeApplicationPayloadReadinessOptions, G as RuntimeAuthContext, H as RuntimeAuthIdentity, J as RuntimeAutoConnectPolicy, l as RuntimeChannelDescriptor, u as RuntimeConnectionEvent, s as RuntimeConnectionStateSnapshot, K as RuntimeConnectionTarget, c as RuntimeDevice, e as RuntimeDeviceConnectOptions, L as RuntimeDevicePresenceStatus, M as RuntimeDeviceStatus, d as RuntimeDeviceStatusSnapshot, n as RuntimeIncomingStream, q as RuntimeJoinRoomOptions, f as RuntimeLocalDeviceInfo, g as RuntimeLocalDeviceProfile, N as RuntimeLogicalChannelFraming, b as RuntimeManagedSession, O as RuntimeManagedSessionKind, a as RuntimeManagedSessionOptions, Q as RuntimeManagedSessionPlatform, i as RuntimePeerConnectOptions, k as RuntimePeerHealth, S as RuntimePeerLifecycleStatus, j as RuntimePeerReadinessSnapshot, T as RuntimePeerScope, U as RuntimePeerSessionSnapshot, h as RuntimePeerState, m as RuntimePeerStreamOptions, V as RuntimePresenceLoopOptions, W as RuntimePresencePolicy, v as RuntimeRawConnection, r as RuntimeRoomMember, o as RuntimeScopedChannelOptions, p as RuntimeScopedLogicalChannel, X as RuntimeSession, Y as RuntimeUiConnectionStatus, Z as ScopedChannelOptions, _ as ScopedLogicalChannel } from './types-QMj23Nvm.js';
1
+ import { R as RuntimeClientOptions, I as ITransport } from './types-N9s66nF8.js';
2
+ export { w as ChannelDescriptor, x as ConnectionEvent, y as ConnectionTarget, D as DeviceProfile, z as IncomingStream, P as PeerConnectOptions, A as PeerReadiness, B as PeerStreamOptions, E as PresenceLoopOptions, F as RawConnection, t as RuntimeApplicationPayloadReadinessOptions, G as RuntimeAuthContext, H as RuntimeAuthIdentity, J as RuntimeAutoConnectPolicy, l as RuntimeChannelDescriptor, u as RuntimeConnectionEvent, s as RuntimeConnectionStateSnapshot, K as RuntimeConnectionTarget, c as RuntimeDevice, e as RuntimeDeviceConnectOptions, L as RuntimeDevicePresenceStatus, M as RuntimeDeviceStatus, d as RuntimeDeviceStatusSnapshot, n as RuntimeIncomingStream, q as RuntimeJoinRoomOptions, f as RuntimeLocalDeviceInfo, g as RuntimeLocalDeviceProfile, N as RuntimeLogicalChannelFraming, b as RuntimeManagedSession, O as RuntimeManagedSessionKind, a as RuntimeManagedSessionOptions, Q as RuntimeManagedSessionPlatform, i as RuntimePeerConnectOptions, k as RuntimePeerHealth, S as RuntimePeerLifecycleStatus, j as RuntimePeerReadinessSnapshot, T as RuntimePeerScope, U as RuntimePeerSessionSnapshot, h as RuntimePeerState, m as RuntimePeerStreamOptions, V as RuntimePresenceLoopOptions, W as RuntimePresencePolicy, v as RuntimeRawConnection, r as RuntimeRoomMember, o as RuntimeScopedChannelOptions, p as RuntimeScopedLogicalChannel, X as RuntimeSession, Y as RuntimeUiConnectionStatus, Z as ScopedChannelOptions, _ as ScopedLogicalChannel } from './types-N9s66nF8.js';
3
3
  import { P as PlutoIpcBridge } from './ipc-CflAVodw.js';
4
- import { O as OpenRTCClient } from './OpenRTCShared-BvTf2gFH.js';
5
- export { a as OpenRTCChannelConnectOptions, b as OpenRTCDeviceNamespace, c as OpenRTCDeviceSessionOptions, d as OpenRTCRoomNamespace, e as OpenRTCTicketNamespace } from './OpenRTCShared-BvTf2gFH.js';
6
- import { s as ProtocolName, O as ProtocolCapability, Q as ProtocolCapabilityMap, p as ApplicationPayloadCrypto, U as ApplicationCryptoStreamTools, V as SpaceTokenProvider } from './types-BCkKK8dy.js';
7
- export { W as AppLimits, X as ApplicationCryptoBiStream, q as ApplicationPayloadReadinessOptions, r as ApplicationPayloadRouteOptions, t as ApplicationPayloadSendOptions, A as AuthMode, H as DevicePresenceStatus, D as DiscoveryMode, G as GrantScope, Y as ProtocolBaseName, Z as ProtocolImplementationKind, _ as ProtocolLocality, $ as RouteDescriptor, a0 as RouteFamily, a1 as RouteImplementationKind, S as SignalingMode, a2 as SpaceAuthMode } from './types-BCkKK8dy.js';
4
+ import { O as OpenRTCClient } from './spaceTokens-3sbs1mUF.js';
5
+ export { E as EnableSpaceAuthResponse, M as MintSpaceTokenRequest, a as MintSpaceTokenResponse, b as OpenRTCChannelConnectOptions, c as OpenRTCDeviceNamespace, d as OpenRTCDeviceSessionOptions, e as OpenRTCRoomNamespace, f as OpenRTCTicketNamespace, g as createPublicSpaceTokenProvider, h as createSpaceTokenProvider, i as enableSpaceAuth, m as mintSpaceToken, s as sandboxSpaceKey, j as spaceToken } from './spaceTokens-3sbs1mUF.js';
6
+ import { u as ProtocolName, U as ProtocolCapability, V as ProtocolCapabilityMap, r as ApplicationPayloadCrypto, W as ApplicationCryptoStreamTools } from './types-ZDsZknDI.js';
7
+ export { X as AppLimits, Y as ApplicationCryptoBiStream, s as ApplicationPayloadReadinessOptions, t as ApplicationPayloadRouteOptions, v as ApplicationPayloadSendOptions, A as AuthMode, O as DevicePresenceStatus, D as DiscoveryMode, G as GrantScope, Z as ProtocolBaseName, _ as ProtocolImplementationKind, $ as ProtocolLocality, a0 as RouteDescriptor, a1 as RouteFamily, a2 as RouteImplementationKind, d as SignalingMode, S as SpaceAuthMode, a as SpaceTokenProvider } from './types-ZDsZknDI.js';
8
8
  export { ROUTE_DESCRIPTORS, TRANSPORT_LABELS, getRouteDescriptor, isDirectIrohTransportLabel, isIndependentTransportLabel, isIrohBaseTransportLabel, isOptionalTransportLabel, isWebRtcTransportLabel, listRouteDescriptors, normalizeTransportLabel } from './transport/index.js';
9
9
  export { isRuntimeDeviceActive, isRuntimeDeviceConnectable, isRuntimeDeviceRoutable } from './runtime/device-status.js';
10
10
  export { R as RuntimeJsonFrameHandler, a as RuntimeU32BEFrameHandler, c as createRuntimeJsonFrameDecoder, b as createRuntimeU32BEFrameDecoder, d as decodeRuntimeJsonPayload, e as encodeRuntimeJsonFrame, f as encodeRuntimeJsonPayload, g as encodeRuntimeU32BEFrame } from './framing-zRvEKOld.js';
11
- export { O as OPENRTC_RUNTIME_POLICY, a as RuntimePolicySnapshot, S as ScopedSession, c as Session, d as SessionOptions, g as getRuntimePolicy } from './assembly-BH-ZekkH.js';
11
+ export { O as OPENRTC_RUNTIME_POLICY, a as RuntimePolicySnapshot, S as ScopedSession, c as Session, d as SessionOptions, g as getRuntimePolicy } from './assembly-C2G0P2L5.js';
12
12
  export { b as RuntimeAdapterKind, R as RuntimeCapabilities } from './capabilities-C4Dqs_pB.js';
13
13
  import './IEngineBridge-C7OT2CRv.js';
14
14
 
@@ -67,55 +67,7 @@ declare function generateEphemeralKeyAgreement(randomBytes?: (byteLength: number
67
67
  declare function deriveApplicationCryptoKey(localSecretKey: Uint8Array, remotePublicKey: Uint8Array, localNodeId: string, remoteNodeId: string): Uint8Array;
68
68
  declare function encodeApplicationKeyAgreementPayload(publicKey: Uint8Array): ApplicationKeyAgreementPayload;
69
69
 
70
- type MintSpaceTokenRequest = {
71
- spaceKey: string;
72
- memberId?: string;
73
- ttl?: number;
74
- sandboxAppId?: string;
75
- };
76
- type MintSpaceTokenResponse = {
77
- token: string;
78
- expiresAt: number;
79
- tokenLifetimeSeconds: number;
80
- namespaceId: string;
81
- spaceAppTag: string;
82
- };
83
- /**
84
- * Mint a namespace-scoped Firebase custom token from your backend using the
85
- * OpenRTC `POST /v1/spaces/tokens` endpoint. Never call this from browser code
86
- * with a secret key — proxy through your server.
87
- */
88
- type EnableSpaceAuthResponse = {
89
- success: true;
90
- space: {
91
- namespaceId: string;
92
- requireScopedAuth: boolean;
93
- status: 'active' | 'revoked';
94
- };
95
- };
96
- /**
97
- * Opt a provisioned space into scoped-auth mode (required for all spaces).
98
- * Call from your backend with sk_live_... only.
99
- */
100
- declare function enableSpaceAuth(endpointUrl: string, secretKey: string, namespaceId: string): Promise<EnableSpaceAuthResponse>;
101
- declare function mintSpaceToken(endpointUrl: string, secretKey: string, request: MintSpaceTokenRequest): Promise<MintSpaceTokenResponse>;
102
- /**
103
- * Browser-safe space auth for static sites. Calls the rate-limited
104
- * `v1SpacePublicTokens` endpoint (pk_live_ + spaceKey only).
105
- */
106
- declare function createPublicSpaceTokenProvider(options: {
107
- apiKey: string;
108
- space?: string;
109
- spaceKey?: string;
110
- endpointUrl?: string;
111
- memberIdStorageKey?: string;
112
- sandboxAppId?: string;
113
- }): SpaceTokenProvider;
114
- declare function sandboxSpaceKey(spaceKey: string, sandboxAppId?: string): string;
115
- declare const spaceToken: typeof createPublicSpaceTokenProvider;
116
- declare const createSpaceTokenProvider: typeof createPublicSpaceTokenProvider;
117
-
118
70
  type UpgradeState = 'none' | 'upgrading' | 'upgraded' | 'failed';
119
71
  type OutboundMessage = string | object | ArrayBuffer | Uint8Array;
120
72
 
121
- export { ApplicationCryptoStreamTools, type ApplicationKeyAgreementPayload, ApplicationPayloadCrypto, type EnableSpaceAuthResponse, KEY_AGREEMENT_ALGORITHM, KEY_AGREEMENT_PUBLIC_KEY_BYTES, type MintSpaceTokenRequest, type MintSpaceTokenResponse, OpenRTC, OpenRTCClient, RuntimeClientOptions as OpenRTCOptions, type OutboundMessage, ProtocolCapability, ProtocolCapabilityMap, ProtocolName, RuntimeClientOptions, SpaceTokenProvider, type UpgradeState, createApplicationCryptoStreamTools, createPublicSpaceTokenProvider, createSharedSecretApplicationCrypto, createSpaceTokenProvider, deriveApplicationCryptoKey, enableSpaceAuth, encodeApplicationKeyAgreementPayload, generateEphemeralKeyAgreement, getPreferredProtocolOrder, isApplicationEncryptedPayload, mintSpaceToken, sandboxSpaceKey, spaceToken };
73
+ export { ApplicationCryptoStreamTools, type ApplicationKeyAgreementPayload, ApplicationPayloadCrypto, KEY_AGREEMENT_ALGORITHM, KEY_AGREEMENT_PUBLIC_KEY_BYTES, OpenRTC, OpenRTCClient, RuntimeClientOptions as OpenRTCOptions, type OutboundMessage, ProtocolCapability, ProtocolCapabilityMap, ProtocolName, RuntimeClientOptions, type UpgradeState, createApplicationCryptoStreamTools, createSharedSecretApplicationCrypto, deriveApplicationCryptoKey, encodeApplicationKeyAgreementPayload, generateEphemeralKeyAgreement, getPreferredProtocolOrder, isApplicationEncryptedPayload };
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
- import {a,b}from'./chunk-WUREK3SW.js';import {a as a$1,b as b$1}from'./chunk-4AXAWVC6.js';export{d as KEY_AGREEMENT_ALGORITHM,c as KEY_AGREEMENT_PUBLIC_KEY_BYTES,h as ScopedSession,w as createRuntimeJsonFrameDecoder,s as createRuntimeU32BEFrameDecoder,u as decodeRuntimeJsonPayload,f as deriveApplicationCryptoKey,g as encodeApplicationKeyAgreementPayload,v as encodeRuntimeJsonFrame,t as encodeRuntimeJsonPayload,r as encodeRuntimeU32BEFrame,e as generateEphemeralKeyAgreement,b as getPreferredProtocolOrder}from'./chunk-7352ZIXN.js';export{a as isRuntimeDeviceActive,c as isRuntimeDeviceConnectable,b as isRuntimeDeviceRoutable}from'./chunk-CK6WQV7J.js';import'./chunk-MNI6JGR2.js';import {g as g$1}from'./chunk-DI5IPRPM.js';export{w as OPENRTC_RUNTIME_POLICY,n as createApplicationCryptoStreamTools,m as createSharedSecretApplicationCrypto,x as getRuntimePolicy,l as isApplicationEncryptedPayload}from'./chunk-YTUWXCRO.js';export{a as TRANSPORT_LABELS,d as isDirectIrohTransportLabel,h as isIndependentTransportLabel,c as isIrohBaseTransportLabel,e as isOptionalTransportLabel,f as isWebRtcTransportLabel,b as normalizeTransportLabel}from'./chunk-QT2ASNI3.js';import'./chunk-HVTYSEU7.js';export{a as ROUTE_DESCRIPTORS,e as getRouteDescriptor,f as listRouteDescriptors}from'./chunk-C7YN5MSV.js';function f(e){let t=a(e),o=a$1(t);return b(o,"web")}f.native=function(e,t){let o=a(e),n=t??g$1(),r=b$1(o,n);return b(r,"native")};var V="https://api.openrtc.app";async function X(e,t,o){let n=e.replace(/\/$/,""),r=await fetch(`${n}/v1/spaces/${encodeURIComponent(o)}/scoped-auth`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:"{}"}),a=await r.json().catch(()=>({}));if(!r.ok){let p=typeof a?.error=="string"?a.error:`enableSpaceAuth failed (${r.status})`;throw new Error(p)}return a}async function Z(e,t,o){let n=await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(o)}),r=await n.json().catch(()=>({}));if(!n.ok){let a=typeof r?.error=="string"?r.error:`mintSpaceToken failed (${n.status})`;throw new Error(a)}if(typeof r?.token!="string"||!r.token.trim())throw new Error("mintSpaceToken response missing token");return r}function l(e){let t=e.apiKey.trim(),o=(e.spaceKey??e.space??"").trim(),n=g(e.sandboxAppId),r=(e.endpointUrl??V).replace(/\/$/,""),a=e.memberIdStorageKey??`openrtc:space-member:${o}${n?`:sandbox:${n}`:""}`;return async()=>{if(!t||!o)throw new Error("spaceToken requires apiKey and space");let p=null;typeof sessionStorage<"u"?(p=sessionStorage.getItem(a),p||(p=globalThis.crypto?.randomUUID?.()??`member-${Date.now()}`,sessionStorage.setItem(a,p))):p=`member-${Date.now()}`;let s=await fetch(`${r}/v1SpacePublicTokens`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t,spaceKey:o,memberId:p,...n?{sandboxAppId:n}:{}})}),{text:d,payload:i}=await te(s);if(!s.ok){let S=typeof i?.error=="string"?i.error:d.trim()?d.trim().slice(0,240):`public space token mint failed (${s.status})`;throw new Error(S)}let y=typeof i?.token=="string"?i.token.trim():"";if(!y)throw new Error("public space token response missing token");return {customToken:y}}}function ee(e){if(!e.trim())return {};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}async function te(e){let t=e.text;if(typeof t=="function"){let n=await t.call(e).catch(()=>"");return {text:n,payload:ee(n)}}let o=await e.json().catch(()=>({}));return {text:JSON.stringify(o),payload:o&&typeof o=="object"?o:{}}}function g(e){let t=e?.trim().toLowerCase()??"";if(!t)return "";if(!/^[a-z0-9][a-z0-9-]{0,47}$/.test(t))throw new Error("sandboxAppId must be 1-48 lowercase letters, numbers, or dashes.");return t}function oe(e,t){let o=e.trim(),n=g(t);return n?`${o}::sandbox::${n}`:o}var ne=l,re=l;
2
- export{f as OpenRTC,l as createPublicSpaceTokenProvider,re as createSpaceTokenProvider,X as enableSpaceAuth,Z as mintSpaceToken,oe as sandboxSpaceKey,ne as spaceToken};
1
+ import {a,b}from'./chunk-SJ5BFL6W.js';export{e as createPublicSpaceTokenProvider,h as createSpaceTokenProvider,c as enableSpaceAuth,d as mintSpaceToken,f as sandboxSpaceKey,g as spaceToken}from'./chunk-SJ5BFL6W.js';import {a as a$1,b as b$1}from'./chunk-4AXAWVC6.js';export{d as KEY_AGREEMENT_ALGORITHM,c as KEY_AGREEMENT_PUBLIC_KEY_BYTES,h as ScopedSession,w as createRuntimeJsonFrameDecoder,s as createRuntimeU32BEFrameDecoder,u as decodeRuntimeJsonPayload,f as deriveApplicationCryptoKey,g as encodeApplicationKeyAgreementPayload,v as encodeRuntimeJsonFrame,t as encodeRuntimeJsonPayload,r as encodeRuntimeU32BEFrame,e as generateEphemeralKeyAgreement,b as getPreferredProtocolOrder}from'./chunk-7352ZIXN.js';export{a as isRuntimeDeviceActive,c as isRuntimeDeviceConnectable,b as isRuntimeDeviceRoutable}from'./chunk-CK6WQV7J.js';import'./chunk-MNI6JGR2.js';import {g}from'./chunk-DI5IPRPM.js';export{w as OPENRTC_RUNTIME_POLICY,n as createApplicationCryptoStreamTools,m as createSharedSecretApplicationCrypto,x as getRuntimePolicy,l as isApplicationEncryptedPayload}from'./chunk-YTUWXCRO.js';export{a as TRANSPORT_LABELS,d as isDirectIrohTransportLabel,h as isIndependentTransportLabel,c as isIrohBaseTransportLabel,e as isOptionalTransportLabel,f as isWebRtcTransportLabel,b as normalizeTransportLabel}from'./chunk-QT2ASNI3.js';import'./chunk-HVTYSEU7.js';export{a as ROUTE_DESCRIPTORS,e as getRouteDescriptor,f as listRouteDescriptors}from'./chunk-C7YN5MSV.js';function s(e){let t=a(e),o=a$1(t);return b(o,"web")}s.native=function(e,t){let o=a(e),c=t??g(),m=b$1(o,c);return b(m,"native")};export{s as OpenRTC};
package/dist/native.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { R as RuntimeClientOptions } from './types-QMj23Nvm.js';
1
+ import { R as RuntimeClientOptions } from './types-N9s66nF8.js';
2
2
  import { P as PlutoIpcBridge } from './ipc-CflAVodw.js';
3
- import { O as OpenRTCClient } from './OpenRTCShared-BvTf2gFH.js';
4
- export { a as OpenRTCChannelConnectOptions, b as OpenRTCDeviceNamespace, c as OpenRTCDeviceSessionOptions, d as OpenRTCRoomNamespace, e as OpenRTCTicketNamespace } from './OpenRTCShared-BvTf2gFH.js';
3
+ import { O as OpenRTCClient } from './spaceTokens-3sbs1mUF.js';
4
+ export { E as EnableSpaceAuthResponse, M as MintSpaceTokenRequest, a as MintSpaceTokenResponse, b as OpenRTCChannelConnectOptions, c as OpenRTCDeviceNamespace, d as OpenRTCDeviceSessionOptions, e as OpenRTCRoomNamespace, f as OpenRTCTicketNamespace, g as createPublicSpaceTokenProvider, h as createSpaceTokenProvider, i as enableSpaceAuth, m as mintSpaceToken, s as sandboxSpaceKey, j as spaceToken } from './spaceTokens-3sbs1mUF.js';
5
+ export { S as SpaceAuthMode, a as SpaceTokenProvider } from './types-ZDsZknDI.js';
5
6
  import './IEngineBridge-C7OT2CRv.js';
6
- import './types-BCkKK8dy.js';
7
- import './assembly-BH-ZekkH.js';
7
+ import './assembly-C2G0P2L5.js';
8
8
  import './capabilities-C4Dqs_pB.js';
9
9
 
10
10
  /**
package/dist/native.js CHANGED
@@ -1 +1 @@
1
- import {a,b}from'./chunk-WUREK3SW.js';import {A}from'./chunk-7352ZIXN.js';import {h}from'./chunk-DI5IPRPM.js';import'./chunk-YTUWXCRO.js';import'./chunk-QT2ASNI3.js';import {s as s$1}from'./chunk-HVTYSEU7.js';import'./chunk-C7YN5MSV.js';function s(t,p){let e=s$1(t);return A(e,new h({...e,bridge:p}))}function C(t,p){let e=s(a(t),p);return b(e,"native")}export{C as createNativeOpenRTC};
1
+ import {a as a$1,b}from'./chunk-SJ5BFL6W.js';export{e as createPublicSpaceTokenProvider,h as createSpaceTokenProvider,c as enableSpaceAuth,d as mintSpaceToken,f as sandboxSpaceKey,g as spaceToken}from'./chunk-SJ5BFL6W.js';import {A as A$1}from'./chunk-7352ZIXN.js';import {h}from'./chunk-DI5IPRPM.js';import'./chunk-YTUWXCRO.js';import'./chunk-QT2ASNI3.js';import {s}from'./chunk-HVTYSEU7.js';import'./chunk-C7YN5MSV.js';function a(t,p){let e=s(t);return A$1(e,new h({...e,bridge:p}))}function A(t,p){let e=a(a$1(t),p);return b(e,"native")}export{A as createNativeOpenRTC};
@@ -1,5 +1,5 @@
1
- import { D as DelegatingRuntimeAdapter, W as WasmBridgeOptions } from '../DelegatingRuntimeAdapter-DlC0TZB0.js';
2
- import '../types-BCkKK8dy.js';
1
+ import { D as DelegatingRuntimeAdapter, W as WasmBridgeOptions } from '../DelegatingRuntimeAdapter-lFDUNBy9.js';
2
+ import '../types-ZDsZknDI.js';
3
3
  import '../IEngineBridge-C7OT2CRv.js';
4
4
  import '../capabilities-C4Dqs_pB.js';
5
5
 
@@ -1,6 +1,6 @@
1
- import { c as RuntimeDevice, d as RuntimeDeviceStatusSnapshot } from '../types-QMj23Nvm.js';
1
+ import { c as RuntimeDevice, d as RuntimeDeviceStatusSnapshot } from '../types-N9s66nF8.js';
2
2
  import '../IEngineBridge-C7OT2CRv.js';
3
- import '../types-BCkKK8dy.js';
3
+ import '../types-ZDsZknDI.js';
4
4
 
5
5
  interface RuntimeDeviceActiveOptions {
6
6
  now?: number;
@@ -1,21 +1,21 @@
1
- import { e as RuntimeFactoryOptions, b as PlutoRuntimeAssembly, P as PeerReconciliationStats } from '../assembly-BH-ZekkH.js';
2
- export { O as OPENRTC_RUNTIME_POLICY, R as RuntimeClient, a as RuntimePolicySnapshot, D as ScopedConnectionActorError, f as ScopedConnectionActorErrorKind, h as ScopedConnectionActorHandle, i as ScopedConnectionActorHandleOptions, j as ScopedConnectionActorRegistry, k as ScopedConnectionActorState, l as ScopedConnectionClose, m as ScopedConnectionDial, n as ScopedConnectionKey, o as ScopedLogicalChannelHandle, p as ScopedPreferredTransport, g as getRuntimePolicy, q as scopedConnectionKey, r as scopedConnectionKeyToString } from '../assembly-BH-ZekkH.js';
1
+ import { e as RuntimeFactoryOptions, b as PlutoRuntimeAssembly, P as PeerReconciliationStats } from '../assembly-C2G0P2L5.js';
2
+ export { O as OPENRTC_RUNTIME_POLICY, R as RuntimeClient, a as RuntimePolicySnapshot, D as ScopedConnectionActorError, f as ScopedConnectionActorErrorKind, h as ScopedConnectionActorHandle, i as ScopedConnectionActorHandleOptions, j as ScopedConnectionActorRegistry, k as ScopedConnectionActorState, l as ScopedConnectionClose, m as ScopedConnectionDial, n as ScopedConnectionKey, o as ScopedLogicalChannelHandle, p as ScopedPreferredTransport, g as getRuntimePolicy, q as scopedConnectionKey, r as scopedConnectionKeyToString } from '../assembly-C2G0P2L5.js';
3
3
  import * as Draft14 from '@moq/net';
4
- import { a3 as SignalingOptions, I as ISignalingBackend, c as RuntimeIdentity, f as SignalingEnvelope, h as SignalingSession, d as Device, m as BackendConnectionState, W as AppLimits, G as GrantScope, J as JoinRoomOptions, z as RoomMember, v as IncomingStreamChannelMetadata, U as ApplicationCryptoStreamTools, a4 as RoomCreationMode, n as ClientOptions, p as ApplicationPayloadCrypto, D as DiscoveryMode, Q as ProtocolCapabilityMap, a5 as ScanningLoopOptions, a6 as ScanningLoopHandle, a7 as RuntimeBootstrapOptions, a8 as RuntimeBootstrapResult, q as ApplicationPayloadReadinessOptions, a9 as ManagedApplicationRouteOptions, x as PeerState, F as PeerScope, y as PeerHealth, u as ChannelDescriptor, aa as JoinRequest, k as NativeConnectParams, l as NativeConnectResult } from '../types-BCkKK8dy.js';
5
- import { C as Connection, K as RuntimeConnectionTarget, v as RuntimeRawConnection } from '../types-QMj23Nvm.js';
6
- export { w as ChannelDescriptor, x as ConnectionEvent, y as ConnectionTarget, D as DeviceProfile, z as IncomingStream, P as PeerConnectOptions, A as PeerReadiness, B as PeerStreamOptions, E as PresenceLoopOptions, F as RawConnection, t as RuntimeApplicationPayloadReadinessOptions, G as RuntimeAuthContext, H as RuntimeAuthIdentity, J as RuntimeAutoConnectPolicy, l as RuntimeChannelDescriptor, R as RuntimeClientOptions, u as RuntimeConnectionEvent, s as RuntimeConnectionStateSnapshot, c as RuntimeDevice, e as RuntimeDeviceConnectOptions, L as RuntimeDevicePresenceStatus, M as RuntimeDeviceStatus, d as RuntimeDeviceStatusSnapshot, n as RuntimeIncomingStream, q as RuntimeJoinRoomOptions, f as RuntimeLocalDeviceInfo, g as RuntimeLocalDeviceProfile, N as RuntimeLogicalChannelFraming, b as RuntimeManagedSession, O as RuntimeManagedSessionKind, a as RuntimeManagedSessionOptions, Q as RuntimeManagedSessionPlatform, i as RuntimePeerConnectOptions, k as RuntimePeerHealth, S as RuntimePeerLifecycleStatus, j as RuntimePeerReadinessSnapshot, T as RuntimePeerScope, U as RuntimePeerSessionSnapshot, h as RuntimePeerState, m as RuntimePeerStreamOptions, V as RuntimePresenceLoopOptions, W as RuntimePresencePolicy, r as RuntimeRoomMember, o as RuntimeScopedChannelOptions, p as RuntimeScopedLogicalChannel, X as RuntimeSession, Y as RuntimeUiConnectionStatus, Z as ScopedChannelOptions, _ as ScopedLogicalChannel, $ as Session, a0 as SessionOptions } from '../types-QMj23Nvm.js';
4
+ import { a3 as SignalingOptions, I as ISignalingBackend, e as RuntimeIdentity, h as SignalingEnvelope, j as SignalingSession, f as Device, o as BackendConnectionState, X as AppLimits, G as GrantScope, J as JoinRoomOptions, H as RoomMember, x as IncomingStreamChannelMetadata, W as ApplicationCryptoStreamTools, a4 as RoomCreationMode, p as ClientOptions, r as ApplicationPayloadCrypto, D as DiscoveryMode, V as ProtocolCapabilityMap, a5 as ScanningLoopOptions, a6 as ScanningLoopHandle, a7 as RuntimeBootstrapOptions, a8 as RuntimeBootstrapResult, s as ApplicationPayloadReadinessOptions, a9 as ManagedApplicationRouteOptions, z as PeerState, K as PeerScope, F as PeerHealth, w as ChannelDescriptor, aa as JoinRequest, m as NativeConnectParams, n as NativeConnectResult } from '../types-ZDsZknDI.js';
5
+ import { C as Connection, K as RuntimeConnectionTarget, v as RuntimeRawConnection } from '../types-N9s66nF8.js';
6
+ export { w as ChannelDescriptor, x as ConnectionEvent, y as ConnectionTarget, D as DeviceProfile, z as IncomingStream, P as PeerConnectOptions, A as PeerReadiness, B as PeerStreamOptions, E as PresenceLoopOptions, F as RawConnection, t as RuntimeApplicationPayloadReadinessOptions, G as RuntimeAuthContext, H as RuntimeAuthIdentity, J as RuntimeAutoConnectPolicy, l as RuntimeChannelDescriptor, R as RuntimeClientOptions, u as RuntimeConnectionEvent, s as RuntimeConnectionStateSnapshot, c as RuntimeDevice, e as RuntimeDeviceConnectOptions, L as RuntimeDevicePresenceStatus, M as RuntimeDeviceStatus, d as RuntimeDeviceStatusSnapshot, n as RuntimeIncomingStream, q as RuntimeJoinRoomOptions, f as RuntimeLocalDeviceInfo, g as RuntimeLocalDeviceProfile, N as RuntimeLogicalChannelFraming, b as RuntimeManagedSession, O as RuntimeManagedSessionKind, a as RuntimeManagedSessionOptions, Q as RuntimeManagedSessionPlatform, i as RuntimePeerConnectOptions, k as RuntimePeerHealth, S as RuntimePeerLifecycleStatus, j as RuntimePeerReadinessSnapshot, T as RuntimePeerScope, U as RuntimePeerSessionSnapshot, h as RuntimePeerState, m as RuntimePeerStreamOptions, V as RuntimePresenceLoopOptions, W as RuntimePresencePolicy, r as RuntimeRoomMember, o as RuntimeScopedChannelOptions, p as RuntimeScopedLogicalChannel, X as RuntimeSession, Y as RuntimeUiConnectionStatus, Z as ScopedChannelOptions, _ as ScopedLogicalChannel, $ as Session, a0 as SessionOptions } from '../types-N9s66nF8.js';
7
7
  import { FirebaseApp } from 'firebase/app';
8
8
  import { R as RuntimeCapabilities } from '../capabilities-C4Dqs_pB.js';
9
9
  export { B as BROWSER_WASM_RUNTIME_CAPABILITIES, c as BrowserRuntimeCapabilityHost, N as NATIVE_IPC_RUNTIME_CAPABILITIES, d as NativeRuntimeStatusSnapshot, e as NativeRuntimeTransportFeatureStatus, b as RuntimeAdapterKind, a as RuntimeCapabilityProfile, f as cloneRuntimeCapabilities, r as runtimeCapabilitiesForBrowserHost, g as runtimeCapabilitiesFromNativeStatus, h as runtimeCapabilityProfile } from '../capabilities-C4Dqs_pB.js';
10
10
  export { RuntimeDeviceActiveOptions, isRuntimeDeviceActive, isRuntimeDeviceConnectable, isRuntimeDeviceRoutable } from './device-status.js';
11
11
  export { h as RuntimeJsonFrameDecoderOptions, R as RuntimeJsonFrameHandler, a as RuntimeU32BEFrameHandler, i as concatRuntimeBytes, c as createRuntimeJsonFrameDecoder, b as createRuntimeU32BEFrameDecoder, d as decodeRuntimeJsonPayload, e as encodeRuntimeJsonFrame, f as encodeRuntimeJsonPayload, g as encodeRuntimeU32BEFrame, r as readRuntimeU32BE } from '../framing-zRvEKOld.js';
12
- import { I as IpcRuntimeAdapter } from '../tauri-BVSxK0jq.js';
13
- export { a as IpcRuntimeAdapterOptions, T as TauriRuntimeAdapter, b as TauriRuntimeAdapterOptions, c as createTauriIpcBridge } from '../tauri-BVSxK0jq.js';
12
+ import { I as IpcRuntimeAdapter } from '../tauri-WEvOC_Z6.js';
13
+ export { a as IpcRuntimeAdapterOptions, T as TauriRuntimeAdapter, b as TauriRuntimeAdapterOptions, c as createTauriIpcBridge } from '../tauri-WEvOC_Z6.js';
14
14
  import { WasmRuntimeAdapter } from './WasmRuntimeAdapter.js';
15
15
  import { P as PlutoIpcBridge } from '../ipc-CflAVodw.js';
16
16
  export { N as NativeIpcFailureKind, a as PlutoIpcUnlisten, c as classifyNativeIpcFailure, i as isNativeIpcCommandUnavailable } from '../ipc-CflAVodw.js';
17
17
  import '../IEngineBridge-C7OT2CRv.js';
18
- import '../DelegatingRuntimeAdapter-DlC0TZB0.js';
18
+ import '../DelegatingRuntimeAdapter-lFDUNBy9.js';
19
19
 
20
20
  /**
21
21
  * RtdbPresence — Phase 1 RTDB-backed device presence.
@@ -1,6 +1,6 @@
1
- export { T as TauriRuntimeAdapter, b as TauriRuntimeAdapterOptions, c as createTauriIpcBridge } from '../tauri-BVSxK0jq.js';
1
+ export { T as TauriRuntimeAdapter, b as TauriRuntimeAdapterOptions, c as createTauriIpcBridge } from '../tauri-WEvOC_Z6.js';
2
2
  import '../ipc-CflAVodw.js';
3
- import '../types-BCkKK8dy.js';
4
- import '../DelegatingRuntimeAdapter-DlC0TZB0.js';
3
+ import '../types-ZDsZknDI.js';
4
+ import '../DelegatingRuntimeAdapter-lFDUNBy9.js';
5
5
  import '../IEngineBridge-C7OT2CRv.js';
6
6
  import '../capabilities-C4Dqs_pB.js';
@@ -1,7 +1,7 @@
1
- import { R as RuntimeClient, a as RuntimePolicySnapshot, P as PeerReconciliationStats, b as PlutoRuntimeAssembly } from './assembly-BH-ZekkH.js';
2
- import { C as ConnectDeviceResult, a as ConnectDeviceHooks, b as ConnectDeviceOptions, P as PeerSessionSnapshot, R as ResolvedPeerIdentity, G as GrantScope } from './types-BCkKK8dy.js';
1
+ import { R as RuntimeClient, a as RuntimePolicySnapshot, P as PeerReconciliationStats, b as PlutoRuntimeAssembly } from './assembly-C2G0P2L5.js';
2
+ import { C as ConnectDeviceResult, b as ConnectDeviceHooks, c as ConnectDeviceOptions, P as PeerSessionSnapshot, R as ResolvedPeerIdentity, G as GrantScope, a as SpaceTokenProvider } from './types-ZDsZknDI.js';
3
3
  import { A as AuthContext } from './IEngineBridge-C7OT2CRv.js';
4
- import { a as RuntimeManagedSessionOptions, b as RuntimeManagedSession, c as RuntimeDevice, d as RuntimeDeviceStatusSnapshot, e as RuntimeDeviceConnectOptions, f as RuntimeLocalDeviceInfo, g as RuntimeLocalDeviceProfile, h as RuntimePeerState, i as RuntimePeerConnectOptions, C as Connection, j as RuntimePeerReadinessSnapshot, k as RuntimePeerHealth, l as RuntimeChannelDescriptor, m as RuntimePeerStreamOptions, n as RuntimeIncomingStream, o as RuntimeScopedChannelOptions, p as RuntimeScopedLogicalChannel, q as RuntimeJoinRoomOptions, r as RuntimeRoomMember, s as RuntimeConnectionStateSnapshot, t as RuntimeApplicationPayloadReadinessOptions, u as RuntimeConnectionEvent, v as RuntimeRawConnection } from './types-QMj23Nvm.js';
4
+ import { a as RuntimeManagedSessionOptions, b as RuntimeManagedSession, c as RuntimeDevice, d as RuntimeDeviceStatusSnapshot, e as RuntimeDeviceConnectOptions, f as RuntimeLocalDeviceInfo, g as RuntimeLocalDeviceProfile, h as RuntimePeerState, i as RuntimePeerConnectOptions, C as Connection, j as RuntimePeerReadinessSnapshot, k as RuntimePeerHealth, l as RuntimeChannelDescriptor, m as RuntimePeerStreamOptions, n as RuntimeIncomingStream, o as RuntimeScopedChannelOptions, p as RuntimeScopedLogicalChannel, q as RuntimeJoinRoomOptions, r as RuntimeRoomMember, s as RuntimeConnectionStateSnapshot, t as RuntimeApplicationPayloadReadinessOptions, u as RuntimeConnectionEvent, v as RuntimeRawConnection } from './types-N9s66nF8.js';
5
5
  import { R as RuntimeCapabilities, a as RuntimeCapabilityProfile } from './capabilities-C4Dqs_pB.js';
6
6
 
7
7
  type OpenRTCChannelConnectOptions = Omit<RuntimeScopedChannelOptions, 'scope' | 'deviceId' | 'ticket'> & {
@@ -246,4 +246,52 @@ interface OpenRTCClient extends RuntimeClient {
246
246
  readonly _assembly: PlutoRuntimeAssembly;
247
247
  }
248
248
 
249
- export type { OpenRTCClient as O, OpenRTCChannelConnectOptions as a, OpenRTCDeviceNamespace as b, OpenRTCDeviceSessionOptions as c, OpenRTCRoomNamespace as d, OpenRTCTicketNamespace as e };
249
+ type MintSpaceTokenRequest = {
250
+ spaceKey: string;
251
+ memberId?: string;
252
+ ttl?: number;
253
+ sandboxAppId?: string;
254
+ };
255
+ type MintSpaceTokenResponse = {
256
+ token: string;
257
+ expiresAt: number;
258
+ tokenLifetimeSeconds: number;
259
+ namespaceId: string;
260
+ spaceAppTag: string;
261
+ };
262
+ /**
263
+ * Mint a namespace-scoped Firebase custom token from your backend using the
264
+ * OpenRTC `POST /v1/spaces/tokens` endpoint. Never call this from browser code
265
+ * with a secret key — proxy through your server.
266
+ */
267
+ type EnableSpaceAuthResponse = {
268
+ success: true;
269
+ space: {
270
+ namespaceId: string;
271
+ requireScopedAuth: boolean;
272
+ status: 'active' | 'revoked';
273
+ };
274
+ };
275
+ /**
276
+ * Opt a provisioned space into scoped-auth mode (required for all spaces).
277
+ * Call from your backend with sk_live_... only.
278
+ */
279
+ declare function enableSpaceAuth(endpointUrl: string, secretKey: string, namespaceId: string): Promise<EnableSpaceAuthResponse>;
280
+ declare function mintSpaceToken(endpointUrl: string, secretKey: string, request: MintSpaceTokenRequest): Promise<MintSpaceTokenResponse>;
281
+ /**
282
+ * Browser-safe space auth for static sites. Calls the rate-limited
283
+ * `v1SpacePublicTokens` endpoint (pk_live_ + spaceKey only).
284
+ */
285
+ declare function createPublicSpaceTokenProvider(options: {
286
+ apiKey: string;
287
+ space?: string;
288
+ spaceKey?: string;
289
+ endpointUrl?: string;
290
+ memberIdStorageKey?: string;
291
+ sandboxAppId?: string;
292
+ }): SpaceTokenProvider;
293
+ declare function sandboxSpaceKey(spaceKey: string, sandboxAppId?: string): string;
294
+ declare const spaceToken: typeof createPublicSpaceTokenProvider;
295
+ declare const createSpaceTokenProvider: typeof createPublicSpaceTokenProvider;
296
+
297
+ export { type EnableSpaceAuthResponse as E, type MintSpaceTokenRequest as M, type OpenRTCClient as O, type MintSpaceTokenResponse as a, type OpenRTCChannelConnectOptions as b, type OpenRTCDeviceNamespace as c, type OpenRTCDeviceSessionOptions as d, type OpenRTCRoomNamespace as e, type OpenRTCTicketNamespace as f, createPublicSpaceTokenProvider as g, createSpaceTokenProvider as h, enableSpaceAuth as i, spaceToken as j, mintSpaceToken as m, sandboxSpaceKey as s };
@@ -1,5 +1,5 @@
1
- import { n as ClientOptions } from './types-BCkKK8dy.js';
2
- import { W as WasmBridgeOptions, D as DelegatingRuntimeAdapter } from './DelegatingRuntimeAdapter-DlC0TZB0.js';
1
+ import { p as ClientOptions } from './types-ZDsZknDI.js';
2
+ import { W as WasmBridgeOptions, D as DelegatingRuntimeAdapter } from './DelegatingRuntimeAdapter-lFDUNBy9.js';
3
3
  import { P as PlutoIpcBridge } from './ipc-CflAVodw.js';
4
4
 
5
5
  interface NativeIpcBridgeOptions extends WasmBridgeOptions {
@@ -1,5 +1,5 @@
1
- import { $ as RouteDescriptor, s as ProtocolName } from '../types-BCkKK8dy.js';
2
- export { a0 as RouteFamily, a1 as RouteImplementationKind } from '../types-BCkKK8dy.js';
1
+ import { a0 as RouteDescriptor, u as ProtocolName } from '../types-ZDsZknDI.js';
2
+ export { a1 as RouteFamily, a2 as RouteImplementationKind } from '../types-ZDsZknDI.js';
3
3
 
4
4
  declare const ROUTE_DESCRIPTORS: readonly RouteDescriptor[];
5
5
  declare function getRouteDescriptor(id: ProtocolName): RouteDescriptor;
@@ -1,5 +1,5 @@
1
1
  import { A as AuthContext } from './IEngineBridge-C7OT2CRv.js';
2
- import { o as ConnectionOptions, p as ApplicationPayloadCrypto, q as ApplicationPayloadReadinessOptions, r as ApplicationPayloadRouteOptions, s as ProtocolName, t as ApplicationPayloadSendOptions, T as TransportLatencySnapshot, u as ChannelDescriptor$1, L as LocalDeviceInfo, v as IncomingStreamChannelMetadata, n as ClientOptions, d as Device, h as SignalingSession, c as RuntimeIdentity, e as DeviceStatusSnapshot, w as ManagedDeviceConnectOptions, x as PeerState, y as PeerHealth, J as JoinRoomOptions, z as RoomMember, F as PeerScope, m as BackendConnectionState, H as DevicePresenceStatus, K as PeerLifecycleStatus, P as PeerSessionSnapshot } from './types-BCkKK8dy.js';
2
+ import { q as ConnectionOptions, r as ApplicationPayloadCrypto, s as ApplicationPayloadReadinessOptions, t as ApplicationPayloadRouteOptions, u as ProtocolName, v as ApplicationPayloadSendOptions, T as TransportLatencySnapshot, w as ChannelDescriptor$1, L as LocalDeviceInfo, x as IncomingStreamChannelMetadata, p as ClientOptions, f as Device, j as SignalingSession, e as RuntimeIdentity, g as DeviceStatusSnapshot, y as ManagedDeviceConnectOptions, z as PeerState, F as PeerHealth, J as JoinRoomOptions, H as RoomMember, K as PeerScope, o as BackendConnectionState, O as DevicePresenceStatus, Q as PeerLifecycleStatus, P as PeerSessionSnapshot } from './types-ZDsZknDI.js';
3
3
 
4
4
  interface ITransport {
5
5
  readonly name: string;
@@ -934,4 +934,4 @@ interface JoinRequest {
934
934
  state: 'pending' | 'accepted' | 'rejected';
935
935
  }
936
936
 
937
- export type { RouteDescriptor as $, AuthMode as A, BackendPeerBiStream as B, ConnectDeviceResult as C, DiscoveryMode as D, ExplicitFileDataSendParams as E, PeerScope as F, GrantScope as G, DevicePresenceStatus as H, ISignalingBackend as I, JoinRoomOptions as J, PeerLifecycleStatus as K, LocalDeviceInfo as L, ManagedConnectionRecord as M, NativeManagedSessionStartResult as N, ProtocolCapability as O, PeerSessionSnapshot as P, ProtocolCapabilityMap as Q, ResolvedPeerIdentity as R, SignalingMode as S, TransportLatencySnapshot as T, ApplicationCryptoStreamTools as U, SpaceTokenProvider as V, AppLimits as W, ApplicationCryptoBiStream as X, ProtocolBaseName as Y, ProtocolImplementationKind as Z, ProtocolLocality as _, ConnectDeviceHooks as a, RouteFamily as a0, RouteImplementationKind as a1, SpaceAuthMode as a2, SignalingOptions as a3, RoomCreationMode as a4, ScanningLoopOptions as a5, ScanningLoopHandle as a6, RuntimeBootstrapOptions as a7, RuntimeBootstrapResult as a8, ManagedApplicationRouteOptions as a9, JoinRequest as aa, ConnectDeviceOptions as b, RuntimeIdentity as c, Device as d, DeviceStatusSnapshot as e, SignalingEnvelope as f, DeviceEvent as g, SignalingSession as h, SessionEvent as i, BackendPeerUniStream as j, NativeConnectParams as k, NativeConnectResult as l, BackendConnectionState as m, ClientOptions as n, ConnectionOptions as o, ApplicationPayloadCrypto as p, ApplicationPayloadReadinessOptions as q, ApplicationPayloadRouteOptions as r, ProtocolName as s, ApplicationPayloadSendOptions as t, ChannelDescriptor as u, IncomingStreamChannelMetadata as v, ManagedDeviceConnectOptions as w, PeerState as x, PeerHealth as y, RoomMember as z };
937
+ export type { ProtocolLocality as $, AuthMode as A, BackendPeerBiStream as B, ConnectDeviceResult as C, DiscoveryMode as D, ExplicitFileDataSendParams as E, PeerHealth as F, GrantScope as G, RoomMember as H, ISignalingBackend as I, JoinRoomOptions as J, PeerScope as K, LocalDeviceInfo as L, ManagedConnectionRecord as M, NativeManagedSessionStartResult as N, DevicePresenceStatus as O, PeerSessionSnapshot as P, PeerLifecycleStatus as Q, ResolvedPeerIdentity as R, SpaceAuthMode as S, TransportLatencySnapshot as T, ProtocolCapability as U, ProtocolCapabilityMap as V, ApplicationCryptoStreamTools as W, AppLimits as X, ApplicationCryptoBiStream as Y, ProtocolBaseName as Z, ProtocolImplementationKind as _, SpaceTokenProvider as a, RouteDescriptor as a0, RouteFamily as a1, RouteImplementationKind as a2, SignalingOptions as a3, RoomCreationMode as a4, ScanningLoopOptions as a5, ScanningLoopHandle as a6, RuntimeBootstrapOptions as a7, RuntimeBootstrapResult as a8, ManagedApplicationRouteOptions as a9, JoinRequest as aa, ConnectDeviceHooks as b, ConnectDeviceOptions as c, SignalingMode as d, RuntimeIdentity as e, Device as f, DeviceStatusSnapshot as g, SignalingEnvelope as h, DeviceEvent as i, SignalingSession as j, SessionEvent as k, BackendPeerUniStream as l, NativeConnectParams as m, NativeConnectResult as n, BackendConnectionState as o, ClientOptions as p, ConnectionOptions as q, ApplicationPayloadCrypto as r, ApplicationPayloadReadinessOptions as s, ApplicationPayloadRouteOptions as t, ProtocolName as u, ApplicationPayloadSendOptions as v, ChannelDescriptor as w, IncomingStreamChannelMetadata as x, ManagedDeviceConnectOptions as y, PeerState as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openrtc",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1 +0,0 @@
1
- import {o}from'./chunk-HVTYSEU7.js';function O(i){let s=o({...i});if("auth"in i&&!i.authMode){let n=i.auth;s.authMode=n==="none"?"anonymous":n;}if("identity"in i){let n=i.identity,r=n==="temporary"?"ephemeral":n;!i.deviceIdPersistence&&!i.nodeIdPersistence&&(s.deviceIdPersistence=r),!i.endpointIdPersistence&&!i.nodeIdPersistence&&(s.endpointIdPersistence=r);}return "namespace"in i&&!i.storagePrefix&&(s.storagePrefix=i.namespace),"privacy"in i&&i.strictMode===void 0&&(s.strictMode=!!i.privacy),s}function I(i,s){let n=i.runtime,r=Object.create(n),l=async e=>{if(typeof e!="string")return e;let o=(await n.listDevices()).find(c=>c.deviceId===e);if(!o)throw new Error(`OpenRTC device '${e}' is not currently discoverable.`);return o},u=async e=>({...e,localDeviceId:e?.localDeviceId??await n.getLocalDeviceId()??""}),R=async e=>{let{device:t,scope:o,...c}=e,a=c.deviceId??(typeof t=="string"?t:t?.deviceId)??null,m=c.ticket??(typeof t=="string"?void 0:t?.ticket);a&&!m&&(m=(await l(a).catch(()=>null))?.ticket);let d={...c,scope:o??"session"};return a&&(d.deviceId=a),m&&(d.ticket=m),d},g={list:()=>n.listDevices(),startSession:(e={})=>n.startManagedSession({...e,platform:e.platform??s}),stopSession:e=>n.stopManagedSession(e),listWithStatus:()=>n.listDevicesWithStatus(),watch:e=>n.watchDevices(e),watchWithStatus:e=>n.watchDevicesWithStatus(e),connect:async(e,t)=>n.connectDevice(await l(e),await u(t)),connectWithRetry:async(e,t,o)=>n.connectDeviceWithRetry(await l(e),t,o),disconnect:e=>n.disconnectDevice(e),update:(e,t)=>n.updateDevice(e,t),delete:e=>n.deleteDevice(e),localId:()=>n.getLocalDeviceId(),localInfo:()=>n.getLocalDeviceInfo(),localProfile:e=>n.getLocalDeviceProfile(e),updateLocalName:e=>n.updateLocalDeviceName(e)},v={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,t)=>n.disconnectPeer(e,t),forceDisconnect:e=>n.forceDisconnectPeer(e),session:e=>n.getPeerSession(e),sessions:()=>n.listPeerSessions(),waitConnected:(e,t)=>n.waitForConnectedPeer(e,t),readiness:(e,t)=>n.getPeerReadiness(e,t),health:e=>n.getPeerHealth(e),identity:e=>n.resolvePeerIdentity(e),addScope:(e,t)=>n.addPeerScope(e,t),releaseScope:(e,t)=>n.releasePeerScope(e,t),scopes:e=>n.getPeerScopes(e),refresh:()=>n.refreshPeerSnapshot()},C={register:e=>n.registerChannel(e),unregister:e=>n.unregisterChannel(e),list:()=>n.listChannels(),openBi:(e,t,o)=>n.openPeerBi(e,{...o,channelId:t}),openUni:(e,t,o)=>n.openPeerUni(e,{...o,channelId:t}),onIncoming:e=>n.onIncomingStream(e),onIncomingChannel:(e,t)=>n.onIncomingChannelStream(e,o=>{if(o.channel)return t(o)}),connect:async e=>n.connectScopedChannel(await R(e)),connectScoped:e=>n.connectScopedChannel(e)},P={create:e=>n.createRoom(e),join:(e,t)=>n.joinRoom(e,t),leave:e=>n.leaveRoom(e),watch:(e,t)=>n.watchRoom(e,t),members:e=>n.getRoomMembers(e)},h={raw:()=>n.getInvite(),share:e=>n.getTicketWithToken("share",e?.maxConnections??1),grant:(e,t)=>n.getTicketWithToken(e,t?.maxConnections??0),revoke:e=>n.revokeTokensByScope(e)},S={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()},b={runtime:n,assembly:i,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,t)=>n.setAutoConnectExcluded(e,t),notifyNetworkChange:e=>n.notifyNetworkChange(e)};return Object.defineProperties(r,{devices:{get:()=>g,enumerable:true},peers:{get:()=>v,enumerable:true},channels:{get:()=>C,enumerable:true},rooms:{get:()=>P,enumerable:true},tickets:{get:()=>h,enumerable:true},diagnostics:{get:()=>S,enumerable:true},advanced:{get:()=>b,enumerable:true},setAuth:{value:e=>i.setAuthContext(e),enumerable:true,writable:true,configurable:true},setAuthContext:{value:e=>i.setAuthContext(e),enumerable:true,writable:true,configurable:true},syncPlutoAuth:{value:e=>i.syncPlutoAuth(e),enumerable:true,writable:true,configurable:true},bindPlutoAuthHost:{value:()=>i.bindPlutoAuthHost(),enumerable:true,writable:true,configurable:true},signIn:{value:()=>i.signInWithPluto(),enumerable:true,writable:true,configurable:true},signOut:{value:()=>i.signOut(),enumerable:true,writable:true,configurable:true},runtime:{get:()=>n,enumerable:false},_assembly:{get:()=>i,enumerable:false}}),r}export{O as a,I as b};