buckyos 0.7.133 → 0.7.136
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/cli/dist/cli.mjs +1 -1
- package/cli/dist/cli.mjs.map +1 -1
- package/cli/version.ts +1 -1
- package/dist/account.d.ts +11 -0
- package/dist/account.d.ts.map +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.mjs +166 -143
- package/dist/browser.mjs.map +1 -1
- package/dist/hybrid_sso.d.ts +110 -0
- package/dist/hybrid_sso.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +166 -143
- package/dist/index.mjs.map +1 -1
- package/dist/krpc_client.d.ts +7 -1
- package/dist/krpc_client.d.ts.map +1 -1
- package/dist/msg_center_client.d.ts +13 -1
- package/dist/msg_center_client.d.ts.map +1 -1
- package/dist/ndm_client.d.ts +6 -0
- package/dist/ndm_client.d.ts.map +1 -1
- package/dist/ndm_proxy-7cf15839.js +13 -0
- package/dist/ndm_proxy-7cf15839.js.map +1 -0
- package/dist/{ndm_proxy-501cb1e8.mjs → ndm_proxy-b5c95488.mjs} +360 -170
- package/dist/ndm_proxy-b5c95488.mjs.map +1 -0
- package/dist/ndn_types-324121ae.js +2 -0
- package/dist/ndn_types-324121ae.js.map +1 -0
- package/dist/{ndn_types-d768245f.mjs → ndn_types-ac9c1e48.mjs} +64 -38
- package/dist/ndn_types-ac9c1e48.mjs.map +1 -0
- package/dist/node.cjs +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +2 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.mjs +166 -143
- package/dist/node.mjs.map +1 -1
- package/dist/provision.cjs +1 -1
- package/dist/provision.mjs +1 -1
- package/dist/runtime.d.ts +30 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/sdk_core.d.ts +14 -1
- package/dist/sdk_core.d.ts.map +1 -1
- package/dist/{tus_client-b1c35e8c.mjs → tus_client-19baa342.mjs} +2 -2
- package/dist/{tus_client-b1c35e8c.mjs.map → tus_client-19baa342.mjs.map} +1 -1
- package/dist/{tus_client-d0798623.js → tus_client-2b915a81.js} +2 -2
- package/dist/{tus_client-d0798623.js.map → tus_client-2b915a81.js.map} +1 -1
- package/dist/verify-hub-client.d.ts +1 -0
- package/dist/verify-hub-client.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/ndm_proxy-501cb1e8.mjs.map +0 -1
- package/dist/ndm_proxy-68b8160c.js +0 -13
- package/dist/ndm_proxy-68b8160c.js.map +0 -1
- package/dist/ndn_types-44c69036.js +0 -2
- package/dist/ndn_types-44c69036.js.map +0 -1
- package/dist/ndn_types-d768245f.mjs.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t="ARRAYBUFFER not supported by this environment",n="UINT8ARRAY not supported by this environment";function i(e,t,n,i){let r,o,s;const c=t||[0],a=(n=n||0)>>>3,u=-1===i?3:0;for(r=0;r<e.length;r+=1)s=r+a,o=s>>>2,c.length<=o&&c.push(0),c[o]|=e[r]<<8*(u+i*(s%4));return{value:c,binLen:8*e.length+n}}function r(r,o,s){switch(o){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(r){case"HEX":return function(e,t,n){return function(e,t,n,i){let r,o,s,c;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const a=t||[0],u=(n=n||0)>>>3,h=-1===i?3:0;for(r=0;r<e.length;r+=2){if(o=parseInt(e.substr(r,2),16),isNaN(o))throw new Error("String of HEX type contains invalid characters");for(c=(r>>>1)+u,s=c>>>2;a.length<=s;)a.push(0);a[s]|=o<<8*(h+i*(c%4))}return{value:a,binLen:4*e.length+n}}(e,t,n,s)};case"TEXT":return function(e,t,n){return function(e,t,n,i,r){let o,s,c,a,u,h,l,d,f=0;const w=n||[0],p=(i=i||0)>>>3;if("UTF8"===t)for(l=-1===r?3:0,c=0;c<e.length;c+=1)for(o=e.charCodeAt(c),s=[],128>o?s.push(o):2048>o?(s.push(192|o>>>6),s.push(128|63&o)):55296>o||57344<=o?s.push(224|o>>>12,128|o>>>6&63,128|63&o):(c+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(c)),s.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),a=0;a<s.length;a+=1){for(h=f+p,u=h>>>2;w.length<=u;)w.push(0);w[u]|=s[a]<<8*(l+r*(h%4)),f+=1}else for(l=-1===r?2:0,d="UTF16LE"===t&&1!==r||"UTF16LE"!==t&&1===r,c=0;c<e.length;c+=1){for(o=e.charCodeAt(c),!0===d&&(a=255&o,o=a<<8|o>>>8),h=f+p,u=h>>>2;w.length<=u;)w.push(0);w[u]|=o<<8*(l+r*(h%4)),f+=2}return{value:w,binLen:8*f+i}}(e,o,t,n,s)};case"B64":return function(t,n,i){return function(t,n,i,r){let o,s,c,a,u,h,l,d=0;const f=n||[0],w=(i=i||0)>>>3,p=-1===r?3:0,m=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==m&&m<t.length)throw new Error("Invalid '=' found in base-64 string");for(s=0;s<t.length;s+=4){for(u=t.substr(s,4),a=0,c=0;c<u.length;c+=1)o=e.indexOf(u.charAt(c)),a|=o<<18-6*c;for(c=0;c<u.length-1;c+=1){for(l=d+w,h=l>>>2;f.length<=h;)f.push(0);f[h]|=(a>>>16-8*c&255)<<8*(p+r*(l%4)),d+=1}}return{value:f,binLen:8*d+i}}(t,n,i,s)};case"BYTES":return function(e,t,n){return function(e,t,n,i){let r,o,s,c;const a=t||[0],u=(n=n||0)>>>3,h=-1===i?3:0;for(o=0;o<e.length;o+=1)r=e.charCodeAt(o),c=o+u,s=c>>>2,a.length<=s&&a.push(0),a[s]|=r<<8*(h+i*(c%4));return{value:a,binLen:8*e.length+n}}(e,t,n,s)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(c){throw new Error(t)}return function(e,t,n){return r=t,o=n,c=s,i(new Uint8Array(e),r,o,c);var r,o,c};case"UINT8ARRAY":try{new Uint8Array(0)}catch(c){throw new Error(n)}return function(e,t,n){return i(e,t,n,s)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function o(i,r,o,s){switch(i){case"HEX":return function(e){return function(e,t,n,i){const r="0123456789abcdef";let o,s,c="";const a=t/8,u=-1===n?3:0;for(o=0;o<a;o+=1)s=e[o>>>2]>>>8*(u+n*(o%4)),c+=r.charAt(s>>>4&15)+r.charAt(15&s);return i.outputUpper?c.toUpperCase():c}(e,r,o,s)};case"B64":return function(t){return function(t,n,i,r){let o,s,c,a,u,h="";const l=n/8,d=-1===i?3:0;for(o=0;o<l;o+=3)for(a=o+1<l?t[o+1>>>2]:0,u=o+2<l?t[o+2>>>2]:0,c=(t[o>>>2]>>>8*(d+i*(o%4))&255)<<16|(a>>>8*(d+i*((o+1)%4))&255)<<8|u>>>8*(d+i*((o+2)%4))&255,s=0;s<4;s+=1)h+=8*o+6*s<=n?e.charAt(c>>>6*(3-s)&63):r.b64Pad;return h}(t,r,o,s)};case"BYTES":return function(e){return function(e,t,n){let i,r,o="";const s=t/8,c=-1===n?3:0;for(i=0;i<s;i+=1)r=e[i>>>2]>>>8*(c+n*(i%4))&255,o+=String.fromCharCode(r);return o}(e,r,o)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(c){throw new Error(t)}return function(e){return function(e,t,n){let i;const r=t/8,o=new ArrayBuffer(r),s=new Uint8Array(o),c=-1===n?3:0;for(i=0;i<r;i+=1)s[i]=e[i>>>2]>>>8*(c+n*(i%4))&255;return o}(e,r,o)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(c){throw new Error(n)}return function(e){return function(e,t,n){let i;const r=t/8,o=-1===n?3:0,s=new Uint8Array(r);for(i=0;i<r;i+=1)s[i]=e[i>>>2]>>>8*(o+n*(i%4))&255;return s}(e,r,o)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const s=4294967296,c=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],u=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],h="Chosen SHA variant is not supported",l="Cannot set numRounds with MAC";function d(e,t){let n,i;const r=e.binLen>>>3,o=t.binLen>>>3,s=r<<3,c=4-r<<3;if(r%4!=0){for(n=0;n<o;n+=4)i=r+n>>>2,e.value[i]|=t.value[n>>>2]<<s,e.value.push(0),e.value[i+1]|=t.value[n>>>2]>>>c;return(e.value.length<<2)-4>=o+r&&e.value.pop(),{value:e.value,binLen:e.binLen+t.binLen}}return{value:e.value.concat(t.value),binLen:e.binLen+t.binLen}}function f(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},i="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(i);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(i);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function w(e,t,n,i){const o=e+" must include a value and format";if(!t){if(!i)throw new Error(o);return i}if(void 0===t.value||!t.format)throw new Error(o);return r(t.format,t.encoding||"UTF8",n)(t.value)}class p{constructor(e,t,n){const i=n||{};if(this.t=t,this.i=i.encoding||"UTF8",this.numRounds=i.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.H=!1,this.S=[],this.p=[]}update(e){let t,n=0;const i=this.m>>>5,r=this.C(e,this.h,this.u),o=r.binLen,s=r.value,c=o>>>5;for(t=0;t<c;t+=i)n+this.m<=o&&(this.U=this.v(s.slice(t,t+i),this.U),n+=this.m);return this.A+=n,this.h=s.slice(n>>>5),this.u=o%this.m,this.l=!0,this}getHash(e,t){let n,i,r=this.R;const s=f(t);if(this.K){if(-1===s.outputLen)throw new Error("Output length must be specified in options");r=s.outputLen}const c=o(e,r,this.T,s);if(this.H&&this.g)return c(this.g(s));for(i=this.F(this.h.slice(),this.u,this.A,this.L(this.U),r),n=1;n<this.numRounds;n+=1)this.K&&r%32!=0&&(i[i.length-1]&=16777215>>>24-r%32),i=this.F(i,r,0,this.B(this.o),r);return c(i)}setHMACKey(e,t,n){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const i=r(t,(n||{}).encoding||"UTF8",this.T);this.k(i(e))}k(e){const t=this.m>>>3,n=t/4-1;let i;if(1!==this.numRounds)throw new Error(l);if(this.H)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.F(e.value,e.binLen,0,this.B(this.o),this.R));e.value.length<=n;)e.value.push(0);for(i=0;i<=n;i+=1)this.S[i]=909522486^e.value[i],this.p[i]=1549556828^e.value[i];this.U=this.v(this.S,this.U),this.A=this.m,this.H=!0}getHMAC(e,t){const n=f(t);return o(e,this.R,this.T,n)(this.Y())}Y(){let e;if(!this.H)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.F(this.h.slice(),this.u,this.A,this.L(this.U),this.R);return e=this.v(this.p,this.B(this.o)),e=this.F(t,this.R,this.m,e,this.R),e}}function m(e,t){return e<<t|e>>>32-t}function y(e,t){return e>>>t|e<<32-t}function b(e,t){return e>>>t}function g(e,t,n){return e^t^n}function _(e,t,n){return e&t^~e&n}function v(e,t,n){return e&t^e&n^t&n}function I(e){return y(e,2)^y(e,13)^y(e,22)}function S(e,t){const n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function j(e,t,n,i){const r=(65535&e)+(65535&t)+(65535&n)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(i>>>16)+(r>>>16))<<16|65535&r}function k(e,t,n,i,r){const o=(65535&e)+(65535&t)+(65535&n)+(65535&i)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(i>>>16)+(r>>>16)+(o>>>16))<<16|65535&o}function O(e){return y(e,7)^y(e,18)^b(e,3)}function x(e){return y(e,6)^y(e,11)^y(e,25)}function E(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function N(e,t){let n,i,r,o,s,c,a;const u=[];for(n=t[0],i=t[1],r=t[2],o=t[3],s=t[4],a=0;a<80;a+=1)u[a]=a<16?e[a]:m(u[a-3]^u[a-8]^u[a-14]^u[a-16],1),c=a<20?k(m(n,5),_(i,r,o),s,1518500249,u[a]):a<40?k(m(n,5),g(i,r,o),s,1859775393,u[a]):a<60?k(m(n,5),v(i,r,o),s,2400959708,u[a]):k(m(n,5),g(i,r,o),s,3395469782,u[a]),s=o,o=r,r=m(i,30),i=n,n=c;return t[0]=S(n,t[0]),t[1]=S(i,t[1]),t[2]=S(r,t[2]),t[3]=S(o,t[3]),t[4]=S(s,t[4]),t}function T(e,t,n,i){let r;const o=15+(t+65>>>9<<4),c=t+n;for(;e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[o]=4294967295&c,e[o-1]=c/s|0,r=0;r<e.length;r+=16)i=N(e.slice(r,r+16),i);return i}let D=class extends p{constructor(e,t,n){if("SHA-1"!==e)throw new Error(h);super(e,t,n);const i=n||{};this.M=!0,this.g=this.Y,this.T=-1,this.C=r(this.t,this.i,this.T),this.v=N,this.L=function(e){return e.slice()},this.B=E,this.F=T,this.U=[1732584193,4023233417,2562383102,271733878,3285377520],this.m=512,this.R=160,this.K=!1,i.hmacKey&&this.k(w("hmacKey",i.hmacKey,this.T))}};function A(e){let t;return t="SHA-224"==e?a.slice():u.slice(),t}function J(e,t){let n,i,r,o,s,a,u,h,l,d,f;const w=[];for(n=t[0],i=t[1],r=t[2],o=t[3],s=t[4],a=t[5],u=t[6],h=t[7],f=0;f<64;f+=1)w[f]=f<16?e[f]:j(y(p=w[f-2],17)^y(p,19)^b(p,10),w[f-7],O(w[f-15]),w[f-16]),l=k(h,x(s),_(s,a,u),c[f],w[f]),d=S(I(n),v(n,i,r)),h=u,u=a,a=s,s=S(o,l),o=r,r=i,i=n,n=S(l,d);var p;return t[0]=S(n,t[0]),t[1]=S(i,t[1]),t[2]=S(r,t[2]),t[3]=S(o,t[3]),t[4]=S(s,t[4]),t[5]=S(a,t[5]),t[6]=S(u,t[6]),t[7]=S(h,t[7]),t}let C=class extends p{constructor(e,t,n){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error(h);super(e,t,n);const i=n||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=r(this.t,this.i,this.T),this.v=J,this.L=function(e){return e.slice()},this.B=A,this.F=function(t,n,i,r){return function(e,t,n,i,r){let o,c;const a=15+(t+65>>>9<<4),u=t+n;for(;e.length<=a;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[a]=4294967295&u,e[a-1]=u/s|0,o=0;o<e.length;o+=16)i=J(e.slice(o,o+16),i);return c="SHA-224"===r?[i[0],i[1],i[2],i[3],i[4],i[5],i[6]]:i,c}(t,n,i,r,e)},this.U=A(e),this.m=512,this.R="SHA-224"===e?224:256,this.K=!1,i.hmacKey&&this.k(w("hmacKey",i.hmacKey,this.T))}};class K{constructor(e,t){this.N=e,this.I=t}}function B(e,t){let n;return t>32?(n=64-t,new K(e.I<<t|e.N>>>n,e.N<<t|e.I>>>n)):0!==t?(n=32-t,new K(e.N<<t|e.I>>>n,e.I<<t|e.N>>>n)):e}function H(e,t){let n;return t<32?(n=32-t,new K(e.N>>>t|e.I<<n,e.I>>>t|e.N<<n)):(n=64-t,new K(e.I>>>t|e.N<<n,e.N>>>t|e.I<<n))}function $(e,t){return new K(e.N>>>t,e.I>>>t|e.N<<32-t)}function P(e,t,n){return new K(e.N&t.N^e.N&n.N^t.N&n.N,e.I&t.I^e.I&n.I^t.I&n.I)}function R(e){const t=H(e,28),n=H(e,34),i=H(e,39);return new K(t.N^n.N^i.N,t.I^n.I^i.I)}function M(e,t){let n,i;n=(65535&e.I)+(65535&t.I),i=(e.I>>>16)+(t.I>>>16)+(n>>>16);const r=(65535&i)<<16|65535&n;return n=(65535&e.N)+(65535&t.N)+(i>>>16),i=(e.N>>>16)+(t.N>>>16)+(n>>>16),new K((65535&i)<<16|65535&n,r)}function U(e,t,n,i){let r,o;r=(65535&e.I)+(65535&t.I)+(65535&n.I)+(65535&i.I),o=(e.I>>>16)+(t.I>>>16)+(n.I>>>16)+(i.I>>>16)+(r>>>16);const s=(65535&o)<<16|65535&r;return r=(65535&e.N)+(65535&t.N)+(65535&n.N)+(65535&i.N)+(o>>>16),o=(e.N>>>16)+(t.N>>>16)+(n.N>>>16)+(i.N>>>16)+(r>>>16),new K((65535&o)<<16|65535&r,s)}function L(e,t,n,i,r){let o,s;o=(65535&e.I)+(65535&t.I)+(65535&n.I)+(65535&i.I)+(65535&r.I),s=(e.I>>>16)+(t.I>>>16)+(n.I>>>16)+(i.I>>>16)+(r.I>>>16)+(o>>>16);const c=(65535&s)<<16|65535&o;return o=(65535&e.N)+(65535&t.N)+(65535&n.N)+(65535&i.N)+(65535&r.N)+(s>>>16),s=(e.N>>>16)+(t.N>>>16)+(n.N>>>16)+(i.N>>>16)+(r.N>>>16)+(o>>>16),new K((65535&s)<<16|65535&o,c)}function z(e,t){return new K(e.N^t.N,e.I^t.I)}function F(e){const t=H(e,19),n=H(e,61),i=$(e,6);return new K(t.N^n.N^i.N,t.I^n.I^i.I)}function Y(e){const t=H(e,1),n=H(e,8),i=$(e,7);return new K(t.N^n.N^i.N,t.I^n.I^i.I)}function q(e){const t=H(e,14),n=H(e,18),i=H(e,41);return new K(t.N^n.N^i.N,t.I^n.I^i.I)}const W=[new K(c[0],3609767458),new K(c[1],602891725),new K(c[2],3964484399),new K(c[3],2173295548),new K(c[4],4081628472),new K(c[5],3053834265),new K(c[6],2937671579),new K(c[7],3664609560),new K(c[8],2734883394),new K(c[9],1164996542),new K(c[10],1323610764),new K(c[11],3590304994),new K(c[12],4068182383),new K(c[13],991336113),new K(c[14],633803317),new K(c[15],3479774868),new K(c[16],2666613458),new K(c[17],944711139),new K(c[18],2341262773),new K(c[19],2007800933),new K(c[20],1495990901),new K(c[21],1856431235),new K(c[22],3175218132),new K(c[23],2198950837),new K(c[24],3999719339),new K(c[25],766784016),new K(c[26],2566594879),new K(c[27],3203337956),new K(c[28],1034457026),new K(c[29],2466948901),new K(c[30],3758326383),new K(c[31],168717936),new K(c[32],1188179964),new K(c[33],1546045734),new K(c[34],1522805485),new K(c[35],2643833823),new K(c[36],2343527390),new K(c[37],1014477480),new K(c[38],1206759142),new K(c[39],344077627),new K(c[40],1290863460),new K(c[41],3158454273),new K(c[42],3505952657),new K(c[43],106217008),new K(c[44],3606008344),new K(c[45],1432725776),new K(c[46],1467031594),new K(c[47],851169720),new K(c[48],3100823752),new K(c[49],1363258195),new K(c[50],3750685593),new K(c[51],3785050280),new K(c[52],3318307427),new K(c[53],3812723403),new K(c[54],2003034995),new K(c[55],3602036899),new K(c[56],1575990012),new K(c[57],1125592928),new K(c[58],2716904306),new K(c[59],442776044),new K(c[60],593698344),new K(c[61],3733110249),new K(c[62],2999351573),new K(c[63],3815920427),new K(3391569614,3928383900),new K(3515267271,566280711),new K(3940187606,3454069534),new K(4118630271,4000239992),new K(116418474,1914138554),new K(174292421,2731055270),new K(289380356,3203993006),new K(460393269,320620315),new K(685471733,587496836),new K(852142971,1086792851),new K(1017036298,365543100),new K(1126000580,2618297676),new K(1288033470,3409855158),new K(1501505948,4234509866),new K(1607167915,987167468),new K(1816402316,1246189591)];function Z(e){return"SHA-384"===e?[new K(3418070365,a[0]),new K(1654270250,a[1]),new K(2438529370,a[2]),new K(355462360,a[3]),new K(1731405415,a[4]),new K(41048885895,a[5]),new K(3675008525,a[6]),new K(1203062813,a[7])]:[new K(u[0],4089235720),new K(u[1],2227873595),new K(u[2],4271175723),new K(u[3],1595750129),new K(u[4],2917565137),new K(u[5],725511199),new K(u[6],4215389547),new K(u[7],327033209)]}function X(e,t){let n,i,r,o,s,c,a,u,h,l,d,f;const w=[];for(n=t[0],i=t[1],r=t[2],o=t[3],s=t[4],c=t[5],a=t[6],u=t[7],d=0;d<80;d+=1)d<16?(f=2*d,w[d]=new K(e[f],e[f+1])):w[d]=U(F(w[d-2]),w[d-7],Y(w[d-15]),w[d-16]),h=L(u,q(s),(m=c,y=a,new K((p=s).N&m.N^~p.N&y.N,p.I&m.I^~p.I&y.I)),W[d],w[d]),l=M(R(n),P(n,i,r)),u=a,a=c,c=s,s=M(o,h),o=r,r=i,i=n,n=M(h,l);var p,m,y;return t[0]=M(n,t[0]),t[1]=M(i,t[1]),t[2]=M(r,t[2]),t[3]=M(o,t[3]),t[4]=M(s,t[4]),t[5]=M(c,t[5]),t[6]=M(a,t[6]),t[7]=M(u,t[7]),t}let G=class extends p{constructor(e,t,n){if("SHA-384"!==e&&"SHA-512"!==e)throw new Error(h);super(e,t,n);const i=n||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=r(this.t,this.i,this.T),this.v=X,this.L=function(e){return e.slice()},this.B=Z,this.F=function(t,n,i,r){return function(e,t,n,i,r){let o,c;const a=31+(t+129>>>10<<5),u=t+n;for(;e.length<=a;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[a]=4294967295&u,e[a-1]=u/s|0,o=0;o<e.length;o+=32)i=X(e.slice(o,o+32),i);return c="SHA-384"===r?[i[0].N,i[0].I,i[1].N,i[1].I,i[2].N,i[2].I,i[3].N,i[3].I,i[4].N,i[4].I,i[5].N,i[5].I]:[i[0].N,i[0].I,i[1].N,i[1].I,i[2].N,i[2].I,i[3].N,i[3].I,i[4].N,i[4].I,i[5].N,i[5].I,i[6].N,i[6].I,i[7].N,i[7].I],c}(t,n,i,r,e)},this.U=Z(e),this.m=1024,this.R="SHA-384"===e?384:512,this.K=!1,i.hmacKey&&this.k(w("hmacKey",i.hmacKey,this.T))}};const V=[new K(0,1),new K(0,32898),new K(2147483648,32906),new K(2147483648,2147516416),new K(0,32907),new K(0,2147483649),new K(2147483648,2147516545),new K(2147483648,32777),new K(0,138),new K(0,136),new K(0,2147516425),new K(0,2147483658),new K(0,2147516555),new K(2147483648,139),new K(2147483648,32905),new K(2147483648,32771),new K(2147483648,32770),new K(2147483648,128),new K(0,32778),new K(2147483648,2147483658),new K(2147483648,2147516545),new K(2147483648,32896),new K(0,2147483649),new K(2147483648,2147516424)],Q=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function ee(e){let t;const n=[];for(t=0;t<5;t+=1)n[t]=[new K(0,0),new K(0,0),new K(0,0),new K(0,0),new K(0,0)];return n}function te(e){let t;const n=[];for(t=0;t<5;t+=1)n[t]=e[t].slice();return n}function ne(e,t){let n,i,r,o;const s=[],c=[];if(null!==e)for(i=0;i<e.length;i+=2)t[(i>>>1)%5][(i>>>1)/5|0]=z(t[(i>>>1)%5][(i>>>1)/5|0],new K(e[i+1],e[i]));for(n=0;n<24;n+=1){for(o=ee(),i=0;i<5;i+=1)s[i]=(a=t[i][0],u=t[i][1],h=t[i][2],l=t[i][3],d=t[i][4],new K(a.N^u.N^h.N^l.N^d.N,a.I^u.I^h.I^l.I^d.I));for(i=0;i<5;i+=1)c[i]=z(s[(i+4)%5],B(s[(i+1)%5],1));for(i=0;i<5;i+=1)for(r=0;r<5;r+=1)t[i][r]=z(t[i][r],c[i]);for(i=0;i<5;i+=1)for(r=0;r<5;r+=1)o[r][(2*i+3*r)%5]=B(t[i][r],Q[i][r]);for(i=0;i<5;i+=1)for(r=0;r<5;r+=1)t[i][r]=z(o[i][r],new K(~o[(i+1)%5][r].N&o[(i+2)%5][r].N,~o[(i+1)%5][r].I&o[(i+2)%5][r].I));t[0][0]=z(t[0][0],V[n])}var a,u,h,l,d;return t}function ie(e){let t,n,i=0;const r=[0,0],o=[4294967295&e,e/s&2097151];for(t=6;t>=0;t--)n=o[t>>2]>>>8*t&255,0===n&&0===i||(r[i+1>>2]|=n<<8*(i+1),i+=1);return i=0!==i?i:1,r[0]|=i,{value:i+1>4?r:[r[0]],binLen:8+8*i}}function re(e){return d(ie(e.binLen),e)}function oe(e,t){let n,i=ie(t);i=d(i,e);const r=t>>>2,o=(r-i.value.length%r)%r;for(n=0;n<o;n++)i.value.push(0);return i.value}let se=class extends p{constructor(e,t,n){let i=6,o=0;super(e,t,n);const s=n||{};if(1!==this.numRounds){if(s.kmacKey||s.hmacKey)throw new Error(l);if("CSHAKE128"===this.o||"CSHAKE256"===this.o)throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.T=1,this.C=r(this.t,this.i,this.T),this.v=ne,this.L=te,this.B=ee,this.U=ee(),this.K=!1,e){case"SHA3-224":this.m=o=1152,this.R=224,this.M=!0,this.g=this.Y;break;case"SHA3-256":this.m=o=1088,this.R=256,this.M=!0,this.g=this.Y;break;case"SHA3-384":this.m=o=832,this.R=384,this.M=!0,this.g=this.Y;break;case"SHA3-512":this.m=o=576,this.R=512,this.M=!0,this.g=this.Y;break;case"SHAKE128":i=31,this.m=o=1344,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"SHAKE256":i=31,this.m=o=1088,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"KMAC128":i=4,this.m=o=1344,this.X(n),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"KMAC256":i=4,this.m=o=1088,this.X(n),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"CSHAKE128":this.m=o=1344,i=this.O(n),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"CSHAKE256":this.m=o=1088,i=this.O(n),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;default:throw new Error(h)}this.F=function(e,t,n,r,s){return function(e,t,n,i,r,o,s){let c,a,u=0;const h=[],l=r>>>5,d=t>>>5;for(c=0;c<d&&t>=r;c+=l)i=ne(e.slice(c,c+l),i),t-=r;for(e=e.slice(c),t%=r;e.length<l;)e.push(0);for(c=t>>>3,e[c>>2]^=o<<c%4*8,e[l-1]^=2147483648,i=ne(e,i);32*h.length<s&&(a=i[u%5][u/5|0],h.push(a.I),!(32*h.length>=s));)h.push(a.N),u+=1,0==64*u%r&&(ne(null,i),u=0);return h}(e,t,0,r,o,i,s)},s.hmacKey&&this.k(w("hmacKey",s.hmacKey,this.T))}O(e,t){const n=function(e){const t=e||{};return{funcName:w("funcName",t.funcName,1,{value:[],binLen:0}),customization:w("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);const i=d(re(n.funcName),re(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){const e=oe(i,this.m>>>3);for(let t=0;t<e.length;t+=this.m>>>5)this.U=this.v(e.slice(t,t+(this.m>>>5)),this.U),this.A+=this.m;return 4}return 31}X(e){const t=function(e){const t=e||{};return{kmacKey:w("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:w("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});this.O(e,t.funcName);const n=oe(re(t.kmacKey),this.m>>>3);for(let i=0;i<n.length;i+=this.m>>>5)this.U=this.v(n.slice(i,i+(this.m>>>5)),this.U),this.A+=this.m;this.H=!0}_(e){const t=d({value:this.h.slice(),binLen:this.u},function(e){let t,n,i=0;const r=[0,0],o=[4294967295&e,e/s&2097151];for(t=6;t>=0;t--)n=o[t>>2]>>>8*t&255,0===n&&0===i||(r[i>>2]|=n<<8*i,i+=1);return i=0!==i?i:1,r[i>>2]|=i<<8*i,{value:i+1>4?r:[r[0]],binLen:8+8*i}}(e.outputLen));return this.F(t.value,t.binLen,this.A,this.L(this.U),e.outputLen)}};class ce{constructor(e,t,n){if("SHA-1"==e)this.P=new D(e,t,n);else if("SHA-224"==e||"SHA-256"==e)this.P=new C(e,t,n);else if("SHA-384"==e||"SHA-512"==e)this.P=new G(e,t,n);else{if("SHA3-224"!=e&&"SHA3-256"!=e&&"SHA3-384"!=e&&"SHA3-512"!=e&&"SHAKE128"!=e&&"SHAKE256"!=e&&"CSHAKE128"!=e&&"CSHAKE256"!=e&&"KMAC128"!=e&&"KMAC256"!=e)throw new Error(h);this.P=new se(e,t,n)}}update(e){return this.P.update(e),this}getHash(e,t){return this.P.getHash(e,t)}setHMACKey(e,t,n){this.P.setHMACKey(e,t,n)}getHMAC(e,t){return this.P.getHMAC(e,t)}}const ae="buckyos.account_info",ue="user_info";function he(e){return`buckyos.account_info.${e}`}const le="DIDObjectService",de="buckyos.node_identity.v2";function fe(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function we(e){return"string"==typeof e||Array.isArray(e)&&e.every((e=>"string"==typeof e))}function pe(e){return!!fe(e)&&(we(e["@context"])&&"string"==typeof e.id&&function(e){return Array.isArray(e)}(e.verificationMethod)&&Array.isArray(e.authentication)&&"number"==typeof e.exp&&"number"==typeof e.iat&&function(e){return void 0===e||Array.isArray(e)}(e.service))}function me(e){return pe(e)&&"string"==typeof e.name&&("string"==typeof e.display_name||"string"==typeof e.displayName||"string"==typeof e.full_name)}function ye(e){return fe(e)&&"string"==typeof e.n&&"string"==typeof e.x&&"number"==typeof e.exp}function be(e){return pe(e)&&"string"==typeof e.owner&&"string"==typeof e.device_type&&"string"==typeof e.name}function ge(e){return pe(e)&&"string"==typeof e.owner&&fe(e.httpServicePorts)}function _e(e){return pe(e)&&"string"==typeof e.hostname&&"string"==typeof e.owner&&Array.isArray(e.oods)&&"string"==typeof e.boot_jwt}function ve(e){if(!fe(e)||!we(e["@context"])||"string"!=typeof e.id)return!1;const t=e.service;return Array.isArray(t)&&t.some((e=>fe(e)&&e.type===le))}const Ie="https://www.w3.org/ns/did/v1",Se="https://buckyos.org/ns",je=15768e4,ke=31536e4;function Oe(e){return[Ie,`${Se}/${e}/v1`]}function xe(){return Math.floor(Date.now()/1e3)}const Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Ne(e){let t="";for(let n=0;n<e.length;n+=3){const i=e[n],r=n+1<e.length?e[n+1]:0,o=n+2<e.length?e[n+2]:0;t+=Ee[i>>2],t+=Ee[(3&i)<<4|r>>4],t+=n+1<e.length?Ee[(15&r)<<2|o>>6]:"=",t+=n+2<e.length?Ee[63&o]:"="}return t}function Te(e){const t=e.replace(/[^A-Za-z0-9+/]/g,""),n=Math.floor(3*t.length/4),i=new Uint8Array(n);let r=0;for(let o=0;o<t.length;o+=4){const e=Ee.indexOf(t[o]),n=Ee.indexOf(t[o+1]),s=o+2<t.length?Ee.indexOf(t[o+2]):-1,c=o+3<t.length?Ee.indexOf(t[o+3]):-1;i[r++]=e<<2|n>>4,s>=0&&(i[r++]=(15&n)<<4|s>>2),c>=0&&(i[r++]=(3&s)<<6|c)}return i.subarray(0,r)}function De(e){return Ne(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Ae(e){return Te(e.replace(/-/g,"+").replace(/_/g,"/"))}function Je(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);const t=[];for(let n=0;n<e.length;n++){let i=e.codePointAt(n);i>65535&&n++,i<128?t.push(i):i<2048?t.push(192|i>>6,128|63&i):i<65536?t.push(224|i>>12,128|i>>6&63,128|63&i):t.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i)}return new Uint8Array(t)}function Ce(e){return De(Je(e))}function Ke(e){return function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0;n<e.length;){const i=e[n];if(i<128)t+=String.fromCharCode(i),n+=1;else if(i<224)t+=String.fromCharCode((31&i)<<6|63&e[n+1]),n+=2;else if(i<240)t+=String.fromCharCode((15&i)<<12|(63&e[n+1])<<6|63&e[n+2]),n+=3;else{const r=(7&i)<<18|(63&e[n+1])<<12|(63&e[n+2])<<6|63&e[n+3];t+=String.fromCodePoint(r),n+=4}}return t}(Ae(e))}async function Be(){if(!function(){var e;const t=globalThis.process;return Boolean(null==(e=null==t?void 0:t.versions)?void 0:e.node)}())return null;try{return await async function(e){return"function"==typeof require?require(e):Function("name","return import(name)")(e)}("node:crypto")}catch{return null}}function He(){var e;const t=null==(e=globalThis.crypto)?void 0:e.subtle;if(!t)throw new Error("namelib: no crypto backend available (need node:crypto or WebCrypto with Ed25519 support)");return t}const $e=new Uint8Array([48,42,48,5,6,3,43,101,112,3,33,0]);function Pe(e){return Te(e.replace(/-----BEGIN [^-]+-----/g,"").replace(/-----END [^-]+-----/g,"").replace(/\s+/g,""))}function Re(e){const t=Ne(e),n=[];for(let i=0;i<t.length;i+=64)n.push(t.slice(i,i+64));return`-----BEGIN PRIVATE KEY-----\n${n.join("\n")}\n-----END PRIVATE KEY-----\n`}function Me(e){const t=Ae(e.x);if(32!==t.length)throw new Error(`namelib: invalid Ed25519 jwk, x must be 32 bytes, got ${t.length}`);return function(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}($e,t)}async function Ue(e){const t=await Be();if(t){const n=t.createPrivateKey({key:e,format:"pem"});return t.createPublicKey(n).export({format:"jwk"}).x}const n=He(),i=Pe(e),r=await n.importKey("pkcs8",i,{name:"Ed25519"},!0,["sign"]),o=await n.exportKey("jwk",r);if(!o.x)throw new Error("namelib: cannot derive public key from private pem");return o.x}function Le(e){const t=e.x;if("string"!=typeof t||0===t.length)throw new Error("namelib: invalid jwk, missing x");return t}function ze(e){return{kty:"OKP",crv:"Ed25519",x:e}}async function Fe(e,t,n){const i=`${Ce(JSON.stringify(n??{alg:"EdDSA"}))}.${Ce(JSON.stringify(e))}`,r=await async function(e,t){const n=await Be();if(n){const i=n.createPrivateKey({key:t,format:"pem"});return new Uint8Array(n.sign(null,e,i))}const i=He(),r=Pe(t),o=await i.importKey("pkcs8",r,{name:"Ed25519"},!1,["sign"]),s=await i.sign({name:"Ed25519"},o,e);return new Uint8Array(s)}(Je(i),t);return`${i}.${De(r)}`}function Ye(e){const t=e.split(".");if(3!==t.length)throw new Error("namelib: invalid jwt, parts.len != 3");return JSON.parse(Ke(t[1]))}async function qe(e,t){const n=e.split(".");if(3!==n.length)throw new Error("namelib: invalid jwt, parts.len != 3");const i=JSON.parse(Ke(n[0]));if("EdDSA"!==i.alg)throw new Error(`namelib: unsupported jwt alg: ${i.alg}`);const r=`${n[0]}.${n[1]}`,o=await async function(e,t,n){const i=await Be();if(i){const r=i.createPublicKey({key:{kty:n.kty,crv:n.crv,x:n.x},format:"jwk"});return i.verify(null,e,r,t)}const r=He(),o=Me(n),s=await r.importKey("spki",o,{name:"Ed25519"},!1,["verify"]);return r.verify({name:"Ed25519"},s,t,e)}(Je(r),Ae(n[2]),t);if(!o)throw new Error("namelib: jwt signature verify failed");return JSON.parse(Ke(n[1]))}function We(e){return e.startsWith("{")||e.startsWith("[")?{type:"json",value:JSON.parse(e)}:{type:"jwt",jwt:e}}function Ze(e){return"jwt"===e.type?Ye(e.jwt):e.value}let Xe=null;class Ge{constructor(e,t){this.method=e,this.id=t}static undefined(){return new Ge("undefined","undefined")}isUndefined(){return"undefined"===this.method}isValid(){return"undefined"!==this.method}static isDid(e){return e.startsWith("did:")}static fromStr(e){const t=e.split(":");if("did"!==t[0]){const t=Ge.fromHostName(e);if(t)return t;throw new Error(`namelib: invalid did ${e}`)}return new Ge(t[1],t.slice(2).join(":"))}static fromHostName(e){if(e.endsWith(".did")){const t=e.slice(0,-4),n=t.lastIndexOf(".");if(n>0&&n<t.length-1)return new Ge(t.slice(n+1),t.slice(0,n))}if(Xe)for(const t of Object.keys(Xe)){const n=Xe[t];if(e.endsWith(n)){if(e===n)break;const i=e.slice(0,e.length-n.length-1);return new Ge(t,i)}}return new Ge("web",e)}static fromHostNameByBridge(e,t,n){if(e.endsWith(n)&&e!==n){const i=e.slice(0,e.length-n.length-1);return new Ge(t,i)}if(e.endsWith(".did")){const t=e.slice(0,-4),n=t.lastIndexOf(".");if(n>0&&n<t.length-1)return new Ge(t.slice(n+1),t.slice(0,n))}return new Ge("web",e)}toString(){return`did:${this.method}:${this.id}`}isNamedObjId(){return"dev"===this.method}getPathFromId(){const e=this.id.split(":");return e.length>1?e.slice(1).join("/"):null}upperDid(){const e=(this.id.split(":")[0]??"").split("%")[0]??"";switch(this.method){case"web":{if(tt(e))return null;const t=e.indexOf(".");if(t<0)return null;const n=e.slice(t+1);return n.includes(".")?new Ge("web",n):null}case"bns":{const t=e.indexOf(".");return t<0?null:new Ge("bns",e.slice(t+1))}default:return null}}toFilename(){const e="0123456789ABCDEF",t=Je(this.toRawHostUri());let n="";for(const i of t){const t=String.fromCharCode(i);/[A-Za-z0-9._-]/.test(t)?n+=t:n+=`%${e[i>>4]}${e[15&i]}`}return n}getEd25519AuthKey(){return"dev"===this.method?Ae(this.id):null}getAuthKeyJwk(){return"dev"===this.method?ze(this.id):null}toRawHostName(){const e=this.id.split(":")[0];return"web"===this.method?e:`${e}.${this.method}.did`}toRawHostUri(){const e=this.toRawHostName(),t=this.getPathFromId();return t?`${e}/${t}`:e}toHostNameByBridge(e){const t=this.id.split(":")[0];return"web"===this.method?t:`${t}.${e}`}toHostName(){const e=this.id.split(":")[0];if("web"===this.method)return e;if(Xe){const t=Xe[this.method];if(t)return`${e}.${t}`}return`${e}.${this.method}.did`}toHostUri(){const e=this.toHostName(),t=this.getPathFromId();return t?`${e}/${t}`:e}equals(e){return this.method===e.method&&this.id===e.id}}function Ve(e){let t,n="OOD",i=e;e.startsWith("#")?(n="Gateway",i=e.slice(1)):e.startsWith("$")&&(n="OODOnly",i=e.slice(1));const r=i.lastIndexOf("@");let o,s=i;r>=0&&(s=i.slice(0,r),t=i.slice(r+1));let c=s;const a=s.indexOf(":");if(a>=0&&(c=s.slice(0,a),o=s.slice(a+1),!tt(o)))throw new Error(`namelib: invalid ip addr: ${o}`);if(void 0!==o&&void 0===t&&(t="wan"),!c)throw new Error("namelib: name in OODDescriptionString is empty");return nt({name:c,nodeType:n,netId:t,ip:o})}function Qe(e){let t;switch(e.nodeType){case"OOD":t=e.name;break;case"Gateway":t=`#${e.name}`;break;case"OODOnly":t=`$${e.name}`;break;default:throw new Error("namelib: node type is not allow in oods")}return void 0!==e.ip?(t+=`:${e.ip}`,void 0!==e.netId&&"wan"!==e.netId&&(t+=`@${e.netId}`),t):(void 0!==e.netId&&(t+=`@${e.netId}`),t)}function et(e){return"Gateway"===e||"OOD"===e}function tt(e){const t=e.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);return t?t.slice(1).every((e=>Number(e)<=255)):/^[0-9a-fA-F:]+$/.test(e)&&e.includes(":")}function nt(e){for(const t of Object.keys(e))void 0===e[t]&&delete e[t];return e}function it(e){return e instanceof Ge?e:Ge.fromStr(e)}function rt(e){const t=it(e.did),n=e.now??xe(),i=t.toString();return{"@context":Oe("owner"),id:i,verificationMethod:[{type:"Ed25519VerificationKey2020",id:"#main_key",controller:i,publicKeyJwk:e.publicKeyJwk}],authentication:["#main_key"],assertion_method:["#main_key"],capabilityInvocation:["#main_key"],exp:n+ke,iat:n,version_seq:0,name:e.name,display_name:e.displayName,zone_binding_model_version:2}}function ot(e,t){const n=it(t).toString(),i=(e.binded_zone_list??[]).filter((e=>e!==n));i.unshift(n),e.binded_zone_list=i,e.zone_binding_model_version=2,st(e)}function st(e){var t;const n=null==(t=e.binded_zone_list)?void 0:t[0],i=`${e.id}#lastDoc`,r=(e.service??[]).filter((e=>e.id!==i));if(void 0!==n){const t=it(n);r.push({id:i,type:"DIDDoc",serviceEndpoint:`https://${t.toHostName()}/resolve/${e.id}`})}e.service=r}function ct(e,t){const n=it(t).toString();return(e.binded_zone_list??[]).includes(n)}function at(e){const t=it(e.id),n=it(e.ownerDid),i=e.now??xe(),r=t.toString();return{"@context":Oe("zone"),id:r,verificationMethod:[{type:"Ed25519VerificationKey2020",id:"#main_key",controller:n.toString(),publicKeyJwk:e.publicKeyJwk}],authentication:["#main_key"],assertionMethod:["#main_key"],capabilityInvocation:["#main_key"],service:[{id:`${r}#lastDoc`,type:"DIDDoc",serviceEndpoint:`https://${t.toHostName()}/resolve/this_zone`}],exp:i+ke,iat:i,version_seq:0,hostname:t.toHostName(),owner:n.toString(),oods:[],boot_jwt:""}}function ut(e){return nt({id:void 0!==e.id?it(e.id).toString():void 0,oods:[...e.oods],sn:e.sn,exp:e.exp,owner:void 0!==e.owner?it(e.owner).toString():void 0,owner_key:e.ownerKey})}async function ht(e,t){const{id:n,oods:i,sn:r,exp:o,owner:s,owner_key:c,...a}=e;return Fe(nt({id:n,oods:i,sn:r,exp:o,owner:s,...a,owner_key:c}),t)}function lt(e){const t=e.now??xe(),n=`did:dev:${e.pkx}`;return{"@context":Oe("device"),id:n,verificationMethod:[{type:"Ed25519VerificationKey2020",id:"#main_key",controller:n,publicKeyJwk:ze(e.pkx)}],authentication:["#main_key"],assertion_method:["#main_key"],capabilityInvocation:["#main_key"],exp:t+je,iat:t,version_seq:0,owner:Ge.undefined().toString(),device_type:"ood",name:e.name}}function dt(e,t,n){return lt({name:e,pkx:Le(t),now:n})}function ft(e,t,n,i){const r=`did:dev:${t.x}`,o={"@context":Oe("device"),id:r,verificationMethod:[{type:"Ed25519VerificationKey2020",id:"#main_key",controller:r,publicKeyJwk:ze(t.x)}],authentication:["#main_key"],assertion_method:["#main_key"],capabilityInvocation:["#main_key"],exp:t.exp,iat:t.exp-je,version_seq:0,zone_did:it(n).toString(),owner:it(i).toString(),device_type:"ood",device_mini_document_jwt:e,name:t.n};return void 0!==t.p&&(o.rtcp_port=t.p),o}async function wt(e,t){if(void 0===e.version_seq)throw new Error("namelib: DeviceDocument version_seq is required when encoding as JWT");return Fe(pt(e),t)}function pt(e){const{"@context":t,id:n,verificationMethod:i,authentication:r,assertion_method:o,capabilityInvocation:s,service:c,exp:a,iat:u,version_seq:h,keyScope:l,"buckyos:scopes":d,zone_did:f,owner:w,device_type:p,device_mini_document_jwt:m,name:y,rtcp_port:b,ips:g,net_id:_,ddns_sn_url:v,support_container:I,capbilities:S,...j}=e,k=l??d;return nt({"@context":t,id:n,verificationMethod:i,authentication:r,assertion_method:o&&o.length>0?o:void 0,capabilityInvocation:s&&s.length>0?s:void 0,service:c&&c.length>0?c:void 0,exp:a,iat:u,version_seq:h,...j,keyScope:k&&Object.keys(k).length>0?k:void 0,zone_did:f,owner:w,device_type:p,device_mini_document_jwt:m,name:y,rtcp_port:b,ips:g&&g.length>0?g:void 0,net_id:_,ddns_sn_url:v,support_container:!1!==I&&void 0,capbilities:S&&Object.keys(S).length>0?S:void 0})}function mt(e){return nt({n:e.name,x:e.x,p:e.rtcpPort,exp:e.exp})}function yt(e){const t=e.verificationMethod.find((e=>"#main_key"===e.id));if(!t)throw new Error("namelib: device document has no #main_key verification method");return mt({name:e.name,x:Le(t.publicKeyJwk),rtcpPort:e.rtcp_port,exp:e.exp})}async function bt(e,t){const{n:n,x:i,p:r,exp:o,...s}=e;return Fe(nt({n:n,x:i,p:r,exp:o,...s}),t)}function gt(e){const{"@context":t,id:n,verificationMethod:i,authentication:r,assertion_method:o,capabilityInvocation:s,service:c,exp:a,iat:u,version_seq:h,mini_version_seq:l,valid_iat:d,keyScope:f,"buckyos:scopes":w,name:p,display_name:m,avatar:y,meta:b,zone_binding_model_version:g,binded_zone_list:_,wallets:v,...I}=e,S=f??w;return nt({"@context":t,id:n,verificationMethod:i,authentication:r,assertion_method:o&&o.length>0?o:void 0,capabilityInvocation:s&&s.length>0?s:void 0,service:c&&c.length>0?c:void 0,exp:a,iat:u,version_seq:h,mini_version_seq:l,valid_iat:d,...I,keyScope:S&&Object.keys(S).length>0?S:void 0,name:p,display_name:m,avatar:y,meta:b,zone_binding_model_version:g,binded_zone_list:_&&_.length>0?_:void 0,wallets:v&&Object.keys(v).length>0?v:void 0})}async function _t(e,t){if(void 0===e.version_seq)throw new Error("namelib: ZoneDocument version_seq is required when encoding as JWT");return Fe(vt(e),t)}function vt(e){const{"@context":t,id:n,verificationMethod:i,authentication:r,assertionMethod:o,capabilityInvocation:s,service:c,exp:a,iat:u,version_seq:h,keyScope:l,"buckyos:scopes":d,hostname:f,owner:w,oods:p,boot_jwt:m,mini_device_jwts:y,devices:b,sn:g,..._}=e,v=l??d;return nt({"@context":t,id:n,verificationMethod:i,authentication:r,assertionMethod:o&&o.length>0?o:void 0,capabilityInvocation:s&&s.length>0?s:void 0,service:c&&c.length>0?c:void 0,exp:a,iat:u,version_seq:h,..._,keyScope:v&&Object.keys(v).length>0?v:void 0,hostname:f,owner:w,oods:p,boot_jwt:m,mini_device_jwts:y&&Object.keys(y).length>0?y:void 0,devices:b&&Object.keys(b).length>0?b:void 0,sn:g})}function It(e){return gt(e)}function St(e){return vt(e)}function jt(e){return pt(e)}function kt(e){return e.keyScope??e["buckyos:scopes"]??{}}function Ot(e,t){const n=e.verificationMethod??[];if(0===n.length)return null;if(void 0===t)return n[0].publicKeyJwk;const i=n.find((e=>e.id===t));return i?i.publicKeyJwk:null}function xt(e,t){return kt(e)[t]??null}function Et(e){return Object.keys(kt(e)).length>0}function Nt(e){const t=e.capabilityInvocation;if(Array.isArray(t)&&t.length>0)return t;const n=e.authentication;if(Array.isArray(n)&&n.length>0)return n;if(ve(e)){const t=e.assertionMethod;if(Array.isArray(t)&&t.length>0)return t}return null}function Tt(e,t){const n=e.id;if(t.startsWith(n)){const e=t.slice(n.length);if(e.startsWith("#"))return e}return t}function Dt(e,t){return t.startsWith("#")?`${e.id}${t}`:t}function At(e,t,n){return t===n||Tt(e,t)===Tt(e,n)||Dt(e,t)===Dt(e,n)}function Jt(e,t){for(const n of t){const t=Ot(e,Tt(e,n));if(t)return[n,t]}return null}function Ct(e){const t="string"==typeof e?We(e):e,n="jwt"===t.type,i=Ze(t);if("object"!=typeof i||null===i)throw new Error("namelib: unknown did document");const r=e=>{if(n&&"number"!=typeof i.version_seq)throw new Error(`namelib: ${e} version_seq is required when encoding as JWT`)};if(void 0!==i.verificationMethod&&void 0!==i.name&&(void 0!==i.display_name||void 0!==i.displayName||void 0!==i.full_name))return r("OwnerDocument"),{docType:"owner",doc:i};if(void 0!==i.httpServicePorts)return r("AgentDocument"),{docType:"agent",doc:i};if(void 0!==i.device_type)return r("DeviceDocument"),{docType:"device",doc:i};if(void 0!==i.oods)return r("ZoneDocument"),{docType:"zone",doc:i};if(Array.isArray(i.service)&&i.service.some((e=>(null==e?void 0:e.type)===le)))return r("DIDObjectCard"),{docType:"did-object",doc:i};throw new Error("namelib: unknown did document")}const Kt=Object.freeze(Object.defineProperty({__proto__:null,BUCKYOS_CONTEXT_BASE:Se,DEFAULT_EXPIRE_TIME:je,DID:Ge,DID_CORE_CONTEXT:Ie,DID_DOC_AUTHKEY:"#auth-key",KEY_SCOPE_AGENT_CREATE_CONTENT:"agent:create-content",KEY_SCOPE_AGENT_RECEIVE:"agent:receive",KEY_SCOPE_AGENT_SPEND:"agent:spend",KEY_SCOPE_CONTENT_CREATE:"content:create",KEY_SCOPE_MANUAL:"manual",KEY_SCOPE_MESSAGE_CREATE:"message:create",KEY_SCOPE_ZONE_PUBLISH:"zone:publish",ZONE_BINDING_MODEL_VERSION:2,base64UrlDecodeToBytes:Ae,base64UrlDecodeToString:Ke,base64UrlEncodeBytes:De,base64UrlEncodeString:Ce,buckyosContext:Oe,buckyosGetUnixTimestamp:xe,createJwkByX:ze,decodeDeviceDocument:async function(e,t){const n=t?await qe(e,t):Ye(e);if(void 0===n.version_seq)throw new Error("namelib: DeviceDocument version_seq is required when decoding from JWT");return n},decodeJwtClaimWithoutVerify:Ye,decodeJwtHeaderWithoutVerify:function(e){const t=e.split(".");if(3!==t.length)throw new Error("namelib: invalid jwt, parts.len != 3");return JSON.parse(Ke(t[0]))},decodeZoneBootDocument:async function(e,t){return t?await qe(e,t):Ye(e)},derToPkcs8Pem:Re,deviceDocumentToOrderedJson:jt,deviceMiniDocumentFromJwt:async function(e,t){return t?await qe(e,t):Ye(e)},deviceMiniDocumentToJwt:bt,encodeDeviceDocument:wt,encodeOwnerDocument:async function(e,t){if(void 0===e.version_seq)throw new Error("namelib: OwnerDocument version_seq is required when encoding as JWT");return Fe(gt(e),t)},encodeZoneBootDocument:ht,encodeZoneDocument:_t,encodedDocumentFromStr:We,encodedDocumentToJsonValue:Ze,encodedDocumentToString:function(e){return"jwt"===e.type?e.jwt:JSON.stringify(e.value)},expandLocalKeyId:Dt,generateEd25519KeyPair:async function(){const e=await Be();if(e){const{privateKey:t,publicKey:n}=e.generateKeyPairSync("ed25519");return{privateKeyPem:t.export({type:"pkcs8",format:"pem"}).toString(),publicKeyJwk:ze(n.export({format:"jwk"}).x)}}const t=He(),n=await t.generateKey({name:"Ed25519"},!0,["sign","verify"]),i=new Uint8Array(await t.exportKey("pkcs8",n.privateKey)),r=await t.exportKey("jwk",n.publicKey);if(!r.x)throw new Error("namelib: WebCrypto did not return Ed25519 public jwk");return{privateKeyPem:Re(i),publicKeyJwk:ze(r.x)}},getDeviceDidFromJwk:function(e){return`did:dev:${Le(e)}`},getDidDocType:function(e){return e.docType},getDocumentAuthKey:Ot,getDocumentDefaultKey:function(e){const t=(e.verificationMethod??[]).find((e=>"#main_key"===e.id));return t?t.publicKeyJwk:null},getDocumentKeyScope:kt,getKeyByScope:function(e,t){const n=xt(e,t);if(n)return Jt(e,n);if(Et(e))return null;const i=Nt(e);if(i){const t=Jt(e,i);if(t)return t}const r=Ot(e);return r?["",r]:null},getKeyFromKeyIds:Jt,getKeyIdsByScope:xt,getKnownWeb3BridgeConfig:function(){return Xe},getPublicKeyXFromPrivatePem:Ue,getStandardScopeKeyIds:Nt,getXFromJwk:Le,hasKeyScope:Et,isKeyAllowedInScope:function(e,t,n){const i=xt(e,t);if(i)return i.some((t=>At(e,t,n)));if(Et(e))return!1;const r=Nt(e);return r?r.some((t=>At(e,t,n))):null!==Ot(e,Tt(e,n))},isSameDocumentKeyId:At,newDeviceDocument:lt,newDeviceDocumentByJwk:dt,newDeviceDocumentByMiniDocument:ft,newDeviceMiniDocument:mt,newDeviceMiniDocumentByDeviceDocument:yt,newNodeIdentityConfig:function(e){return{zone_did:it(e.zoneDid).toString(),owner_public_key:e.ownerPublicKey,owner_did:it(e.ownerDid).toString(),device_doc_jwt:e.deviceDocJwt,device_mini_doc_jwt:e.deviceMiniDocJwt,zone_iat:e.zoneIat}},newOwnerDocument:rt,newOwnerDocumentByPkx:function(e,t){const n=e.split(":");if(0===n.length||!n[0])throw new Error("namelib: invalid pkx: empty x");const i=n[0];if(!/^[A-Za-z0-9_-]+$/.test(i))throw new Error("namelib: invalid pkx: x must be base64url");if(32!==Ae(i).length)throw new Error("namelib: invalid pkx: x length must be 32 bytes");const r=ze(i);if(1===n.length){const e=Ge.fromStr(t),n=e.id;return rt({did:e,name:n,displayName:`${n}@${t}`,publicKeyJwk:r})}if(n.length>=3){const e=n[2];return rt({did:new Ge(n[1],n[2]),name:e,displayName:`${e}@${t}`,publicKeyJwk:r})}throw new Error(`namelib: invalid pkx: ${e}`)},newZoneBootDocument:ut,newZoneDocument:at,normalizeKeyIdForLocalLookup:Tt,oodDescriptionToString:Qe,oodNodeTypeIsGateway:et,oodNodeTypeIsOod:function(e){return"OOD"===e||"OODOnly"===e},ownerDocumentGetDefaultZoneDid:function(e){var t;return(null==(t=e.binded_zone_list)?void 0:t[0])??null},ownerDocumentGetHistoricalKeys:function(e){return e.verificationMethod.filter((e=>"#main_key"!==e.id)).map((e=>[e.id,e.publicKeyJwk]))},ownerDocumentGetZoneBindingState:function(e,t){const n=e.zone_binding_model_version;return void 0===n?"legacy":2!==n?"unsupported_version":ct(e,t)?"bound_v2":"unbound_v2"},ownerDocumentIsBoundToZone:ct,ownerDocumentRemoveBoundZone:function(e,t){var n;const i=it(t).toString(),r=(null==(n=e.binded_zone_list)?void 0:n.length)??0;e.binded_zone_list=(e.binded_zone_list??[]).filter((e=>e!==i));const o=e.binded_zone_list.length!==r;return e.zone_binding_model_version=2,st(e),o},ownerDocumentSetDefaultZoneDid:ot,ownerDocumentToOrderedJson:It,ownerDocumentValidateJwtRevocation:function(e,t,n){if(void 0===e.mini_version_seq&&void 0===e.valid_iat)return;if("jwt"!==n.type)return;const i=Ze(n);if(void 0!==e.mini_version_seq){const n="number"==typeof(null==i?void 0:i.version_seq)?i.version_seq:void 0;if(void 0===n)throw new Error(`namelib: ${t} JWT missing version_seq required by owner revocation policy`);if(n<=e.mini_version_seq)throw new Error(`namelib: ${t} JWT version_seq ${n} is not greater than owner mini_version_seq ${e.mini_version_seq}`)}if(void 0!==e.valid_iat){const n="number"==typeof(null==i?void 0:i.iat)?i.iat:void 0;if(void 0===n)throw new Error(`namelib: ${t} JWT missing iat required by owner revocation policy`);if(n<=e.valid_iat)throw new Error(`namelib: ${t} JWT iat ${n} is not greater than owner valid_iat ${e.valid_iat}`)}},parseDidDoc:Ct,parseDidDocAs:function(e,t){const n=Ct(e);if(n.docType!==t)throw new Error(`namelib: expected ${t} document, got ${n.docType}`);return n.doc},parseOODDescription:Ve,pemToDer:Pe,resetKnownWeb3BridgeConfigForTest:function(){Xe=null},setKnownWeb3BridgeConfig:function(e){return null===Xe&&(Xe={...e},!0)},signJwtEdDSA:Fe,verifyJwtEdDSA:qe,zoneBootDocumentGetGatewayName:function(e){for(const t of e.oods){const e=Ve(t);if(et(e.nodeType))return e.name}return""},zoneBootDocumentToZoneDocument:function(e,t){if(!e.id||!e.owner_key)throw new Error("namelib: zone boot document needs id and owner_key to build zone document");const n=e.owner?Ge.fromStr(e.owner):Ge.undefined(),i=at({id:e.id,ownerDid:n,publicKeyJwk:e.owner_key});return i.boot_jwt=t,i.oods=[...e.oods],void 0!==e.sn?i.sn=e.sn:delete i.sn,i.exp=e.exp,i.iat=e.exp-je,i.version_seq=0,i.owner=e.owner??Ge.undefined().toString(),i},zoneDocumentGetDefaultGateway:function(e){for(const t of e.oods){const e=Ve(t);if(et(e.nodeType))return e.name}return null},zoneDocumentGetSnApiUrl:function(e){return void 0!==e.sn?`https://${e.sn}/kapi/sn`:null},zoneDocumentToOrderedJson:St},Symbol.toStringTag,{value:"Module"}));var Bt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ht(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const $t=Ht((function e(t){if("number"==typeof t&&isNaN(t))throw new Error("NaN is not allowed");if("number"==typeof t&&!isFinite(t))throw new Error("Infinity is not allowed");if(null===t||"object"!=typeof t)return JSON.stringify(t);if(t.toJSON instanceof Function)return e(t.toJSON());if(Array.isArray(t)){return`[${t.reduce(((t,n,i)=>`${t}${0===i?"":","}${e(void 0===n||"symbol"==typeof n?null:n)}`),"")}]`}return`{${Object.keys(t).sort().reduce(((n,i)=>{if(void 0===t[i]||"symbol"==typeof t[i])return n;return`${n}${0===n.length?"":","}${e(i)}:${e(t[i])}`}),"")}}`}));class Pt extends Error{constructor(e,t){super(`${e}: ${t}`),this.kind=e,this.name="NdnError"}}const Rt="cyfile",Mt="cydir",Ut="cypath",Lt="cyinc",zt="cyrel",Ft="cypack",Yt="cytrie",qt="cytrie-s",Wt="cymap-mtp",Zt="cymap",Xt="cylist-mtree",Gt="cylist",Vt="cl",Qt="clist",en="clist-fix",tn="cl-sf",nn="same",rn="part_of",on="0123456789abcdef";function sn(e){let t="";for(let n=0;n<e.length;n++){const i=e[n];t+=on[i>>>4&15],t+=on[15&i]}return t}function cn(e){if(e.length%2!=0)throw new Pt("InvalidId",`invalid hex length: ${e.length}`);const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){const i=on.indexOf(e[2*n].toLowerCase()),r=on.indexOf(e[2*n+1].toLowerCase());if(i<0||r<0)throw new Pt("InvalidId","invalid hex char at offset "+2*n);t[n]=i<<4|r}return t}const an="abcdefghijklmnopqrstuvwxyz234567";function un(e){let t=0,n=0,i="";for(let r=0;r<e.length;r++)for(n=n<<8|e[r],t+=8;t>=5;)t-=5,i+=an[n>>>t&31];return t>0&&(i+=an[n<<5-t&31]),i}function hn(e){const t=e.toLowerCase();let n=0,i=0;const r=[];for(let o=0;o<t.length;o++){const e=t[o],s=an.indexOf(e);if(s<0)throw new Pt("InvalidId",`invalid base32 char '${e}' at ${o}`);i=i<<5|s,n+=5,n>=8&&(n-=8,r.push(i>>>n&255))}return new Uint8Array(r)}function ln(e){if(!Number.isFinite(e)||e<0)throw new Pt("InvalidParam",`varint must be non-negative finite: ${e}`);if(!Number.isSafeInteger(e))throw new Pt("InvalidParam",`varint exceeds safe integer range: ${e}`);const t=[];let n=e;for(;n>=128;)t.push(127&n|128),n=Math.floor(n/128);return t.push(127&n),new Uint8Array(t)}function dn(e,t=0){let n=0,i=1,r=t,o=0;for(;r<e.length;){const t=e[r++];o++;if(n+=(127&t)*i,!Number.isSafeInteger(n))throw new Pt("InvalidData","varint exceeds safe integer range");if(!(128&t))return[n,o];if(i*=128,o>10)throw new Pt("InvalidData","varint too long")}throw new Pt("InvalidData","varint truncated")}function fn(e){const t=new ce("SHA-256","UINT8ARRAY");return t.update(e),t.getHash("UINT8ARRAY")}function wn(e){const t=new ce("SHA-256","TEXT",{encoding:"UTF8"});return t.update(e),t.getHash("UINT8ARRAY")}function pn(e){for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(!(n<55296||n>57343)){if(n<=56319){const n=e.charCodeAt(t+1);if(t+1<e.length&&n>=56320&&n<=57343){t++;continue}}throw new Pt("InvalidData","JSON string contains lone surrogate")}}}function mn(e){if(function(e){switch(typeof e){case"string":return void pn(e);case"number":if(!Number.isFinite(e))throw new Pt("InvalidData","JSON number MUST be finite for JCS");if(Object.is(e,-0))throw new Pt("InvalidData","JSON number MUST NOT be negative zero for JCS");return;case"boolean":case"object":return;case"undefined":throw new Pt("InvalidData","undefined is not a valid JSON value");case"bigint":throw new Pt("InvalidData","bigint is not a valid JSON value");case"function":throw new Pt("InvalidData","function is not a valid JSON value");case"symbol":throw new Pt("InvalidData","symbol is not a valid JSON value")}}(e),null===e||"object"!=typeof e)return e;if(Array.isArray(e)){const t=new Array(e.length);for(let n=0;n<e.length;n++){if(!Object.prototype.hasOwnProperty.call(e,n))throw new Pt("InvalidData","sparse arrays are not valid JSON values");t[n]=mn(e[n])}return t}const t=Object.keys(e).sort(),n={};for(const i of t)pn(i),n[i]=mn(e[i]);return n}function yn(e){const t=mn(e),n=$t(t);if(void 0===n)throw new Pt("InvalidData","failed to canonicalize JSON value");return n}const bn={Sha256:"sha256",Sha512:"sha512",QCID:"qcid",Blake2s256:"blake2s256",Keccak256:"keccak256",hashResultSize(e){switch(e){case"sha256":case"qcid":case"blake2s256":case"keccak256":return 32;case"sha512":return 64}},parse(e){const t=e.startsWith("mix");return[bn.fromString(e),t]},fromString(e){switch(e){case"sha256":case"mix256":return"sha256";case"sha512":case"mix512":return"sha512";case"qcid":case"mixqcid":return"qcid";case"blake2s256":case"mixblake2s256":return"blake2s256";case"keccak256":case"mixkeccak256":return"keccak256";default:throw new Pt("InvalidData",`Invalid hash method: ${e}`)}}},gn={Sha256:"sha256",Mix256:"mix256",Sha512:"sha512",Mix512:"mix512",QCID:"qcid",Blake2s256:"blake2s256",MixBlake2s256:"mixblake2s256",Keccak256:"keccak256",MixKeccak256:"mixkeccak256",isChunkType(e){switch(e){case"sha256":case"mix256":case"sha512":case"mix512":case"qcid":case"blake2s256":case"mixblake2s256":case"keccak256":case"mixkeccak256":return!0;default:return!1}},isMix(e){switch(e){case"mix256":case"mix512":case"mixblake2s256":case"mixkeccak256":case"qcid":return!0;default:return!1}},fromHashType(e,t){switch(e){case"sha256":return t?"mix256":"sha256";case"sha512":return t?"mix512":"sha512";case"qcid":if(!t)throw new Pt("InvalidObjType","QCID must be mix hash");return"qcid";case"blake2s256":return t?"mixblake2s256":"blake2s256";case"keccak256":return t?"mixkeccak256":"keccak256"}},toHashMethod(e){switch(e){case"sha256":case"mix256":return"sha256";case"sha512":case"mix512":return"sha512";case"qcid":return"qcid";case"blake2s256":case"mixblake2s256":return"blake2s256";case"keccak256":case"mixkeccak256":return"keccak256";default:throw new Pt("InvalidObjType",`invalid chunk type: ${e}`)}}};class _n{constructor(e,t){this.objType=e,this.objHash=t}static fromString(e){const t=e.split(":");if(1===t.length){const e=hn(t[0]);let n=-1;for(let t=0;t<e.length;t++)if(58===e[t]){n=t;break}if(n<0)throw new Pt("InvalidId","separator ':' not found");const i=Mn(e.subarray(0,n)),r=e.slice(n+1);return new _n(i,r)}if(2===t.length)return new _n(t[0],cn(t[1]));throw new Pt("InvalidId",e)}static fromBytes(e){if(e.length<3)throw new Pt("InvalidId","objid bytes too short");let t=-1;for(let r=0;r<e.length;r++)if(58===e[r]){t=r;break}if(t<0)throw new Pt("InvalidId","separator ':' not found");const n=Mn(e.subarray(0,t)),i=e.slice(t+1);return new _n(n,i)}static fromValue(e){if("string"==typeof e)return _n.fromString(e);throw new Pt("InvalidData","ObjId MUST be string")}static fromHostname(e){const t=e.split(".")[0];return _n.fromString(t)}static fromPath(e){const t=e.split("/");for(let n=0;n<t.length;n++){const e=t[n];if(0!==e.length)try{const i=_n.fromString(e);return n<t.length-1?{objId:i,subPath:"/"+t.slice(n+1).join("/")}:{objId:i,subPath:null}}catch{}}throw new Pt("InvalidId",`no objid found in path: ${e}`)}static fromRaw(e,t){return new _n(e,t)}isChunk(){return gn.isChunkType(this.objType)}isChunkList(){return this.objType===Qt}isJson(){return!this.isChunk()&&!this.isContainer()&&this.objType!==Ft}isDirObject(){return this.objType===Mt}isFileObject(){return this.objType===Rt}isContainer(){switch(this.objType){case Mt:case Yt:case qt:case Wt:case Zt:case Xt:case Gt:case Vt:case Qt:case en:case tn:return!0;default:return!1}}isBigContainer(){switch(this.objType){case Yt:case Wt:case Xt:case Vt:case en:return!0;default:return!1}}toString(){return`${this.objType}:${sn(this.objHash)}`}toFilename(){return`${sn(this.objHash)}.${this.objType}`}toBase32(){return un(this.toBytes())}toBytes(){const e=Rn(this.objType),t=new Uint8Array(e.length+1+this.objHash.length);return t.set(e,0),t[e.length]=58,t.set(this.objHash,e.length+1),t}toJSON(){return this.toString()}equals(e){if(this.objType!==e.objType)return!1;if(this.objHash.length!==e.objHash.length)return!1;for(let t=0;t<this.objHash.length;t++)if(this.objHash[t]!==e.objHash[t])return!1;return!0}}class vn{constructor(e,t){this.chunkType=e,this.hashResult=t}static defaultChunkType(){return"mix256"}static fromString(e){const t=_n.fromString(e);if(!t.isChunk())throw new Pt("InvalidId",`invalid chunk id: ${e}`);return new vn(t.objType,t.objHash)}static fromObjId(e){return new vn(e.objType,new Uint8Array(e.objHash))}static fromBytes(e){const t=_n.fromBytes(e);return new vn(t.objType,t.objHash)}static fromHashResult(e,t){return new vn(t,new Uint8Array(e))}static fromMixHashResult(e,t,n){return new vn(n,vn.mixLengthAndHashResult(e,t))}static fromMixHashResultByHashMethod(e,t,n){const i=gn.fromHashType(n,!0);return new vn(i,vn.mixLengthAndHashResult(e,t))}static fromSha256Result(e){return new vn("sha256",new Uint8Array(e))}static fromMix256Result(e,t){return new vn("mix256",vn.mixLengthAndHashResult(e,t))}static mixLengthAndHashResult(e,t){const n=ln(e),i=new Uint8Array(n.length+t.length);return i.set(n,0),i.set(t,n.length),i}toObjId(){return new _n(this.chunkType,new Uint8Array(this.hashResult))}toString(){return`${this.chunkType}:${sn(this.hashResult)}`}toBase32(){const e=Rn(this.chunkType),t=new Uint8Array(e.length+1+this.hashResult.length);return t.set(e,0),t[e.length]=58,t.set(this.hashResult,e.length+1),un(t)}toDidString(){return`did:${this.chunkType}:${sn(this.hashResult)}`}toBytes(){return this.toObjId().toBytes()}toJSON(){return this.toString()}getLength(){if(0===this.hashResult.length)return null;if(!gn.isMix(this.chunkType))return null;try{const[e]=dn(this.hashResult,0);return e}catch{return null}}equalsHash(e){if(this.hashResult.length!==e.length)return!1;for(let t=0;t<this.hashResult.length;t++)if(this.hashResult[t]!==e[t])return!1;return!0}}class In{genObjId(){return jn(this.getObjType(),this.toJSON())}}function Sn(e,t){const n=wn(t);return _n.fromRaw(e,n)}function jn(e,t){const n=yn(t);return[Sn(e,n),n]}function kn(e,t){const[n]=jn(e.objType,t);return e.equals(n)}function On(e){if(e.indexOf("{")>=0)try{return JSON.parse(e)}catch(t){throw new Pt("InvalidId",`failed to parse obj_str: ${t.message}`)}throw new Pt("Unsupported","JWT-encoded named objects are not supported in this TypeScript port")}class xn{constructor(e={}){this.did=e.did??null,this.name=e.name??"",this.author=e.author??"",this.owner=e.owner??"",this.create_time=e.create_time??0,this.last_update_time=e.last_update_time??0,this.copyright=e.copyright??null,this.tags=e.tags??[],this.categories=e.categories??[],this.base_on=e.base_on??null,this.directory=e.directory??{},this.references=e.references??{},this.exp=e.exp??0}toJSON(){const e={};return null!=this.did&&(e.did=this.did),this.name.length>0&&(e.name=this.name),this.author.length>0&&(e.author=this.author),this.owner.length>0&&(e.owner=this.owner),e.create_time=this.create_time,e.last_update_time=this.last_update_time,null!=this.copyright&&(e.copyright=this.copyright),this.tags.length>0&&(e.tags=this.tags),this.categories.length>0&&(e.categories=this.categories),null!=this.base_on&&(e.base_on=this.base_on.toString()),Object.keys(this.directory).length>0&&(e.directory=this.directory),Object.keys(this.references).length>0&&(e.references=this.references),0!==this.exp&&(e.exp=this.exp),e}}function En(){return Math.floor(Date.now()/1e3)}class Nn extends In{constructor(e,t,n){super(),this.content_obj=new xn({name:e}),this.size=t,this.content=n,this.meta={}}static fromJSON(e){const t=new Nn("",0,""),n={},i={},r=new Set(["did","name","author","owner","create_time","last_update_time","copyright","tags","categories","base_on","directory","references","exp"]);for(const[o,s]of Object.entries(e))"size"===o?t.size=s??0:"content"===o?t.content=s??"":r.has(o)?"base_on"===o&&"string"==typeof s?n.base_on=_n.fromString(s):n[o]=s:i[o]=s;return t.content_obj=new xn(n),t.meta=i,t}getObjType(){return Rt}toJSON(){const e={...this.content_obj.toJSON()};0!==this.size&&(e.size=this.size),this.content.length>0&&(e.content=this.content);for(const[t,n]of Object.entries(this.meta))e[t]=n;return e}}class Tn extends In{constructor(e,t,n,i){super();const r=En();this.path=e,this.target=t,this.uptime=n??r,this.exp=i??r+94608e3}static fromJSON(e){const t=String(e.path??""),n=_n.fromString(String(e.target??"")),i=Number(e.uptime??0),r=Number(e.exp??0);return new Tn(t,n,i,r)}getObjType(){return Ut}toJSON(){return{path:this.path,uptime:this.uptime,target:this.target.toString(),exp:this.exp}}}class Dn extends In{constructor(e,t,n,i,r){super();const o=En();this.content_id=e.toString(),this.content_obj=t,this.curator=n,this.editor=[],this.meta=null,this.rank=i,this.collection=r,this.review_url=null,this.iat=o,this.exp=o+31104e3}static fromJSON(e){const t=new Dn(_n.fromString(String(e.content_id??"")),e.content_obj??null,String(e.curator??""),Number(e.rank??0),Array.isArray(e.collection)?e.collection.slice():[]);return t.content_id=String(e.content_id??""),t.editor=Array.isArray(e.editor)?e.editor.slice():[],t.meta=e.meta??null,t.review_url="string"==typeof e.review_url?e.review_url:null,t.iat=Number(e.iat??0),t.exp=Number(e.exp??0),t}getObjType(){return Lt}toJSON(){const e={content_id:this.content_id,content_obj:this.content_obj,curator:this.curator,editor:this.editor,meta:this.meta,rank:this.rank,iat:this.iat,exp:this.exp};return this.collection.length>0&&(e.collection=this.collection),null!=this.review_url&&(e.review_url=this.review_url),e}}const An={fromObjId:e=>({kind:"objId",objId:e}),fromObject:(e,t)=>({kind:"object",objType:e,obj:t}),fromObjectJwt:(e,t)=>({kind:"objectJwt",objType:e,jwt:t}),getObjType(e){switch(e.kind){case"objId":return e.objId.objType;case"object":case"objectJwt":return e.objType}},getObjId(e){switch(e.kind){case"objId":return[e.objId,""];case"object":return jn(e.objType,e.obj);case"objectJwt":throw new Pt("Unsupported","JWT-encoded SimpleMapItem requires JWT decoding (not implemented in TS port)")}},toJSON(e){switch(e.kind){case"objId":return e.objId.toString();case"object":return{obj_type:e.objType,body:e.obj};case"objectJwt":return{obj_type:e.objType,jwt:e.jwt}}},fromJSON(e){if("string"==typeof e)return{kind:"objId",objId:_n.fromString(e)};if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e,n=t.obj_type;if("string"!=typeof n)throw new Pt("InvalidData","SimpleMapItem must have obj_type field");if("string"==typeof t.jwt)return{kind:"objectJwt",objType:n,jwt:t.jwt};if("body"in t)return{kind:"object",objType:n,obj:t.body};throw new Pt("InvalidData","SimpleMapItem must have body or jwt field")}throw new Pt("InvalidData","SimpleMapItem must be string or object")}};class Jn{constructor(){this.body=new Map}static fromJSON(e){const t=new Jn;if(!e||"object"!=typeof e)throw new Pt("InvalidData","SimpleObjectMap must be an object");const n=e.body;if(null==n)return t;if("object"!=typeof n||Array.isArray(n))throw new Pt("InvalidData","SimpleObjectMap.body must be an object");for(const[i,r]of Object.entries(n))t.body.set(i,An.fromJSON(r));return t}genObjIdWithRealObj(e,t){const n={};for(const[i,r]of this.body){const[e]=An.getObjId(r);n[i]=e.toString()}return t.body=n,jn(e,t)}get size(){return this.body.size}isEmpty(){return 0===this.body.size}get(e){return this.body.get(e)}set(e,t){this.body.set(e,t)}delete(e){return this.body.delete(e)}has(e){return this.body.has(e)}keys(){return this.body.keys()}values(){return this.body.values()}entries(){return this.body.entries()}toJSON(){const e={};for(const[t,n]of this.body)e[t]=An.toJSON(n);return{body:e}}}class Cn extends In{constructor(e){super(),this.content_obj=null!=e?new xn({name:e}):new xn,this.meta={},this.total_size=0,this.file_count=0,this.file_size=0,this.object_map=new Jn}static fromJSON(e){const t=new Cn,n=new Set(["did","name","author","owner","create_time","last_update_time","copyright","tags","categories","base_on","directory","references","exp"]),i={};for(const[r,o]of Object.entries(e))if("meta"===r)t.meta=o??{};else if("total_size"===r)t.total_size=Number(o??0);else if("file_count"===r)t.file_count=Number(o??0);else if("file_size"===r)t.file_size=Number(o??0);else if("body"===r){const e=o;if(e)for(const[n,i]of Object.entries(e))t.object_map.set(n,An.fromJSON(i))}else n.has(r)&&("base_on"===r&&"string"==typeof o?i.base_on=_n.fromString(o):i[r]=o);return t.content_obj=new xn(i),t}getObjType(){return Mt}toJSON(){const e={...this.content_obj.toJSON()};return Object.keys(this.meta).length>0&&(e.meta=this.meta),e.total_size=this.total_size,e.file_count=this.file_count,e.file_size=this.file_size,e.body=this.object_map.toJSON().body,e}genObjId(){const e={...this.content_obj.toJSON()};return e.total_size=this.total_size,e.file_count=this.file_count,e.file_size=this.file_size,this.object_map.genObjIdWithRealObj(Mt,e)}get size(){return this.object_map.size}isEmpty(){return this.object_map.isEmpty()}get(e){return this.object_map.get(e)}delete(e){return this.object_map.delete(e)}has(e){return this.object_map.has(e)}keys(){return this.object_map.keys()}values(){return this.object_map.values()}entries(){return this.object_map.entries()}addFile(e,t,n){this.file_size+=n,this.file_count+=1,this.total_size+=n,this.object_map.set(e,An.fromObject(Rt,t))}addDirectory(e,t,n){if(t.objType!==Mt)throw new Pt("InvalidParam","dir_obj_id is not a directory");this.total_size+=n,this.object_map.set(e,An.fromObjId(t))}listEntries(){return Array.from(this.object_map.keys())}isFile(e){const t=this.object_map.get(e);return!!t&&("object"===t.kind&&t.objType===Rt)}isDirectory(e){const t=this.object_map.get(e);if(!t)return!1;switch(t.kind){case"objId":return t.objId.objType===Mt;case"objectJwt":return t.objType===Mt;default:return!1}}}class Kn{constructor(){this.total_size=0,this.body=[]}static fromChunkList(e){const t=new Kn;for(const n of e){const e=n.getLength();if(null==e)throw new Pt("InvalidParam","get chunk length from chunkid failed");t.total_size+=e}return t.body=e.slice(),t}static fromJson(e){let t;try{t=JSON.parse(e)}catch(n){throw new Pt("InvalidParam",`parse chunk list from json failed: ${n.message}`)}return Kn.fromJsonValue(t)}static fromJsonValue(e){if(!Array.isArray(e))throw new Pt("InvalidParam","chunk list must be a JSON array");const t=e.map((e=>{if("string"!=typeof e)throw new Pt("InvalidParam","chunk list item must be a string");return vn.fromString(e)}));return Kn.fromChunkList(t)}appendChunk(e){const t=e.getLength();if(null==t)throw new Pt("InvalidParam","get chunk length from chunkid failed");this.body.push(e),this.total_size+=t}genObjId(){const e=this.body.map((e=>e.toString())),[t,n]=jn(Qt,e),i=vn.mixLengthAndHashResult(this.total_size,t.objHash);return[_n.fromRaw(Qt,i),n]}}class Bn extends In{constructor(e,t,n,i={}){super(),this.source=e,this.relation=t,this.target=n,this.body=i,this.iat=null,this.exp=null}static fromJSON(e){const t=new Set(["source","relation","target","iat","exp"]),n={};for(const[r,o]of Object.entries(e))t.has(r)||(n[r]=o);const i=new Bn(_n.fromString(String(e.source??"")),String(e.relation??""),_n.fromString(String(e.target??"")),n);return i.iat="number"==typeof e.iat?e.iat:null,i.exp="number"==typeof e.exp?e.exp:null,i}static createByLinkData(e,t){switch(t.kind){case"sameAs":return new Bn(e,nn,t.target);case"partOf":return new Bn(e,rn,t.target,{range:{start:t.range.start,end:t.range.end}})}}getLinkData(){switch(this.relation){case nn:return{kind:"sameAs",target:this.target};case rn:{const e=this.body.range;if(!e||"number"!=typeof e.start||"number"!=typeof e.end)throw new Pt("InvalidLink",`invalid range: ${JSON.stringify(this.body.range)}`);return{kind:"partOf",target:this.target,range:{start:e.start,end:e.end}}}default:throw new Pt("InvalidLink",`invalid relation: ${this.relation}`)}}getObjType(){return zt}toJSON(){const e={source:this.source.toString(),relation:this.relation,target:this.target.toString()};for(const[t,n]of Object.entries(this.body))e[t]=n;return null!=this.iat&&(e.iat=this.iat),null!=this.exp&&(e.exp=this.exp),e}}const Hn={fromObjData(e,t){switch(e.objType){case Mt:{let e;try{e=JSON.parse(t)}catch(n){throw new Pt("InvalidParam",`parse dir object from json failed: ${n.message}`)}return{kind:"dir",obj:Cn.fromJSON(e),objStr:t}}case Rt:{let e;try{e=JSON.parse(t)}catch(n){throw new Pt("InvalidParam",`parse file object from json failed: ${n.message}`)}return{kind:"file",obj:Nn.fromJSON(e),objStr:t}}case Qt:return{kind:"chunkList",obj:Kn.fromJson(t),objStr:t};default:throw new Pt("InvalidParam",`Unknown object type: ${e.objType}`)}},getChildObjs(e){switch(e.kind){case"dir":{const t=[];for(const[,n]of e.obj.entries()){const[e,i]=An.getObjId(n);t.push({objId:e,objStr:i.length>0?i:null})}return t}case"file":return 0===e.obj.content.length?[]:[{objId:_n.fromString(e.obj.content),objStr:null}];case"chunkList":return e.obj.body.map((e=>({objId:e.toObjId(),objStr:null})))}}},$n="undefined"!=typeof TextEncoder?new TextEncoder:null,Pn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Rn(e){if($n)return $n.encode(e);const t=[];for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(i<128)t.push(i);else if(i<2048)t.push(192|i>>6,128|63&i);else if(i>=55296&&i<=56319&&n+1<e.length){const r=65536+((1023&i)<<10|1023&e.charCodeAt(++n));t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r)}else t.push(224|i>>12,128|i>>6&63,128|63&i)}return new Uint8Array(t)}function Mn(e){if(Pn)return Pn.decode(e);let t="",n=0;for(;n<e.length;){const i=e[n++];if(i<128)t+=String.fromCharCode(i);else if(i<224)t+=String.fromCharCode((31&i)<<6|63&e[n++]);else if(i<240)t+=String.fromCharCode((15&i)<<12|(63&e[n++])<<6|63&e[n++]);else{const r=((7&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t+=String.fromCharCode(55296+(r>>10),56320+(1023&r))}}return t}const Un=Object.freeze(Object.defineProperty({__proto__:null,BaseContentObject:xn,ChunkId:vn,ChunkType:gn,DEFAULT_HASH_METHOD:"sha256",DirObject:Cn,FileObject:Nn,HashMethod:bn,InclusionProof:Dn,KnownStandardObject:Hn,NamedObjectBase:In,NdnError:Pt,OBJ_TYPE_ACTION:"cyact",OBJ_TYPE_CHUNK_LIST:Vt,OBJ_TYPE_CHUNK_LIST_FIX_SIZE:en,OBJ_TYPE_CHUNK_LIST_SIMPLE:Qt,OBJ_TYPE_CHUNK_LIST_SIMPLE_FIX_SIZE:tn,OBJ_TYPE_DIR:Mt,OBJ_TYPE_FILE:Rt,OBJ_TYPE_INCLUSION_PROOF:Lt,OBJ_TYPE_LIST:Xt,OBJ_TYPE_LIST_SIMPLE:Gt,OBJ_TYPE_MSG:"cymsg",OBJ_TYPE_MSG_RECE:"cymsgr",OBJ_TYPE_OBJMAP:Wt,OBJ_TYPE_OBJMAP_SIMPLE:Zt,OBJ_TYPE_PACK:Ft,OBJ_TYPE_PATH:Ut,OBJ_TYPE_PKG:"pkg",OBJ_TYPE_RELATION:zt,OBJ_TYPE_TRIE:Yt,OBJ_TYPE_TRIE_SIMPLE:qt,ObjId:_n,PathObject:Tn,RELATION_TYPE_PART_OF:rn,RELATION_TYPE_SAME:nn,RelationObject:Bn,SimpleChunkList:Kn,SimpleMapItem:An,SimpleObjectMap:Jn,base32Decode:hn,base32Encode:un,buildNamedObjectByJson:jn,buildObjId:Sn,bytesToHex:sn,canonicalizeJson:mn,extractObjIdByPath:function(e,t){const n=t.split("/").filter((e=>e.length>0));let i=e;for(const o of n){if(null==i)throw new Pt("InvalidParam",`objid path not found: ${t}`);if(Array.isArray(i)){const e=Number(o);if(!Number.isInteger(e)||e<0||e>=i.length)throw new Pt("InvalidParam",`objid path not found: ${t}`);i=i[e]}else{if("object"!=typeof i)throw new Pt("InvalidParam",`objid path not found: ${t}`);if(!(o in i))throw new Pt("InvalidParam",`objid path not found: ${t}`);i=i[o]}}try{return _n.fromValue(i)}catch(r){throw new Pt("InvalidData",`invalid objid at path ${t}: ${r.message}`)}},hexToBytes:cn,loadNamedObj:function(e){return On(e)},loadNamedObjAndVerify:function(e,t){const n=On(t);if(!kn(e,n))throw new Pt("InvalidId",`verify named object failed for obj_id: ${e.toString()}`);return n},loadNamedObjectFromObjStr:On,sha256Bytes:fn,sha256Utf8:wn,toCanonicalJsonString:yn,varintDecode:dn,varintEncode:ln,verifyNamedObject:kn,verifyNamedObjectFromStr:function(e,t){let n;try{n=JSON.parse(t)}catch(i){throw new Pt("InvalidId",`failed to parse obj_str: ${i.message}`)}if(!kn(e,n))throw new Pt("InvalidId",`verify named object failed: ${t}`);return n}},Symbol.toStringTag,{value:"Module"}));exports.ChunkId=vn,exports.DEFAULT_EXPIRE_TIME=je,exports.DID=Ge,exports.DID_OBJECT_SERVICE_ID="#did-object",exports.DID_OBJECT_SERVICE_TYPE=le,exports.DirObject=Cn,exports.FileObject=Nn,exports.NODE_IDENTITY_SCHEMA_V2=de,exports.ObjId=_n,exports.SimpleChunkList=Kn,exports.buckyosGetUnixTimestamp=xe,exports.buildNamedObjectByJson=jn,exports.canonicalize=$t,exports.cleanLocalAccountInfo=function(e){localStorage.removeItem(he(e)),localStorage.removeItem(ue);const t=function(e){if(null==e)return null;try{return JSON.parse(e)}catch{return null}}(localStorage.getItem(ae));(null==t?void 0:t.session_token)&&function(e){const t=e.split(".");if(t.length<2)return null;try{const e=t[1].replace(/-/g,"+").replace(/_/g,"/"),n=e+"=".repeat((4-e.length%4)%4),i=JSON.parse(atob(n));if("string"==typeof i.appid&&i.appid.trim().length>0)return i.appid}catch{return null}return null}(t.session_token)===e&&localStorage.removeItem(ae);let n={path:"/",expires:new Date(0),secure:!0,sameSite:"Lax"};document.cookie=`${e}_token=; ${Object.entries(n).map((([e,t])=>`${e}=${t}`)).join("; ")}`},exports.commonjsGlobal=Bt,exports.createJwkByX=ze,exports.decodeJwtClaimWithoutVerify=Ye,exports.deviceDocumentToOrderedJson=jt,exports.deviceMiniDocumentToJwt=bt,exports.encodeDeviceDocument=wt,exports.encodeZoneBootDocument=ht,exports.encodeZoneDocument=_t,exports.getBrowserUserInfo=function(){return function(e){if(null==e)return null;try{const t=JSON.parse(e),n="string"==typeof t.user_id?t.user_id.trim():"",i="string"==typeof t.user_type?t.user_type.trim():"",r="string"==typeof t.user_name?t.user_name.trim():"string"==typeof t.show_name?t.show_name.trim():"";return n&&i?{user_name:r||n,user_id:n,user_type:i}:null}catch{return null}}(localStorage.getItem(ue))},exports.getDefaultExportFromCjs=Ht,exports.getDidIdentifier=function(e){if("string"!=typeof e||!e.startsWith("did:"))return null;const t=e.split(":");return t.length>=3?t.slice(2).join(":"):null},exports.getDidMethod=function(e){if("string"!=typeof e||!e.startsWith("did:"))return null;const t=e.split(":");return t.length>=3?t[1]:null},exports.getPublicKeyXFromPrivatePem=Ue,exports.getXFromJwk=Le,exports.hashPassword=function(e,t,n=null){const i=new ce("SHA-256","TEXT",{encoding:"UTF8"});i.update(t+e+".buckyos");let r=i.getHash("B64");if(null==n)return r;const o=new ce("SHA-256","TEXT",{encoding:"UTF8"});let s=r+n.toString();return o.update(s),o.getHash("B64")},exports.isBuckyOSAgentDocument=ge,exports.isBuckyOSDIDObjectCard=ve,exports.isBuckyOSDeviceDocument=be,exports.isBuckyOSDeviceMiniDocument=ye,exports.isBuckyOSLocalNodeIdentityConfig=function(e){return fe(e)&&e.schema===de&&"string"==typeof e.zone_did&&"string"==typeof e.owner_did&&fe(e.owner_public_key)&&"string"==typeof e.device_name&&"string"==typeof e.device_did&&"number"==typeof e.zone_iat},exports.isBuckyOSNodeIdentityConfig=function(e){return fe(e)&&"string"==typeof e.zone_did&&fe(e.owner_public_key)&&"string"==typeof e.owner_did&&"string"==typeof e.device_doc_jwt&&"string"==typeof e.device_mini_doc_jwt&&"number"==typeof e.zone_iat},exports.isBuckyOSOwnerDocument=me,exports.isBuckyOSZoneBootDocument=function(e){return fe(e)&&Array.isArray(e.oods)&&e.oods.every((e=>"string"==typeof e))&&"number"==typeof e.exp},exports.isBuckyOSZoneConfig=function(e){return fe(e)&&"string"==typeof e.zone_document},exports.isBuckyOSZoneDocument=_e,exports.isW3CDIDDocumentBase=pe,exports.namelib=Kt,exports.ndn_types=Un,exports.newDeviceDocumentByJwk=dt,exports.newDeviceDocumentByMiniDocument=ft,exports.newDeviceMiniDocument=mt,exports.newDeviceMiniDocumentByDeviceDocument=yt,exports.newOwnerDocument=rt,exports.newZoneBootDocument=ut,exports.newZoneDocument=at,exports.oodDescriptionToString=Qe,exports.ownerDocumentSetDefaultZoneDid=ot,exports.ownerDocumentToOrderedJson=It,exports.parseBuckyOSDIDDocument=function(e){return me(e)||ge(e)||be(e)||_e(e)||ve(e)?e:null},exports.parseBuckyOSDeviceMiniDocument=function(e){return ye(e)?e:null},exports.parseBuckyOSOwnerDocument=function(e){return me(e)?e:null},exports.parseOODDescription=Ve,exports.parseW3CDIDDocumentBase=function(e){return pe(e)?e:null},exports.saveBrowserUserInfo=function(e){localStorage.setItem(ue,JSON.stringify(e))},exports.saveLocalAccountInfo=function(e,t){if(null==t.session_token)return void console.error("session_token is null,can't save account info");localStorage.setItem(he(e),JSON.stringify(t));let n={path:"/",expires:new Date(Date.now()+2592e6),secure:!0,sameSite:"Lax"};document.cookie=`${e}_token=${t.session_token}; ${Object.entries(n).map((([e,t])=>`${e}=${t}`)).join("; ")}`},exports.sha256Bytes=fn,exports.signJwtEdDSA=Fe,exports.verifyJwtEdDSA=qe,exports.zoneDocumentToOrderedJson=St;
|
|
2
|
-
//# sourceMappingURL=ndn_types-44c69036.js.map
|