openrtc 2.0.0-rc.20 → 2.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/WasmBridge-T5XMT6FH.js +1 -0
- package/dist/{chunk-RGRVKR66.js → chunk-5OHYIHPT.js} +1 -1
- package/dist/chunk-DA3HSI3K.js +2 -0
- package/dist/{chunk-FQH6O3SU.js → chunk-FAPRYEWI.js} +1 -1
- package/dist/{chunk-R2QM2IDY.js → chunk-HTAWPIP2.js} +1 -1
- package/dist/{chunk-KEPDY3LB.js → chunk-PPZRTJHE.js} +1 -1
- package/dist/{chunk-NCMT4MKM.js → chunk-WWC767HK.js} +1 -1
- package/dist/deviceManagement-PHY5TIOS.js +1 -0
- package/dist/factories-SMMQHXUH.js +1 -0
- package/dist/index.js +1 -1
- package/dist/ipcFactory-AR3VIBM4.js +1 -0
- package/dist/native.js +1 -1
- package/dist/openrtc_bg.wasm +0 -0
- package/dist/runtime/WasmRuntimeAdapter.js +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/WasmBridge-VN3MA4LT.js +0 -1
- package/dist/chunk-NW25RLPN.js +0 -2
- package/dist/factories-NLQVWWJE.js +0 -1
- package/dist/ipcFactory-SMUMTEMH.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import {v}from'./chunk-
|
|
1
|
+
import {v}from'./chunk-FAPRYEWI.js';var a=class{constructor(e){this.backend=e;}get currentUser(){return this.backend.currentUser}setAuthContext(e){return this.backend.setAuthContext?.(e)}async signInAnonymously(){return this.backend.signInAnonymously()}async signInWithPluto(){if(typeof this.backend.signInWithPluto!="function")throw new Error("Selected runtime adapter does not support Pluto SSO.");return this.backend.signInWithPluto()}async signOut(){return this.backend.signOut()}async stopAuthScopedActivity(){typeof this.backend.stopAuthScopedActivity=="function"&&await this.backend.stopAuthScopedActivity();}usesCoordinationGateway(){return this.backend.usesCoordinationGateway?.()===true}async joinCoordinationRoom(e,n,t){if(!this.backend.joinCoordinationRoom)throw new Error("Selected runtime adapter does not support coordination rooms.");await this.backend.joinCoordinationRoom(e,n,t);}async leaveCoordinationRoom(e){if(!this.backend.leaveCoordinationRoom)throw new Error("Selected runtime adapter does not support coordination rooms.");await this.backend.leaveCoordinationRoom(e);}async getCoordinationRoomMembers(e){if(!this.backend.getCoordinationRoomMembers)throw new Error("Selected runtime adapter does not support coordination rooms.");return this.backend.getCoordinationRoomMembers(e)}watchCoordinationRoomMembers(e,n){if(!this.backend.watchCoordinationRoomMembers)throw new Error("Selected runtime adapter does not support coordination rooms.");return this.backend.watchCoordinationRoomMembers(e,n)}async getTurnCredentials(){return this.backend.getTurnCredentials()}async updatePresence(e,n,t,i,r){return this.backend.updatePresence(e,n,t,i,r)}async refreshLivePresence(e,n,t){if(typeof this.backend.refreshLivePresence!="function")throw new Error("Selected runtime adapter does not support refreshLivePresence().");return this.backend.refreshLivePresence(e,n,t)}async setOffline(e){return this.backend.setOffline(e)}async cleanupStaleDevices(){return this.backend.cleanupStaleDevices()}async searchDevices(e){return this.backend.searchDevices(e)}async listDevicesWithStatus(){if(typeof this.backend.listDevicesWithStatus!="function")throw new Error("Selected runtime adapter does not support listDevicesWithStatus().");return this.backend.listDevicesWithStatus()}async getPeerSession(e){return typeof this.backend.getPeerSession!="function"?null:this.backend.getPeerSession(e)}async listPeerSessions(){return typeof this.backend.listPeerSessions!="function"?[]:this.backend.listPeerSessions()}async waitForSettledPeer(e,n){return typeof this.backend.waitForSettledPeer!="function"?null:this.backend.waitForSettledPeer(e,n)}async resolvePeerIdentity(e){return typeof this.backend.resolvePeerIdentity!="function"?{peerId:null,deviceId:null,deviceIdHint:null,nodeId:null}:this.backend.resolvePeerIdentity(e)}async resolvePeerConnectionRecords(e){return typeof this.backend.resolvePeerConnectionRecords!="function"?[]:this.backend.resolvePeerConnectionRecords(e)}async updateDevice(e,n){return this.backend.updateDevice(e,n)}async deleteDevice(e){return this.backend.deleteDevice(e)}onDevicesChange(e,n){return this.backend.onDevicesChange(e,n)}onAuthChange(e){return this.backend.onAuthChange(e)}async checkForSSOToken(){return this.backend.checkForSSOToken()}async waitForAuth(){return this.backend.waitForAuth()}async sendMessage(e,n,t,i){return this.backend.sendMessage(e,n,t,i)}async pollMessages(e){return this.backend.pollMessages(e)}watchFriendDevices(e,n){let t=this.backend;return t.watchFriendDevices?t.watchFriendDevices(e,n):()=>{}}async updateFriendTicket(e){let n=this.backend;n.updateFriendTicket&&await n.updateFriendTicket(e);}async subscribeDevices(e){return this.backend.subscribeDevices(e)}startAutoConnect(e,n){this.backend.startAutoConnect(e,n);}async submitDesiredPeerProjection(e,n){if(typeof this.backend.submitDesiredPeerProjection!="function")throw new Error("Selected runtime adapter does not support desired-peer projections.");await this.backend.submitDesiredPeerProjection(e,n);}startPresenceLoop(e,n,t,i,r){this.backend.startPresenceLoop(e,n,t,i,r);}async createSession(e){return this.backend.createSession(e)}async updateSession(e,n){return this.backend.updateSession(e,n)}async subscribeSessions(e){return this.backend.subscribeSessions(e)}forceReconnectSnapshot(){this.backend.forceReconnectSnapshot();}async getLocalDeviceId(){return typeof this.backend.getLocalDeviceId!="function"?null:this.backend.getLocalDeviceId()}async getLocalDeviceInfo(){return typeof this.backend.getLocalDeviceInfo!="function"?null:this.backend.getLocalDeviceInfo()}async updateLocalDeviceName(e){return typeof this.backend.updateLocalDeviceName!="function"?null:this.backend.updateLocalDeviceName(e)}async startManagedSessionNative(e){let n=this.backend;if(typeof n.startManagedSessionNative!="function")throw new Error("Selected runtime adapter does not support startManagedSessionNative().");return n.startManagedSessionNative(e)}async notifyNetworkChange(e){return typeof this.backend.notifyNetworkChange!="function"?null:this.backend.notifyNetworkChange(e)}async getManagedNodeId(e){if(console.info("[DelegatingRuntimeAdapter][getManagedNodeId] enter",{hasMethod:typeof this.backend.getManagedNodeId=="function",backendCtor:this.backend.constructor?.name??null}),typeof this.backend.getManagedNodeId!="function")return null;let n=await this.backend.getManagedNodeId(e);return console.info("[DelegatingRuntimeAdapter][getManagedNodeId] resolved",{result:n}),n}async startPresenceLoopOnce(e,n,t,i,r){let o=this.backend;if(typeof o.startPresenceLoopOnce!="function")throw new Error("Selected runtime adapter does not support startPresenceLoopOnce().");return o.startPresenceLoopOnce(e,n,t,i,r)}async startAutoConnectOnce(e,n){let t=this.backend;if(typeof t.startAutoConnectOnce!="function")throw new Error("Selected runtime adapter does not support startAutoConnectOnce().");return t.startAutoConnectOnce(e,n)}async getEndpointTicket(){if(typeof this.backend.getEndpointTicket!="function")throw new Error("Selected runtime adapter does not support getEndpointTicket().");return this.backend.getEndpointTicket()}async getEndpointTicketWithToken(e,n){let t=this.backend;return typeof t.getEndpointTicketWithToken!="function"?null:t.getEndpointTicketWithToken(e,n)}async registerSessionToken(e,n,t,i){let r=this.backend;typeof r.registerSessionToken=="function"&&await r.registerSessionToken(e,n,t,i);}async revokeSessionTokensByScope(e){let n=this.backend;return typeof n.revokeSessionTokensByScope!="function"?[]:n.revokeSessionTokensByScope(e)}async openPeerBi(e,n){if(typeof this.backend.openPeerBi!="function")throw new Error("Selected runtime adapter does not support openPeerBi().");return this.backend.openPeerBi(e,n)}async incoming_streams(){let e=this.backend;if(typeof e.incoming_streams!="function")throw new Error("Selected runtime adapter does not support incoming_streams().");return e.incoming_streams()}async is_current_transport_stable_id(e,n){let t=this.backend;return typeof t.is_current_transport_stable_id!="function"?false:t.is_current_transport_stable_id(e,n)}async openPeerNativeBi(e,n,t){let i=this.backend;if(typeof i.openPeerNativeBi!="function")throw new Error("Selected runtime adapter does not support openPeerNativeBi().");return i.openPeerNativeBi(e,n,t)}async openPeerBiTransportOnly(e,n){let t=this.backend;return typeof t.openPeerBiTransportOnly=="function"?t.openPeerBiTransportOnly(e,n):this.openPeerBi(e,n)}async openPeerUni(e,n){if(typeof this.backend.openPeerUni!="function")throw new Error("Selected runtime adapter does not support openPeerUni().");return this.backend.openPeerUni(e,n)}async connectToDevice(e){if(typeof this.backend.connectToDevice!="function")throw new Error("Selected runtime adapter does not support connectToDevice().");return this.backend.connectToDevice(e)}async disconnectDevice(e){if(typeof this.backend.disconnectDevice!="function")throw new Error("Selected runtime adapter does not support disconnectDevice().");return this.backend.disconnectDevice(e)}async setAutoConnectExcluded(e,n){if(typeof this.backend.setAutoConnectExcluded!="function")throw new Error("Selected runtime adapter does not support setAutoConnectExcluded().");return this.backend.setAutoConnectExcluded(e,n)}async isConnected(e){return this.backend.isConnected(e)}async getConnectionStates(){return typeof this.backend.getConnectionStates!="function"?[]:this.backend.getConnectionStates()}onConnectionStateChange(e){return typeof this.backend.onConnectionStateChange!="function"?()=>{}:this.backend.onConnectionStateChange(e)}async sendExplicitFilePath(e,n,t){if(typeof this.backend.sendExplicitFilePath!="function")throw new Error("Selected runtime adapter does not support sendExplicitFilePath().");return this.backend.sendExplicitFilePath(e,n,t)}async sendExplicitFileData(e){if(typeof this.backend.sendExplicitFileData!="function")throw new Error("Selected runtime adapter does not support sendExplicitFileData().");return this.backend.sendExplicitFileData(e)}async getTransferHistory(e){return typeof this.backend.getTransferHistory!="function"?[]:this.backend.getTransferHistory(e)}async deleteTransferJob(e){if(typeof this.backend.deleteTransferJob=="function")return this.backend.deleteTransferJob(e)}getRuntimeCapabilities(){let e=this.backend;return typeof e.getRuntimeCapabilities=="function"?e.getRuntimeCapabilities():v()}async onIncomingNativeMessage(e){let n=this.backend;return typeof n.onIncomingNativeMessage!="function"?()=>{}:n.onIncomingNativeMessage(e)}unwrap(){return this.backend}setCoreClient(e){let n=this.backend;typeof n.setCoreClient=="function"&&n.setCoreClient(e);}};export{a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function a(e){let t=e.split(".")[1];if(!t)throw new Error("OpenRTC returned a malformed credential.");let r=t.replace(/-/g,"+").replace(/_/g,"/");return String(JSON.parse(atob(r.padEnd(Math.ceil(r.length/4)*4,"="))).jti??"")}async function d(e){if(e.source.type!=="device-certificate")throw new Error("Device management requires an authenticated device certificate.");let t=async r=>{let c=a(r.token),n=await(await e.key()).proof((i,o)=>["openrtc:v2:device-management",c,e.action,e.targetDeviceId??"",e.exceptCurrent?"except-current":"include-current",i,o].join(":"));return e.post({action:e.action,deviceCertificate:r.token,currentDeviceId:e.currentDeviceId,...e.targetDeviceId?{targetDeviceId:e.targetDeviceId}:{},...e.exceptCurrent?{exceptCurrent:true}:{},deviceProof:n})};try{return await t(e.source)}catch(r){if(!e.isStale(r))throw r;let c=await e.source.recoverRejectedCertificate?.();if(!c)throw r;return t(c)}}export{d as manageDevice};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$2}from'./chunk-5OHYIHPT.js';import {u,a as a$3}from'./chunk-PPZRTJHE.js';import'./chunk-Z2WVSXPW.js';import'./chunk-WWC767HK.js';import'./chunk-FAPRYEWI.js';import {a as a$1}from'./chunk-QHSM5NFZ.js';import'./chunk-NT5YHZQH.js';import'./chunk-RRMBD5OL.js';import'./chunk-PQK5SJ47.js';import'./chunk-C7YN5MSV.js';var s=false;function a(){s||(s=true,a$3(async()=>{let t=await import('./openrtc-3YHRRPAG.js');return {initWasm:t.default,WasmClient:t.WasmClient,start:t.start}}));}async function d(t){a();let e=a$1(t),{WasmBridge:i}=await import('./WasmBridge-T5XMT6FH.js');return a$2(e,new i(e))}function y(t,e){let i=a$1(t);return a$2(i,new u({...i,bridge:e}))}export{y as createIpcClient,d as createWasmClient};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-HTAWPIP2.js';import {d}from'./chunk-Z2WVSXPW.js';import {c}from'./chunk-DA3HSI3K.js';export{a as OPENRTC_ERROR_CODES,b as OpenRtcError,e as classifyOpenRtcFailure,d as openRtcError,c as projectOpenRtcErrorFields}from'./chunk-NT5YHZQH.js';function i(p){return c(p,{platform:"web",runtimeFactory:async e=>{let{createWasmClient:t}=await import('./factories-SMMQHXUH.js');return t(e)}})}i.native=function(p,e=d()){return c(p,{platform:"native",deviceKeyProvider:a(e),deviceIdProvider:async()=>{let t=await e.invoke("get_rtc_local_device_info");return String(t?.deviceId??"")},runtimeFactory:async t=>{let{createIpcClient:c}=await import('./ipcFactory-AR3VIBM4.js');return c(t,e)}})};export{i as OpenRTC};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-5OHYIHPT.js';import {u}from'./chunk-PPZRTJHE.js';import'./chunk-Z2WVSXPW.js';import'./chunk-WWC767HK.js';import'./chunk-FAPRYEWI.js';import {a}from'./chunk-QHSM5NFZ.js';import'./chunk-NT5YHZQH.js';import'./chunk-RRMBD5OL.js';import'./chunk-PQK5SJ47.js';import'./chunk-C7YN5MSV.js';function s(i,r){let t=a(i);return a$1(t,new u({...t,bridge:r}))}export{s as createIpcClient};
|
package/dist/native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-HTAWPIP2.js';export{a as classifyNativeIpcFailure,b as isNativeIpcCommandUnavailable}from'./chunk-Z2WVSXPW.js';import {c}from'./chunk-DA3HSI3K.js';function m(n,e){return c(n,{platform:"native",deviceKeyProvider:a(e),deviceIdProvider:async()=>{let t=await e.invoke("get_rtc_local_device_info");return String(t?.deviceId??"")},runtimeFactory:async t=>{let{createIpcClient:o}=await import('./ipcFactory-AR3VIBM4.js');return o(t,e)}})}export{m as createNativeOpenRTC};
|
package/dist/openrtc_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'../chunk-
|
|
1
|
+
import {a}from'../chunk-WWC767HK.js';import {y}from'../chunk-FAPRYEWI.js';import'../chunk-QHSM5NFZ.js';import'../chunk-NT5YHZQH.js';import'../chunk-PQK5SJ47.js';import'../chunk-C7YN5MSV.js';var n=class extends a{constructor(e){super(new y(e));}setWasmClient(e){this.unwrap().setWasmClient(e);}};export{n as WasmRuntimeAdapter};
|
package/dist/runtime/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b as Connection,u as IpcRuntimeAdapter,t as RuntimeClient,c as RuntimeConnectionController,g as ScopedConnectionActorError,j as ScopedConnectionActorHandle,k as ScopedConnectionActorRegistry,f as clog,r as concatRuntimeBytes,e as correlationForDriveGrantScope,q as createRuntimeJsonFrameDecoder,m as createRuntimeU32BEFrameDecoder,o as decodeRuntimeJsonPayload,p as encodeRuntimeJsonFrame,n as encodeRuntimeJsonPayload,l as encodeRuntimeU32BEFrame,s as readRuntimeU32BE,d as renderCorrelationFields,h as scopedConnectionKey,i as scopedConnectionKeyToString}from'../chunk-
|
|
1
|
+
export{b as Connection,u as IpcRuntimeAdapter,t as RuntimeClient,c as RuntimeConnectionController,g as ScopedConnectionActorError,j as ScopedConnectionActorHandle,k as ScopedConnectionActorRegistry,f as clog,r as concatRuntimeBytes,e as correlationForDriveGrantScope,q as createRuntimeJsonFrameDecoder,m as createRuntimeU32BEFrameDecoder,o as decodeRuntimeJsonPayload,p as encodeRuntimeJsonFrame,n as encodeRuntimeJsonPayload,l as encodeRuntimeU32BEFrame,s as readRuntimeU32BE,d as renderCorrelationFields,h as scopedConnectionKey,i as scopedConnectionKeyToString}from'../chunk-PPZRTJHE.js';export{a as classifyNativeIpcFailure,b as isNativeIpcCommandUnavailable}from'../chunk-Z2WVSXPW.js';export{b as runtimeFromCapability}from'../chunk-DA3HSI3K.js';export{a as isRuntimeDeviceActive,c as isRuntimeDeviceConnectable,b as isRuntimeDeviceRoutable}from'../chunk-CK6WQV7J.js';import'../chunk-WWC767HK.js';export{s as BROWSER_WASM_RUNTIME_CAPABILITIES,t as NATIVE_IPC_RUNTIME_CAPABILITIES,q as OPENRTC_RUNTIME_POLICY,u as cloneRuntimeCapabilities,r as getRuntimePolicy,i as logOpenRtcTeardownTrace,v as runtimeCapabilitiesForBrowserHost,w as runtimeCapabilitiesFromNativeStatus,x as runtimeCapabilityProfile}from'../chunk-FAPRYEWI.js';import'../chunk-QHSM5NFZ.js';import'../chunk-NT5YHZQH.js';import'../chunk-RRMBD5OL.js';export{b as openRtcDebug,a as openRtcDebugEnabled,c as openRtcDebugInfo,d as openRtcDebugLog}from'../chunk-PQK5SJ47.js';import'../chunk-C7YN5MSV.js';
|
package/dist/testing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-HTAWPIP2.js';import {c}from'./chunk-DA3HSI3K.js';function l(r,n,e={}){return c(r,{endpoints:n,testingAllowInsecureLoopback:true,platform:"web",...e.deviceId?{deviceIdProvider:async()=>e.deviceId}:{},...e.irohTestRelayUrl?{irohTestRelayUrl:e.irohTestRelayUrl}:{},runtimeFactory:async t=>{let{createWasmClient:i}=await import('./factories-SMMQHXUH.js');return i(t)}})}function s(r,n,e){return c(r,{endpoints:n,testingAllowInsecureLoopback:true,platform:"native",deviceKeyProvider:a(e),deviceIdProvider:async()=>{let t=await e.invoke("get_rtc_local_device_info");return String(t?.deviceId??"")},runtimeFactory:async t=>{let{createIpcClient:i}=await import('./ipcFactory-AR3VIBM4.js');return i(t,e)}})}export{s as createTestingNativeOpenRTC,l as createTestingOpenRTC};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{y as WasmBridge}from'./chunk-FQH6O3SU.js';import'./chunk-NT5YHZQH.js';import'./chunk-PQK5SJ47.js';import'./chunk-QHSM5NFZ.js';import'./chunk-C7YN5MSV.js';
|
package/dist/chunk-NW25RLPN.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var T=new Map;function k(a){let e=new Uint8Array(a),t="";for(let i of e)t+=String.fromCharCode(i);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function V(a){let e=JSON.stringify({crv:a.crv,kty:a.kty,x:a.x});return k(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e)))}function q(){return k(crypto.getRandomValues(new Uint8Array(24)).buffer)}async function S(){return typeof indexedDB>"u"?null:new Promise((a,e)=>{let t=indexedDB.open("openrtc-v2-device-keys",1);t.onupgradeneeded=()=>{t.result.objectStoreNames.contains("keys")||t.result.createObjectStore("keys");},t.onsuccess=()=>a(t.result),t.onerror=()=>e(t.error);})}async function B(a){let e=await S().catch(()=>null);if(!e)return T.get(a)??null;try{return await new Promise((t,i)=>{let n=e.transaction("keys","readonly").objectStore("keys").get(a);n.onsuccess=()=>t(n.result??null),n.onerror=()=>i(n.error);})}finally{e.close();}}async function z(a,e){let t=await S().catch(()=>null);if(!t){T.set(a,e);return}try{await new Promise((i,n)=>{let r=t.transaction("keys","readwrite").objectStore("keys").put(e,a);r.onsuccess=()=>i(),r.onerror=()=>n(r.error);});}finally{t.close();}}async function Z(a){T.delete(a);let e=await S().catch(()=>null);if(e)try{await new Promise((t,i)=>{let n=e.transaction("keys","readwrite").objectStore("keys").delete(a);n.onsuccess=()=>t(),n.onerror=()=>i(n.error);});}finally{e.close();}}async function X(a){let e=await B(a);if(e)return e;let t=await crypto.subtle.generateKey({name:"Ed25519"},false,["sign","verify"]);return await z(a,t),t}var N={async getOrCreate(a){let e=await X(a),t=await crypto.subtle.exportKey("jwk",e.publicKey),i=await V(t);return {publicKeyJwk:t,thumbprint:i,async proof(n){let r=q(),s=Math.floor(Date.now()/1e3),o=await crypto.subtle.sign({name:"Ed25519"},e.privateKey,new TextEncoder().encode(n(r,s)));return {publicKeyJwk:t,signature:k(o),nonce:r,issuedAt:s}}}},delete:Z};var U={"identity.assertion.exchange":25692e-8,"identity.monthly-active-principal":110352e-9,"capability.issue":212346e-9,"device.enroll":218946e-9,"gateway.grant.issue":202146e-9,"gateway.grant.refresh":200346e-9,"security.attestation.verify":29694e-8,"room.create":388056e-9,"room.join":209946e-9,"room.leave":200346e-9,"coordination.connection.open":299532e-9,"coordination.credential.refresh":259662e-9,"coordination.presence.offline":253638e-9,"coordination.signal.send":259638e-9,"coordination.session.put":259638e-9,"coordination.session.delete":253638e-9,"coordination.usage.ingest":197088e-9};var D={controlPlane:"https://api.openrtc.app",gateway:"https://gateway.openrtc.app"},F=1440*6e4,w=class extends Error{constructor(t,i){super(t);this.status=i;this.name="OpenRTCV2HttpError";}};function A(a,e,t){return `openrtc:v2:device-certificate:${a}:${e}:${t}`}function I(a,e){return `openrtc:v2:device-session:${a}:${e}`}async function Q(a,e,t){let i=new TextEncoder().encode(`openrtc:v2:session\0${a}\0${e}\0${t}`),n=new Uint8Array(await crypto.subtle.digest("SHA-256",i)),r="";for(let s of n)r+=String.fromCharCode(s);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function $(a){let e=a.replace(/-/g,"+").replace(/_/g,"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"="),i=atob(t);return Uint8Array.from(i,n=>n.charCodeAt(0))}async function H(a,e,t,i,n){if(typeof a.token!="string"||typeof a.expiresAtMs!="number"||a.expiresAtMs<=Date.now()+F||!a.signingPublicJwk||a.signingPublicJwk.kty!=="OKP"||a.signingPublicJwk.crv!=="Ed25519"||typeof a.signingPublicJwk.x!="string")return null;let r=a.token.split(".");if(r.length!==3)return null;let s,o;try{s=JSON.parse(new TextDecoder().decode($(r[0]))),o=y(a.token);}catch{return null}if(s.alg!=="EdDSA"||a.signingPublicJwk.kid&&s.kid!==a.signingPublicJwk.kid)return null;try{let h=await crypto.subtle.importKey("jwk",a.signingPublicJwk,{name:"Ed25519"},!1,["verify"]);if(!await crypto.subtle.verify({name:"Ed25519"},h,$(r[2]),new TextEncoder().encode(`${r[0]}.${r[1]}`)))return null}catch{return null}let c=typeof o.principalId=="string"?o.principalId:"",l=Number(o.iat),d=Number(o.exp);return o.iss!=="openrtc"||o.aud!=="openrtc:v2:gateway-grant"||o.typ!=="device-certificate"||o.appTag!==e||!c||n!==void 0&&c!==n||typeof o.principalKey!="string"||o.principalKey.length===0||o.deviceId!==t||o.deviceKeyThumbprint!==i||typeof o.jti!="string"||o.jti.length===0||!Number.isSafeInteger(l)||!Number.isSafeInteger(d)||l>=d||d*1e3!==a.expiresAtMs?null:{token:a.token,expiresAtMs:a.expiresAtMs,principalId:c,signingPublicJwk:a.signingPublicJwk,enrolled:false}}async function Y(a,e,t,i,n){try{let r=A(e,t,i),s=a.readSecureRecord?await a.readSecureRecord(e,r):globalThis.localStorage?.getItem(r);if(!s)return null;let o=JSON.parse(s),c=await H(o,e,i,n,t);return c?{token:c.token,expiresAtMs:c.expiresAtMs,principalId:t,signingPublicJwk:c.signingPublicJwk}:null}catch(r){if(a.readSecureRecord)throw r;return null}}async function ee(a,e,t,i,n){try{let r=I(e,i),s=a.readSecureRecord?await a.readSecureRecord(t,r):globalThis.localStorage?.getItem(r);return s?await H(JSON.parse(s),t,i,n):null}catch(r){if(a.readSecureRecord)throw r;return null}}async function te(a,e,t,i,n){try{let r=A(e,t,i),s=JSON.stringify(n);a.writeSecureRecord?await a.writeSecureRecord(e,r,s):globalThis.localStorage?.setItem(r,s);}catch(r){if(a.writeSecureRecord)throw r}}async function ie(a,e,t,i,n){try{let r=I(t,i),s=JSON.stringify({token:n.token,expiresAtMs:n.expiresAtMs,principalId:n.principalId,signingPublicJwk:n.signingPublicJwk});a.writeSecureRecord?await a.writeSecureRecord(e,r,s):globalThis.localStorage?.setItem(r,s);}catch(r){if(a.writeSecureRecord)throw r}}async function j(a,e,t,i,n){try{let r=A(e,t,i);if(a.deleteSecureRecord?await a.deleteSecureRecord(e,r):globalThis.localStorage?.removeItem(r),n){let s=I(n,i);a.deleteSecureRecord?await a.deleteSecureRecord(e,s):globalThis.localStorage?.removeItem(s);}}catch(r){if(a.deleteSecureRecord)throw r}}function ne(a){return `${a}_${crypto.randomUUID()}`}async function re(a,e){let t=new TextEncoder().encode(`${a}:${e}`);return [...new Uint8Array(await crypto.subtle.digest("SHA-256",t))].map(n=>n.toString(16).padStart(2,"0")).join("")}function y(a){let e=a.split(".")[1];if(!e)throw new Error("OpenRTC returned a malformed credential.");let t=e.replace(/-/g,"+").replace(/_/g,"/"),i=t.padEnd(Math.ceil(t.length/4)*4,"=");return JSON.parse(atob(i))}var b=class{constructor(e,t,i,n,r={},s){this.apiKey=e;this.endpoints=t;this.keyProvider=i;this.attestation=n;this.events=r;this.botVerification=s;this.keyPromise=null;this.authEpochs=new Map;this.appTag=`app_${e.slice(-16)}`;}record(e){this.events.onLogicalOperation?.(e);}before(e){this.events.beforeLogicalOperation?.(e);}authEpoch(e){let t=this.authEpochs.get(e);if(t)return t;let i={generation:0,devices:new Map};return this.authEpochs.set(e,i),e.subscribe&&(i.unsubscribe=e.subscribe(n=>{n?.type==="principal-changed"&&(i.generation+=1,i.devices.clear(),i.sessionKeyHash=void 0,this.events.onAuthEpochChanged?.(e));})),i}dispose(){for(let e of this.authEpochs.values())e.unsubscribe?.();this.authEpochs.clear();}key(){return this.keyPromise??(this.keyPromise=this.keyProvider.getOrCreate(this.appTag))}async post(e,t){let i=ne("request"),n=JSON.stringify({apiKey:this.apiKey,...t}),r=null;for(let s=0;s<2;s+=1)try{let o=await fetch(`${this.endpoints.controlPlane}${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-OpenRTC-Idempotency-Key":i},body:n,signal:AbortSignal.timeout(15e3)});if(o.ok)return o.json();let c=`OpenRTC request failed (${o.status}).`;try{let d=await o.json();typeof d.error=="string"&&(c=d.error.slice(0,256));}catch{}let l=new w(c,o.status);if(r=l,s===0&&[502,503,504].includes(o.status))continue;throw l}catch(o){if(r=o,s===0&&o instanceof TypeError)continue;throw o}throw r instanceof Error?r:new Error("OpenRTC request failed.")}async capability(e,t,i,n=false){this.before("capability.issue");let r=e==="space"?await re(this.apiKey,t):t,o=await(await this.key()).proof((h,p)=>["openrtc:v2:capability",this.apiKey,e,r,h,p].join(":")),c=this.botVerification?await this.botVerification.getToken({action:"openrtc_capability",apiKey:this.apiKey}):void 0,l=await this.post("/v2/capabilities",{avenue:{kind:e,id:r},deviceProof:o,...i?{maxPeers:i}:{},...n?{advancedFanout:true}:{},...c?{turnstileToken:c}:{}});this.record("capability.issue");let d={type:"capability",token:l.capability,avenue:e==="ticket"?{kind:"session",id:r}:l.avenue,expiresAtMs:l.expiresAt*1e3};return d.renew=()=>this.capability(e,t,i,n),d}async deviceCertificate(e,t,i,n){let r=this.authEpoch(e),s=r.devices.get(t)??{};if(r.devices.set(t,s),s.current&&s.current.expiresAtMs>Date.now()+F)return this.deviceCertificateResult(e,t,i,n,{...s.current,enrolled:false});if(!s.inFlight){let c=r.generation;s.inFlight=this.resolveAuthenticatedDevice(e,t,r,n).then(l=>{if(r.generation!==c)throw new Error("The OpenRTC authentication identity changed during enrollment.");return s.current=l,l}).finally(()=>{s.inFlight=void 0;});}let o=await s.inFlight;return this.deviceCertificateResult(e,t,i,n,o)}async resolveAuthenticatedDevice(e,t,i,n){let r=await this.key();if(e.getSessionKey){let s=await e.getSessionKey();if(!s)throw new Error("The OpenRTC auth provider has no active principal.");let o=await Q(this.appTag,r.thumbprint,s);i.sessionKeyHash=o;let c=await ee(this.keyProvider,o,this.appTag,t,r.thumbprint);if(c)return c}return this.enrollAuthenticatedDevice(e,t,i.sessionKeyHash,n)}deviceCertificateResult(e,t,i,n,r){let s={type:"device-certificate",token:r.token,avenue:i??{kind:"user",id:r.principalId},expiresAtMs:r.expiresAtMs};return s.renew=async()=>(await this.deviceCertificate(e,t,i,n)).source,{principalId:r.principalId,source:s,enrolled:r.enrolled}}async enrollAuthenticatedDevice(e,t,i,n){this.before("identity.assertion.exchange"),this.before("identity.monthly-active-principal");let r=async u=>{let v=await e.getAssertion({audience:"https://api.openrtc.app/v2/assertions/exchange",forceRefresh:u,deviceId:t});if(!v)throw new Error("The OpenRTC auth provider returned no assertion.");return this.post("/v2/assertions/exchange",{assertion:v,...e.providerId?{providerId:e.providerId}:{}})},s;try{s=await r(!1);}catch(u){if(!(u instanceof w)||u.status!==401)throw u;s=await r(true);}this.record("identity.assertion.exchange"),this.record("identity.monthly-active-principal");let o=await this.key(),c=await Y(this.keyProvider,this.appTag,s.principalId,t,o.thumbprint);if(c)return {...c,principalId:s.principalId,enrolled:false};this.before("device.enroll"),this.attestation&&this.before("security.attestation.verify");let l=await o.proof((u,v)=>["openrtc:v2:device-enroll",this.appTag,s.principalId,t,u,v].join(":")),d=this.attestation?{kind:this.attestation.kind,...await this.attestation.getEvidence({challenge:`openrtc:v2:attestation:${this.appTag}:${s.principalId}:${t}:${l.nonce}`,apiKey:this.apiKey})}:void 0,h=await this.post("/v2/devices/enroll",{identitySession:s.identitySession,deviceId:t,deviceProof:l,...n?.name||n?.platform?{deviceProfile:{...n.name?{name:n.name}:{},...n.platform?{platform:n.platform}:{}}}:{},...d?{attestation:d}:{}});this.record("device.enroll"),d&&this.record("security.attestation.verify");let p={principalId:s.principalId,token:h.deviceCertificate,expiresAtMs:h.expiresAt*1e3,signingPublicJwk:h.signingPublicJwk,enrolled:true};return await te(this.keyProvider,this.appTag,s.principalId,t,{token:p.token,expiresAtMs:p.expiresAtMs,signingPublicJwk:p.signingPublicJwk}),i&&await ie(this.keyProvider,this.appTag,i,t,p),p}async listEnrolledDevices(e,t){let i=await this.deviceCertificate(e,t);return (await this.deviceManagement(i.source,t,"list")).devices??[]}async revokeDevice(e,t,i){let n=await this.deviceCertificate(e,t);if(await this.deviceManagement(n.source,t,"revoke",i),i===t){let r=this.authEpoch(e);await j(this.keyProvider,this.appTag,n.principalId,t,r.sessionKeyHash),r.devices.delete(t),await this.deleteDeviceKey();}}async revokeAllDevices(e,t,i){let n=await this.deviceCertificate(e,t);await this.deviceManagement(n.source,t,"revoke-all",void 0,i);let r=this.authEpoch(e);await j(this.keyProvider,this.appTag,n.principalId,t,r.sessionKeyHash),r.devices.delete(t),i?await this.deviceCertificate(e,t):(r.devices.clear(),await this.deleteDeviceKey());}async deleteDeviceKey(){this.keyPromise=null,await this.keyProvider.delete?.(this.appTag);}async deviceManagement(e,t,i,n,r=false){if(e.type!=="device-certificate")throw new Error("Device management requires an authenticated device certificate.");let s=y(e.token),o=String(s.jti??""),l=await(await this.key()).proof((p,u)=>["openrtc:v2:device-management",o,i,n??"",r?"except-current":"include-current",p,u].join(":")),d=i==="revoke"?"device.revoke":i==="revoke-all"?"identity.revoke-all":null;d&&this.before(d);let h=await this.post("/v2/devices/manage",{action:i,deviceCertificate:e.token,currentDeviceId:t,...n?{targetDeviceId:n}:{},...r?{exceptCurrent:true}:{},deviceProof:l});return d&&this.record(d),h}async durableRoomMembership(e,t,i){if(e.type!=="device-certificate")throw new Error("Durable rooms require a device certificate.");this.before(i==="join"?"room.join":"room.leave");let n=y(e.token),r=String(n.jti??""),o=await(await this.key()).proof((c,l)=>["openrtc:v2:room-membership",r,i,t,c,l].join(":"));await this.post("/v2/rooms/memberships",{action:i,roomId:t,deviceCertificate:e.token,deviceProof:o}),this.record(i==="join"?"room.join":"room.leave");}grantProvider(e,t={}){let i=null,n=e;return async r=>{if(i)return i;let s=(async()=>{let o=false;n.expiresAtMs<=Date.now()+5*6e4&&n.renew&&(n=await n.renew(),o=true);let c=r.refreshGrant?"gateway.grant.refresh":"gateway.grant.issue";this.before(c),r.refreshGrant&&this.before("coordination.credential.refresh");let l=y(n.token),d=String(l.jti??""),p=await(await this.key()).proof((v,g)=>["openrtc:v2:gateway-grant",d,r.avenue.kind,r.avenue.id,r.runtimeInstanceId,v,g].join(":")),u=await this.post("/v2/gateway/grants",{credentialType:n.type,credential:n.token,avenue:r.avenue,runtimeInstanceId:r.runtimeInstanceId,ticketFingerprint:r.ticketFingerprint,deviceProof:p,...r.refreshGrant?{refreshGrant:r.refreshGrant}:{},...t.maxPeers?{maxPeers:t.maxPeers}:{},...t.features?{features:t.features}:{},...n.type==="device-certificate"&&t.deviceProfile?{deviceProfile:t.deviceProfile}:{}});return this.record(c),r.refreshGrant&&this.record("coordination.credential.refresh"),o&&await t.onSourceRenewed?.({token:n.token,expiresAtMs:n.expiresAtMs}),u})();i=s;try{return await s}finally{i===s&&(i=null);}}}};var R=new WeakMap;function ye(a){let e=R.get(a);if(!e)throw new Error("[OpenRTC] Capability runtime is unavailable or already closed.");return e}function ae(a){let e=a?.trim()??"";if(!/^pk_(?:live|test)_[0-9a-f]{40}$/.test(e))throw new Error("[OpenRTC] apiKey must be a public pk_live_ or pk_test_ key.");return e}function m(a){let e=a?.trim()??"";if(!e||e.length>160||!/^[A-Za-z0-9_.:@-]+$/.test(e))throw new Error("[OpenRTC] Capability id is invalid.");return e}var L=/^[A-Za-z0-9_.:@-]{1,160}$/,se=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function W(a){let e=typeof a=="string"?a.trim():"";if(!L.test(e))return null;let t=e.startsWith("device_")?e.slice(7):"";return se.test(t)?t:e}function oe(a,e){try{let t=a.getItem(`pluto_rtc_web_device_identity_${e}`);if(!t)return null;let i=JSON.parse(t);return W(i?.deviceId)}catch{return null}}function ce(a){let e=`openrtc:v2:device-id:${a}`,t=`pluto_rtc_web_device_identity_${a}`,i,n=(()=>{try{return i=globalThis.localStorage,i&&oe(i,a)||W(i?.getItem(e))||crypto.randomUUID()}catch{return crypto.randomUUID()}})();try{i?.setItem(e,n),i?.setItem(t,JSON.stringify({deviceId:n}));}catch{}return n}function G(a){let e=typeof a=="string"?a.trim():"";if(!L.test(e))throw new Error("[OpenRTC] The native host returned an invalid durable device ID.");return e}function x(a){let e=y(a.token),t=typeof e.deviceKeyThumbprint=="string"?e.deviceKeyThumbprint.trim():"";if(!/^[A-Za-z0-9_-]{43}$/.test(t))throw new Error("[OpenRTC] Anonymous capability is missing its device-key binding.");return `anon_${t.slice(0,32)}`}var E=class{constructor(){this.descriptors=new Map;this.targets=new Map;}register(e){if(!e?.id?.trim())throw new Error("[OpenRTC] Channel id is required.");this.descriptors.set(e.id,{...e});for(let[t,i]of this.targets)t.channels.register({...e,delivery:e.delivery??i});return ()=>{this.descriptors.delete(e.id);for(let t of this.targets.keys())t.channels.unregister(e.id);}}list(){return [...this.descriptors.values()].map(e=>({...e}))}attach(e,t){this.targets.set(e,t);for(let i of this.descriptors.values())e.channels.register({...i,delivery:i.delivery??t});}detach(e){this.targets.delete(e);}},K=class{constructor(e){this.options=e;this.total=0;this.warned=false;}get sessionCreditsUsd(){return this.total}estimate(e){let t=Math.max(0,Math.floor(e.units??1));return {creditsUsd:(U[e.operation]??0)*t,estimated:true}}assertCanSpend(e,t=1){let i=this.options?.maxSessionCreditsUsd;if(i===void 0||this.total+this.estimate({operation:e,units:t}).creditsUsd<=i)return;let r={sessionCreditsUsd:this.total,operation:e,estimated:true,thresholdCreditsUsd:i,kind:"session-limit"};throw this.options?.onWarning?.(r),new Error("[OpenRTC] The client-side session credit limit was reached.")}record(e,t=1){let i=this.estimate({operation:e,units:t}).creditsUsd;this.total+=i;let n={sessionCreditsUsd:this.total,operation:e,estimated:true};this.options?.onUsage?.(n);let r=this.options?.warnAtSessionCreditsUsd;!this.warned&&r!==void 0&&this.total>=r&&(this.warned=true,this.options?.onWarning?.({...n,thresholdCreditsUsd:r,kind:"warning"}));}},C=class{constructor(e,t,i,n){this.kind=e;this.id=t;this.client=i;this.onClosed=n;this.closed=false;R.set(this,i);}get peers(){return this.client.peers}get channels(){return this.client.channels}get diagnostics(){return this.client.diagnostics}async retireDeviceIfPresent(e){(await this.client.devices.list()).some(i=>i.deviceId===e)&&await this.client.devices.delete(e);}async retireAllOtherDevices(e){let t=await this.client.devices.list();for(let i of t)i.deviceId!==e&&await this.client.devices.delete(i.deviceId);}async close(){if(!this.closed){this.closed=true;try{await this.client.advanced.runtime.shutdown();}finally{R.delete(this),this.onClosed();}}}},f=class extends C{constructor(t,i,n,r){super("devices",t,i,n);this.roster=r;this.kind="devices";this.localId=()=>this.client.devices.localId();this.localInfo=()=>this.client.devices.localInfo();this.list=async()=>this.roster.mergeDevices(await this.client.devices.list());this.listWithStatus=async()=>this.roster.mergeStatus(await this.client.devices.listWithStatus());this.watch=t=>this.client.devices.watch(i=>t(this.roster.mergeDevices(i)));this.connect=this.client.devices.connect;this.disconnect=this.client.devices.disconnect;let s=i.devices.list,o=i.devices.listWithStatus,c=i.devices.watch,l=i.devices.watchWithStatus,d=async()=>this.roster.mergeDevices(await s()),h=async()=>this.roster.mergeStatus(await o()),p=g=>c(O=>g(this.roster.mergeDevices(O))),u=g=>l(O=>g(this.roster.mergeStatus(O))),v=Object.create(i);Object.defineProperties(v,{listDevices:{value:d,enumerable:false},listDevicesWithStatus:{value:h,enumerable:false},watchDevices:{value:p,enumerable:false},watchDevicesWithStatus:{value:u,enumerable:false},devices:{value:{...i.devices,list:d,listWithStatus:h,watch:p,watchWithStatus:u},enumerable:true}}),R.set(this,v);}replaceEnrolledDevices(t){this.roster.replace(t);}removeEnrolledDevice(t){this.roster.remove(t);}retainCurrentEnrolledDevice(t){this.roster.retain(t);}},M=class extends C{constructor(t,i,n,r){super("space",t,i,n);this.delivery=r;this.kind="space";this.leave=()=>this.close();}},P=class extends C{constructor(t,i,n,r,s){super("room",t,i,n);this.membership=r;this.onLeave=s;this.kind="room";this.left=false;}async leave(){this.left||(this.left=true,await this.onLeave?.()),await this.close();}},_=class extends C{constructor(t,i,n,r){super("ticket",t,i,n);this.token=r;this.kind="ticket";}},J=class{constructor(e,t){this.options=e;this.internals=t;this.channels=new E;this.handles=new Set;this.activations=new Map;this.closed=false;this.devices={localId:()=>(this.assertOpen(),this.deviceId()),start:(e={})=>{let t=e.auth??this.options.auth;return this.activateOnce("devices",JSON.stringify({autoConnect:e.autoConnect??"online",maxPeers:e.maxPeers??null,advancedFanout:e.advancedFanout===true,profile:e.profile??null}),t,()=>this.startDevices(e))},listEnrolled:async(e={})=>{this.assertOpen();let t=e.auth??this.options.auth;if(!t)throw new Error("[OpenRTC] devices.listEnrolled() requires an auth provider.");let i=await this.controlPlane.listEnrolledDevices(t,await this.deviceId());for(let n of this.handles)n instanceof f&&n.replaceEnrolledDevices(i);return i},revoke:async(e,t={})=>{this.assertOpen();let i=t.auth??this.options.auth;if(!i)throw new Error("[OpenRTC] devices.revoke() requires an auth provider.");let n=G(e),r=await this.deviceId();await this.controlPlane.revokeDevice(i,r,n),await Promise.allSettled([...this.handles].map(s=>s.retireDeviceIfPresent(n)));for(let s of this.handles)s instanceof f&&s.removeEnrolledDevice(n);n===r&&this.retireAuthCapabilities(i);},revokeAll:async(e={})=>{this.assertOpen();let t=e.auth??this.options.auth;if(!t)throw new Error("[OpenRTC] devices.revokeAll() requires an auth provider.");if(await this.controlPlane.revokeAllDevices(t,await this.deviceId(),e.exceptCurrent===true),e.exceptCurrent===true){let i=await this.deviceId();for(let n of this.handles)n instanceof f&&n.retainCurrentEnrolledDevice(i);await Promise.allSettled([...this.handles].map(n=>n.retireAllOtherDevices(i)));}e.exceptCurrent!==true&&this.retireAuthCapabilities(t);}};this.spaces={join:(e,t={})=>this.activateOnce(`space:${m(e)}`,JSON.stringify({payload:t.payload??"reliable",maxPeers:t.maxPeers??null,advancedFanout:t.advancedFanout===true}),void 0,()=>this.joinSpace(e,t))};this.rooms={join:(e,t={})=>{let i=t.access??"capability";return this.activateOnce(`room:${m(e)}`,JSON.stringify({access:i,membership:t.membership??"ephemeral",maxPeers:t.maxPeers??null,advancedFanout:t.advancedFanout===true}),i==="authenticated"?t.auth??this.options.auth:void 0,()=>this.joinRoom(e,t))}};this.tickets={issue:(e,t={})=>this.activateOnce(`ticket:${m(e)}`,JSON.stringify({maxPeers:t.maxPeers??null,advancedFanout:t.advancedFanout===true}),void 0,()=>this.issueTicket(e,t))};this.onClosed=e=>{this.handles.delete(e);for(let[t,i]of this.activations)i.handle===e&&this.activations.delete(t);};this.apiKey=ae(e.apiKey),this.usage=new K(e.usage),this.controlPlane=new b(this.apiKey,t.endpoints??D,t.deviceKeyProvider??N,e.trust?.attestation,{beforeLogicalOperation:i=>this.usage.assertCanSpend(i),onLogicalOperation:i=>this.usage.record(i),onAuthEpochChanged:i=>this.retireAuthCapabilities(i)},e.trust?.botVerification);}assertOpen(){if(this.closed)throw new Error("[OpenRTC] Client is closed.")}activateOnce(e,t,i,n){this.assertOpen();let r=this.activations.get(e);if(r){if(r.fingerprint!==t||r.auth!==i)throw new Error(`[OpenRTC] ${e} is already active with different options.`);return r.promise}let s={fingerprint:t,auth:i},o=n().then(c=>(s.handle=c,c)).catch(c=>{throw this.activations.get(e)===s&&this.activations.delete(e),c});return s.promise=o,this.activations.set(e,s),o}retireAuthCapabilities(e){for(let t of this.activations.values())t.auth===e&&t.promise.then(i=>i.close()).catch(()=>{});}async deviceId(){let e=this.internals.deviceIdProvider?await this.internals.deviceIdProvider(this.controlPlane.appTag):ce(this.controlPlane.appTag);return G(e)}runtimeOptions(e){let t=this.options.transports,i=t?.privacy==="relay-only";if(i&&t?.relay!==true)throw new Error("[OpenRTC] transports.privacy: relay-only requires transports.relay: true.");return {apiKey:this.apiKey,authMode:"external",discoveryMode:e.avenue?.kind==="user"?"user-scoped":"space",space:e.avenue?.id,localDeviceId:e.deviceId,deviceIdPersistence:"persistent",endpointIdPersistence:this.internals.platform==="native"?"persistent":"ephemeral",deviceName:e.deviceName?.trim()||void 0,coordinationPlatformType:e.devicePlatform?.trim()||void 0,nativeApplicationStreamConsumer:this.internals.platform==="native"&&t?.nativeHostProtocols===true?"host":"runtime",coordinationAvenueOverride:e.avenue,coordinationGateway:{endpoint:(this.internals.endpoints??D).gateway,environment:"production",grantProvider:e.grantProvider,testingAllowInsecureLoopback:this.internals.testingAllowInsecureLoopback},transports:{iroh:i?{relayOnly:true,relayTransportPolicy:"websocketRequired",localDiscovery:false,persistenceMode:this.internals.platform==="native"?"persistent":"ephemeral",...this.internals.irohTestRelayUrl?{testRelayUrl:this.internals.irohTestRelayUrl}:{}}:this.internals.irohTestRelayUrl?{testRelayUrl:this.internals.irohTestRelayUrl,persistenceMode:this.internals.platform==="native"?"persistent":"ephemeral"}:t?.iroh??true,webrtc:t?.webrtc===true?i?{privacyMode:true,useTurn:true,useDefaultIceServers:false}:true:false,ble:t?.ble??false,moq:t?.moq??false},transportPriority:t?.priority}}async activate(e){let t={relay:this.options.transports?.relay===true,moq:this.options.transports?.moq===true,ble:this.options.transports?.ble===true,advancedFanout:e.advancedFanout===true,durableMembership:e.durableMembership===true},i=e.source,n=null,r=()=>({userId:e.principalId,token:i.token,tokenProvider:async()=>i.token,expiresAtMs:i.expiresAtMs}),s=this.runtimeOptions({avenue:e.source.avenue,grantProvider:this.controlPlane.grantProvider(e.source,{maxPeers:e.maxPeers,features:t,deviceProfile:e.deviceName&&e.devicePlatform?{name:e.deviceName,platform:e.devicePlatform}:void 0,onSourceRenewed:async l=>{i={...i,...l},await n?.setAuth(r());}}),deviceId:e.deviceId,userId:e.principalId,deviceName:e.deviceName,devicePlatform:e.devicePlatform}),[o,{wrapAssembly:c}]=await Promise.all([this.internals.runtimeFactory(s),import('./OpenRTCShared-LDKG5RPN.js')]);n=c(o,this.internals.platform==="native"?"native":"web"),await n.setAuth(r()),this.channels.attach(n,e.defaultDelivery??"reliable");try{this.usage.assertCanSpend("coordination.connection.open"),await n.devices.startSession({sessionKind:e.kind==="devices"?"app-user-device":"scoped-guest",scope:`v2:${e.kind}:${e.id}`,userId:e.principalId,localDeviceId:e.deviceId,metadata:e.deviceMetadata,autoConnectPolicy:e.autoConnect?"enabled":"disabled",presencePolicy:"online"});}catch(l){throw this.channels.detach(n),await n.advanced.runtime.shutdown().catch(()=>{}),l}return this.usage.record("coordination.connection.open"),n}async startDevices(e={}){this.assertOpen();let t=e.auth??this.options.auth;if(!t)throw new Error("[OpenRTC] devices.start() requires an auth provider.");let i=await this.deviceId(),{resolveDeviceProfile:n}=await import('./deviceProfile-3BEQZLJF.js'),r=n(e.profile,this.internals.platform==="native"?"native":"web"),s=await this.controlPlane.deviceCertificate(t,i,void 0,r),o=await this.controlPlane.listEnrolledDevices(t,i),{AuthenticatedDeviceRoster:c}=await import('./deviceRoster-GHF6MWXF.js'),l=await this.activate({kind:"devices",id:s.principalId,source:s.source,principalId:s.principalId,deviceId:i,maxPeers:e.maxPeers,autoConnect:e.autoConnect!=="none",advancedFanout:e.advancedFanout,deviceName:r.name,devicePlatform:r.platform,deviceMetadata:r.metadata}),d;return d=new f(s.principalId,l,()=>{this.channels.detach(l),this.onClosed(d);},new c(o)),this.handles.add(d),d}async joinSpace(e,t={}){this.assertOpen();let i=m(e),n=await this.controlPlane.capability("space",i,t.maxPeers,t.advancedFanout),r=String(y(n.token).principalId),s=await this.activate({kind:"space",id:i,source:n,principalId:r,deviceId:x(n),maxPeers:t.maxPeers,autoConnect:true,defaultDelivery:t.payload??"reliable",advancedFanout:t.advancedFanout}),o;return o=new M(i,s,()=>{this.channels.detach(s),this.onClosed(o);},t.payload??"reliable"),this.handles.add(o),o}async joinRoom(e,t={}){this.assertOpen();let i=m(e),n=t.membership??"ephemeral",r=t.access??"capability";if(n==="durable"&&r!=="authenticated")throw new Error("[OpenRTC] Durable room membership requires access: authenticated.");if(r==="authenticated"){let d=t.auth??this.options.auth;if(!d)throw new Error("[OpenRTC] Authenticated rooms require an auth provider.");let h=await this.deviceId(),p=await this.controlPlane.deviceCertificate(d,h,{kind:"room",id:i});n==="durable"&&await this.controlPlane.durableRoomMembership(p.source,i,"join");let u;try{u=await this.activate({kind:"room",id:i,source:p.source,principalId:p.principalId,deviceId:h,maxPeers:t.maxPeers,autoConnect:!0,durableMembership:n==="durable",advancedFanout:t.advancedFanout});}catch(g){throw n==="durable"&&await this.controlPlane.durableRoomMembership(p.source,i,"leave").catch(()=>{}),g}let v;return v=new P(i,u,()=>{this.channels.detach(u),this.onClosed(v);},n,n==="durable"?async()=>{await this.controlPlane.durableRoomMembership(p.source,i,"leave");}:void 0),this.handles.add(v),v}let s=await this.controlPlane.capability("room",i,t.maxPeers,t.advancedFanout),o=String(y(s.token).principalId),c=await this.activate({kind:"room",id:i,source:s,principalId:o,deviceId:x(s),maxPeers:t.maxPeers,autoConnect:true,advancedFanout:t.advancedFanout}),l;return l=new P(i,c,()=>{this.channels.detach(c),this.onClosed(l);},"ephemeral"),this.handles.add(l),l}async issueTicket(e,t={}){this.assertOpen();let i=m(e),n=await this.controlPlane.capability("ticket",i,t.maxPeers,t.advancedFanout),r=String(y(n.token).principalId),s=await this.activate({kind:"ticket",id:i,source:n,principalId:r,deviceId:x(n),maxPeers:t.maxPeers,autoConnect:false,advancedFanout:t.advancedFanout}),o;return o=new _(i,s,()=>{this.channels.detach(s),this.onClosed(o);},n.token),this.handles.add(o),o}async close(){if(!this.closed){this.closed=true;try{await Promise.all([...this.handles].map(e=>e.close()));}finally{this.controlPlane.dispose(),this.activations.clear();}}}};function ge(a,e){return new J(a,e)}
|
|
2
|
-
export{V as a,ye as b,ge as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-RGRVKR66.js';import {u,a as a$3}from'./chunk-KEPDY3LB.js';import'./chunk-Z2WVSXPW.js';import'./chunk-NCMT4MKM.js';import'./chunk-FQH6O3SU.js';import'./chunk-NT5YHZQH.js';import'./chunk-RRMBD5OL.js';import'./chunk-PQK5SJ47.js';import {a as a$1}from'./chunk-QHSM5NFZ.js';import'./chunk-C7YN5MSV.js';var s=false;function a(){s||(s=true,a$3(async()=>{let t=await import('./openrtc-3YHRRPAG.js');return {initWasm:t.default,WasmClient:t.WasmClient,start:t.start}}));}async function d(t){a();let e=a$1(t),{WasmBridge:i}=await import('./WasmBridge-VN3MA4LT.js');return a$2(e,new i(e))}function y(t,e){let i=a$1(t);return a$2(i,new u({...i,bridge:e}))}export{y as createIpcClient,d as createWasmClient};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-RGRVKR66.js';import {u}from'./chunk-KEPDY3LB.js';import'./chunk-Z2WVSXPW.js';import'./chunk-NCMT4MKM.js';import'./chunk-FQH6O3SU.js';import'./chunk-NT5YHZQH.js';import'./chunk-RRMBD5OL.js';import'./chunk-PQK5SJ47.js';import {a}from'./chunk-QHSM5NFZ.js';import'./chunk-C7YN5MSV.js';function s(i,r){let t=a(i);return a$1(t,new u({...t,bridge:r}))}export{s as createIpcClient};
|