@junobuild/admin 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/declarations/cmc/cmc.did +122 -0
- package/declarations/cmc/cmc.did.d.ts +48 -0
- package/declarations/cmc/cmc.factory.did.js +65 -0
- package/declarations/cmc/index.d.ts +45 -0
- package/declarations/cmc/index.js +32 -0
- package/declarations/console/console.did.d.ts +60 -0
- package/declarations/console/console.factory.did.js +62 -0
- package/declarations/console/console.factory.did.mjs +62 -0
- package/declarations/console/index.d.ts +45 -0
- package/declarations/console/index.js +32 -0
- package/declarations/frontend/frontend.did +188 -0
- package/declarations/frontend/frontend.did.d.ts +172 -0
- package/declarations/frontend/frontend.factory.did.js +208 -0
- package/declarations/frontend/index.d.ts +45 -0
- package/declarations/frontend/index.js +32 -0
- package/declarations/ic/ic.did +82 -0
- package/declarations/ic/ic.did.d.ts +77 -0
- package/declarations/ic/ic.factory.did.js +128 -0
- package/declarations/internet_identity/index.d.ts +45 -0
- package/declarations/internet_identity/index.js +32 -0
- package/declarations/internet_identity/internet_identity.did +330 -0
- package/declarations/internet_identity/internet_identity.did.d.ts +204 -0
- package/declarations/internet_identity/internet_identity.factory.did.js +233 -0
- package/declarations/ledger/index.d.ts +45 -0
- package/declarations/ledger/index.js +32 -0
- package/declarations/ledger/ledger.did +249 -0
- package/declarations/ledger/ledger.did.d.ts +100 -0
- package/declarations/ledger/ledger.factory.did.js +98 -0
- package/declarations/mission_control/index.d.ts +45 -0
- package/declarations/mission_control/index.js +32 -0
- package/declarations/mission_control/mission_control.did.d.ts +41 -0
- package/declarations/mission_control/mission_control.factory.did.js +50 -0
- package/declarations/satellite/index.d.ts +45 -0
- package/declarations/satellite/index.js +32 -0
- package/declarations/satellite/satellite-deprecated.did.d.ts +182 -0
- package/declarations/satellite/satellite-deprecated.factory.did.js +191 -0
- package/declarations/satellite/satellite-deprecated.factory.did.mjs +191 -0
- package/declarations/satellite/satellite.did.d.ts +183 -0
- package/declarations/satellite/satellite.factory.did.js +194 -0
- package/declarations/satellite/satellite.factory.did.mjs +192 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +2 -2
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +2 -2
- package/package.json +3 -3
package/dist/node/index.mjs
CHANGED
|
@@ -29,7 +29,7 @@ ${A(i)}
|
|
|
29
29
|
)`}case 3:return`leaf(...${e[1].byteLength} bytes)`;case 4:return`pruned(${(0,fe.toHex)(new Uint8Array(e[1]))}`;default:return`unknown(${JSON.stringify(e[0])})`}}xA.hashTreeToString=Ur;function ga(e,A){if(e.byteLength!==A.byteLength)return!1;let t=new Uint8Array(e),r=new Uint8Array(A);for(let i=0;i<t.length;i++)if(t[i]!==r[i])return!1;return!0}var It=class{constructor(A,t,r,i){this._rootKey=t,this._canisterId=r,this._blsVerify=i,this.cert=aa.decode(new Uint8Array(A))}static async create(A){let t=A.blsVerify;t||(t=VB.blsVerify);let r=new It(A.certificate,A.rootKey,A.canisterId,t);return await r.verify(),r}lookup(A){return tn(A,this.cert.tree)}async verify(){let A=await Ot(this.cert.tree),t=await this._checkDelegationAndGetKey(this.cert.delegation),r=this.cert.signature,i=XB(t),n=(0,fe.concat)(Yt("ic-state-root"),A),s=!1;try{s=await this._blsVerify(new Uint8Array(i),new Uint8Array(r),new Uint8Array(n))}catch{s=!1}if(!s)throw new Et("Signature verification failed")}async _checkDelegationAndGetKey(A){if(!A)return this._rootKey;let t=await It.create({certificate:A.certificate,rootKey:this._rootKey,canisterId:this._canisterId}),r=t.lookup(["subnet",A.subnet_id,"canister_ranges"]);if(!r)throw new Et(`Could not find canister ranges for subnet 0x${(0,fe.toHex)(A.subnet_id)}`);if(!aa.decode(r).map(c=>[oa.Principal.fromUint8Array(c[0]),oa.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(this._canisterId)&&c[1].gtEq(this._canisterId)))throw new Et(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,fe.toHex)(A.subnet_id)}`);let o=t.lookup(["subnet",A.subnet_id,"public_key"]);if(!o)throw new Error(`Could not find subnet key for subnet 0x${(0,fe.toHex)(A.subnet_id)}`);return o}};xA.Certificate=It;var Dt=(0,fe.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),WB=96;function XB(e){let A=Dt.byteLength+WB;if(e.byteLength!==A)throw new TypeError(`BLS DER-encoded public key must be ${A} bytes long`);let t=e.slice(0,Dt.byteLength);if(!ga(t,Dt))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Dt}, but get ${t}`);return e.slice(Dt.byteLength)}async function Ot(e){switch(e[0]){case 0:return(0,vr.hash)(Yt("ic-hashtree-empty"));case 4:return e[1];case 3:return(0,vr.hash)((0,fe.concat)(Yt("ic-hashtree-leaf"),e[1]));case 2:return(0,vr.hash)((0,fe.concat)(Yt("ic-hashtree-labeled"),e[1],await Ot(e[2])));case 1:return(0,vr.hash)((0,fe.concat)(Yt("ic-hashtree-fork"),await Ot(e[1]),await Ot(e[2])));default:throw new Error("unreachable")}}xA.reconstruct=Ot;function Yt(e){let A=new Uint8Array([e.length]),t=new TextEncoder().encode(e);return(0,fe.concat)(A,t)}function tn(e,A){if(e.length===0)switch(A[0]){case 3:return new Uint8Array(A[1]).buffer;default:return}let t=typeof e[0]=="string"?new TextEncoder().encode(e[0]):e[0],r=ZB(t,en(A));if(r)return tn(e.slice(1),r)}xA.lookup_path=tn;function en(e){switch(e[0]){case 0:return[];case 1:return en(e[1]).concat(en(e[2]));default:return[e]}}function ZB(e,A){if(A.length!==0){for(let t of A)if(t[0]===2){let r=t[1];if(ga(e,r))return t[2]}}}});var Hr=U(jA=>{"use strict";var zB=jA&&jA.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(A,t);(!i||("get"in i?!A.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,i)}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),LB=jA&&jA.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),$B=jA&&jA.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.prototype.hasOwnProperty.call(e,t)&&zB(A,e,t);return LB(A,e),A};Object.defineProperty(jA,"__esModule",{value:!0});jA.encodePath=jA.request=void 0;var Ba=He(),Au=YA(),eu=Rt(),tu=kr(),ru=te(),iu=$B(Ht()),nu=async e=>{let{canisterId:A,agent:t,paths:r}=e,i=[...new Set(r)],n=i.map(c=>(0,jA.encodePath)(c,A)),s=new Map,o=i.map((c,y)=>(async()=>{var x;try{let m=await t.readState(A,{paths:[n[y]]}),w=(await tu.Certificate.create({certificate:m.certificate,rootKey:t.rootKey,canisterId:A})).lookup((0,jA.encodePath)(i[y],A));if(!w)console.warn(`Expected to find result for path ${c}, but instead found nothing.`),typeof c=="string"?s.set(c,null):s.set(c.key,null);else switch(c){case"time":{s.set(c,ou(w));break}case"controllers":{s.set(c,cu(w));break}case"module_hash":{s.set(c,ua(w));break}case"candid":{s.set(c,new TextDecoder().decode(w));break}default:if(typeof c!="string"&&"key"in c&&"path"in c)switch(c.decodeStrategy){case"raw":s.set(c.key,w);break;case"leb128":{s.set(c.key,Ea(w));break}case"cbor":{s.set(c.key,Ia(w));break}case"hex":{s.set(c.key,ua(w));break}case"utf-8":s.set(c.key,au(w))}}}catch(m){if(!((x=m?.message)===null||x===void 0)&&x.includes("Invalid certificate"))throw new eu.AgentError(m.message);typeof c!="string"&&"key"in c&&"path"in c?s.set(c.key,null):s.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(m),console.groupEnd()}})());return await Promise.all(o),s};jA.request=nu;var su=(e,A)=>{let t=new TextEncoder,r=n=>new DataView(t.encode(n).buffer).buffer,i=new DataView(A.toUint8Array().buffer).buffer;switch(e){case"time":return[r("time")];case"controllers":return[r("canister"),i,r("controllers")];case"module_hash":return[r("canister"),i,r("module_hash")];case"subnet":return[r("subnet")];case"candid":return[r("canister"),i,r("metadata"),r("candid:service")];default:if("key"in e&&"path"in e)if(typeof e.path=="string"||e.path instanceof ArrayBuffer){let n=e.path,s=typeof n=="string"?r(n):n;return[r("canister"),i,r("metadata"),s]}else return e.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${e} was formatted correctly.`)};jA.encodePath=su;var ua=e=>(0,ru.toHex)(e),Ea=e=>(0,Ba.lebDecode)(new Ba.PipeArrayBuffer(e)),Ia=e=>iu.decode(e),au=e=>new TextDecoder().decode(e),ou=e=>{let A=Ea(e);return new Date(Number(A/BigInt(1e6)))},cu=e=>{let[A,...t]=Ia(e);return t.map(r=>Au.Principal.fromUint8Array(new Uint8Array(r)))}});var rn=U(dA=>{"use strict";var Qa=dA&&dA.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(A,t);(!i||("get"in i?!A.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,i)}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),gu=dA&&dA.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),ha=dA&&dA.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.prototype.hasOwnProperty.call(e,t)&&Qa(A,e,t);return gu(A,e),A},Bu=dA&&dA.__exportStar||function(e,A){for(var t in e)t!=="default"&&!Object.prototype.hasOwnProperty.call(A,t)&&Qa(A,e,t)};Object.defineProperty(dA,"__esModule",{value:!0});dA.HttpAgent=dA.IdentityInvalidError=dA.RequestStatusResponseStatus=dA.makeNonce=void 0;var Ge=YA(),fa=Rt(),uu=Yi(),lt=ha(Ht()),Eu=Ut(),Iu=te(),Jt=Mr(),la=qt();Bu(Mr(),dA);var lu=qt();Object.defineProperty(dA,"makeNonce",{enumerable:!0,get:function(){return lu.makeNonce}});var Qu;(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(Qu=dA.RequestStatusResponseStatus||(dA.RequestStatusResponseStatus={}));var qr=5*60*1e3,hu="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",fu="ic0.app",Cu=".ic0.app",du="icp0.io",pu=".icp0.io",yu="icp-api.io",wu=".icp-api.io",Pt=class extends fa.AgentError{constructor(A){super(A),this.message=A}},Je=class extends fa.AgentError{constructor(A){super(A),this.message=A}};dA.IdentityInvalidError=Je;function Su(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Pt("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)e=global.fetch.bind(global);else throw new Pt("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(e=self.fetch.bind(self));if(e)return e;throw new Pt("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Kt=class{constructor(A={}){if(this.rootKey=(0,Iu.fromHex)(hu),this._pipeline=[],this._timeDiffMsecs=0,this._rootKeyFetched=!1,this._retryTimes=3,this._isAgent=!0,A.source){if(!(A.source instanceof Kt))throw new Error("An Agent's source can only be another HttpAgent");this._pipeline=[...A.source._pipeline],this._identity=A.source._identity,this._fetch=A.source._fetch,this._host=A.source._host,this._credentials=A.source._credentials}else this._fetch=A.fetch||Su()||fetch.bind(global),this._fetchOptions=A.fetchOptions,this._callOptions=A.callOptions;if(A.host!==void 0)!A.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+A.host):this._host=new URL(A.host);else if(A.source!==void 0)this._host=A.source._host;else{let t=typeof window<"u"?window.location:void 0;if(!t)throw new Error("Must specify a host to connect to.");this._host=new URL(t+"")}if(A.retryTimes!==void 0&&(this._retryTimes=A.retryTimes),this._host.hostname.endsWith(Cu)?this._host.hostname=fu:this._host.hostname.endsWith(pu)?this._host.hostname=du:this._host.hostname.endsWith(wu)&&(this._host.hostname=yu),A.credentials){let{name:t,password:r}=A.credentials;this._credentials=`${t}${r?":"+r:""}`}this._identity=Promise.resolve(A.identity||new uu.AnonymousIdentity),A.disableNonce||this.addTransform((0,Jt.makeNonceTransform)(la.makeNonce))}isLocal(){let A=this._host.hostname;return A==="127.0.0.1"||A.endsWith("localhost")}addTransform(A,t=A.priority||0){let r=this._pipeline.findIndex(i=>(i.priority||0)<t);this._pipeline.splice(r>=0?r:this._pipeline.length,0,Object.assign(A,{priority:t}))}async getPrincipal(){if(!this._identity)throw new Je("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(A,t,r){let i=await(r!==void 0?await r:await this._identity);if(!i)throw new Je("This identity has expired due this application's security policy. Please refresh your authentication.");let n=Ge.Principal.from(A),s=t.effectiveCanisterId?Ge.Principal.from(t.effectiveCanisterId):n,o=i.getPrincipal()||Ge.Principal.anonymous(),c=new Jt.Expiry(qr);Math.abs(this._timeDiffMsecs)>1e3*30&&(c=new Jt.Expiry(qr+this._timeDiffMsecs));let y={request_type:la.SubmitRequestType.Call,canister_id:n,method_name:t.methodName,arg:t.arg,sender:o,ingress_expiry:c},x=await this._transform({request:{body:null,method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"call",body:y});x=await i.transformRequest(x);let m=lt.encode(x.body),T=this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${s.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),x.request),{body:m}))),[w,G]=await Promise.all([T,(0,Eu.requestIdOf)(y)]);return{requestId:G,response:{ok:w.ok,status:w.status,statusText:w.statusText}}}async _requestAndRetry(A,t=0){if(t>this._retryTimes&&this._retryTimes!==0)throw new Error(`AgentError: Exceeded configured limit of ${this._retryTimes} retry attempts. Please check your network connection or try again in a few moments`);let r=await A();if(!r.ok){let i=await r.clone().text(),n=`Server returned an error:
|
|
30
30
|
Code: ${r.status} (${r.statusText})
|
|
31
31
|
Body: ${i}
|
|
32
|
-
`;if(this._retryTimes>t)return console.warn(n+" Retrying request."),await this._requestAndRetry(A,t+1);throw new Error(n)}return r}async query(A,t,r){let i=await(r!==void 0?await r:await this._identity);if(!i)throw new Je("This identity has expired due this application's security policy. Please refresh your authentication.");let n=typeof A=="string"?Ge.Principal.fromText(A):A,s=i?.getPrincipal()||Ge.Principal.anonymous(),o={request_type:"query",canister_id:n,method_name:t.methodName,arg:t.arg,sender:s,ingress_expiry:new Jt.Expiry(qr)},c=await this._transform({request:{method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"read",body:o});c=await i?.transformRequest(c);let y=lt.encode(c.body),x=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${n.toText()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),c.request),{body:y})));return lt.decode(await x.arrayBuffer())}async createReadStateRequest(A,t){let r=await(t!==void 0?await t:await this._identity);if(!r)throw new Je("This identity has expired due this application's security policy. Please refresh your authentication.");let i=r?.getPrincipal()||Ge.Principal.anonymous(),n=await this._transform({request:{method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"read_state",body:{request_type:"read_state",paths:A.paths,sender:i,ingress_expiry:new Jt.Expiry(qr)}});return r?.transformRequest(n)}async readState(A,t,r,i){let n=typeof A=="string"?Ge.Principal.fromText(A):A,s=i??await this.createReadStateRequest(t,r),o=lt.encode(s.body),c=await this._fetch(""+new URL(`/api/v2/canister/${n}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),s.request),{body:o}));if(!c.ok)throw new Error(`Server returned an error:
|
|
32
|
+
`;if(this._retryTimes>t)return console.warn(n+" Retrying request."),await this._requestAndRetry(A,t+1);throw new Error(n)}return r}async query(A,t,r){let i=await(r!==void 0?await r:await this._identity);if(!i)throw new Je("This identity has expired due this application's security policy. Please refresh your authentication.");let n=typeof A=="string"?Ge.Principal.fromText(A):A,s=i?.getPrincipal()||Ge.Principal.anonymous(),o={request_type:"query",canister_id:n,method_name:t.methodName,arg:t.arg,sender:s,ingress_expiry:new Jt.Expiry(qr)},c=await this._transform({request:{method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"read",body:o});c=await i?.transformRequest(c);let y=lt.encode(c.body),x=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${n.toText()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),c.request),{body:y})));return lt.decode(await x.arrayBuffer())}async createReadStateRequest(A,t){let r=await(t!==void 0?await t:await this._identity);if(!r)throw new Je("This identity has expired due this application's security policy. Please refresh your authentication.");let i=r?.getPrincipal()||Ge.Principal.anonymous(),n=await this._transform({request:{method:"POST",headers:new Headers(Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{}))},endpoint:"read_state",body:{request_type:"read_state",paths:A.paths,sender:i,ingress_expiry:new Jt.Expiry(qr)}});return r?.transformRequest(n)}async readState(A,t,r,i){let n=typeof A=="string"?Ge.Principal.fromText(A):A,s=i??await this.createReadStateRequest(t,r),o=lt.encode(s.body),c=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${n}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),s.request),{body:o})));if(!c.ok)throw new Error(`Server returned an error:
|
|
33
33
|
Code: ${c.status} (${c.statusText})
|
|
34
34
|
Body: ${await c.text()}
|
|
35
35
|
`);return lt.decode(await c.arrayBuffer())}async syncTime(A){let t=await Promise.resolve().then(()=>ha(Hr())),r=Date.now();try{A||console.log("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let n=(await t.request({canisterId:A??Ge.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");n&&(this._timeDiffMsecs=Number(n)-Number(r))}catch(i){console.error("Caught exception while attempting to sync time:",i)}}async status(){let A=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{},t=await this._requestAndRetry(()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:A},this._fetchOptions)));return lt.decode(await t.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(A){this._identity=Promise.resolve(A)}_transform(A){let t=Promise.resolve(A);for(let r of this._pipeline)t=t.then(i=>r(i).then(n=>n||i));return t}};dA.HttpAgent=Kt});var Ca=U(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.ProxyAgent=Se.ProxyStubAgent=Se.ProxyMessageKind=void 0;var _u=YA(),QA;(function(e){e.Error="err",e.GetPrincipal="gp",e.GetPrincipalResponse="gpr",e.Query="q",e.QueryResponse="qr",e.Call="c",e.CallResponse="cr",e.ReadState="rs",e.ReadStateResponse="rsr",e.Status="s",e.StatusResponse="sr"})(QA=Se.ProxyMessageKind||(Se.ProxyMessageKind={}));var nn=class{constructor(A,t){this._frontend=A,this._agent=t}onmessage(A){switch(A.type){case QA.GetPrincipal:this._agent.getPrincipal().then(t=>{this._frontend({id:A.id,type:QA.GetPrincipalResponse,response:t.toText()})});break;case QA.Query:this._agent.query(...A.args).then(t=>{this._frontend({id:A.id,type:QA.QueryResponse,response:t})});break;case QA.Call:this._agent.call(...A.args).then(t=>{this._frontend({id:A.id,type:QA.CallResponse,response:t})});break;case QA.ReadState:this._agent.readState(...A.args).then(t=>{this._frontend({id:A.id,type:QA.ReadStateResponse,response:t})});break;case QA.Status:this._agent.status().then(t=>{this._frontend({id:A.id,type:QA.StatusResponse,response:t})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(A)}`)}}};Se.ProxyStubAgent=nn;var sn=class{constructor(A){this._backend=A,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(A){let t=A.id,r=this._pendingCalls.get(t);if(!r)throw new Error("A proxy get the same message twice...");this._pendingCalls.delete(t);let[i,n]=r;switch(A.type){case QA.Error:return n(A.error);case QA.GetPrincipalResponse:case QA.CallResponse:case QA.QueryResponse:case QA.ReadStateResponse:case QA.StatusResponse:return i(A.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(A)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:QA.GetPrincipal}).then(A=>{if(typeof A!="string")throw new Error("Invalid principal received.");return _u.Principal.fromText(A)})}readState(A,t){return this._sendAndWait({id:this._nextId++,type:QA.ReadState,args:[A.toString(),t]})}call(A,t){return this._sendAndWait({id:this._nextId++,type:QA.Call,args:[A.toString(),t]})}status(){return this._sendAndWait({id:this._nextId++,type:QA.Status})}query(A,t){return this._sendAndWait({id:this._nextId++,type:QA.Query,args:[A.toString(),t]})}async _sendAndWait(A){return new Promise((t,r)=>{this._pendingCalls.set(A.id,[t,r]),this._backend(A)})}async fetchRootKey(){let A=(await this.status()).root_key;return this.rootKey=A,A}};Se.ProxyAgent=sn});var Dr=U(ne=>{"use strict";var Fu=ne&&ne.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(A,t);(!i||("get"in i?!A.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,i)}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),an=ne&&ne.__exportStar||function(e,A){for(var t in e)t!=="default"&&!Object.prototype.hasOwnProperty.call(A,t)&&Fu(A,e,t)};Object.defineProperty(ne,"__esModule",{value:!0});ne.getDefaultAgent=void 0;an(Is(),ne);an(rn(),ne);an(Ca(),ne);function mu(){let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!e)throw new Error("No Agent could be found.");return e}ne.getDefaultAgent=mu});var on=U(NA=>{"use strict";Object.defineProperty(NA,"__esModule",{value:!0});NA.chain=NA.backoff=NA.timeout=NA.throttle=NA.maxAttempts=NA.conditionalDelay=NA.once=NA.defaultStrategy=void 0;var da=te(),xu=5*60*1e3;function Nu(){return _a(ya(pa(),1e3),Sa(1e3,1.2),wa(xu))}NA.defaultStrategy=Nu;function pa(){let e=!0;return async()=>e?(e=!1,!0):!1}NA.once=pa;function ya(e,A){return async(t,r,i)=>{if(await e(t,r,i))return new Promise(n=>setTimeout(n,A))}}NA.conditionalDelay=ya;function bu(e){let A=e;return async(t,r,i)=>{if(--A<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
|