openrtc 1.0.13 → 1.0.14
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/auth/index.d.ts +2 -0
- package/dist/auth/index.js +1 -1
- package/dist/auth/internal.js +1 -1
- package/dist/{chunk-NP3JZ2LD.js → chunk-6J3QKQRS.js} +1 -1
- package/dist/chunk-HFWOWDEH.js +2 -0
- package/dist/{chunk-HXTGHALT.js → chunk-JGBEYISL.js} +1 -1
- package/dist/{chunk-WFUW3BHK.js → chunk-R5P73PEG.js} +1 -1
- package/dist/chunk-SVBFZRGV.js +2 -0
- package/dist/{chunk-LVJSU53Y.js → chunk-TOO3FUPK.js} +1 -1
- package/dist/chunk-TW4HQLK6.js +1 -0
- package/dist/{chunk-KP5H3SYJ.js → chunk-W5YFLH2U.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/native.js +1 -1
- package/dist/runtime/WasmRuntimeAdapter.js +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/tauri.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3SND2COC.js +0 -1
- package/dist/chunk-YFNRKQEA.js +0 -2
- package/dist/chunk-ZZIIBIEC.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {o,G}from'./chunk-SVBFZRGV.js';function x(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 A(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,P=l.deviceId??(typeof o=="string"?o:o?.deviceId)??null,v=l.ticket??(typeof o=="string"?void 0:o?.ticket);P&&!v&&(v=(await r(P).catch(()=>null))?.ticket);let C={...l,scope:a??"session"};return P&&(C.deviceId=P),v&&(C.ticket=v),C},u={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)},d={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()},g={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)},p={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)},R={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)},h={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()},I={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:()=>u,enumerable:true},peers:{get:()=>d,enumerable:true},channels:{get:()=>g,enumerable:true},rooms:{get:()=>p,enumerable:true},tickets:{get:()=>R,enumerable:true},diagnostics:{get:()=>h,enumerable:true},advanced:{get:()=>I,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 k="https://api.openrtc.app";async function E(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 L(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 b(t){let i=t.apiKey.trim(),n=(t.spaceKey??t.space??"").trim(),s=f(t.sandboxAppId),r=(t.endpointUrl??k).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 u=await G().getAppCheckToken(),d=await fetch(`${r}/v1SpacePublicTokens`,{method:"POST",headers:{"Content-Type":"application/json",...u?{"X-Firebase-AppCheck":u}:{}},body:JSON.stringify({apiKey:i,spaceKey:n,memberId:m,...s?{sandboxAppId:s}:{}})}),{text:g,payload:p}=await w(d);if(!d.ok){let h=typeof p?.error=="string"?p.error:g.trim()?g.trim().slice(0,240):`public space token mint failed (${d.status})`;throw new Error(h)}let R=typeof p?.token=="string"?p.token.trim():"";if(!R)throw new Error("public space token response missing token");return {customToken:R}}}function O(t){if(!t.trim())return {};try{let i=JSON.parse(t);return i&&typeof i=="object"?i:{}}catch{return {}}}async function w(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 f(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 U(t,i){let n=t.trim(),s=f(i);return s?`${n}::sandbox::${s}`:n}var W=b,$=b;
|
|
2
|
+
export{x as a,A as b,E as c,L as d,b as e,U as f,W as g,$ as h};
|