openrtc 2.0.0-rc.21 → 2.0.0-rc.23
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/{chunk-HTAWPIP2.js → chunk-3PE6TWIX.js} +1 -1
- package/dist/chunk-4UAAQLXK.js +2 -0
- package/dist/{factories-SMMQHXUH.js → factories-SIBGRPTH.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/native.js +1 -1
- package/dist/{openrtc-3YHRRPAG.js → openrtc-VDVNE725.js} +1 -1
- package/dist/openrtc_bg.wasm +0 -0
- package/dist/runtime/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-DA3HSI3K.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-4UAAQLXK.js';function p(){let r=crypto.getRandomValues(new Uint8Array(24)),e="";for(let t of r)e+=String.fromCharCode(t);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function u(r){if(!r||typeof r!="object")throw new Error("[OpenRTC] Native host returned no device public key.");let e=r;if(e.kty!=="OKP"||e.crv!=="Ed25519"||typeof e.x!="string"||!/^[A-Za-z0-9_-]{43}$/.test(e.x)||e.d!==void 0)throw new Error("[OpenRTC] Native host returned an invalid Ed25519 public key.");return {kty:"OKP",crv:"Ed25519",x:e.x}}function v(r){return {async readSecureRecord(e,t){return r.invoke("openrtc_v2_read_secure_record",{appTag:e,key:t})},async writeSecureRecord(e,t,n){await r.invoke("openrtc_v2_write_secure_record",{appTag:e,key:t,value:n});},async deleteSecureRecord(e,t){await r.invoke("openrtc_v2_delete_secure_record",{appTag:e,key:t});},async delete(e){await r.invoke("openrtc_v2_delete_device_key",{appTag:e});},async getOrCreate(e){let t=u(await r.invoke("openrtc_v2_device_public_key",{appTag:e})),n=await a(t);return {publicKeyJwk:t,thumbprint:n,async proof(s){let o=p(),c=Math.floor(Date.now()/1e3),i=await r.invoke("openrtc_v2_sign_device_proof",{appTag:e,challenge:s(o,c)});if(!/^[A-Za-z0-9_-]{80,128}$/.test(i))throw new Error("[OpenRTC] Native host returned an invalid device proof.");return {publicKeyJwk:t,signature:i,nonce:o,issuedAt:c}}}}}}
|
|
2
2
|
export{v as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
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 B(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 z(){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 Z(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 X(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 Q(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 Y(a){let e=await Z(a);if(e)return e;let t=await crypto.subtle.generateKey({name:"Ed25519"},false,["sign","verify"]);return await X(a,t),t}var U={async getOrCreate(a){let e=await Y(a),t=await crypto.subtle.exportKey("jwk",e.publicKey),i=await B(t);return {publicKeyJwk:t,thumbprint:i,async proof(n){let r=z(),o=Math.floor(Date.now()/1e3),s=await crypto.subtle.sign({name:"Ed25519"},e.privateKey,new TextEncoder().encode(n(r,o)));return {publicKeyJwk:t,signature:k(s),nonce:r,issuedAt:o}}}},delete:Q};var $={"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 A={controlPlane:"https://api.openrtc.app",gateway:"https://gateway.openrtc.app"},H=1440*6e4,b=class extends Error{constructor(t,i,n){super(t);this.status=i;this.reason=n;this.name="OpenRTCV2HttpError";}};function F(a){return !(a instanceof b)||a.status!==403?false:a.reason==="device-certificate-stale"||a.reason==="device-certificate-revoked"?true:!a.reason&&a.message==="Device certificate is revoked or stale."}function I(a,e,t){return `openrtc:v2:device-certificate:${a}:${e}:${t}`}function x(a,e){return `openrtc:v2:device-session:${a}:${e}`}async function ee(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 o of n)r+=String.fromCharCode(o);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function j(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 G(a,e,t,i,n){if(typeof a.token!="string"||typeof a.expiresAtMs!="number"||a.expiresAtMs<=Date.now()+H||!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 o,s;try{o=JSON.parse(new TextDecoder().decode(j(r[0]))),s=g(a.token);}catch{return null}if(o.alg!=="EdDSA"||a.signingPublicJwk.kid&&o.kid!==a.signingPublicJwk.kid)return null;try{let d=await crypto.subtle.importKey("jwk",a.signingPublicJwk,{name:"Ed25519"},!1,["verify"]);if(!await crypto.subtle.verify({name:"Ed25519"},d,j(r[2]),new TextEncoder().encode(`${r[0]}.${r[1]}`)))return null}catch{return null}let c=typeof s.principalId=="string"?s.principalId:"",l=Number(s.iat),p=Number(s.exp);return s.iss!=="openrtc"||s.aud!=="openrtc:v2:gateway-grant"||s.typ!=="device-certificate"||s.appTag!==e||!c||n!==void 0&&c!==n||typeof s.principalKey!="string"||s.principalKey.length===0||s.deviceId!==t||s.deviceKeyThumbprint!==i||typeof s.jti!="string"||s.jti.length===0||!Number.isSafeInteger(l)||!Number.isSafeInteger(p)||l>=p||p*1e3!==a.expiresAtMs?null:{token:a.token,expiresAtMs:a.expiresAtMs,principalId:c,signingPublicJwk:a.signingPublicJwk,enrolled:false}}async function te(a,e,t,i,n){try{let r=I(e,t,i),o=a.readSecureRecord?await a.readSecureRecord(e,r):globalThis.localStorage?.getItem(r);if(!o)return null;let s=JSON.parse(o),c=await G(s,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 ie(a,e,t,i,n){try{let r=x(e,i),o=a.readSecureRecord?await a.readSecureRecord(t,r):globalThis.localStorage?.getItem(r);return o?await G(JSON.parse(o),t,i,n):null}catch(r){if(a.readSecureRecord)throw r;return null}}async function ne(a,e,t,i,n){try{let r=I(e,t,i),o=JSON.stringify(n);a.writeSecureRecord?await a.writeSecureRecord(e,r,o):globalThis.localStorage?.setItem(r,o);}catch(r){if(a.writeSecureRecord)throw r}}async function re(a,e,t,i,n){try{let r=x(t,i),o=JSON.stringify({token:n.token,expiresAtMs:n.expiresAtMs,principalId:n.principalId,signingPublicJwk:n.signingPublicJwk});a.writeSecureRecord?await a.writeSecureRecord(e,r,o):globalThis.localStorage?.setItem(r,o);}catch(r){if(a.writeSecureRecord)throw r}}async function D(a,e,t,i,n){try{let r=I(e,t,i);if(a.deleteSecureRecord?await a.deleteSecureRecord(e,r):globalThis.localStorage?.removeItem(r),n){let o=x(n,i);a.deleteSecureRecord?await a.deleteSecureRecord(e,o):globalThis.localStorage?.removeItem(o);}}catch(r){if(a.deleteSecureRecord)throw r}}function ae(a){return `${a}_${crypto.randomUUID()}`}async function se(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 g(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 R=class{constructor(e,t,i,n,r={},o){this.apiKey=e;this.endpoints=t;this.keyProvider=i;this.attestation=n;this.events=r;this.botVerification=o;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=ae("request"),n=JSON.stringify({apiKey:this.apiKey,...t}),r=null;for(let o=0;o<2;o+=1)try{let s=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(s.ok)return s.json();let c=`OpenRTC request failed (${s.status}).`,l;try{let d=await s.json();typeof d.error=="string"&&(c=d.error.slice(0,256)),typeof d.reason=="string"&&/^[a-z0-9-]{1,80}$/.test(d.reason)&&(l=d.reason);}catch{}let p=new b(c,s.status,l);if(r=p,o===0&&[502,503,504].includes(s.status))continue;throw p}catch(s){if(r=s,o===0&&s instanceof TypeError)continue;throw s}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 se(this.apiKey,t):t,s=await(await this.key()).proof((d,u)=>["openrtc:v2:capability",this.apiKey,e,r,d,u].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:s,...i?{maxPeers:i}:{},...n?{advancedFanout:true}:{},...c?{turnstileToken:c}:{}});this.record("capability.issue");let p={type:"capability",token:l.capability,avenue:e==="ticket"?{kind:"session",id:r}:l.avenue,expiresAtMs:l.expiresAt*1e3};return p.renew=()=>this.capability(e,t,i,n),p}async deviceCertificate(e,t,i,n,r){let o=this.authEpoch(e),s=o.devices.get(t)??{};if(o.devices.set(t,s),r&&s.current&&s.current.token!==r.token)return this.deviceCertificateResult(e,t,i,n,{...s.current,enrolled:false});if(!r&&s.current&&s.current.expiresAtMs>Date.now()+H)return this.deviceCertificateResult(e,t,i,n,{...s.current,enrolled:false});if(!s.inFlight){let l=o.generation;r&&(s.current=void 0);let p=r?D(this.keyProvider,this.appTag,r.principalId,t,o.sessionKeyHash).then(()=>this.enrollAuthenticatedDevice(e,t,o.sessionKeyHash,n,true)):this.resolveAuthenticatedDevice(e,t,o,n);s.inFlight=p.then(d=>{if(o.generation!==l)throw new Error("The OpenRTC authentication identity changed during enrollment.");return s.current=d,d}).finally(()=>{s.inFlight=void 0;});}let c=await s.inFlight;return this.deviceCertificateResult(e,t,i,n,c)}async resolveAuthenticatedDevice(e,t,i,n){let r=await this.key();if(e.getSessionKey){let o=await e.getSessionKey();if(!o)throw new Error("The OpenRTC auth provider has no active principal.");let s=await ee(this.appTag,r.thumbprint,o);i.sessionKeyHash=s;let c=await ie(this.keyProvider,s,this.appTag,t,r.thumbprint);if(c)return c}return this.enrollAuthenticatedDevice(e,t,i.sessionKeyHash,n)}deviceCertificateResult(e,t,i,n,r){let o={type:"device-certificate",token:r.token,avenue:i??{kind:"user",id:r.principalId},expiresAtMs:r.expiresAtMs};return o.renew=async()=>(await this.deviceCertificate(e,t,i,n)).source,o.recoverRejectedCertificate=async()=>(await this.deviceCertificate(e,t,i,n,r)).source,{principalId:r.principalId,source:o,enrolled:r.enrolled}}async enrollAuthenticatedDevice(e,t,i,n,r=false){this.before("identity.assertion.exchange"),this.before("identity.monthly-active-principal");let o=async h=>{let y=await e.getAssertion({audience:"https://api.openrtc.app/v2/assertions/exchange",forceRefresh:h,deviceId:t});if(!y)throw new Error("The OpenRTC auth provider returned no assertion.");return this.post("/v2/assertions/exchange",{assertion:y,...e.providerId?{providerId:e.providerId}:{}})},s;try{s=await o(!1);}catch(h){if(!(h instanceof b)||h.status!==401)throw h;s=await o(true);}this.record("identity.assertion.exchange"),this.record("identity.monthly-active-principal");let c=await this.key(),l=await te(this.keyProvider,this.appTag,s.principalId,t,c.thumbprint);if(l)return {...l,principalId:s.principalId,enrolled:false};this.before("device.enroll"),this.attestation&&this.before("security.attestation.verify");let p=await c.proof((h,y)=>["openrtc:v2:device-enroll",this.appTag,s.principalId,t,h,y].join(":")),d=this.attestation?{kind:this.attestation.kind,...await this.attestation.getEvidence({challenge:`openrtc:v2:attestation:${this.appTag}:${s.principalId}:${t}:${p.nonce}`,apiKey:this.apiKey})}:void 0,u=await this.post("/v2/devices/enroll",{identitySession:s.identitySession,deviceId:t,deviceProof:p,...n?.name||n?.platform?{deviceProfile:{...n.name?{name:n.name}:{},...n.platform?{platform:n.platform}:{}}}:{},...r?{recoverRevokedEnrollment:true}:{},...d?{attestation:d}:{}});this.record("device.enroll"),d&&this.record("security.attestation.verify");let v={principalId:s.principalId,token:u.deviceCertificate,expiresAtMs:u.expiresAt*1e3,signingPublicJwk:u.signingPublicJwk,enrolled:true};return await ne(this.keyProvider,this.appTag,s.principalId,t,{token:v.token,expiresAtMs:v.expiresAtMs,signingPublicJwk:v.signingPublicJwk}),i&&await re(this.keyProvider,this.appTag,i,t,v),v}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 D(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 D(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){let o=i==="revoke"?"device.revoke":i==="revoke-all"?"identity.revoke-all":null;o&&this.before(o);let{manageDevice:s}=await import('./deviceManagement-PHY5TIOS.js'),c=await s({source:e,currentDeviceId:t,action:i,targetDeviceId:n,exceptCurrent:r,key:()=>this.key(),post:l=>this.post("/v2/devices/manage",l),isStale:F});return o&&this.record(o),c}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=g(e.token),r=String(n.jti??""),s=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:s}),this.record(i==="join"?"room.join":"room.leave");}grantProvider(e,t={}){let i=null,n=e;return async r=>{if(i)return i;let o=(async()=>{let s=false;n.expiresAtMs<=Date.now()+5*6e4&&n.renew&&(n=await n.renew(),s=true);let c=r.refreshGrant?"gateway.grant.refresh":"gateway.grant.issue";this.before(c),r.refreshGrant&&this.before("coordination.credential.refresh");let l=async d=>{let u=g(d.token),v=String(u.jti??""),y=await(await this.key()).proof((w,q)=>["openrtc:v2:gateway-grant",v,r.avenue.kind,r.avenue.id,r.runtimeInstanceId,w,q].join(":"));return this.post("/v2/gateway/grants",{credentialType:d.type,credential:d.token,avenue:r.avenue,runtimeInstanceId:r.runtimeInstanceId,ticketFingerprint:r.ticketFingerprint,deviceProof:y,...r.refreshGrant?{refreshGrant:r.refreshGrant}:{},...t.maxPeers?{maxPeers:t.maxPeers}:{},...t.features?{features:t.features}:{},...d.type==="device-certificate"&&t.deviceProfile?{deviceProfile:t.deviceProfile}:{}})},p;try{p=await l(n);}catch(d){if(!F(d))throw d;let u=await n.recoverRejectedCertificate?.();if(!u)throw d;n=u,s=true,p=await l(n);}return this.record(c),r.refreshGrant&&this.record("coordination.credential.refresh"),s&&await t.onSourceRenewed?.({token:n.token,expiresAtMs:n.expiresAtMs}),p})();i=o;try{return await o}finally{i===o&&(i=null);}}}};var P=new WeakMap;function fe(a){let e=P.get(a);if(!e)throw new Error("[OpenRTC] Capability runtime is unavailable or already closed.");return e}function oe(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 f(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 W=/^[A-Za-z0-9_.:@-]{1,160}$/,ce=/^[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 V(a){let e=typeof a=="string"?a.trim():"";if(!W.test(e))return null;let t=e.startsWith("device_")?e.slice(7):"";return ce.test(t)?t:e}function le(a,e){try{let t=a.getItem(`pluto_rtc_web_device_identity_${e}`);if(!t)return null;let i=JSON.parse(t);return V(i?.deviceId)}catch{return null}}function de(a){let e=`openrtc:v2:device-id:${a}`,t=`pluto_rtc_web_device_identity_${a}`,i,n=(()=>{try{return i=globalThis.localStorage,i&&le(i,a)||V(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 L(a){let e=typeof a=="string"?a.trim():"";if(!W.test(e))throw new Error("[OpenRTC] The native host returned an invalid durable device ID.");return e}function E(a){let e=g(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 K=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);}},M=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:($[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;P.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{P.delete(this),this.onClosed();}}}},m=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 o=i.devices.list,s=i.devices.listWithStatus,c=i.devices.watch,l=i.devices.watchWithStatus,p=async()=>this.roster.mergeDevices(await o()),d=async()=>this.roster.mergeStatus(await s()),u=y=>c(w=>y(this.roster.mergeDevices(w))),v=y=>l(w=>y(this.roster.mergeStatus(w))),h=Object.create(i);Object.defineProperties(h,{listDevices:{value:p,enumerable:false},listDevicesWithStatus:{value:d,enumerable:false},watchDevices:{value:u,enumerable:false},watchDevicesWithStatus:{value:v,enumerable:false},devices:{value:{...i.devices,list:p,listWithStatus:d,watch:u,watchWithStatus:v},enumerable:true}}),P.set(this,h);}replaceEnrolledDevices(t){this.roster.replace(t);}removeEnrolledDevice(t){this.roster.remove(t);}retainCurrentEnrolledDevice(t){this.roster.retain(t);}},_=class extends C{constructor(t,i,n,r){super("space",t,i,n);this.delivery=r;this.kind="space";this.leave=()=>this.close();}},O=class extends C{constructor(t,i,n,r,o){super("room",t,i,n);this.membership=r;this.onLeave=o;this.kind="room";this.left=false;}async leave(){this.left||(this.left=true,await this.onLeave?.()),await this.close();}},J=class extends C{constructor(t,i,n,r){super("ticket",t,i,n);this.token=r;this.kind="ticket";}},N=class{constructor(e,t){this.options=e;this.internals=t;this.channels=new K;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 m&&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=L(e),r=await this.deviceId();await this.controlPlane.revokeDevice(i,r,n),await Promise.allSettled([...this.handles].map(o=>o.retireDeviceIfPresent(n)));for(let o of this.handles)o instanceof m&&o.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 m&&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:${f(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:${f(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:${f(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=oe(e.apiKey),this.usage=new M(e.usage),this.controlPlane=new R(this.apiKey,t.endpoints??A,t.deviceKeyProvider??U,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 o={fingerprint:t,auth:i},s=n().then(c=>(o.handle=c,c)).catch(c=>{throw this.activations.get(e)===o&&this.activations.delete(e),c});return o.promise=s,this.activations.set(e,o),s}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):de(this.controlPlane.appTag);return L(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??A).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}),o=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}),[s,{wrapAssembly:c}]=await Promise.all([this.internals.runtimeFactory(o),import('./OpenRTCShared-LDKG5RPN.js')]);n=c(s,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"),o=await this.controlPlane.deviceCertificate(t,i,void 0,r),s=await this.activate({kind:"devices",id:o.principalId,source:o.source,principalId:o.principalId,deviceId:i,maxPeers:e.maxPeers,autoConnect:e.autoConnect!=="none",advancedFanout:e.advancedFanout,deviceName:r.name,devicePlatform:r.platform,deviceMetadata:r.metadata}),c;try{c=await this.controlPlane.listEnrolledDevices(t,i);}catch(d){throw this.channels.detach(s),await s.advanced.runtime.shutdown().catch(()=>{}),d}let{AuthenticatedDeviceRoster:l}=await import('./deviceRoster-GHF6MWXF.js'),p;return p=new m(o.principalId,s,()=>{this.channels.detach(s),this.onClosed(p);},new l(c)),this.handles.add(p),p}async joinSpace(e,t={}){this.assertOpen();let i=f(e),n=await this.controlPlane.capability("space",i,t.maxPeers,t.advancedFanout),r=String(g(n.token).principalId),o=await this.activate({kind:"space",id:i,source:n,principalId:r,deviceId:E(n),maxPeers:t.maxPeers,autoConnect:true,defaultDelivery:t.payload??"reliable",advancedFanout:t.advancedFanout}),s;return s=new _(i,o,()=>{this.channels.detach(o),this.onClosed(s);},t.payload??"reliable"),this.handles.add(s),s}async joinRoom(e,t={}){this.assertOpen();let i=f(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 p=t.auth??this.options.auth;if(!p)throw new Error("[OpenRTC] Authenticated rooms require an auth provider.");let d=await this.deviceId(),u=await this.controlPlane.deviceCertificate(p,d,{kind:"room",id:i});n==="durable"&&await this.controlPlane.durableRoomMembership(u.source,i,"join");let v;try{v=await this.activate({kind:"room",id:i,source:u.source,principalId:u.principalId,deviceId:d,maxPeers:t.maxPeers,autoConnect:!0,durableMembership:n==="durable",advancedFanout:t.advancedFanout});}catch(y){throw n==="durable"&&await this.controlPlane.durableRoomMembership(u.source,i,"leave").catch(()=>{}),y}let h;return h=new O(i,v,()=>{this.channels.detach(v),this.onClosed(h);},n,n==="durable"?async()=>{await this.controlPlane.durableRoomMembership(u.source,i,"leave");}:void 0),this.handles.add(h),h}let o=await this.controlPlane.capability("room",i,t.maxPeers,t.advancedFanout),s=String(g(o.token).principalId),c=await this.activate({kind:"room",id:i,source:o,principalId:s,deviceId:E(o),maxPeers:t.maxPeers,autoConnect:true,advancedFanout:t.advancedFanout}),l;return l=new O(i,c,()=>{this.channels.detach(c),this.onClosed(l);},"ephemeral"),this.handles.add(l),l}async issueTicket(e,t={}){this.assertOpen();let i=f(e),n=await this.controlPlane.capability("ticket",i,t.maxPeers,t.advancedFanout),r=String(g(n.token).principalId),o=await this.activate({kind:"ticket",id:i,source:n,principalId:r,deviceId:E(n),maxPeers:t.maxPeers,autoConnect:false,advancedFanout:t.advancedFanout}),s;return s=new J(i,o,()=>{this.channels.detach(o),this.onClosed(s);},n.token),this.handles.add(s),s}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 me(a,e){return new N(a,e)}
|
|
2
|
+
export{B as a,fe as b,me as c};
|
|
@@ -1 +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-
|
|
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-VDVNE725.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-3PE6TWIX.js';import {d}from'./chunk-Z2WVSXPW.js';import {c}from'./chunk-4UAAQLXK.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-SIBGRPTH.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};
|
package/dist/native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-3PE6TWIX.js';export{a as classifyNativeIpcFailure,b as isNativeIpcCommandUnavailable}from'./chunk-Z2WVSXPW.js';import {c}from'./chunk-4UAAQLXK.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var z=class i{static __wrap(t){let e=Object.create(i.prototype);return e.__wbg_ptr=t,K.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,K.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_bistream_free(t,0);}get applicationCryptoWrapped(){return n.bistream_applicationCryptoWrapped(this.__wbg_ptr)!==0}get endpoint_id(){let t,e;try{let s=n.__wbindgen_add_to_stack_pointer(-16);n.bistream_endpoint_id(s,this.__wbg_ptr);var _=f().getInt32(s+0,!0),r=f().getInt32(s+4,!0);return t=_,e=r,v(_,r)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(t,e,1);}}finishSend(){let t=n.bistream_finishSend(this.__wbg_ptr);return p(t)}get recv(){let t=n.bistream_recv(this.__wbg_ptr);return p(t)}get send(){let t=n.bistream_send(this.__wbg_ptr);return p(t)}};Symbol.dispose&&(z.prototype[Symbol.dispose]=z.prototype.free);var U=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,kt.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingbytesource_free(t,0);}get autoAllocateChunkSize(){return n.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr)>>>0}cancel(){let t=this.__destroy_into_raw();n.intounderlyingbytesource_cancel(t);}pull(t){let e=n.intounderlyingbytesource_pull(this.__wbg_ptr,w(t));return p(e)}start(t){n.intounderlyingbytesource_start(this.__wbg_ptr,w(t));}get type(){let t=n.intounderlyingbytesource_type(this.__wbg_ptr);return mt[t]}};Symbol.dispose&&(U.prototype[Symbol.dispose]=U.prototype.free);var B=class i{static __wrap(t){let e=Object.create(i.prototype);return e.__wbg_ptr=t,H.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,H.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingsink_free(t,0);}abort(t){let e=this.__destroy_into_raw(),_=n.intounderlyingsink_abort(e,w(t));return p(_)}close(){let t=this.__destroy_into_raw(),e=n.intounderlyingsink_close(t);return p(e)}write(t){let e=n.intounderlyingsink_write(this.__wbg_ptr,w(t));return p(e)}};Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);var N=class i{static __wrap(t){let e=Object.create(i.prototype);return e.__wbg_ptr=t,J.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,J.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingsource_free(t,0);}cancel(){let t=this.__destroy_into_raw();n.intounderlyingsource_cancel(t);}pull(t){let e=n.intounderlyingsource_pull(this.__wbg_ptr,w(t));return p(e)}};Symbol.dispose&&(N.prototype[Symbol.dispose]=N.prototype.free);var q=class i{static __wrap(t){let e=Object.create(i.prototype);return e.__wbg_ptr=t,Y.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Y.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_peerunistream_free(t,0);}get applicationCryptoWrapped(){return n.peerunistream_applicationCryptoWrapped(this.__wbg_ptr)!==0}finishSend(){let t=n.peerunistream_finishSend(this.__wbg_ptr);return p(t)}get writable(){let t=n.peerunistream_writable(this.__wbg_ptr);return p(t)}};Symbol.dispose&&(q.prototype[Symbol.dispose]=q.prototype.free);var D=class i{static __wrap(t){let e=Object.create(i.prototype);return e.__wbg_ptr=t,Q.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Q.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_wasmclient_free(t,0);}add_peer_scope(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_add_peer_scope(this.__wbg_ptr,_,r,s,a);return p(g)}bind_connection_device_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_bind_connection_device_id(this.__wbg_ptr,_,r,s,a);return p(g)}bind_node_device_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_bind_node_device_id(this.__wbg_ptr,_,r,s,a);return p(g)}clearConnectionApplicationCryptoKey(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;n.wasmclient_clearConnectionApplicationCryptoKey(this.__wbg_ptr,e,_);}clearIdentityCredential(){n.wasmclient_clearIdentityCredential(this.__wbg_ptr);}clear_session_tokens(){n.wasmclient_clear_session_tokens(this.__wbg_ptr);}confirm_inline_reciprocal_session_admission(t,e,_,r,s,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,y=b(r,n.__wbindgen_export,n.__wbindgen_export2),h=c;var k=u(a)?0:b(a,n.__wbindgen_export,n.__wbindgen_export2),I=c;let R=n.wasmclient_confirm_inline_reciprocal_session_admission(this.__wbg_ptr,g,d,e,x,l,y,h,s,k,I);return p(R)}connect(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_connect(this.__wbg_ptr,e,_);return p(r)}connect_device(t,e){var _=u(t)?0:b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;let s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_connect_device(this.__wbg_ptr,_,r,s,a);return p(g)}connection_state(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_connection_state(this.__wbg_ptr,e,_);return p(r)}connection_states(){let t=n.wasmclient_connection_states(this.__wbg_ptr);return p(t)}create_room(t,e,_,r,s,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(e,n.__wbindgen_export,n.__wbindgen_export2),l=c,y=b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c,k=b(r,n.__wbindgen_export,n.__wbindgen_export2),I=c,R=b(s,n.__wbindgen_export,n.__wbindgen_export2),C=c,X=n.wasmclient_create_room(this.__wbg_ptr,g,d,x,l,y,h,k,I,R,C,u(a)?Number.MAX_SAFE_INTEGER:a>>>0);return p(X)}create_session(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_create_session(this.__wbg_ptr,e,_);return p(r)}delete_device(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_delete_device(this.__wbg_ptr,_,r,s,a);return p(g)}devices_with_status(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_devices_with_status(this.__wbg_ptr,e,_);return p(r)}disconnect(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_disconnect(this.__wbg_ptr,e,_);return p(r)}disconnect_device(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;var s=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_disconnect_device(this.__wbg_ptr,_,r,s,a);return p(g)}disconnect_transient(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_disconnect_transient(this.__wbg_ptr,e,_);return p(r)}endpoint_id_from_ticket(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),y=b(t,n.__wbindgen_export,n.__wbindgen_export2),h=c;n.wasmclient_endpoint_id_from_ticket(l,this.__wbg_ptr,y,h);var r=f().getInt32(l+0,!0),s=f().getInt32(l+4,!0),a=f().getInt32(l+8,!0),g=f().getInt32(l+12,!0),d=r,x=s;if(g)throw d=0,x=0,p(a);return e=d,_=x,v(d,x)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(e,_,1);}}endpoint_ticket(){let t=n.wasmclient_endpoint_ticket(this.__wbg_ptr);return p(t)}endpoint_ticket_with_token(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_endpoint_ticket_with_token(this.__wbg_ptr,_,r,e);return p(s)}force_reconnect_snapshot(){n.wasmclient_force_reconnect_snapshot(this.__wbg_ptr);}get_members(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=n.wasmclient_get_members(this.__wbg_ptr,r,s,a,g,d,x);return p(l)}incoming_streams(){let t=n.wasmclient_incoming_streams(this.__wbg_ptr);return p(t)}initIrohWithTestRelay(t,e){var _=u(t)?0:j(t,n.__wbindgen_export),r=c,s=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_initIrohWithTestRelay(this.__wbg_ptr,_,r,s,a);return p(g)}init_iroh(t){var e=u(t)?0:j(t,n.__wbindgen_export),_=c;let r=n.wasmclient_init_iroh(this.__wbg_ptr,e,_);return p(r)}iroh_path_kind(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_iroh_path_kind(this.__wbg_ptr,e,_);return p(r)}iroh_secret_key(){let t=n.wasmclient_iroh_secret_key(this.__wbg_ptr);return p(t)}iroh_transport_rtt_ms(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_iroh_transport_rtt_ms(this.__wbg_ptr,e,_);return p(r)}is_auto_connect_excluded(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;return n.wasmclient_is_auto_connect_excluded(this.__wbg_ptr,e,_)!==0}is_connected(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_is_connected(this.__wbg_ptr,e,_);return p(r)}is_current_transport_stable_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_is_current_transport_stable_id(this.__wbg_ptr,_,r,e);return p(s)}join_room(t,e,_,r,s){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c,h=b(r,n.__wbindgen_export,n.__wbindgen_export2),k=c,I=b(s,n.__wbindgen_export,n.__wbindgen_export2),R=c,C=n.wasmclient_join_room(this.__wbg_ptr,a,g,d,x,l,y,h,k,I,R);return p(C)}leave_room(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=n.wasmclient_leave_room(this.__wbg_ptr,r,s,a,g,d,x);return p(l)}list_managed_connections(){let t=n.wasmclient_list_managed_connections(this.__wbg_ptr);return p(t)}static newV2(t){try{let s=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_newV2(s,a,g);var e=f().getInt32(s+0,!0),_=f().getInt32(s+4,!0),r=f().getInt32(s+8,!0);if(r)throw p(_);return i.__wrap(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}node_addr(){let t=n.wasmclient_node_addr(this.__wbg_ptr);return p(t)}open_bi(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_bi(this.__wbg_ptr,e,_);return p(r)}open_native_main_control_bi(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_native_main_control_bi(this.__wbg_ptr,e,_);return p(r)}open_peer_bi(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_open_peer_bi(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(s)}open_peer_bi_explicit_file_sender(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_open_peer_bi_explicit_file_sender(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(s)}open_peer_bi_transport_only(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_open_peer_bi_transport_only(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(s)}open_peer_native_bi(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=n.wasmclient_open_peer_native_bi(this.__wbg_ptr,r,s,a,g,u(_)?Number.MAX_SAFE_INTEGER:_>>>0);return p(d)}open_peer_uni(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_open_peer_uni(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(s)}open_uni(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_uni(this.__wbg_ptr,e,_);return p(r)}peer_scopes(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_scopes(this.__wbg_ptr,e,_);return p(r)}peer_session(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_session(this.__wbg_ptr,e,_);return p(r)}peer_sessions(){let t=n.wasmclient_peer_sessions(this.__wbg_ptr);return p(t)}peer_snapshot(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_snapshot(this.__wbg_ptr,e,_);return p(r)}prepare_inline_reciprocal_session_admission(t,e,_,r,s,a,g,d){let x=b(t,n.__wbindgen_export,n.__wbindgen_export2),l=c,y=b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c,k=b(r,n.__wbindgen_export,n.__wbindgen_export2),I=c,R=b(s,n.__wbindgen_export,n.__wbindgen_export2),C=c,X=b(a,n.__wbindgen_export,n.__wbindgen_export2),_t=c,rt=b(g,n.__wbindgen_export,n.__wbindgen_export2),ot=c,it=b(d,n.__wbindgen_export,n.__wbindgen_export2),st=c,ct=n.wasmclient_prepare_inline_reciprocal_session_admission(this.__wbg_ptr,x,l,e,y,h,k,I,R,C,X,_t,rt,ot,it,st);return p(ct)}present_session_token_to_host(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_present_session_token_to_host(this.__wbg_ptr,_,r,s,a);return p(g)}present_session_token_to_host_with_payload(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;var d=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c;let l=n.wasmclient_present_session_token_to_host_with_payload(this.__wbg_ptr,r,s,a,g,d,x);return p(l)}present_session_token_to_host_with_payload_and_device_id(t,e,_,r){let s=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,y=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),h=c;let k=n.wasmclient_present_session_token_to_host_with_payload_and_device_id(this.__wbg_ptr,s,a,g,d,x,l,y,h);return p(k)}rankRoutes(t,e){try{let a=n.__wbindgen_add_to_stack_pointer(-16),g=tt(t,n.__wbindgen_export),d=c,x=tt(e,n.__wbindgen_export),l=c;n.wasmclient_rankRoutes(a,this.__wbg_ptr,g,d,x,l);var _=f().getInt32(a+0,!0),r=f().getInt32(a+4,!0),s=At(_,r).slice();return n.__wbindgen_export4(_,r*4,4),s}finally{n.__wbindgen_add_to_stack_pointer(16);}}register_session_token(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_register_session_token(this.__wbg_ptr,r,s,a,g,_);}register_session_token_with_expiry_ms(t,e,_,r){let s=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;n.wasmclient_register_session_token_with_expiry_ms(this.__wbg_ptr,s,a,g,d,_,r);}reject_connection_admission(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_reject_connection_admission(this.__wbg_ptr,_,r,s,a);return p(g)}release_peer_scope(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;var s=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_release_peer_scope(this.__wbg_ptr,_,r,s,a);return p(g)}remote_session_admission_ready_for_ticket(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_remote_session_admission_ready_for_ticket(this.__wbg_ptr,e,_);return p(r)}report_managed_connection_settled(t,e,_,r,s,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c;let y=n.wasmclient_report_managed_connection_settled(this.__wbg_ptr,g,d,e,x,l,!u(r),u(r)?BigInt(0):r,!u(s),u(s)?BigInt(0):s,!u(a),u(a)?BigInt(0):a);return p(y)}report_transport_status(t,e,_,r,s,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(e,n.__wbindgen_export,n.__wbindgen_export2),l=c;var y=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c;let k=n.wasmclient_report_transport_status(this.__wbg_ptr,g,d,x,l,y,h,!u(r),u(r)?BigInt(0):r,!u(s),u(s)?BigInt(0):s,!u(a),u(a)?BigInt(0):a);return p(k)}resolve_peer_connection_records(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_resolve_peer_connection_records(this.__wbg_ptr,e,_);return p(r)}revoke_session_token(t){try{let s=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_revoke_session_token(s,this.__wbg_ptr,a,g);var e=f().getInt32(s+0,!0),_=f().getInt32(s+4,!0),r=f().getInt32(s+8,!0);if(r)throw p(_);return p(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}revoke_tokens_by_scope(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_revoke_tokens_by_scope(this.__wbg_ptr,e,_);return p(r)}runtime_policy(){try{let r=n.__wbindgen_add_to_stack_pointer(-16);n.wasmclient_runtime_policy(r,this.__wbg_ptr);var t=f().getInt32(r+0,!0),e=f().getInt32(r+4,!0),_=f().getInt32(r+8,!0);if(_)throw p(e);return p(t)}finally{n.__wbindgen_add_to_stack_pointer(16);}}same_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_same_peer(this.__wbg_ptr,_,r,s,a);return p(g)}search_devices(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_search_devices(this.__wbg_ptr,e,_);return p(r)}send_message(t,e,_,r){let s=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,y=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),h=c;let k=n.wasmclient_send_message(this.__wbg_ptr,s,a,g,d,x,l,y,h);return p(k)}send_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=j(e,n.__wbindgen_export),a=c,g=n.wasmclient_send_peer(this.__wbg_ptr,_,r,s,a);return p(g)}send_peer_application_frame(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=j(e,n.__wbindgen_export),g=c,d=n.wasmclient_send_peer_application_frame(this.__wbg_ptr,r,s,a,g,u(_)?Number.MAX_SAFE_INTEGER:_>>>0);return p(d)}setConnectionApplicationCryptoKey(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=j(e,n.__wbindgen_export),a=c,g=n.wasmclient_setConnectionApplicationCryptoKey(this.__wbg_ptr,_,r,s,a);return p(g)}setConnectionApplicationCryptoRequired(t){try{let r=n.__wbindgen_add_to_stack_pointer(-16),s=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c;n.wasmclient_setConnectionApplicationCryptoRequired(r,this.__wbg_ptr,s,a);var e=f().getInt32(r+0,!0),_=f().getInt32(r+4,!0);if(_)throw p(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}setIdentityCredential(t){var e=u(t)?0:b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;n.wasmclient_setIdentityCredential(this.__wbg_ptr,e,_);}set_auto_connect_excluded(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_set_auto_connect_excluded(this.__wbg_ptr,_,r,e);return p(s)}set_offline(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_set_offline(this.__wbg_ptr,e,_);return p(r)}start_auto_connect(t,e){try{let s=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c;n.wasmclient_start_auto_connect(s,this.__wbg_ptr,a,g,d,x);var _=f().getInt32(s+0,!0),r=f().getInt32(s+4,!0);if(r)throw p(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}start_presence_loop(t,e,_,r){let s=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c;var y=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),h=c;n.wasmclient_start_presence_loop(this.__wbg_ptr,s,a,g,d,x,l,y,h);}stop_auth_scoped_activity(){n.wasmclient_stop_auth_scoped_activity(this.__wbg_ptr);}stop_auto_connect(){n.wasmclient_stop_auto_connect(this.__wbg_ptr);}stop_presence_loop(){n.wasmclient_stop_presence_loop(this.__wbg_ptr);}submit_browser_desired_peers(t,e){try{let a=n.__wbindgen_add_to_stack_pointer(-16),g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;n.wasmclient_submit_browser_desired_peers(a,this.__wbg_ptr,t,g,d);var _=f().getInt32(a+0,!0),r=f().getInt32(a+4,!0),s=f().getInt32(a+8,!0);if(s)throw p(r);return _!==0}finally{n.__wbindgen_add_to_stack_pointer(16);}}update_device(t,e,_,r,s){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c;var l=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c,h=u(s)?0:b(s,n.__wbindgen_export,n.__wbindgen_export2),k=c;let I=n.wasmclient_update_device(this.__wbg_ptr,a,g,d,x,l,y,u(r)?0:w(r),h,k);return p(I)}update_presence(t,e,_,r,s){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c;var h=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),k=c;let I=n.wasmclient_update_presence(this.__wbg_ptr,a,g,d,x,l,y,h,k,!u(s),u(s)?BigInt(0):s);return p(I)}update_session(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_update_session(this.__wbg_ptr,_,r,s,a);return p(g)}validate_session_token(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),y=b(t,n.__wbindgen_export,n.__wbindgen_export2),h=c;n.wasmclient_validate_session_token(l,this.__wbg_ptr,y,h);var r=f().getInt32(l+0,!0),s=f().getInt32(l+4,!0),a=f().getInt32(l+8,!0),g=f().getInt32(l+12,!0),d=r,x=s;if(g)throw d=0,x=0,p(a);return e=d,_=x,v(d,x)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(e,_,1);}}validate_session_token_for_connection(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_validate_session_token_for_connection(this.__wbg_ptr,_,r,s,a);return p(g)}validate_session_token_for_connection_with_payload(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;var d=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c;let l=n.wasmclient_validate_session_token_for_connection_with_payload(this.__wbg_ptr,r,s,a,g,d,x);return p(l)}wait_for_settled_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_wait_for_settled_peer(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(s)}wake_browser_auto_connect(){return n.wasmclient_wake_browser_auto_connect(this.__wbg_ptr)!==0}};Symbol.dispose&&(D.prototype[Symbol.dispose]=D.prototype.free);var V=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Z.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_wasmconnection_free(t,0);}create_data_channel(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmconnection_create_data_channel(this.__wbg_ptr,e,_);return p(r)}constructor(){try{let r=n.__wbindgen_add_to_stack_pointer(-16);n.wasmconnection_new(r);var t=f().getInt32(r+0,!0),e=f().getInt32(r+4,!0),_=f().getInt32(r+8,!0);if(_)throw p(e);return this.__wbg_ptr=t,Z.register(this,this.__wbg_ptr,this),this}finally{n.__wbindgen_add_to_stack_pointer(16);}}};Symbol.dispose&&(V.prototype[Symbol.dispose]=V.prototype.free);function jt(){n.start();}function et(){return {__proto__:null,"./openrtc_bg.js":{__proto__:null,__wbg_Error_9dc85fe1bc224456:function(t,e){let _=Error(v(t,e));return w(_)},__wbg_String_8564e559799eccda:function(t,e){let _=String(o(e)),r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg___wbindgen_boolean_get_b131b2f36d6b2f55:function(t){let e=o(t),_=typeof e=="boolean"?e:void 0;return u(_)?16777215:_?1:0},__wbg___wbindgen_debug_string_56c147eb1a51f0c4:function(t,e){let _=P(o(e)),r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg___wbindgen_in_ce8569b2fc6f5088:function(t,e){return o(t)in o(e)},__wbg___wbindgen_is_function_147961669f068cd4:function(t){return typeof o(t)=="function"},__wbg___wbindgen_is_null_ced4761460071341:function(t){return o(t)===null},__wbg___wbindgen_is_object_3a2c414391dbf751:function(t){let e=o(t);return typeof e=="object"&&e!==null},__wbg___wbindgen_is_string_6541b0f6ecd4e8e5:function(t){return typeof o(t)=="string"},__wbg___wbindgen_is_undefined_4410e3c20a99fa97:function(t){return o(t)===void 0},__wbg___wbindgen_jsval_eq_174c93ec61bab0c5:function(t,e){return o(t)===o(e)},__wbg___wbindgen_jsval_loose_eq_e07e3b1f5db6da6c:function(t,e){return o(t)==o(e)},__wbg___wbindgen_number_get_588ed6b97f0d7e14:function(t,e){let _=o(e),r=typeof _=="number"?_:void 0;f().setFloat64(t+8,u(r)?0:r,true),f().setInt32(t+0,!u(r),true);},__wbg___wbindgen_string_get_fa2687d531ed17a5:function(t,e){let _=o(e),r=typeof _=="string"?_:void 0;var s=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),a=c;f().setInt32(t+4,a,true),f().setInt32(t+0,s,true);},__wbg___wbindgen_throw_bbadd78c1bac3a77:function(t,e){throw new Error(v(t,e))},__wbg__wbg_cb_unref_c2301a3c9b78104b:function(t){o(t)._wbg_cb_unref();},__wbg_abort_56c00f462c9261d9:function(t,e){o(t).abort(o(e));},__wbg_abort_f2416f4a9852003e:function(t){o(t).abort();},__wbg_addEventListener_b635263c509aa7de:function(){return m(function(t,e,_,r){o(t).addEventListener(v(e,_),o(r));},arguments)},__wbg_append_c5a0c94a6a73b22e:function(){return m(function(t,e,_,r,s){o(t).append(v(e,_),v(r,s));},arguments)},__wbg_arrayBuffer_cc7704fa158b907a:function(){return m(function(t){let e=o(t).arrayBuffer();return w(e)},arguments)},__wbg_bistream_new:function(t){let e=z.__wrap(t);return w(e)},__wbg_body_442a47f02322d7b0:function(t){let e=o(t).body;return u(e)?0:w(e)},__wbg_buffer_8524b3453cde4918:function(t){let e=o(t).buffer;return w(e)},__wbg_byobRequest_cc72d210de793e64:function(t){let e=o(t).byobRequest;return u(e)?0:w(e)},__wbg_byteLength_96807b1d9ab24a4c:function(t){return o(t).byteLength},__wbg_byteOffset_a9c7002428843c41:function(t){return o(t).byteOffset},__wbg_call_ec09a4cf93377d3a:function(){return m(function(t,e,_){let r=o(t).call(o(e),o(_));return w(r)},arguments)},__wbg_cancel_f3a197b26dc88b39:function(t){let e=o(t).cancel();return w(e)},__wbg_catch_66060324c27be6f7:function(t,e){let _=o(t).catch(o(e));return w(_)},__wbg_clearTimeout_113b1cde814ec762:function(t){let e=clearTimeout(p(t));return w(e)},__wbg_clearTimeout_333bba87532ab9d3:function(t){let e=clearTimeout(p(t));return w(e)},__wbg_clearTimeout_47a40e3be01ed7a3:function(){return m(function(t,e){o(t).clearTimeout(p(e));},arguments)},__wbg_close_296263cfe1bb2999:function(){return m(function(t){o(t).close();},arguments)},__wbg_close_388d99468213b286:function(){return m(function(t){o(t).close();},arguments)},__wbg_close_4857e22d08b71356:function(){return m(function(t){o(t).close();},arguments)},__wbg_code_1cda2855fcd9b009:function(t){return o(t).code},__wbg_code_70beb7b22374d55e:function(t){return o(t).code},__wbg_createDataChannel_122bd3d8aacee49b:function(t,e,_){let r=o(t).createDataChannel(v(e,_));return w(r)},__wbg_crypto_38df2bab126b63dc:function(t){let e=o(t).crypto;return w(e)},__wbg_data_8a04443c1e5a8cd3:function(t){let e=o(t).data;return w(e)},__wbg_dispatchEvent_cc62a6a43d28b01c:function(){return m(function(t,e){return o(t).dispatchEvent(o(e))},arguments)},__wbg_done_6a8439e544ec6206:function(t){return o(t).done},__wbg_enqueue_bbeb09ba0b140f76:function(){return m(function(t,e){o(t).enqueue(o(e));},arguments)},__wbg_entries_4e00eefd3fd54cf1:function(t){let e=o(t).entries();return w(e)},__wbg_error_6651fee1c71e5da9:function(t){console.error(o(t));},__wbg_error_a6fa202b58aa1cd3:function(t,e){let _,r;try{_=t,r=e,console.error(v(t,e));}finally{n.__wbindgen_export4(_,r,1);}},__wbg_fetch_074561c3e313c86f:function(t){let e=fetch(o(t));return w(e)},__wbg_fetch_22858a12fcf93152:function(t,e){let _=o(t).fetch(o(e));return w(_)},__wbg_getRandomValues_76dfc69825c9c552:function(){return m(function(t,e){globalThis.crypto.getRandomValues(S(t,e));},arguments)},__wbg_getRandomValues_c44a50d8cfdaebeb:function(){return m(function(t,e){o(t).getRandomValues(o(e));},arguments)},__wbg_getReader_9facd4f899beac89:function(){return m(function(t){let e=o(t).getReader();return w(e)},arguments)},__wbg_get_4b90d6d8c5deb5d5:function(t,e){let _=o(t)[e>>>0];return w(_)},__wbg_get_52a8a619f7b88df6:function(){return m(function(t,e){let _=Reflect.get(o(t),o(e));return w(_)},arguments)},__wbg_get_done_c21b9933fc9a9e9c:function(t){let e=o(t).done;return u(e)?16777215:e?1:0},__wbg_get_value_ad568c7d3db9073f:function(t){let e=o(t).value;return w(e)},__wbg_get_with_ref_key_6412cf3094599694:function(t,e){let _=o(t)[o(e)];return w(_)},__wbg_has_14676d88c1340d2c:function(){return m(function(t,e){return Reflect.has(o(t),o(e))},arguments)},__wbg_headers_5b19cf40627ae54d:function(t){let e=o(t).headers;return w(e)},__wbg_info_a2b5f8a5dae8b26c:function(t){console.info(o(t));},__wbg_instanceof_ArrayBuffer_a581da923203f29f:function(t){let e;try{e=o(t)instanceof ArrayBuffer;}catch{e=false;}return e},__wbg_instanceof_Blob_5c4e145be35f9b1e:function(t){let e;try{e=o(t)instanceof Blob;}catch{e=false;}return e},__wbg_instanceof_Response_36a65a969abaa7c6:function(t){let e;try{e=o(t)instanceof Response;}catch{e=false;}return e},__wbg_instanceof_Uint8Array_b6fe1ac89eba107e:function(t){let e;try{e=o(t)instanceof Uint8Array;}catch{e=false;}return e},__wbg_instanceof_Window_9e0fe7d3d1ff4342:function(t){let e;try{e=o(t)instanceof Window;}catch{e=false;}return e},__wbg_isArray_139f48e3c057ede8:function(t){return Array.isArray(o(t))},__wbg_length_68a9d5278d084f4f:function(t){return o(t).length},__wbg_log_6614a4effdb4e983:function(t){console.log(o(t));},__wbg_message_12958526424a887b:function(t,e){let _=o(e).message,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_msCrypto_bd5a034af96bcba6:function(t){let e=o(t).msCrypto;return w(e)},__wbg_new_0b303268aa395a38:function(){let t=new Array;return w(t)},__wbg_new_189262ff31890c23:function(){return m(function(){let t=new Headers;return w(t)},arguments)},__wbg_new_20b778a4c5c691c3:function(){let t=new Object;return w(t)},__wbg_new_227d7c05414eb861:function(){let t=new Error;return w(t)},__wbg_new_24739629d416f982:function(){return m(function(){let t=new AbortController;return w(t)},arguments)},__wbg_new_5fae30e6b23db8df:function(t,e){let _=new Error(v(t,e));return w(_)},__wbg_new_883c0db065f06efd:function(){return w(new Map)},__wbg_new_a3e5112401a82338:function(){return m(function(t,e){let _=new WebSocket(v(t,e));return w(_)},arguments)},__wbg_new_b06772b280cc6e52:function(t){let e=new Uint8Array(o(t));return w(e)},__wbg_new_from_slice_bb2d1778c0b87eb1:function(t,e){let _=new Uint8Array(S(t,e));return w(_)},__wbg_new_typed_90c3f6c29ba36d19:function(t,e){try{var _={a:t,b:e},r=(a,g)=>{let d=_.a;_.a=0;try{return lt(d,_.b,a,g)}finally{_.a=d;}};let s=new Promise(r);return w(s)}finally{_.a=0;}},__wbg_new_with_byte_offset_and_length_9e1e664fe1a5d385:function(t,e,_){let r=new Uint8Array(o(t),e>>>0,_>>>0);return w(r)},__wbg_new_with_configuration_3a96aa953ca17197:function(){return m(function(t){let e=new RTCPeerConnection(o(t));return w(e)},arguments)},__wbg_new_with_event_init_dict_bd850674488710b1:function(){return m(function(t,e,_){let r=new CustomEvent(v(t,e),o(_));return w(r)},arguments)},__wbg_new_with_into_underlying_sink_2596343f9b6c8e58:function(t){let e=new WritableStream(B.__wrap(t));return w(e)},__wbg_new_with_into_underlying_source_fd904252f385f59c:function(t,e){let _=new ReadableStream(N.__wrap(t),p(e));return w(_)},__wbg_new_with_length_4b57a7a5dc67221c:function(t){let e=new Uint8Array(t>>>0);return w(e)},__wbg_new_with_str_and_init_df876572184fe639:function(){return m(function(t,e,_){let r=new Request(v(t,e),o(_));return w(r)},arguments)},__wbg_new_with_str_sequence_505a4829cc247e79:function(){return m(function(t,e,_){let r=new WebSocket(v(t,e),o(_));return w(r)},arguments)},__wbg_next_8cb028b6ba50743f:function(){return m(function(t){let e=o(t).next();return w(e)},arguments)},__wbg_node_84ea875411254db1:function(t){let e=o(t).node;return w(e)},__wbg_now_bce4dc999095ea77:function(){return Date.now()},__wbg_now_e7c6795a7f81e10f:function(t){return o(t).now()},__wbg_parse_a5c06e19bc1187fd:function(t,e){return Date.parse(v(t,e))},__wbg_peerunistream_new:function(t){let e=q.__wrap(t);return w(e)},__wbg_performance_3fcf6e32a7e1ed0a:function(t){let e=o(t).performance;return w(e)},__wbg_process_44c7a14e11e9f69e:function(t){let e=o(t).process;return w(e)},__wbg_protocol_28aaef5ea42981d6:function(t,e){let _=o(e).protocol,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_prototypesetcall_956c7493c68e29b4:function(t,e,_){Uint8Array.prototype.set.call(S(t,e),o(_));},__wbg_push_ceb8ef046afb2041:function(t,e){return o(t).push(o(e))},__wbg_queueMicrotask_4698f900840e3286:function(t){queueMicrotask(o(t));},__wbg_queueMicrotask_477a5533c7100338:function(t){let e=o(t).queueMicrotask;return w(e)},__wbg_randomFillSync_6c25eac9869eb53c:function(){return m(function(t,e){o(t).randomFillSync(p(e));},arguments)},__wbg_read_8426c146431f2905:function(t){let e=o(t).read();return w(e)},__wbg_readyState_25243ad6ce649774:function(t){return o(t).readyState},__wbg_reason_4ec455bac79b33ce:function(t,e){let _=o(e).reason,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_releaseLock_188846ef719acb10:function(t){o(t).releaseLock();},__wbg_removeEventListener_016c1d24523b4730:function(){return m(function(t,e,_,r){o(t).removeEventListener(v(e,_),o(r));},arguments)},__wbg_require_b4edbdcf3e2a1ef0:function(){return m(function(){let t=module.require;return w(t)},arguments)},__wbg_resolve_0183de2e8c6b1d54:function(t){let e=Promise.resolve(o(t));return w(e)},__wbg_respond_3cdb4cf32683fd79:function(){return m(function(t,e){o(t).respond(e>>>0);},arguments)},__wbg_send_99d049cae69c53cc:function(){return m(function(t,e,_){o(t).send(S(e,_));},arguments)},__wbg_send_bac9d3dc4f21ef28:function(){return m(function(t,e,_){o(t).send(v(e,_));},arguments)},__wbg_setTimeout_3a808dd861dd3c12:function(t,e){let _=setTimeout(o(t),e);return w(_)},__wbg_setTimeout_6613a51400c1bf9f:function(){return m(function(t,e,_){let r=o(t).setTimeout(p(e),_);return w(r)},arguments)},__wbg_setTimeout_ef24d2fc3ad97385:function(){return m(function(t,e){let _=setTimeout(o(t),e);return w(_)},arguments)},__wbg_set_5f806304fb633ab3:function(t,e,_){let r=o(t).set(o(e),o(_));return w(r)},__wbg_set_6be42768c690e380:function(t,e,_){o(t)[p(e)]=p(_);},__wbg_set_86698c227e5b9dad:function(t,e,_){o(t).set(S(e,_));},__wbg_set_a6ba3ac0e634b822:function(){return m(function(t,e,_){return Reflect.set(o(t),o(e),o(_))},arguments)},__wbg_set_binaryType_8c2dd2cf1cfc2e28:function(t,e){o(t).binaryType=xt[e];},__wbg_set_body_d1153b16a2b95ca1:function(t,e){o(t).body=o(e);},__wbg_set_cache_5a01a8b5e6ca6cf2:function(t,e){o(t).cache=yt[e];},__wbg_set_credentials_e9120ed88b1fc0b8:function(t,e){o(t).credentials=ht[e];},__wbg_set_da33c120a6584674:function(t,e,_){o(t)[e>>>0]=p(_);},__wbg_set_detail_c7af5edea934390b:function(t,e){o(t).detail=o(e);},__wbg_set_handle_event_6147c38b782c7b42:function(t,e){o(t).handleEvent=o(e);},__wbg_set_headers_877ed41890d28af2:function(t,e){o(t).headers=o(e);},__wbg_set_high_water_mark_77da20c49668427d:function(t,e){o(t).highWaterMark=e;},__wbg_set_method_b4ede299b2064f37:function(t,e,_){o(t).method=v(e,_);},__wbg_set_mode_d6c2e1991aa963c6:function(t,e){o(t).mode=vt[e];},__wbg_set_onclose_9cb5c3372e16c192:function(t,e){o(t).onclose=o(e);},__wbg_set_onerror_190fe67e911ebf28:function(t,e){o(t).onerror=o(e);},__wbg_set_onmessage_96337495f0bfb796:function(t,e){o(t).onmessage=o(e);},__wbg_set_onopen_3e2bf6b11d434c2d:function(t,e){o(t).onopen=o(e);},__wbg_set_signal_9022b5aa06a6ce5b:function(t,e){o(t).signal=o(e);},__wbg_signal_41dd1a8913cd0b7d:function(t){let e=o(t).signal;return w(e)},__wbg_stack_3b0d974bbf31e44f:function(t,e){let _=o(e).stack,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_static_accessor_GLOBAL_60a4124bab7dcc9a:function(){let t=typeof global>"u"?null:global;return u(t)?0:w(t)},__wbg_static_accessor_GLOBAL_THIS_95ca6460658b5d13:function(){let t=typeof globalThis>"u"?null:globalThis;return u(t)?0:w(t)},__wbg_static_accessor_SELF_4c95f759a91e9aae:function(){let t=typeof self>"u"?null:self;return u(t)?0:w(t)},__wbg_static_accessor_WINDOW_44b435597f9e9ee7:function(){let t=typeof window>"u"?null:window;return u(t)?0:w(t)},__wbg_status_9e6505cfa3e73a7c:function(t){return o(t).status},__wbg_subarray_42216645a367cd7a:function(t,e,_){let r=o(t).subarray(e>>>0,_>>>0);return w(r)},__wbg_then_254bab9b266a77a5:function(t,e,_){let r=o(t).then(o(e),o(_));return w(r)},__wbg_then_3ea18602c6a5123b:function(t,e){let _=o(t).then(o(e));return w(_)},__wbg_url_72c67c175685a054:function(t,e){let _=o(e).url,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_url_d0b8042af0d1bbba:function(t,e){let _=o(e).url,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_value_3d3defe09fb1ffca:function(t){let e=o(t).value;return w(e)},__wbg_versions_276b2795b1c6a219:function(t){let e=o(t).versions;return w(e)},__wbg_view_15fa5865c6b336e3:function(t){let e=o(t).view;return u(e)?0:w(e)},__wbg_warn_633bacc13ba7e6c3:function(t){console.warn(o(t));},__wbg_wasClean_f17429d064911939:function(t){return o(t).wasClean},__wbindgen_cast_0000000000000001:function(t,e){let _=F(t,e,gt);return w(_)},__wbindgen_cast_0000000000000002:function(t,e){let _=F(t,e,ft);return w(_)},__wbindgen_cast_0000000000000003:function(t,e){let _=F(t,e,dt);return w(_)},__wbindgen_cast_0000000000000004:function(t,e){let _=F(t,e,ut);return w(_)},__wbindgen_cast_0000000000000005:function(t,e){let _=F(t,e,bt);return w(_)},__wbindgen_cast_0000000000000006:function(t,e){let _=F(t,e,at);return w(_)},__wbindgen_cast_0000000000000007:function(t,e){let _=Rt(t,e,pt);return w(_)},__wbindgen_cast_0000000000000008:function(t,e){let _=F(t,e,wt);return w(_)},__wbindgen_cast_0000000000000009:function(t){return w(t)},__wbindgen_cast_000000000000000a:function(t){return w(t)},__wbindgen_cast_000000000000000b:function(t,e){let _=S(t,e);return w(_)},__wbindgen_cast_000000000000000c:function(t,e){let _=v(t,e);return w(_)},__wbindgen_cast_000000000000000d:function(t){let e=BigInt.asUintN(64,t);return w(e)},__wbindgen_cast_000000000000000e:function(t,e){var _=S(t,e).slice();return n.__wbindgen_export4(t,e*1,1),w(_)},__wbindgen_object_clone_ref:function(t){let e=o(t);return w(e)},__wbindgen_object_drop_ref:function(t){p(t);}}}}function bt(i,t){n.__wasm_bindgen_func_elem_8862(i,t);}function at(i,t){n.__wasm_bindgen_func_elem_9985(i,t);}function pt(i,t){n.__wasm_bindgen_func_elem_10042(i,t);}function wt(i,t){n.__wasm_bindgen_func_elem_17823(i,t);}function gt(i,t,e){n.__wasm_bindgen_func_elem_9066(i,t,w(e));}function dt(i,t,e){n.__wasm_bindgen_func_elem_6525(i,t,w(e));}function ut(i,t,e){n.__wasm_bindgen_func_elem_10686(i,t,w(e));}function ft(i,t,e){try{let s=n.__wbindgen_add_to_stack_pointer(-16);n.__wasm_bindgen_func_elem_17968(s,i,t,w(e));var _=f().getInt32(s+0,!0),r=f().getInt32(s+4,!0);if(r)throw p(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}function lt(i,t,e,_){n.__wasm_bindgen_func_elem_17970(i,t,w(e),w(_));}var xt=["blob","arraybuffer"],mt=["bytes"],yt=["default","no-store","reload","no-cache","force-cache","only-if-cached"],ht=["omit","same-origin","include"],vt=["same-origin","no-cors","cors","navigate"],K=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_bistream_free(i,1)),kt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_intounderlyingbytesource_free(i,1)),H=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_intounderlyingsink_free(i,1)),J=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_intounderlyingsource_free(i,1)),Y=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_peerunistream_free(i,1)),Q=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_wasmclient_free(i,1)),Z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_wasmconnection_free(i,1));function w(i){W===A.length&&A.push(A.length+1);let t=W;return W=A[t],A[t]=i,t}var G=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbindgen_export5(i.a,i.b));function P(i){let t=typeof i;if(t=="number"||t=="boolean"||i==null)return `${i}`;if(t=="string")return `"${i}"`;if(t=="symbol"){let r=i.description;return r==null?"Symbol":`Symbol(${r})`}if(t=="function"){let r=i.name;return typeof r=="string"&&r.length>0?`Function(${r})`:"Function"}if(Array.isArray(i)){let r=i.length,s="[";r>0&&(s+=P(i[0]));for(let a=1;a<r;a++)s+=", "+P(i[a]);return s+="]",s}let e=/\[object ([^\]]+)\]/.exec(toString.call(i)),_;if(e&&e.length>1)_=e[1];else return toString.call(i);if(_=="Object")try{return "Object("+JSON.stringify(i)+")"}catch{return "Object"}return i instanceof Error?`${i.name}: ${i.message}
|
|
1
|
+
var z=class i{static __wrap(t){let e=Object.create(i.prototype);return e.__wbg_ptr=t,K.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,K.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_bistream_free(t,0);}get applicationCryptoWrapped(){return n.bistream_applicationCryptoWrapped(this.__wbg_ptr)!==0}get endpoint_id(){let t,e;try{let s=n.__wbindgen_add_to_stack_pointer(-16);n.bistream_endpoint_id(s,this.__wbg_ptr);var _=f().getInt32(s+0,!0),r=f().getInt32(s+4,!0);return t=_,e=r,v(_,r)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(t,e,1);}}finishSend(){let t=n.bistream_finishSend(this.__wbg_ptr);return p(t)}get recv(){let t=n.bistream_recv(this.__wbg_ptr);return p(t)}get send(){let t=n.bistream_send(this.__wbg_ptr);return p(t)}};Symbol.dispose&&(z.prototype[Symbol.dispose]=z.prototype.free);var U=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,kt.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingbytesource_free(t,0);}get autoAllocateChunkSize(){return n.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr)>>>0}cancel(){let t=this.__destroy_into_raw();n.intounderlyingbytesource_cancel(t);}pull(t){let e=n.intounderlyingbytesource_pull(this.__wbg_ptr,w(t));return p(e)}start(t){n.intounderlyingbytesource_start(this.__wbg_ptr,w(t));}get type(){let t=n.intounderlyingbytesource_type(this.__wbg_ptr);return mt[t]}};Symbol.dispose&&(U.prototype[Symbol.dispose]=U.prototype.free);var B=class i{static __wrap(t){let e=Object.create(i.prototype);return e.__wbg_ptr=t,H.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,H.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingsink_free(t,0);}abort(t){let e=this.__destroy_into_raw(),_=n.intounderlyingsink_abort(e,w(t));return p(_)}close(){let t=this.__destroy_into_raw(),e=n.intounderlyingsink_close(t);return p(e)}write(t){let e=n.intounderlyingsink_write(this.__wbg_ptr,w(t));return p(e)}};Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);var N=class i{static __wrap(t){let e=Object.create(i.prototype);return e.__wbg_ptr=t,J.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,J.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_intounderlyingsource_free(t,0);}cancel(){let t=this.__destroy_into_raw();n.intounderlyingsource_cancel(t);}pull(t){let e=n.intounderlyingsource_pull(this.__wbg_ptr,w(t));return p(e)}};Symbol.dispose&&(N.prototype[Symbol.dispose]=N.prototype.free);var q=class i{static __wrap(t){let e=Object.create(i.prototype);return e.__wbg_ptr=t,Y.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Y.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_peerunistream_free(t,0);}get applicationCryptoWrapped(){return n.peerunistream_applicationCryptoWrapped(this.__wbg_ptr)!==0}finishSend(){let t=n.peerunistream_finishSend(this.__wbg_ptr);return p(t)}get writable(){let t=n.peerunistream_writable(this.__wbg_ptr);return p(t)}};Symbol.dispose&&(q.prototype[Symbol.dispose]=q.prototype.free);var D=class i{static __wrap(t){let e=Object.create(i.prototype);return e.__wbg_ptr=t,Q.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Q.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_wasmclient_free(t,0);}add_peer_scope(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_add_peer_scope(this.__wbg_ptr,_,r,s,a);return p(g)}bind_connection_device_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_bind_connection_device_id(this.__wbg_ptr,_,r,s,a);return p(g)}bind_node_device_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_bind_node_device_id(this.__wbg_ptr,_,r,s,a);return p(g)}clearConnectionApplicationCryptoKey(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;n.wasmclient_clearConnectionApplicationCryptoKey(this.__wbg_ptr,e,_);}clearIdentityCredential(){n.wasmclient_clearIdentityCredential(this.__wbg_ptr);}clear_session_tokens(){n.wasmclient_clear_session_tokens(this.__wbg_ptr);}confirm_inline_reciprocal_session_admission(t,e,_,r,s,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,y=b(r,n.__wbindgen_export,n.__wbindgen_export2),h=c;var k=u(a)?0:b(a,n.__wbindgen_export,n.__wbindgen_export2),I=c;let R=n.wasmclient_confirm_inline_reciprocal_session_admission(this.__wbg_ptr,g,d,e,x,l,y,h,s,k,I);return p(R)}connect(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_connect(this.__wbg_ptr,e,_);return p(r)}connect_device(t,e){var _=u(t)?0:b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;let s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_connect_device(this.__wbg_ptr,_,r,s,a);return p(g)}connection_state(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_connection_state(this.__wbg_ptr,e,_);return p(r)}connection_states(){let t=n.wasmclient_connection_states(this.__wbg_ptr);return p(t)}create_room(t,e,_,r,s,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(e,n.__wbindgen_export,n.__wbindgen_export2),l=c,y=b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c,k=b(r,n.__wbindgen_export,n.__wbindgen_export2),I=c,R=b(s,n.__wbindgen_export,n.__wbindgen_export2),C=c,X=n.wasmclient_create_room(this.__wbg_ptr,g,d,x,l,y,h,k,I,R,C,u(a)?Number.MAX_SAFE_INTEGER:a>>>0);return p(X)}create_session(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_create_session(this.__wbg_ptr,e,_);return p(r)}delete_device(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_delete_device(this.__wbg_ptr,_,r,s,a);return p(g)}devices_with_status(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_devices_with_status(this.__wbg_ptr,e,_);return p(r)}disconnect(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_disconnect(this.__wbg_ptr,e,_);return p(r)}disconnect_device(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;var s=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_disconnect_device(this.__wbg_ptr,_,r,s,a);return p(g)}disconnect_transient(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_disconnect_transient(this.__wbg_ptr,e,_);return p(r)}endpoint_id_from_ticket(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),y=b(t,n.__wbindgen_export,n.__wbindgen_export2),h=c;n.wasmclient_endpoint_id_from_ticket(l,this.__wbg_ptr,y,h);var r=f().getInt32(l+0,!0),s=f().getInt32(l+4,!0),a=f().getInt32(l+8,!0),g=f().getInt32(l+12,!0),d=r,x=s;if(g)throw d=0,x=0,p(a);return e=d,_=x,v(d,x)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(e,_,1);}}endpoint_ticket(){let t=n.wasmclient_endpoint_ticket(this.__wbg_ptr);return p(t)}endpoint_ticket_with_token(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_endpoint_ticket_with_token(this.__wbg_ptr,_,r,e);return p(s)}force_reconnect_snapshot(){n.wasmclient_force_reconnect_snapshot(this.__wbg_ptr);}get_members(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=n.wasmclient_get_members(this.__wbg_ptr,r,s,a,g,d,x);return p(l)}incoming_streams(){let t=n.wasmclient_incoming_streams(this.__wbg_ptr);return p(t)}initIrohWithTestRelay(t,e){var _=u(t)?0:j(t,n.__wbindgen_export),r=c,s=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_initIrohWithTestRelay(this.__wbg_ptr,_,r,s,a);return p(g)}init_iroh(t){var e=u(t)?0:j(t,n.__wbindgen_export),_=c;let r=n.wasmclient_init_iroh(this.__wbg_ptr,e,_);return p(r)}iroh_path_kind(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_iroh_path_kind(this.__wbg_ptr,e,_);return p(r)}iroh_secret_key(){let t=n.wasmclient_iroh_secret_key(this.__wbg_ptr);return p(t)}iroh_transport_rtt_ms(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_iroh_transport_rtt_ms(this.__wbg_ptr,e,_);return p(r)}is_auto_connect_excluded(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;return n.wasmclient_is_auto_connect_excluded(this.__wbg_ptr,e,_)!==0}is_connected(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_is_connected(this.__wbg_ptr,e,_);return p(r)}is_current_transport_stable_id(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_is_current_transport_stable_id(this.__wbg_ptr,_,r,e);return p(s)}join_room(t,e,_,r,s){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c,h=b(r,n.__wbindgen_export,n.__wbindgen_export2),k=c,I=b(s,n.__wbindgen_export,n.__wbindgen_export2),R=c,C=n.wasmclient_join_room(this.__wbg_ptr,a,g,d,x,l,y,h,k,I,R);return p(C)}leave_room(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=n.wasmclient_leave_room(this.__wbg_ptr,r,s,a,g,d,x);return p(l)}list_managed_connections(){let t=n.wasmclient_list_managed_connections(this.__wbg_ptr);return p(t)}static newV2(t){try{let s=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_newV2(s,a,g);var e=f().getInt32(s+0,!0),_=f().getInt32(s+4,!0),r=f().getInt32(s+8,!0);if(r)throw p(_);return i.__wrap(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}node_addr(){let t=n.wasmclient_node_addr(this.__wbg_ptr);return p(t)}open_bi(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_bi(this.__wbg_ptr,e,_);return p(r)}open_native_main_control_bi(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_native_main_control_bi(this.__wbg_ptr,e,_);return p(r)}open_peer_bi(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_open_peer_bi(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(s)}open_peer_bi_explicit_file_sender(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_open_peer_bi_explicit_file_sender(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(s)}open_peer_bi_transport_only(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_open_peer_bi_transport_only(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(s)}open_peer_native_bi(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=n.wasmclient_open_peer_native_bi(this.__wbg_ptr,r,s,a,g,u(_)?Number.MAX_SAFE_INTEGER:_>>>0);return p(d)}open_peer_uni(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_open_peer_uni(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(s)}open_uni(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_open_uni(this.__wbg_ptr,e,_);return p(r)}peer_scopes(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_scopes(this.__wbg_ptr,e,_);return p(r)}peer_session(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_session(this.__wbg_ptr,e,_);return p(r)}peer_sessions(){let t=n.wasmclient_peer_sessions(this.__wbg_ptr);return p(t)}peer_snapshot(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_peer_snapshot(this.__wbg_ptr,e,_);return p(r)}prepare_inline_reciprocal_session_admission(t,e,_,r,s,a,g,d){let x=b(t,n.__wbindgen_export,n.__wbindgen_export2),l=c,y=b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c,k=b(r,n.__wbindgen_export,n.__wbindgen_export2),I=c,R=b(s,n.__wbindgen_export,n.__wbindgen_export2),C=c,X=b(a,n.__wbindgen_export,n.__wbindgen_export2),_t=c,rt=b(g,n.__wbindgen_export,n.__wbindgen_export2),ot=c,it=b(d,n.__wbindgen_export,n.__wbindgen_export2),st=c,ct=n.wasmclient_prepare_inline_reciprocal_session_admission(this.__wbg_ptr,x,l,e,y,h,k,I,R,C,X,_t,rt,ot,it,st);return p(ct)}present_session_token_to_host(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_present_session_token_to_host(this.__wbg_ptr,_,r,s,a);return p(g)}present_session_token_to_host_with_payload(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;var d=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c;let l=n.wasmclient_present_session_token_to_host_with_payload(this.__wbg_ptr,r,s,a,g,d,x);return p(l)}present_session_token_to_host_with_payload_and_device_id(t,e,_,r){let s=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,y=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),h=c;let k=n.wasmclient_present_session_token_to_host_with_payload_and_device_id(this.__wbg_ptr,s,a,g,d,x,l,y,h);return p(k)}rankRoutes(t,e){try{let a=n.__wbindgen_add_to_stack_pointer(-16),g=tt(t,n.__wbindgen_export),d=c,x=tt(e,n.__wbindgen_export),l=c;n.wasmclient_rankRoutes(a,this.__wbg_ptr,g,d,x,l);var _=f().getInt32(a+0,!0),r=f().getInt32(a+4,!0),s=At(_,r).slice();return n.__wbindgen_export4(_,r*4,4),s}finally{n.__wbindgen_add_to_stack_pointer(16);}}register_session_token(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_register_session_token(this.__wbg_ptr,r,s,a,g,_);}register_session_token_with_expiry_ms(t,e,_,r){let s=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;n.wasmclient_register_session_token_with_expiry_ms(this.__wbg_ptr,s,a,g,d,_,r);}reject_connection_admission(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_reject_connection_admission(this.__wbg_ptr,_,r,s,a);return p(g)}release_peer_scope(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c;var s=u(e)?0:b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c;let g=n.wasmclient_release_peer_scope(this.__wbg_ptr,_,r,s,a);return p(g)}remote_session_admission_ready_for_ticket(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_remote_session_admission_ready_for_ticket(this.__wbg_ptr,e,_);return p(r)}report_managed_connection_settled(t,e,_,r,s,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c;let y=n.wasmclient_report_managed_connection_settled(this.__wbg_ptr,g,d,e,x,l,!u(r),u(r)?BigInt(0):r,!u(s),u(s)?BigInt(0):s,!u(a),u(a)?BigInt(0):a);return p(y)}report_transport_status(t,e,_,r,s,a){let g=b(t,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(e,n.__wbindgen_export,n.__wbindgen_export2),l=c;var y=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),h=c;let k=n.wasmclient_report_transport_status(this.__wbg_ptr,g,d,x,l,y,h,!u(r),u(r)?BigInt(0):r,!u(s),u(s)?BigInt(0):s,!u(a),u(a)?BigInt(0):a);return p(k)}resolve_peer_connection_records(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_resolve_peer_connection_records(this.__wbg_ptr,e,_);return p(r)}revoke_session_token(t){try{let s=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c;n.wasmclient_revoke_session_token(s,this.__wbg_ptr,a,g);var e=f().getInt32(s+0,!0),_=f().getInt32(s+4,!0),r=f().getInt32(s+8,!0);if(r)throw p(_);return p(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}revoke_tokens_by_scope(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_revoke_tokens_by_scope(this.__wbg_ptr,e,_);return p(r)}runtime_policy(){try{let r=n.__wbindgen_add_to_stack_pointer(-16);n.wasmclient_runtime_policy(r,this.__wbg_ptr);var t=f().getInt32(r+0,!0),e=f().getInt32(r+4,!0),_=f().getInt32(r+8,!0);if(_)throw p(e);return p(t)}finally{n.__wbindgen_add_to_stack_pointer(16);}}same_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_same_peer(this.__wbg_ptr,_,r,s,a);return p(g)}search_devices(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_search_devices(this.__wbg_ptr,e,_);return p(r)}send_message(t,e,_,r){let s=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;var x=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c,y=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),h=c;let k=n.wasmclient_send_message(this.__wbg_ptr,s,a,g,d,x,l,y,h);return p(k)}send_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=j(e,n.__wbindgen_export),a=c,g=n.wasmclient_send_peer(this.__wbg_ptr,_,r,s,a);return p(g)}send_peer_application_frame(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=j(e,n.__wbindgen_export),g=c,d=n.wasmclient_send_peer_application_frame(this.__wbg_ptr,r,s,a,g,u(_)?Number.MAX_SAFE_INTEGER:_>>>0);return p(d)}setConnectionApplicationCryptoKey(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=j(e,n.__wbindgen_export),a=c,g=n.wasmclient_setConnectionApplicationCryptoKey(this.__wbg_ptr,_,r,s,a);return p(g)}setConnectionApplicationCryptoRequired(t){try{let r=n.__wbindgen_add_to_stack_pointer(-16),s=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c;n.wasmclient_setConnectionApplicationCryptoRequired(r,this.__wbg_ptr,s,a);var e=f().getInt32(r+0,!0),_=f().getInt32(r+4,!0);if(_)throw p(e)}finally{n.__wbindgen_add_to_stack_pointer(16);}}setIdentityCredential(t){var e=u(t)?0:b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c;n.wasmclient_setIdentityCredential(this.__wbg_ptr,e,_);}set_auto_connect_excluded(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_set_auto_connect_excluded(this.__wbg_ptr,_,r,e);return p(s)}set_offline(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmclient_set_offline(this.__wbg_ptr,e,_);return p(r)}start_auto_connect(t,e){try{let s=n.__wbindgen_add_to_stack_pointer(-16),a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c;n.wasmclient_start_auto_connect(s,this.__wbg_ptr,a,g,d,x);var _=f().getInt32(s+0,!0),r=f().getInt32(s+4,!0);if(r)throw p(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}start_presence_loop(t,e,_,r){let s=b(t,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c,x=b(_,n.__wbindgen_export,n.__wbindgen_export2),l=c;var y=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),h=c;n.wasmclient_start_presence_loop(this.__wbg_ptr,s,a,g,d,x,l,y,h);}stop_auth_scoped_activity(){n.wasmclient_stop_auth_scoped_activity(this.__wbg_ptr);}stop_auto_connect(){n.wasmclient_stop_auto_connect(this.__wbg_ptr);}stop_presence_loop(){n.wasmclient_stop_presence_loop(this.__wbg_ptr);}submit_browser_desired_peers(t,e){try{let a=n.__wbindgen_add_to_stack_pointer(-16),g=b(e,n.__wbindgen_export,n.__wbindgen_export2),d=c;n.wasmclient_submit_browser_desired_peers(a,this.__wbg_ptr,t,g,d);var _=f().getInt32(a+0,!0),r=f().getInt32(a+4,!0),s=f().getInt32(a+8,!0);if(s)throw p(r);return _!==0}finally{n.__wbindgen_add_to_stack_pointer(16);}}update_device(t,e,_,r,s){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c;var l=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c,h=u(s)?0:b(s,n.__wbindgen_export,n.__wbindgen_export2),k=c;let I=n.wasmclient_update_device(this.__wbg_ptr,a,g,d,x,l,y,u(r)?0:w(r),h,k);return p(I)}update_presence(t,e,_,r,s){let a=b(t,n.__wbindgen_export,n.__wbindgen_export2),g=c,d=b(e,n.__wbindgen_export,n.__wbindgen_export2),x=c,l=b(_,n.__wbindgen_export,n.__wbindgen_export2),y=c;var h=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),k=c;let I=n.wasmclient_update_presence(this.__wbg_ptr,a,g,d,x,l,y,h,k,!u(s),u(s)?BigInt(0):s);return p(I)}update_session(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_update_session(this.__wbg_ptr,_,r,s,a);return p(g)}validate_session_token(t){let e,_;try{let l=n.__wbindgen_add_to_stack_pointer(-16),y=b(t,n.__wbindgen_export,n.__wbindgen_export2),h=c;n.wasmclient_validate_session_token(l,this.__wbg_ptr,y,h);var r=f().getInt32(l+0,!0),s=f().getInt32(l+4,!0),a=f().getInt32(l+8,!0),g=f().getInt32(l+12,!0),d=r,x=s;if(g)throw d=0,x=0,p(a);return e=d,_=x,v(d,x)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export4(e,_,1);}}validate_session_token_for_connection(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=b(e,n.__wbindgen_export,n.__wbindgen_export2),a=c,g=n.wasmclient_validate_session_token_for_connection(this.__wbg_ptr,_,r,s,a);return p(g)}validate_session_token_for_connection_with_payload(t,e,_){let r=b(t,n.__wbindgen_export,n.__wbindgen_export2),s=c,a=b(e,n.__wbindgen_export,n.__wbindgen_export2),g=c;var d=u(_)?0:b(_,n.__wbindgen_export,n.__wbindgen_export2),x=c;let l=n.wasmclient_validate_session_token_for_connection_with_payload(this.__wbg_ptr,r,s,a,g,d,x);return p(l)}wait_for_settled_peer(t,e){let _=b(t,n.__wbindgen_export,n.__wbindgen_export2),r=c,s=n.wasmclient_wait_for_settled_peer(this.__wbg_ptr,_,r,u(e)?Number.MAX_SAFE_INTEGER:e>>>0);return p(s)}wake_browser_auto_connect(){return n.wasmclient_wake_browser_auto_connect(this.__wbg_ptr)!==0}};Symbol.dispose&&(D.prototype[Symbol.dispose]=D.prototype.free);var V=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Z.unregister(this),t}free(){let t=this.__destroy_into_raw();n.__wbg_wasmconnection_free(t,0);}create_data_channel(t){let e=b(t,n.__wbindgen_export,n.__wbindgen_export2),_=c,r=n.wasmconnection_create_data_channel(this.__wbg_ptr,e,_);return p(r)}constructor(){try{let r=n.__wbindgen_add_to_stack_pointer(-16);n.wasmconnection_new(r);var t=f().getInt32(r+0,!0),e=f().getInt32(r+4,!0),_=f().getInt32(r+8,!0);if(_)throw p(e);return this.__wbg_ptr=t,Z.register(this,this.__wbg_ptr,this),this}finally{n.__wbindgen_add_to_stack_pointer(16);}}};Symbol.dispose&&(V.prototype[Symbol.dispose]=V.prototype.free);function jt(){n.start();}function et(){return {__proto__:null,"./openrtc_bg.js":{__proto__:null,__wbg_Error_9dc85fe1bc224456:function(t,e){let _=Error(v(t,e));return w(_)},__wbg_String_8564e559799eccda:function(t,e){let _=String(o(e)),r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg___wbindgen_boolean_get_b131b2f36d6b2f55:function(t){let e=o(t),_=typeof e=="boolean"?e:void 0;return u(_)?16777215:_?1:0},__wbg___wbindgen_debug_string_56c147eb1a51f0c4:function(t,e){let _=P(o(e)),r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg___wbindgen_in_ce8569b2fc6f5088:function(t,e){return o(t)in o(e)},__wbg___wbindgen_is_function_147961669f068cd4:function(t){return typeof o(t)=="function"},__wbg___wbindgen_is_null_ced4761460071341:function(t){return o(t)===null},__wbg___wbindgen_is_object_3a2c414391dbf751:function(t){let e=o(t);return typeof e=="object"&&e!==null},__wbg___wbindgen_is_string_6541b0f6ecd4e8e5:function(t){return typeof o(t)=="string"},__wbg___wbindgen_is_undefined_4410e3c20a99fa97:function(t){return o(t)===void 0},__wbg___wbindgen_jsval_eq_174c93ec61bab0c5:function(t,e){return o(t)===o(e)},__wbg___wbindgen_jsval_loose_eq_e07e3b1f5db6da6c:function(t,e){return o(t)==o(e)},__wbg___wbindgen_number_get_588ed6b97f0d7e14:function(t,e){let _=o(e),r=typeof _=="number"?_:void 0;f().setFloat64(t+8,u(r)?0:r,true),f().setInt32(t+0,!u(r),true);},__wbg___wbindgen_string_get_fa2687d531ed17a5:function(t,e){let _=o(e),r=typeof _=="string"?_:void 0;var s=u(r)?0:b(r,n.__wbindgen_export,n.__wbindgen_export2),a=c;f().setInt32(t+4,a,true),f().setInt32(t+0,s,true);},__wbg___wbindgen_throw_bbadd78c1bac3a77:function(t,e){throw new Error(v(t,e))},__wbg__wbg_cb_unref_c2301a3c9b78104b:function(t){o(t)._wbg_cb_unref();},__wbg_abort_56c00f462c9261d9:function(t,e){o(t).abort(o(e));},__wbg_abort_f2416f4a9852003e:function(t){o(t).abort();},__wbg_addEventListener_b635263c509aa7de:function(){return m(function(t,e,_,r){o(t).addEventListener(v(e,_),o(r));},arguments)},__wbg_append_c5a0c94a6a73b22e:function(){return m(function(t,e,_,r,s){o(t).append(v(e,_),v(r,s));},arguments)},__wbg_arrayBuffer_cc7704fa158b907a:function(){return m(function(t){let e=o(t).arrayBuffer();return w(e)},arguments)},__wbg_bistream_new:function(t){let e=z.__wrap(t);return w(e)},__wbg_body_442a47f02322d7b0:function(t){let e=o(t).body;return u(e)?0:w(e)},__wbg_buffer_8524b3453cde4918:function(t){let e=o(t).buffer;return w(e)},__wbg_byobRequest_cc72d210de793e64:function(t){let e=o(t).byobRequest;return u(e)?0:w(e)},__wbg_byteLength_96807b1d9ab24a4c:function(t){return o(t).byteLength},__wbg_byteOffset_a9c7002428843c41:function(t){return o(t).byteOffset},__wbg_call_ec09a4cf93377d3a:function(){return m(function(t,e,_){let r=o(t).call(o(e),o(_));return w(r)},arguments)},__wbg_cancel_f3a197b26dc88b39:function(t){let e=o(t).cancel();return w(e)},__wbg_catch_66060324c27be6f7:function(t,e){let _=o(t).catch(o(e));return w(_)},__wbg_clearTimeout_113b1cde814ec762:function(t){let e=clearTimeout(p(t));return w(e)},__wbg_clearTimeout_333bba87532ab9d3:function(t){let e=clearTimeout(p(t));return w(e)},__wbg_clearTimeout_47a40e3be01ed7a3:function(){return m(function(t,e){o(t).clearTimeout(p(e));},arguments)},__wbg_close_296263cfe1bb2999:function(){return m(function(t){o(t).close();},arguments)},__wbg_close_388d99468213b286:function(){return m(function(t){o(t).close();},arguments)},__wbg_close_4857e22d08b71356:function(){return m(function(t){o(t).close();},arguments)},__wbg_code_1cda2855fcd9b009:function(t){return o(t).code},__wbg_code_70beb7b22374d55e:function(t){return o(t).code},__wbg_createDataChannel_122bd3d8aacee49b:function(t,e,_){let r=o(t).createDataChannel(v(e,_));return w(r)},__wbg_crypto_38df2bab126b63dc:function(t){let e=o(t).crypto;return w(e)},__wbg_data_8a04443c1e5a8cd3:function(t){let e=o(t).data;return w(e)},__wbg_dispatchEvent_cc62a6a43d28b01c:function(){return m(function(t,e){return o(t).dispatchEvent(o(e))},arguments)},__wbg_done_6a8439e544ec6206:function(t){return o(t).done},__wbg_enqueue_bbeb09ba0b140f76:function(){return m(function(t,e){o(t).enqueue(o(e));},arguments)},__wbg_entries_4e00eefd3fd54cf1:function(t){let e=o(t).entries();return w(e)},__wbg_error_6651fee1c71e5da9:function(t){console.error(o(t));},__wbg_error_a6fa202b58aa1cd3:function(t,e){let _,r;try{_=t,r=e,console.error(v(t,e));}finally{n.__wbindgen_export4(_,r,1);}},__wbg_fetch_074561c3e313c86f:function(t){let e=fetch(o(t));return w(e)},__wbg_fetch_22858a12fcf93152:function(t,e){let _=o(t).fetch(o(e));return w(_)},__wbg_getRandomValues_76dfc69825c9c552:function(){return m(function(t,e){globalThis.crypto.getRandomValues(S(t,e));},arguments)},__wbg_getRandomValues_c44a50d8cfdaebeb:function(){return m(function(t,e){o(t).getRandomValues(o(e));},arguments)},__wbg_getReader_9facd4f899beac89:function(){return m(function(t){let e=o(t).getReader();return w(e)},arguments)},__wbg_get_4b90d6d8c5deb5d5:function(t,e){let _=o(t)[e>>>0];return w(_)},__wbg_get_52a8a619f7b88df6:function(){return m(function(t,e){let _=Reflect.get(o(t),o(e));return w(_)},arguments)},__wbg_get_done_c21b9933fc9a9e9c:function(t){let e=o(t).done;return u(e)?16777215:e?1:0},__wbg_get_value_ad568c7d3db9073f:function(t){let e=o(t).value;return w(e)},__wbg_get_with_ref_key_6412cf3094599694:function(t,e){let _=o(t)[o(e)];return w(_)},__wbg_has_14676d88c1340d2c:function(){return m(function(t,e){return Reflect.has(o(t),o(e))},arguments)},__wbg_headers_5b19cf40627ae54d:function(t){let e=o(t).headers;return w(e)},__wbg_info_a2b5f8a5dae8b26c:function(t){console.info(o(t));},__wbg_instanceof_ArrayBuffer_a581da923203f29f:function(t){let e;try{e=o(t)instanceof ArrayBuffer;}catch{e=false;}return e},__wbg_instanceof_Blob_5c4e145be35f9b1e:function(t){let e;try{e=o(t)instanceof Blob;}catch{e=false;}return e},__wbg_instanceof_Response_36a65a969abaa7c6:function(t){let e;try{e=o(t)instanceof Response;}catch{e=false;}return e},__wbg_instanceof_Uint8Array_b6fe1ac89eba107e:function(t){let e;try{e=o(t)instanceof Uint8Array;}catch{e=false;}return e},__wbg_instanceof_Window_9e0fe7d3d1ff4342:function(t){let e;try{e=o(t)instanceof Window;}catch{e=false;}return e},__wbg_isArray_139f48e3c057ede8:function(t){return Array.isArray(o(t))},__wbg_length_68a9d5278d084f4f:function(t){return o(t).length},__wbg_log_6614a4effdb4e983:function(t){console.log(o(t));},__wbg_message_12958526424a887b:function(t,e){let _=o(e).message,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_msCrypto_bd5a034af96bcba6:function(t){let e=o(t).msCrypto;return w(e)},__wbg_new_0b303268aa395a38:function(){let t=new Array;return w(t)},__wbg_new_189262ff31890c23:function(){return m(function(){let t=new Headers;return w(t)},arguments)},__wbg_new_20b778a4c5c691c3:function(){let t=new Object;return w(t)},__wbg_new_227d7c05414eb861:function(){let t=new Error;return w(t)},__wbg_new_24739629d416f982:function(){return m(function(){let t=new AbortController;return w(t)},arguments)},__wbg_new_5fae30e6b23db8df:function(t,e){let _=new Error(v(t,e));return w(_)},__wbg_new_883c0db065f06efd:function(){return w(new Map)},__wbg_new_a3e5112401a82338:function(){return m(function(t,e){let _=new WebSocket(v(t,e));return w(_)},arguments)},__wbg_new_b06772b280cc6e52:function(t){let e=new Uint8Array(o(t));return w(e)},__wbg_new_from_slice_bb2d1778c0b87eb1:function(t,e){let _=new Uint8Array(S(t,e));return w(_)},__wbg_new_typed_90c3f6c29ba36d19:function(t,e){try{var _={a:t,b:e},r=(a,g)=>{let d=_.a;_.a=0;try{return lt(d,_.b,a,g)}finally{_.a=d;}};let s=new Promise(r);return w(s)}finally{_.a=0;}},__wbg_new_with_byte_offset_and_length_9e1e664fe1a5d385:function(t,e,_){let r=new Uint8Array(o(t),e>>>0,_>>>0);return w(r)},__wbg_new_with_configuration_3a96aa953ca17197:function(){return m(function(t){let e=new RTCPeerConnection(o(t));return w(e)},arguments)},__wbg_new_with_event_init_dict_bd850674488710b1:function(){return m(function(t,e,_){let r=new CustomEvent(v(t,e),o(_));return w(r)},arguments)},__wbg_new_with_into_underlying_sink_2596343f9b6c8e58:function(t){let e=new WritableStream(B.__wrap(t));return w(e)},__wbg_new_with_into_underlying_source_fd904252f385f59c:function(t,e){let _=new ReadableStream(N.__wrap(t),p(e));return w(_)},__wbg_new_with_length_4b57a7a5dc67221c:function(t){let e=new Uint8Array(t>>>0);return w(e)},__wbg_new_with_str_and_init_df876572184fe639:function(){return m(function(t,e,_){let r=new Request(v(t,e),o(_));return w(r)},arguments)},__wbg_new_with_str_sequence_505a4829cc247e79:function(){return m(function(t,e,_){let r=new WebSocket(v(t,e),o(_));return w(r)},arguments)},__wbg_next_8cb028b6ba50743f:function(){return m(function(t){let e=o(t).next();return w(e)},arguments)},__wbg_node_84ea875411254db1:function(t){let e=o(t).node;return w(e)},__wbg_now_bce4dc999095ea77:function(){return Date.now()},__wbg_now_e7c6795a7f81e10f:function(t){return o(t).now()},__wbg_parse_a5c06e19bc1187fd:function(t,e){return Date.parse(v(t,e))},__wbg_peerunistream_new:function(t){let e=q.__wrap(t);return w(e)},__wbg_performance_3fcf6e32a7e1ed0a:function(t){let e=o(t).performance;return w(e)},__wbg_process_44c7a14e11e9f69e:function(t){let e=o(t).process;return w(e)},__wbg_protocol_28aaef5ea42981d6:function(t,e){let _=o(e).protocol,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_prototypesetcall_956c7493c68e29b4:function(t,e,_){Uint8Array.prototype.set.call(S(t,e),o(_));},__wbg_push_ceb8ef046afb2041:function(t,e){return o(t).push(o(e))},__wbg_queueMicrotask_4698f900840e3286:function(t){queueMicrotask(o(t));},__wbg_queueMicrotask_477a5533c7100338:function(t){let e=o(t).queueMicrotask;return w(e)},__wbg_randomFillSync_6c25eac9869eb53c:function(){return m(function(t,e){o(t).randomFillSync(p(e));},arguments)},__wbg_read_8426c146431f2905:function(t){let e=o(t).read();return w(e)},__wbg_readyState_25243ad6ce649774:function(t){return o(t).readyState},__wbg_reason_4ec455bac79b33ce:function(t,e){let _=o(e).reason,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_releaseLock_188846ef719acb10:function(t){o(t).releaseLock();},__wbg_removeEventListener_016c1d24523b4730:function(){return m(function(t,e,_,r){o(t).removeEventListener(v(e,_),o(r));},arguments)},__wbg_require_b4edbdcf3e2a1ef0:function(){return m(function(){let t=module.require;return w(t)},arguments)},__wbg_resolve_0183de2e8c6b1d54:function(t){let e=Promise.resolve(o(t));return w(e)},__wbg_respond_3cdb4cf32683fd79:function(){return m(function(t,e){o(t).respond(e>>>0);},arguments)},__wbg_send_99d049cae69c53cc:function(){return m(function(t,e,_){o(t).send(S(e,_));},arguments)},__wbg_send_bac9d3dc4f21ef28:function(){return m(function(t,e,_){o(t).send(v(e,_));},arguments)},__wbg_setTimeout_3a808dd861dd3c12:function(t,e){let _=setTimeout(o(t),e);return w(_)},__wbg_setTimeout_6613a51400c1bf9f:function(){return m(function(t,e,_){let r=o(t).setTimeout(p(e),_);return w(r)},arguments)},__wbg_setTimeout_ef24d2fc3ad97385:function(){return m(function(t,e){let _=setTimeout(o(t),e);return w(_)},arguments)},__wbg_set_5f806304fb633ab3:function(t,e,_){let r=o(t).set(o(e),o(_));return w(r)},__wbg_set_6be42768c690e380:function(t,e,_){o(t)[p(e)]=p(_);},__wbg_set_86698c227e5b9dad:function(t,e,_){o(t).set(S(e,_));},__wbg_set_a6ba3ac0e634b822:function(){return m(function(t,e,_){return Reflect.set(o(t),o(e),o(_))},arguments)},__wbg_set_binaryType_8c2dd2cf1cfc2e28:function(t,e){o(t).binaryType=xt[e];},__wbg_set_body_d1153b16a2b95ca1:function(t,e){o(t).body=o(e);},__wbg_set_cache_5a01a8b5e6ca6cf2:function(t,e){o(t).cache=yt[e];},__wbg_set_credentials_e9120ed88b1fc0b8:function(t,e){o(t).credentials=ht[e];},__wbg_set_da33c120a6584674:function(t,e,_){o(t)[e>>>0]=p(_);},__wbg_set_detail_c7af5edea934390b:function(t,e){o(t).detail=o(e);},__wbg_set_handle_event_6147c38b782c7b42:function(t,e){o(t).handleEvent=o(e);},__wbg_set_headers_877ed41890d28af2:function(t,e){o(t).headers=o(e);},__wbg_set_high_water_mark_77da20c49668427d:function(t,e){o(t).highWaterMark=e;},__wbg_set_method_b4ede299b2064f37:function(t,e,_){o(t).method=v(e,_);},__wbg_set_mode_d6c2e1991aa963c6:function(t,e){o(t).mode=vt[e];},__wbg_set_onclose_9cb5c3372e16c192:function(t,e){o(t).onclose=o(e);},__wbg_set_onerror_190fe67e911ebf28:function(t,e){o(t).onerror=o(e);},__wbg_set_onmessage_96337495f0bfb796:function(t,e){o(t).onmessage=o(e);},__wbg_set_onopen_3e2bf6b11d434c2d:function(t,e){o(t).onopen=o(e);},__wbg_set_signal_9022b5aa06a6ce5b:function(t,e){o(t).signal=o(e);},__wbg_signal_41dd1a8913cd0b7d:function(t){let e=o(t).signal;return w(e)},__wbg_stack_3b0d974bbf31e44f:function(t,e){let _=o(e).stack,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_static_accessor_GLOBAL_60a4124bab7dcc9a:function(){let t=typeof global>"u"?null:global;return u(t)?0:w(t)},__wbg_static_accessor_GLOBAL_THIS_95ca6460658b5d13:function(){let t=typeof globalThis>"u"?null:globalThis;return u(t)?0:w(t)},__wbg_static_accessor_SELF_4c95f759a91e9aae:function(){let t=typeof self>"u"?null:self;return u(t)?0:w(t)},__wbg_static_accessor_WINDOW_44b435597f9e9ee7:function(){let t=typeof window>"u"?null:window;return u(t)?0:w(t)},__wbg_status_9e6505cfa3e73a7c:function(t){return o(t).status},__wbg_subarray_42216645a367cd7a:function(t,e,_){let r=o(t).subarray(e>>>0,_>>>0);return w(r)},__wbg_then_254bab9b266a77a5:function(t,e,_){let r=o(t).then(o(e),o(_));return w(r)},__wbg_then_3ea18602c6a5123b:function(t,e){let _=o(t).then(o(e));return w(_)},__wbg_url_72c67c175685a054:function(t,e){let _=o(e).url,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_url_d0b8042af0d1bbba:function(t,e){let _=o(e).url,r=b(_,n.__wbindgen_export,n.__wbindgen_export2),s=c;f().setInt32(t+4,s,true),f().setInt32(t+0,r,true);},__wbg_value_3d3defe09fb1ffca:function(t){let e=o(t).value;return w(e)},__wbg_versions_276b2795b1c6a219:function(t){let e=o(t).versions;return w(e)},__wbg_view_15fa5865c6b336e3:function(t){let e=o(t).view;return u(e)?0:w(e)},__wbg_warn_633bacc13ba7e6c3:function(t){console.warn(o(t));},__wbg_wasClean_f17429d064911939:function(t){return o(t).wasClean},__wbindgen_cast_0000000000000001:function(t,e){let _=F(t,e,gt);return w(_)},__wbindgen_cast_0000000000000002:function(t,e){let _=F(t,e,ft);return w(_)},__wbindgen_cast_0000000000000003:function(t,e){let _=F(t,e,dt);return w(_)},__wbindgen_cast_0000000000000004:function(t,e){let _=F(t,e,ut);return w(_)},__wbindgen_cast_0000000000000005:function(t,e){let _=F(t,e,bt);return w(_)},__wbindgen_cast_0000000000000006:function(t,e){let _=F(t,e,at);return w(_)},__wbindgen_cast_0000000000000007:function(t,e){let _=Rt(t,e,pt);return w(_)},__wbindgen_cast_0000000000000008:function(t,e){let _=F(t,e,wt);return w(_)},__wbindgen_cast_0000000000000009:function(t){return w(t)},__wbindgen_cast_000000000000000a:function(t){return w(t)},__wbindgen_cast_000000000000000b:function(t,e){let _=S(t,e);return w(_)},__wbindgen_cast_000000000000000c:function(t,e){let _=v(t,e);return w(_)},__wbindgen_cast_000000000000000d:function(t){let e=BigInt.asUintN(64,t);return w(e)},__wbindgen_cast_000000000000000e:function(t,e){var _=S(t,e).slice();return n.__wbindgen_export4(t,e*1,1),w(_)},__wbindgen_object_clone_ref:function(t){let e=o(t);return w(e)},__wbindgen_object_drop_ref:function(t){p(t);}}}}function bt(i,t){n.__wasm_bindgen_func_elem_8891(i,t);}function at(i,t){n.__wasm_bindgen_func_elem_10013(i,t);}function pt(i,t){n.__wasm_bindgen_func_elem_10066(i,t);}function wt(i,t){n.__wasm_bindgen_func_elem_17872(i,t);}function gt(i,t,e){n.__wasm_bindgen_func_elem_9093(i,t,w(e));}function dt(i,t,e){n.__wasm_bindgen_func_elem_6551(i,t,w(e));}function ut(i,t,e){n.__wasm_bindgen_func_elem_10701(i,t,w(e));}function ft(i,t,e){try{let s=n.__wbindgen_add_to_stack_pointer(-16);n.__wasm_bindgen_func_elem_18017(s,i,t,w(e));var _=f().getInt32(s+0,!0),r=f().getInt32(s+4,!0);if(r)throw p(_)}finally{n.__wbindgen_add_to_stack_pointer(16);}}function lt(i,t,e,_){n.__wasm_bindgen_func_elem_18019(i,t,w(e),w(_));}var xt=["blob","arraybuffer"],mt=["bytes"],yt=["default","no-store","reload","no-cache","force-cache","only-if-cached"],ht=["omit","same-origin","include"],vt=["same-origin","no-cors","cors","navigate"],K=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_bistream_free(i,1)),kt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_intounderlyingbytesource_free(i,1)),H=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_intounderlyingsink_free(i,1)),J=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_intounderlyingsource_free(i,1)),Y=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_peerunistream_free(i,1)),Q=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_wasmclient_free(i,1)),Z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbg_wasmconnection_free(i,1));function w(i){W===A.length&&A.push(A.length+1);let t=W;return W=A[t],A[t]=i,t}var G=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>n.__wbindgen_export5(i.a,i.b));function P(i){let t=typeof i;if(t=="number"||t=="boolean"||i==null)return `${i}`;if(t=="string")return `"${i}"`;if(t=="symbol"){let r=i.description;return r==null?"Symbol":`Symbol(${r})`}if(t=="function"){let r=i.name;return typeof r=="string"&&r.length>0?`Function(${r})`:"Function"}if(Array.isArray(i)){let r=i.length,s="[";r>0&&(s+=P(i[0]));for(let a=1;a<r;a++)s+=", "+P(i[a]);return s+="]",s}let e=/\[object ([^\]]+)\]/.exec(toString.call(i)),_;if(e&&e.length>1)_=e[1];else return toString.call(i);if(_=="Object")try{return "Object("+JSON.stringify(i)+")"}catch{return "Object"}return i instanceof Error?`${i.name}: ${i.message}
|
|
2
2
|
${i.stack}`:_}function It(i){i<1028||(A[i]=W,W=i);}function At(i,t){i=i>>>0;let e=f(),_=[];for(let r=i;r<i+4*t;r+=4)_.push(p(e.getUint32(r,true)));return _}function S(i,t){return i=i>>>0,T().subarray(i/1,i/1+t)}var E=null;function f(){return (E===null||E.buffer.detached===true||E.buffer.detached===void 0&&E.buffer!==n.memory.buffer)&&(E=new DataView(n.memory.buffer)),E}function v(i,t){return Ft(i>>>0,t)}var O=null;function T(){return (O===null||O.byteLength===0)&&(O=new Uint8Array(n.memory.buffer)),O}function o(i){return A[i]}function m(i,t){try{return i.apply(this,t)}catch(e){n.__wbindgen_export3(w(e));}}var A=new Array(1024).fill(void 0);A.push(void 0,null,true,false);var W=A.length;function u(i){return i==null}function Rt(i,t,e){let _={a:i,b:t,cnt:1},r=(...s)=>{_.cnt++;try{return e(_.a,_.b,...s)}finally{r._wbg_cb_unref();}};return r._wbg_cb_unref=()=>{--_.cnt===0&&(n.__wbindgen_export5(_.a,_.b),_.a=0,G.unregister(_));},G.register(r,_,_),r}function F(i,t,e){let _={a:i,b:t,cnt:1},r=(...s)=>{_.cnt++;let a=_.a;_.a=0;try{return e(a,_.b,...s)}finally{_.a=a,r._wbg_cb_unref();}};return r._wbg_cb_unref=()=>{--_.cnt===0&&(n.__wbindgen_export5(_.a,_.b),_.a=0,G.unregister(_));},G.register(r,_,_),r}function j(i,t){let e=t(i.length*1,1)>>>0;return T().set(i,e/1),c=i.length,e}function tt(i,t){let e=t(i.length*4,4)>>>0,_=f();for(let r=0;r<i.length;r++)_.setUint32(e+4*r,w(i[r]),true);return c=i.length,e}function b(i,t,e){if(e===void 0){let g=M.encode(i),d=t(g.length,1)>>>0;return T().subarray(d,d+g.length).set(g),c=g.length,d}let _=i.length,r=t(_,1)>>>0,s=T(),a=0;for(;a<_;a++){let g=i.charCodeAt(a);if(g>127)break;s[r+a]=g;}if(a!==_){a!==0&&(i=i.slice(a)),r=e(r,_,_=a+i.length*3,1)>>>0;let g=T().subarray(r+a,r+_),d=M.encodeInto(i,g);a+=d.written,r=e(r,_,a,1)>>>0;}return c=a,r}function p(i){let t=o(i);return It(i),t}var L=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});L.decode();var St=2146435072,$=0;function Ft(i,t){return $+=t,$>=St&&(L=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),L.decode(),$=t),L.decode(T().subarray(i,i+t))}var M=new TextEncoder;"encodeInto"in M||(M.encodeInto=function(i,t){let e=M.encode(i);return t.set(e),{read:i.length,written:e.length}});var c=0,n;function nt(i,t){return n=i.exports,E=null,O=null,n.__wbindgen_start(),n}async function Ct(i,t){if(typeof Response=="function"&&i instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(i,t)}catch(r){if(i.ok&&e(i.type)&&i.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let _=await i.arrayBuffer();return await WebAssembly.instantiate(_,t)}else {let _=await WebAssembly.instantiate(i,t);return _ instanceof WebAssembly.Instance?{instance:_,module:i}:_}function e(_){switch(_){case "basic":case "cors":case "default":return true}return false}}function Ot(i){if(n!==void 0)return n;i!==void 0&&(Object.getPrototypeOf(i)===Object.prototype?{module:i}=i:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=et();i instanceof WebAssembly.Module||(i=new WebAssembly.Module(i));let e=new WebAssembly.Instance(i,t);return nt(e)}async function Wt(i){if(n!==void 0)return n;i!==void 0&&(Object.getPrototypeOf(i)===Object.prototype?{module_or_path:i}=i:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),i===void 0&&(i=new URL("openrtc_bg.wasm",import.meta.url));let t=et();(typeof i=="string"||typeof Request=="function"&&i instanceof Request||typeof URL=="function"&&i instanceof URL)&&(i=fetch(i));let{instance:e,module:_}=await Ct(await i,t);return nt(e)}export{z as BiStream,U as IntoUnderlyingByteSource,B as IntoUnderlyingSink,N as IntoUnderlyingSource,q as PeerUniStream,D as WasmClient,V as WasmConnection,Wt as default,Ot as initSync,jt as start};
|
package/dist/openrtc_bg.wasm
CHANGED
|
Binary file
|
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-PPZRTJHE.js';export{a as classifyNativeIpcFailure,b as isNativeIpcCommandUnavailable}from'../chunk-Z2WVSXPW.js';export{b as runtimeFromCapability}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-4UAAQLXK.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-3PE6TWIX.js';import {c}from'./chunk-4UAAQLXK.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-SIBGRPTH.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
package/dist/chunk-DA3HSI3K.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 B(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 z(){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 Z(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 X(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 Q(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 Y(a){let e=await Z(a);if(e)return e;let t=await crypto.subtle.generateKey({name:"Ed25519"},false,["sign","verify"]);return await X(a,t),t}var U={async getOrCreate(a){let e=await Y(a),t=await crypto.subtle.exportKey("jwk",e.publicKey),i=await B(t);return {publicKeyJwk:t,thumbprint:i,async proof(n){let r=z(),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:Q};var $={"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 A={controlPlane:"https://api.openrtc.app",gateway:"https://gateway.openrtc.app"},H=1440*6e4,b=class extends Error{constructor(t,i,n){super(t);this.status=i;this.reason=n;this.name="OpenRTCV2HttpError";}};function F(a){return !(a instanceof b)||a.status!==403?false:a.reason==="device-certificate-stale"?true:!a.reason&&a.message==="Device certificate is revoked or stale."}function I(a,e,t){return `openrtc:v2:device-certificate:${a}:${e}:${t}`}function x(a,e){return `openrtc:v2:device-session:${a}:${e}`}async function ee(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 j(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 G(a,e,t,i,n){if(typeof a.token!="string"||typeof a.expiresAtMs!="number"||a.expiresAtMs<=Date.now()+H||!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(j(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 d=await crypto.subtle.importKey("jwk",a.signingPublicJwk,{name:"Ed25519"},!1,["verify"]);if(!await crypto.subtle.verify({name:"Ed25519"},d,j(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),p=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(p)||l>=p||p*1e3!==a.expiresAtMs?null:{token:a.token,expiresAtMs:a.expiresAtMs,principalId:c,signingPublicJwk:a.signingPublicJwk,enrolled:false}}async function te(a,e,t,i,n){try{let r=I(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 G(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 ie(a,e,t,i,n){try{let r=x(e,i),s=a.readSecureRecord?await a.readSecureRecord(t,r):globalThis.localStorage?.getItem(r);return s?await G(JSON.parse(s),t,i,n):null}catch(r){if(a.readSecureRecord)throw r;return null}}async function ne(a,e,t,i,n){try{let r=I(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 re(a,e,t,i,n){try{let r=x(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 D(a,e,t,i,n){try{let r=I(e,t,i);if(a.deleteSecureRecord?await a.deleteSecureRecord(e,r):globalThis.localStorage?.removeItem(r),n){let s=x(n,i);a.deleteSecureRecord?await a.deleteSecureRecord(e,s):globalThis.localStorage?.removeItem(s);}}catch(r){if(a.deleteSecureRecord)throw r}}function ae(a){return `${a}_${crypto.randomUUID()}`}async function se(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 R=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=ae("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}).`,l;try{let d=await o.json();typeof d.error=="string"&&(c=d.error.slice(0,256)),typeof d.reason=="string"&&/^[a-z0-9-]{1,80}$/.test(d.reason)&&(l=d.reason);}catch{}let p=new b(c,o.status,l);if(r=p,s===0&&[502,503,504].includes(o.status))continue;throw p}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 se(this.apiKey,t):t,o=await(await this.key()).proof((d,u)=>["openrtc:v2:capability",this.apiKey,e,r,d,u].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 p={type:"capability",token:l.capability,avenue:e==="ticket"?{kind:"session",id:r}:l.avenue,expiresAtMs:l.expiresAt*1e3};return p.renew=()=>this.capability(e,t,i,n),p}async deviceCertificate(e,t,i,n,r){let s=this.authEpoch(e),o=s.devices.get(t)??{};if(s.devices.set(t,o),r&&o.current&&o.current.token!==r.token)return this.deviceCertificateResult(e,t,i,n,{...o.current,enrolled:false});if(!r&&o.current&&o.current.expiresAtMs>Date.now()+H)return this.deviceCertificateResult(e,t,i,n,{...o.current,enrolled:false});if(!o.inFlight){let l=s.generation;r&&(o.current=void 0);let p=r?D(this.keyProvider,this.appTag,r.principalId,t,s.sessionKeyHash).then(()=>this.enrollAuthenticatedDevice(e,t,s.sessionKeyHash,n)):this.resolveAuthenticatedDevice(e,t,s,n);o.inFlight=p.then(d=>{if(s.generation!==l)throw new Error("The OpenRTC authentication identity changed during enrollment.");return o.current=d,d}).finally(()=>{o.inFlight=void 0;});}let c=await o.inFlight;return this.deviceCertificateResult(e,t,i,n,c)}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 ee(this.appTag,r.thumbprint,s);i.sessionKeyHash=o;let c=await ie(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,s.recoverRejectedCertificate=async()=>(await this.deviceCertificate(e,t,i,n,r)).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 h=>{let v=await e.getAssertion({audience:"https://api.openrtc.app/v2/assertions/exchange",forceRefresh:h,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(h){if(!(h instanceof b)||h.status!==401)throw h;s=await r(true);}this.record("identity.assertion.exchange"),this.record("identity.monthly-active-principal");let o=await this.key(),c=await te(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((h,v)=>["openrtc:v2:device-enroll",this.appTag,s.principalId,t,h,v].join(":")),p=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,d=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}:{}}}:{},...p?{attestation:p}:{}});this.record("device.enroll"),p&&this.record("security.attestation.verify");let u={principalId:s.principalId,token:d.deviceCertificate,expiresAtMs:d.expiresAt*1e3,signingPublicJwk:d.signingPublicJwk,enrolled:true};return await ne(this.keyProvider,this.appTag,s.principalId,t,{token:u.token,expiresAtMs:u.expiresAtMs,signingPublicJwk:u.signingPublicJwk}),i&&await re(this.keyProvider,this.appTag,i,t,u),u}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 D(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 D(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){let s=i==="revoke"?"device.revoke":i==="revoke-all"?"identity.revoke-all":null;s&&this.before(s);let{manageDevice:o}=await import('./deviceManagement-PHY5TIOS.js'),c=await o({source:e,currentDeviceId:t,action:i,targetDeviceId:n,exceptCurrent:r,key:()=>this.key(),post:l=>this.post("/v2/devices/manage",l),isStale:F});return s&&this.record(s),c}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=async d=>{let u=y(d.token),h=String(u.jti??""),g=await(await this.key()).proof((w,q)=>["openrtc:v2:gateway-grant",h,r.avenue.kind,r.avenue.id,r.runtimeInstanceId,w,q].join(":"));return this.post("/v2/gateway/grants",{credentialType:d.type,credential:d.token,avenue:r.avenue,runtimeInstanceId:r.runtimeInstanceId,ticketFingerprint:r.ticketFingerprint,deviceProof:g,...r.refreshGrant?{refreshGrant:r.refreshGrant}:{},...t.maxPeers?{maxPeers:t.maxPeers}:{},...t.features?{features:t.features}:{},...d.type==="device-certificate"&&t.deviceProfile?{deviceProfile:t.deviceProfile}:{}})},p;try{p=await l(n);}catch(d){if(!F(d))throw d;let u=await n.recoverRejectedCertificate?.();if(!u)throw d;n=u,o=true,p=await l(n);}return this.record(c),r.refreshGrant&&this.record("coordination.credential.refresh"),o&&await t.onSourceRenewed?.({token:n.token,expiresAtMs:n.expiresAtMs}),p})();i=s;try{return await s}finally{i===s&&(i=null);}}}};var P=new WeakMap;function fe(a){let e=P.get(a);if(!e)throw new Error("[OpenRTC] Capability runtime is unavailable or already closed.");return e}function oe(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 f(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 W=/^[A-Za-z0-9_.:@-]{1,160}$/,ce=/^[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 V(a){let e=typeof a=="string"?a.trim():"";if(!W.test(e))return null;let t=e.startsWith("device_")?e.slice(7):"";return ce.test(t)?t:e}function le(a,e){try{let t=a.getItem(`pluto_rtc_web_device_identity_${e}`);if(!t)return null;let i=JSON.parse(t);return V(i?.deviceId)}catch{return null}}function de(a){let e=`openrtc:v2:device-id:${a}`,t=`pluto_rtc_web_device_identity_${a}`,i,n=(()=>{try{return i=globalThis.localStorage,i&&le(i,a)||V(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 L(a){let e=typeof a=="string"?a.trim():"";if(!W.test(e))throw new Error("[OpenRTC] The native host returned an invalid durable device ID.");return e}function E(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 K=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);}},M=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:($[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;P.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{P.delete(this),this.onClosed();}}}},m=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,p=async()=>this.roster.mergeDevices(await s()),d=async()=>this.roster.mergeStatus(await o()),u=g=>c(w=>g(this.roster.mergeDevices(w))),h=g=>l(w=>g(this.roster.mergeStatus(w))),v=Object.create(i);Object.defineProperties(v,{listDevices:{value:p,enumerable:false},listDevicesWithStatus:{value:d,enumerable:false},watchDevices:{value:u,enumerable:false},watchDevicesWithStatus:{value:h,enumerable:false},devices:{value:{...i.devices,list:p,listWithStatus:d,watch:u,watchWithStatus:h},enumerable:true}}),P.set(this,v);}replaceEnrolledDevices(t){this.roster.replace(t);}removeEnrolledDevice(t){this.roster.remove(t);}retainCurrentEnrolledDevice(t){this.roster.retain(t);}},_=class extends C{constructor(t,i,n,r){super("space",t,i,n);this.delivery=r;this.kind="space";this.leave=()=>this.close();}},O=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();}},J=class extends C{constructor(t,i,n,r){super("ticket",t,i,n);this.token=r;this.kind="ticket";}},N=class{constructor(e,t){this.options=e;this.internals=t;this.channels=new K;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 m&&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=L(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 m&&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 m&&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:${f(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:${f(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:${f(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=oe(e.apiKey),this.usage=new M(e.usage),this.controlPlane=new R(this.apiKey,t.endpoints??A,t.deviceKeyProvider??U,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):de(this.controlPlane.appTag);return L(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??A).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.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}),c;try{c=await this.controlPlane.listEnrolledDevices(t,i);}catch(d){throw this.channels.detach(o),await o.advanced.runtime.shutdown().catch(()=>{}),d}let{AuthenticatedDeviceRoster:l}=await import('./deviceRoster-GHF6MWXF.js'),p;return p=new m(s.principalId,o,()=>{this.channels.detach(o),this.onClosed(p);},new l(c)),this.handles.add(p),p}async joinSpace(e,t={}){this.assertOpen();let i=f(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:E(n),maxPeers:t.maxPeers,autoConnect:true,defaultDelivery:t.payload??"reliable",advancedFanout:t.advancedFanout}),o;return o=new _(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=f(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 p=t.auth??this.options.auth;if(!p)throw new Error("[OpenRTC] Authenticated rooms require an auth provider.");let d=await this.deviceId(),u=await this.controlPlane.deviceCertificate(p,d,{kind:"room",id:i});n==="durable"&&await this.controlPlane.durableRoomMembership(u.source,i,"join");let h;try{h=await this.activate({kind:"room",id:i,source:u.source,principalId:u.principalId,deviceId:d,maxPeers:t.maxPeers,autoConnect:!0,durableMembership:n==="durable",advancedFanout:t.advancedFanout});}catch(g){throw n==="durable"&&await this.controlPlane.durableRoomMembership(u.source,i,"leave").catch(()=>{}),g}let v;return v=new O(i,h,()=>{this.channels.detach(h),this.onClosed(v);},n,n==="durable"?async()=>{await this.controlPlane.durableRoomMembership(u.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:E(s),maxPeers:t.maxPeers,autoConnect:true,advancedFanout:t.advancedFanout}),l;return l=new O(i,c,()=>{this.channels.detach(c),this.onClosed(l);},"ephemeral"),this.handles.add(l),l}async issueTicket(e,t={}){this.assertOpen();let i=f(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:E(n),maxPeers:t.maxPeers,autoConnect:false,advancedFanout:t.advancedFanout}),o;return o=new J(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 me(a,e){return new N(a,e)}
|
|
2
|
-
export{B as a,fe as b,me as c};
|