openrtc 1.0.5 → 1.0.6

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.
@@ -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';
@@ -0,0 +1,297 @@
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
+ 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-N9s66nF8.js';
5
+ import { R as RuntimeCapabilities, a as RuntimeCapabilityProfile } from './capabilities-C4Dqs_pB.js';
6
+
7
+ type OpenRTCChannelConnectOptions = Omit<RuntimeScopedChannelOptions, 'scope' | 'deviceId' | 'ticket'> & {
8
+ /**
9
+ * Device selected from `client.devices.*`. Passing the device object lets
10
+ * OpenRTC reuse its current ticket for native and ticket-gated routes.
11
+ */
12
+ device?: string | RuntimeDevice;
13
+ deviceId?: string | null;
14
+ ticket?: string;
15
+ /**
16
+ * Logical channel lifecycle scope. Most app channels should use the default
17
+ * `session`; pass a custom scope only when you intentionally manage peer
18
+ * lifecycle separately from the channel.
19
+ */
20
+ scope?: RuntimeScopedChannelOptions['scope'];
21
+ };
22
+ type OpenRTCDeviceSessionOptions = Omit<RuntimeManagedSessionOptions, 'platform'> & {
23
+ /**
24
+ * Runtime host for the managed user-device session. Normal apps can omit
25
+ * this: `OpenRTC(...)` defaults to `web`, and `OpenRTC.native(...)` defaults
26
+ * to `native`.
27
+ */
28
+ platform?: RuntimeManagedSessionOptions['platform'];
29
+ };
30
+ interface OpenRTCDeviceNamespace {
31
+ startSession(options?: OpenRTCDeviceSessionOptions): Promise<RuntimeManagedSession>;
32
+ stopSession(options?: {
33
+ preserveBackendSession?: boolean;
34
+ }): Promise<void>;
35
+ list(): Promise<RuntimeDevice[]>;
36
+ listWithStatus(): Promise<RuntimeDeviceStatusSnapshot[]>;
37
+ watch(callback: (devices: RuntimeDevice[]) => void): () => void;
38
+ watchWithStatus(callback: (devices: RuntimeDeviceStatusSnapshot[]) => void): () => void;
39
+ connect(device: string | RuntimeDevice, options?: RuntimeDeviceConnectOptions): Promise<ConnectDeviceResult>;
40
+ /**
41
+ * @deprecated Use `devices.connect()`. Retry and route recovery are owned by
42
+ * OpenRTC; legacy consumer-provided connection hooks are ignored.
43
+ */
44
+ connectWithRetry(device: string | RuntimeDevice, hooks: ConnectDeviceHooks, options: ConnectDeviceOptions): Promise<ConnectDeviceResult>;
45
+ disconnect(deviceId: string): Promise<void>;
46
+ update(deviceId: string, updates: {
47
+ deviceName?: string;
48
+ capabilities?: RuntimeDevice['capabilities'];
49
+ metadata?: string;
50
+ }): Promise<void>;
51
+ delete(deviceId: string): Promise<void>;
52
+ localId(): Promise<string | null>;
53
+ localInfo(): Promise<RuntimeLocalDeviceInfo | null>;
54
+ localProfile(options?: {
55
+ deviceName?: string;
56
+ localDeviceId?: string | null;
57
+ platform?: 'native' | 'web';
58
+ userId?: string | null;
59
+ }): Promise<RuntimeLocalDeviceProfile>;
60
+ updateLocalName(deviceName: string): Promise<RuntimeLocalDeviceInfo | null>;
61
+ }
62
+ interface OpenRTCPeerNamespace {
63
+ watch(callback: (peers: RuntimePeerState[]) => void): () => void;
64
+ watchLifecycle(callback: (peers: RuntimePeerState[]) => void): () => void;
65
+ get(id: string): RuntimePeerState | undefined;
66
+ listConnected(): RuntimePeerState[];
67
+ connect(options: RuntimePeerConnectOptions): Promise<Connection>;
68
+ disconnect(id: string, scope?: string): Promise<void>;
69
+ forceDisconnect(id: string): Promise<void>;
70
+ session(id: string): Promise<PeerSessionSnapshot | null>;
71
+ sessions(): Promise<PeerSessionSnapshot[]>;
72
+ waitConnected(id: string, timeoutMs?: number): Promise<PeerSessionSnapshot | null>;
73
+ readiness(id: string, timeoutMs?: number): Promise<RuntimePeerReadinessSnapshot>;
74
+ health(id: string): Promise<RuntimePeerHealth>;
75
+ identity(id: string): Promise<ResolvedPeerIdentity>;
76
+ addScope(id: string, scope?: string): RuntimePeerState | undefined;
77
+ releaseScope(id: string, scope?: string): RuntimePeerState | undefined;
78
+ scopes(id: string): string[];
79
+ refresh(): Promise<RuntimePeerState[]>;
80
+ }
81
+ interface OpenRTCChannelNamespace {
82
+ register(descriptor: RuntimeChannelDescriptor): void;
83
+ unregister(channelId: string): void;
84
+ list(): RuntimeChannelDescriptor[];
85
+ openBi(id: string, channelId: string, options?: Omit<RuntimePeerStreamOptions, 'channelId'>): Promise<{
86
+ connection: Connection;
87
+ readable: ReadableStream<Uint8Array>;
88
+ writable: WritableStream<Uint8Array>;
89
+ }>;
90
+ openUni(id: string, channelId: string, options?: Omit<RuntimePeerStreamOptions, 'channelId'>): Promise<{
91
+ connection: Connection;
92
+ writable: WritableStream<Uint8Array>;
93
+ }>;
94
+ onIncoming(callback: (stream: RuntimeIncomingStream) => boolean | void): () => void;
95
+ onIncomingChannel(channelId: string, callback: (stream: RuntimeIncomingStream & {
96
+ channel: NonNullable<RuntimeIncomingStream['channel']>;
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[]>;
117
+ }
118
+ interface OpenRTCDiagnosticsNamespace {
119
+ status(): Promise<{
120
+ runtime: 'tauri' | 'browser' | 'unknown';
121
+ wasmLoaded: boolean;
122
+ localNodeId?: string;
123
+ userId?: string;
124
+ }>;
125
+ policy(): RuntimePolicySnapshot;
126
+ capabilities(): RuntimeCapabilities;
127
+ capabilityProfile(): RuntimeCapabilityProfile;
128
+ connectionStates(): Promise<RuntimeConnectionStateSnapshot[]>;
129
+ onConnectionStateChange(callback: (state: RuntimeConnectionStateSnapshot) => void): Promise<() => void> | (() => void);
130
+ connections(): Connection[];
131
+ applicationReadyConnections(options?: RuntimeApplicationPayloadReadinessOptions): Connection[];
132
+ onConnection(callback: (connection: Connection) => void): () => void;
133
+ onDisconnection(callback: (connection: Connection) => void): () => void;
134
+ onConnectionEvent(callback: (event: RuntimeConnectionEvent) => void): () => void;
135
+ forceReconnectSnapshot(): void;
136
+ peerReconciliation(): Readonly<PeerReconciliationStats>;
137
+ }
138
+ interface OpenRTCAdvancedNamespace {
139
+ readonly runtime: RuntimeClient;
140
+ readonly assembly: PlutoRuntimeAssembly;
141
+ nodeId(): Promise<string>;
142
+ nodeIdFromTicket(ticket: string): Promise<string | null>;
143
+ endpointTicket(): Promise<string>;
144
+ connectRaw(target: {
145
+ ticket: string;
146
+ timeoutMs?: number;
147
+ }): Promise<RuntimeRawConnection>;
148
+ openBi(nodeId: string): Promise<{
149
+ readable: ReadableStream<Uint8Array>;
150
+ writable: WritableStream<Uint8Array>;
151
+ }>;
152
+ openUni(nodeId: string): Promise<WritableStream<Uint8Array>>;
153
+ isConnected(nodeId: string): Promise<boolean>;
154
+ disconnectNode(nodeId: string): Promise<void>;
155
+ setAutoConnectExcluded(deviceId: string, excluded: boolean): Promise<void>;
156
+ notifyNetworkChange(reason?: string): Promise<void>;
157
+ }
158
+ /**
159
+ * OpenRTCClient extends RuntimeClient with auth helpers that were
160
+ * previously only available on PlutoRuntimeAssembly.
161
+ *
162
+ * This is the unified type returned by OpenRTC() and OpenRTC.native().
163
+ */
164
+ interface OpenRTCClient extends RuntimeClient {
165
+ readonly devices: OpenRTCDeviceNamespace;
166
+ readonly peers: OpenRTCPeerNamespace;
167
+ readonly channels: OpenRTCChannelNamespace;
168
+ readonly rooms: OpenRTCRoomNamespace;
169
+ readonly tickets: OpenRTCTicketNamespace;
170
+ readonly diagnostics: OpenRTCDiagnosticsNamespace;
171
+ readonly advanced: OpenRTCAdvancedNamespace;
172
+ /** @deprecated Use setAuth() instead */
173
+ setAuthContext(context: AuthContext | null): Promise<void>;
174
+ /** Set auth context for the runtime */
175
+ setAuth(context: AuthContext | null): Promise<void>;
176
+ /** Sync Pluto-hosted auth to the runtime */
177
+ syncPlutoAuth(options?: {
178
+ userId?: string | null;
179
+ forceRefresh?: boolean;
180
+ }): Promise<void>;
181
+ /** Bind Pluto auth host to auto-sync on token changes */
182
+ bindPlutoAuthHost(): () => void;
183
+ /** Sign in via Pluto SSO */
184
+ signIn(): Promise<void>;
185
+ /** Sign out and clear auth context */
186
+ signOut(): Promise<void>;
187
+ /**
188
+ * @deprecated Use `client.devices.startSession(...)` for the public
189
+ * user-device avenue lifecycle. This top-level method remains for
190
+ * RuntimeClient compatibility and advanced integrations.
191
+ */
192
+ startManagedSession(options: RuntimeManagedSessionOptions): Promise<RuntimeManagedSession>;
193
+ /**
194
+ * @deprecated Use `client.devices.stopSession(...)` for the public
195
+ * user-device avenue lifecycle.
196
+ */
197
+ stopManagedSession(options?: {
198
+ preserveBackendSession?: boolean;
199
+ }): Promise<void>;
200
+ /** @deprecated Use `client.rooms.create(...)`. */
201
+ createRoom(roomId?: string): Promise<string>;
202
+ /** @deprecated Use `client.rooms.join(...)`. */
203
+ joinRoom(roomId: string, options?: RuntimeJoinRoomOptions): Promise<Connection[]>;
204
+ /** @deprecated Use `client.rooms.leave(...)`. */
205
+ leaveRoom(roomId: string): Promise<void>;
206
+ /** @deprecated Use `client.rooms.watch(...)`. */
207
+ watchRoom(roomId: string, callback: (members: RuntimeRoomMember[]) => void): () => void;
208
+ /** @deprecated Use `client.rooms.members(...)`. */
209
+ getRoomMembers(roomId: string): Promise<RuntimeRoomMember[]>;
210
+ /** @deprecated Use `client.tickets.raw(...)`. */
211
+ getInvite(): Promise<string>;
212
+ /** @deprecated Use `client.tickets.raw(...)`. */
213
+ getTicket(): Promise<string>;
214
+ /** @deprecated Use `client.tickets.share(...)` or `client.tickets.grant(...)`. */
215
+ getTicketWithToken(scope: GrantScope, maxConnections?: number): Promise<string>;
216
+ /** @deprecated Use `client.tickets.revoke(...)`. */
217
+ revokeTokensByScope(scope: GrantScope): Promise<string[]>;
218
+ /** @deprecated Use `client.peers.connect(...)`. */
219
+ connectPeer(options: RuntimePeerConnectOptions): Promise<Connection>;
220
+ /** @deprecated Use `client.peers.connect(...)`. */
221
+ connectTo(options: RuntimePeerConnectOptions): Promise<Connection>;
222
+ /** @deprecated Use `client.peers.waitConnected(...)`. */
223
+ waitForConnectedPeer(id: string, timeoutMs?: number): Promise<PeerSessionSnapshot | null>;
224
+ /** @deprecated Use `client.channels.connect(...)`; use `client.channels.connectScoped(...)` only for custom lifecycle scopes. */
225
+ connectScopedChannel(options: RuntimeScopedChannelOptions): Promise<RuntimeScopedLogicalChannel>;
226
+ /** @deprecated Use `client.channels.openBi(...)`. */
227
+ openPeerBi(id: string, options?: RuntimePeerStreamOptions): Promise<{
228
+ connection: Connection;
229
+ readable: ReadableStream<Uint8Array>;
230
+ writable: WritableStream<Uint8Array>;
231
+ }>;
232
+ /** @deprecated Use `client.channels.openUni(...)`. */
233
+ openPeerUni(id: string, options?: RuntimePeerStreamOptions): Promise<{
234
+ connection: Connection;
235
+ writable: WritableStream<Uint8Array>;
236
+ }>;
237
+ /**
238
+ * Access to the underlying PlutoRuntimeAssembly for backward compatibility.
239
+ * @deprecated Access methods directly on the client instead.
240
+ */
241
+ readonly runtime: RuntimeClient;
242
+ /**
243
+ * Access to the underlying PlutoRuntimeAssembly for backward compatibility.
244
+ * @internal
245
+ */
246
+ readonly _assembly: PlutoRuntimeAssembly;
247
+ }
248
+
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 };
@@ -0,0 +1,33 @@
1
+ import { p as ClientOptions } from './types-ZDsZknDI.js';
2
+ import { W as WasmBridgeOptions, D as DelegatingRuntimeAdapter } from './DelegatingRuntimeAdapter-lFDUNBy9.js';
3
+ import { P as PlutoIpcBridge } from './ipc-CflAVodw.js';
4
+
5
+ interface NativeIpcBridgeOptions extends WasmBridgeOptions {
6
+ allowWasmFallback?: boolean;
7
+ ipcBridge?: PlutoIpcBridge;
8
+ transports?: ClientOptions['transports'];
9
+ strictMode?: boolean;
10
+ }
11
+
12
+ interface IpcRuntimeAdapterOptions extends NativeIpcBridgeOptions {
13
+ bridge: PlutoIpcBridge;
14
+ }
15
+ declare class IpcRuntimeAdapter extends DelegatingRuntimeAdapter {
16
+ constructor(options: IpcRuntimeAdapterOptions);
17
+ }
18
+
19
+ /**
20
+ * @deprecated Native Tauri support now lives in the first-party `openrtc-tauri` package.
21
+ * Removal target: OpenRTC 0.2.0. This shim remains for one compatibility cycle.
22
+ */
23
+ declare function createTauriIpcBridge(): PlutoIpcBridge;
24
+ /**
25
+ * @deprecated Native Tauri support now lives in the first-party `openrtc-tauri` package.
26
+ * Removal target: OpenRTC 0.2.0. This shim remains for one compatibility cycle.
27
+ */
28
+ declare class TauriRuntimeAdapter extends IpcRuntimeAdapter {
29
+ constructor(options: NativeIpcBridgeOptions);
30
+ }
31
+ type TauriRuntimeAdapterOptions = NativeIpcBridgeOptions;
32
+
33
+ export { IpcRuntimeAdapter as I, TauriRuntimeAdapter as T, type IpcRuntimeAdapterOptions as a, type TauriRuntimeAdapterOptions as b, createTauriIpcBridge as c };
@@ -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;