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
|
@@ -0,0 +1,2 @@
|
|
|
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 v(e,t,n){return e&t^~e&n}function _(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),v(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),_(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),v(s,a,u),c[f],w[f]),d=S(I(n),_(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 B{constructor(e,t){this.N=e,this.I=t}}function K(e,t){let n;return t>32?(n=64-t,new B(e.I<<t|e.N>>>n,e.N<<t|e.I>>>n)):0!==t?(n=32-t,new B(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 B(e.N>>>t|e.I<<n,e.I>>>t|e.N<<n)):(n=64-t,new B(e.I>>>t|e.N<<n,e.N>>>t|e.I<<n))}function $(e,t){return new B(e.N>>>t,e.I>>>t|e.N<<32-t)}function R(e,t,n){return new B(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 P(e){const t=H(e,28),n=H(e,34),i=H(e,39);return new B(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 B((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 B((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 B((65535&s)<<16|65535&o,c)}function z(e,t){return new B(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 B(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 B(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 B(t.N^n.N^i.N,t.I^n.I^i.I)}const W=[new B(c[0],3609767458),new B(c[1],602891725),new B(c[2],3964484399),new B(c[3],2173295548),new B(c[4],4081628472),new B(c[5],3053834265),new B(c[6],2937671579),new B(c[7],3664609560),new B(c[8],2734883394),new B(c[9],1164996542),new B(c[10],1323610764),new B(c[11],3590304994),new B(c[12],4068182383),new B(c[13],991336113),new B(c[14],633803317),new B(c[15],3479774868),new B(c[16],2666613458),new B(c[17],944711139),new B(c[18],2341262773),new B(c[19],2007800933),new B(c[20],1495990901),new B(c[21],1856431235),new B(c[22],3175218132),new B(c[23],2198950837),new B(c[24],3999719339),new B(c[25],766784016),new B(c[26],2566594879),new B(c[27],3203337956),new B(c[28],1034457026),new B(c[29],2466948901),new B(c[30],3758326383),new B(c[31],168717936),new B(c[32],1188179964),new B(c[33],1546045734),new B(c[34],1522805485),new B(c[35],2643833823),new B(c[36],2343527390),new B(c[37],1014477480),new B(c[38],1206759142),new B(c[39],344077627),new B(c[40],1290863460),new B(c[41],3158454273),new B(c[42],3505952657),new B(c[43],106217008),new B(c[44],3606008344),new B(c[45],1432725776),new B(c[46],1467031594),new B(c[47],851169720),new B(c[48],3100823752),new B(c[49],1363258195),new B(c[50],3750685593),new B(c[51],3785050280),new B(c[52],3318307427),new B(c[53],3812723403),new B(c[54],2003034995),new B(c[55],3602036899),new B(c[56],1575990012),new B(c[57],1125592928),new B(c[58],2716904306),new B(c[59],442776044),new B(c[60],593698344),new B(c[61],3733110249),new B(c[62],2999351573),new B(c[63],3815920427),new B(3391569614,3928383900),new B(3515267271,566280711),new B(3940187606,3454069534),new B(4118630271,4000239992),new B(116418474,1914138554),new B(174292421,2731055270),new B(289380356,3203993006),new B(460393269,320620315),new B(685471733,587496836),new B(852142971,1086792851),new B(1017036298,365543100),new B(1126000580,2618297676),new B(1288033470,3409855158),new B(1501505948,4234509866),new B(1607167915,987167468),new B(1816402316,1246189591)];function Z(e){return"SHA-384"===e?[new B(3418070365,a[0]),new B(1654270250,a[1]),new B(2438529370,a[2]),new B(355462360,a[3]),new B(1731405415,a[4]),new B(41048885895,a[5]),new B(3675008525,a[6]),new B(1203062813,a[7])]:[new B(u[0],4089235720),new B(u[1],2227873595),new B(u[2],4271175723),new B(u[3],1595750129),new B(u[4],2917565137),new B(u[5],725511199),new B(u[6],4215389547),new B(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 B(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 B((p=s).N&m.N^~p.N&y.N,p.I&m.I^~p.I&y.I)),W[d],w[d]),l=M(P(n),R(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 B(0,1),new B(0,32898),new B(2147483648,32906),new B(2147483648,2147516416),new B(0,32907),new B(0,2147483649),new B(2147483648,2147516545),new B(2147483648,32777),new B(0,138),new B(0,136),new B(0,2147516425),new B(0,2147483658),new B(0,2147516555),new B(2147483648,139),new B(2147483648,32905),new B(2147483648,32771),new B(2147483648,32770),new B(2147483648,128),new B(0,32778),new B(2147483648,2147483658),new B(2147483648,2147516545),new B(2147483648,32896),new B(0,2147483649),new B(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 B(0,0),new B(0,0),new B(0,0),new B(0,0),new B(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 B(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 B(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],K(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]=K(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 B(~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",he="buckyos.identity";function le(e){return`buckyos.account_info.${e}`}const de="DIDObjectService",fe="buckyos.node_identity.v2";function we(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function pe(e){return"string"==typeof e||Array.isArray(e)&&e.every((e=>"string"==typeof e))}function me(e){return!!we(e)&&(pe(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 ye(e){return me(e)&&"string"==typeof e.name&&("string"==typeof e.display_name||"string"==typeof e.displayName||"string"==typeof e.full_name)}function be(e){return we(e)&&"string"==typeof e.n&&"string"==typeof e.x&&"number"==typeof e.exp}function ge(e){return me(e)&&"string"==typeof e.owner&&"string"==typeof e.device_type&&"string"==typeof e.name}function ve(e){return me(e)&&"string"==typeof e.owner&&we(e.httpServicePorts)}function _e(e){return me(e)&&"string"==typeof e.hostname&&"string"==typeof e.owner&&Array.isArray(e.oods)&&"string"==typeof e.boot_jwt}function Ie(e){if(!we(e)||!pe(e["@context"])||"string"!=typeof e.id)return!1;const t=e.service;return Array.isArray(t)&&t.some((e=>we(e)&&e.type===de))}const Se="https://www.w3.org/ns/did/v1",je="https://buckyos.org/ns",ke=15768e4,Oe=31536e4;function xe(e){return[Se,`${je}/${e}/v1`]}function Ee(){return Math.floor(Date.now()/1e3)}const Ne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Te(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+=Ne[i>>2],t+=Ne[(3&i)<<4|r>>4],t+=n+1<e.length?Ne[(15&r)<<2|o>>6]:"=",t+=n+2<e.length?Ne[63&o]:"="}return t}function De(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=Ne.indexOf(t[o]),n=Ne.indexOf(t[o+1]),s=o+2<t.length?Ne.indexOf(t[o+2]):-1,c=o+3<t.length?Ne.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 Ae(e){return Te(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Je(e){return De(e.replace(/-/g,"+").replace(/_/g,"/"))}function Ce(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 Be(e){return Ae(Ce(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}(Je(e))}async function He(){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 $e(){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 Re=new Uint8Array([48,42,48,5,6,3,43,101,112,3,33,0]);function Pe(e){return De(e.replace(/-----BEGIN [^-]+-----/g,"").replace(/-----END [^-]+-----/g,"").replace(/\s+/g,""))}function Me(e){const t=Te(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 Ue(e){const t=Je(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}(Re,t)}async function Le(e){const t=await He();if(t){const n=t.createPrivateKey({key:e,format:"pem"});return t.createPublicKey(n).export({format:"jwk"}).x}const n=$e(),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 ze(e){const t=e.x;if("string"!=typeof t||0===t.length)throw new Error("namelib: invalid jwk, missing x");return t}function Fe(e){return{kty:"OKP",crv:"Ed25519",x:e}}async function Ye(e,t,n){const i=`${Be(JSON.stringify(n??{alg:"EdDSA"}))}.${Be(JSON.stringify(e))}`,r=await async function(e,t){const n=await He();if(n){const i=n.createPrivateKey({key:t,format:"pem"});return new Uint8Array(n.sign(null,e,i))}const i=$e(),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)}(Ce(i),t);return`${i}.${Ae(r)}`}function qe(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 We(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 He();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=$e(),o=Ue(n),s=await r.importKey("spki",o,{name:"Ed25519"},!1,["verify"]);return r.verify({name:"Ed25519"},s,t,e)}(Ce(r),Je(n[2]),t);if(!o)throw new Error("namelib: jwt signature verify failed");return JSON.parse(Ke(n[1]))}function Ze(e){return e.startsWith("{")||e.startsWith("[")?{type:"json",value:JSON.parse(e)}:{type:"jwt",jwt:e}}function Xe(e){return"jwt"===e.type?qe(e.jwt):e.value}let Ge=null;class Ve{constructor(e,t){this.method=e,this.id=t}static undefined(){return new Ve("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=Ve.fromHostName(e);if(t)return t;throw new Error(`namelib: invalid did ${e}`)}return new Ve(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 Ve(t.slice(n+1),t.slice(0,n))}if(Ge)for(const t of Object.keys(Ge)){const n=Ge[t];if(e.endsWith(n)){if(e===n)break;const i=e.slice(0,e.length-n.length-1);return new Ve(t,i)}}return new Ve("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 Ve(t,i)}if(e.endsWith(".did")){const t=e.slice(0,-4),n=t.lastIndexOf(".");if(n>0&&n<t.length-1)return new Ve(t.slice(n+1),t.slice(0,n))}return new Ve("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(nt(e))return null;const t=e.indexOf(".");if(t<0)return null;const n=e.slice(t+1);return n.includes(".")?new Ve("web",n):null}case"bns":{const t=e.indexOf(".");return t<0?null:new Ve("bns",e.slice(t+1))}default:return null}}toFilename(){const e="0123456789ABCDEF",t=Ce(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?Je(this.id):null}getAuthKeyJwk(){return"dev"===this.method?Fe(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(Ge){const t=Ge[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 Qe(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),!nt(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 it({name:c,nodeType:n,netId:t,ip:o})}function et(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 tt(e){return"Gateway"===e||"OOD"===e}function nt(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 it(e){for(const t of Object.keys(e))void 0===e[t]&&delete e[t];return e}function rt(e){return e instanceof Ve?e:Ve.fromStr(e)}function ot(e){const t=rt(e.did),n=e.now??Ee(),i=t.toString();return{"@context":xe("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+Oe,iat:n,version_seq:0,name:e.name,display_name:e.displayName,zone_binding_model_version:2}}function st(e,t){const n=rt(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,ct(e)}function ct(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=rt(n);r.push({id:i,type:"DIDDoc",serviceEndpoint:`https://${t.toHostName()}/resolve/${e.id}`})}e.service=r}function at(e,t){const n=rt(t).toString();return(e.binded_zone_list??[]).includes(n)}function ut(e){const t=rt(e.id),n=rt(e.ownerDid),i=e.now??Ee(),r=t.toString();return{"@context":xe("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+Oe,iat:i,version_seq:0,hostname:t.toHostName(),owner:n.toString(),oods:[],boot_jwt:""}}function ht(e){return it({id:void 0!==e.id?rt(e.id).toString():void 0,oods:[...e.oods],sn:e.sn,exp:e.exp,owner:void 0!==e.owner?rt(e.owner).toString():void 0,owner_key:e.ownerKey})}async function lt(e,t){const{id:n,oods:i,sn:r,exp:o,owner:s,owner_key:c,...a}=e;return Ye(it({id:n,oods:i,sn:r,exp:o,owner:s,...a,owner_key:c}),t)}function dt(e){const t=e.now??Ee(),n=`did:dev:${e.pkx}`;return{"@context":xe("device"),id:n,verificationMethod:[{type:"Ed25519VerificationKey2020",id:"#main_key",controller:n,publicKeyJwk:Fe(e.pkx)}],authentication:["#main_key"],assertion_method:["#main_key"],capabilityInvocation:["#main_key"],exp:t+ke,iat:t,version_seq:0,owner:Ve.undefined().toString(),device_type:"ood",name:e.name}}function ft(e,t,n){return dt({name:e,pkx:ze(t),now:n})}function wt(e,t,n,i){const r=`did:dev:${t.x}`,o={"@context":xe("device"),id:r,verificationMethod:[{type:"Ed25519VerificationKey2020",id:"#main_key",controller:r,publicKeyJwk:Fe(t.x)}],authentication:["#main_key"],assertion_method:["#main_key"],capabilityInvocation:["#main_key"],exp:t.exp,iat:t.exp-ke,version_seq:0,zone_did:rt(n).toString(),owner:rt(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 pt(e,t){if(void 0===e.version_seq)throw new Error("namelib: DeviceDocument version_seq is required when encoding as JWT");return Ye(mt(e),t)}function mt(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:v,ddns_sn_url:_,support_container:I,capbilities:S,...j}=e,k=l??d;return it({"@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:v,ddns_sn_url:_,support_container:!1!==I&&void 0,capbilities:S&&Object.keys(S).length>0?S:void 0})}function yt(e){return it({n:e.name,x:e.x,p:e.rtcpPort,exp:e.exp})}function bt(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 yt({name:e.name,x:ze(t.publicKeyJwk),rtcpPort:e.rtcp_port,exp:e.exp})}async function gt(e,t){const{n:n,x:i,p:r,exp:o,...s}=e;return Ye(it({n:n,x:i,p:r,exp:o,...s}),t)}function vt(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:v,wallets:_,...I}=e,S=f??w;return it({"@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:v&&v.length>0?v:void 0,wallets:_&&Object.keys(_).length>0?_: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 Ye(It(e),t)}function It(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,...v}=e,_=l??d;return it({"@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,...v,keyScope:_&&Object.keys(_).length>0?_: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 St(e){return vt(e)}function jt(e){return It(e)}function kt(e){return mt(e)}function Ot(e){return e.keyScope??e["buckyos:scopes"]??{}}function xt(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 Et(e,t){return Ot(e)[t]??null}function Nt(e){return Object.keys(Ot(e)).length>0}function Tt(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(Ie(e)){const t=e.assertionMethod;if(Array.isArray(t)&&t.length>0)return t}return null}function Dt(e,t){const n=e.id;if(t.startsWith(n)){const e=t.slice(n.length);if(e.startsWith("#"))return e}return t}function At(e,t){return t.startsWith("#")?`${e.id}${t}`:t}function Jt(e,t,n){return t===n||Dt(e,t)===Dt(e,n)||At(e,t)===At(e,n)}function Ct(e,t){for(const n of t){const t=xt(e,Dt(e,n));if(t)return[n,t]}return null}function Bt(e){const t="string"==typeof e?Ze(e):e,n="jwt"===t.type,i=Xe(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)===de)))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:je,DEFAULT_EXPIRE_TIME:ke,DID:Ve,DID_CORE_CONTEXT:Se,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:Je,base64UrlDecodeToString:Ke,base64UrlEncodeBytes:Ae,base64UrlEncodeString:Be,buckyosContext:xe,buckyosGetUnixTimestamp:Ee,createJwkByX:Fe,decodeDeviceDocument:async function(e,t){const n=t?await We(e,t):qe(e);if(void 0===n.version_seq)throw new Error("namelib: DeviceDocument version_seq is required when decoding from JWT");return n},decodeJwtClaimWithoutVerify:qe,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 We(e,t):qe(e)},derToPkcs8Pem:Me,deviceDocumentToOrderedJson:kt,deviceMiniDocumentFromJwt:async function(e,t){return t?await We(e,t):qe(e)},deviceMiniDocumentToJwt:gt,encodeDeviceDocument:pt,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 Ye(vt(e),t)},encodeZoneBootDocument:lt,encodeZoneDocument:_t,encodedDocumentFromStr:Ze,encodedDocumentToJsonValue:Xe,encodedDocumentToString:function(e){return"jwt"===e.type?e.jwt:JSON.stringify(e.value)},expandLocalKeyId:At,generateEd25519KeyPair:async function(){const e=await He();if(e){const{privateKey:t,publicKey:n}=e.generateKeyPairSync("ed25519");return{privateKeyPem:t.export({type:"pkcs8",format:"pem"}).toString(),publicKeyJwk:Fe(n.export({format:"jwk"}).x)}}const t=$e(),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:Me(i),publicKeyJwk:Fe(r.x)}},getDeviceDidFromJwk:function(e){return`did:dev:${ze(e)}`},getDidDocType:function(e){return e.docType},getDocumentAuthKey:xt,getDocumentDefaultKey:function(e){const t=(e.verificationMethod??[]).find((e=>"#main_key"===e.id));return t?t.publicKeyJwk:null},getDocumentKeyScope:Ot,getKeyByScope:function(e,t){const n=Et(e,t);if(n)return Ct(e,n);if(Nt(e))return null;const i=Tt(e);if(i){const t=Ct(e,i);if(t)return t}const r=xt(e);return r?["",r]:null},getKeyFromKeyIds:Ct,getKeyIdsByScope:Et,getKnownWeb3BridgeConfig:function(){return Ge},getPublicKeyXFromPrivatePem:Le,getStandardScopeKeyIds:Tt,getXFromJwk:ze,hasKeyScope:Nt,isKeyAllowedInScope:function(e,t,n){const i=Et(e,t);if(i)return i.some((t=>Jt(e,t,n)));if(Nt(e))return!1;const r=Tt(e);return r?r.some((t=>Jt(e,t,n))):null!==xt(e,Dt(e,n))},isSameDocumentKeyId:Jt,newDeviceDocument:dt,newDeviceDocumentByJwk:ft,newDeviceDocumentByMiniDocument:wt,newDeviceMiniDocument:yt,newDeviceMiniDocumentByDeviceDocument:bt,newNodeIdentityConfig:function(e){return{zone_did:rt(e.zoneDid).toString(),owner_public_key:e.ownerPublicKey,owner_did:rt(e.ownerDid).toString(),device_doc_jwt:e.deviceDocJwt,device_mini_doc_jwt:e.deviceMiniDocJwt,zone_iat:e.zoneIat}},newOwnerDocument:ot,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!==Je(i).length)throw new Error("namelib: invalid pkx: x length must be 32 bytes");const r=Fe(i);if(1===n.length){const e=Ve.fromStr(t),n=e.id;return ot({did:e,name:n,displayName:`${n}@${t}`,publicKeyJwk:r})}if(n.length>=3){const e=n[2];return ot({did:new Ve(n[1],n[2]),name:e,displayName:`${e}@${t}`,publicKeyJwk:r})}throw new Error(`namelib: invalid pkx: ${e}`)},newZoneBootDocument:ht,newZoneDocument:ut,normalizeKeyIdForLocalLookup:Dt,oodDescriptionToString:et,oodNodeTypeIsGateway:tt,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":at(e,t)?"bound_v2":"unbound_v2"},ownerDocumentIsBoundToZone:at,ownerDocumentRemoveBoundZone:function(e,t){var n;const i=rt(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,ct(e),o},ownerDocumentSetDefaultZoneDid:st,ownerDocumentToOrderedJson:St,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=Xe(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:Bt,parseDidDocAs:function(e,t){const n=Bt(e);if(n.docType!==t)throw new Error(`namelib: expected ${t} document, got ${n.docType}`);return n.doc},parseOODDescription:Qe,pemToDer:Pe,resetKnownWeb3BridgeConfigForTest:function(){Ge=null},setKnownWeb3BridgeConfig:function(e){return null===Ge&&(Ge={...e},!0)},signJwtEdDSA:Ye,verifyJwtEdDSA:We,zoneBootDocumentGetGatewayName:function(e){for(const t of e.oods){const e=Qe(t);if(tt(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?Ve.fromStr(e.owner):Ve.undefined(),i=ut({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-ke,i.version_seq=0,i.owner=e.owner??Ve.undefined().toString(),i},zoneDocumentGetDefaultGateway:function(e){for(const t of e.oods){const e=Qe(t);if(tt(e.nodeType))return e.name}return null},zoneDocumentGetSnApiUrl:function(e){return void 0!==e.sn?`https://${e.sn}/kapi/sn`:null},zoneDocumentToOrderedJson:jt},Symbol.toStringTag,{value:"Module"}));var Ht="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function $t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const Rt=$t((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 Mt="cyfile",Ut="cydir",Lt="cypath",zt="cyinc",Ft="cyrel",Yt="cypack",qt="cytrie",Wt="cytrie-s",Zt="cymap-mtp",Xt="cymap",Gt="cylist-mtree",Vt="cylist",Qt="cl",en="clist",tn="clist-fix",nn="cl-sf",rn="same",on="part_of",sn="0123456789abcdef";function cn(e){let t="";for(let n=0;n<e.length;n++){const i=e[n];t+=sn[i>>>4&15],t+=sn[15&i]}return t}function an(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=sn.indexOf(e[2*n].toLowerCase()),r=sn.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 un="abcdefghijklmnopqrstuvwxyz234567";function hn(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+=un[n>>>t&31];return t>0&&(i+=un[n<<5-t&31]),i}function ln(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=un.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 dn(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 fn(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 wn(e){const t=new ce("SHA-256","UINT8ARRAY");return t.update(e),t.getHash("UINT8ARRAY")}function pn(e){const t=new ce("SHA-256","TEXT",{encoding:"UTF8"});return t.update(e),t.getHash("UINT8ARRAY")}function mn(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 yn(e){if(function(e){switch(typeof e){case"string":return void mn(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]=yn(e[n])}return t}const t=Object.keys(e).sort(),n={};for(const i of t)mn(i),n[i]=yn(e[i]);return n}function bn(e){const t=yn(e),n=Rt(t);if(void 0===n)throw new Pt("InvalidData","failed to canonicalize JSON value");return n}const gn={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[gn.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}`)}}},vn={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=ln(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=Un(e.subarray(0,n)),r=e.slice(n+1);return new _n(i,r)}if(2===t.length)return new _n(t[0],an(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=Un(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 vn.isChunkType(this.objType)}isChunkList(){return this.objType===en}isJson(){return!this.isChunk()&&!this.isContainer()&&this.objType!==Yt}isDirObject(){return this.objType===Ut}isFileObject(){return this.objType===Mt}isContainer(){switch(this.objType){case Ut:case qt:case Wt:case Zt:case Xt:case Gt:case Vt:case Qt:case en:case tn:case nn:return!0;default:return!1}}isBigContainer(){switch(this.objType){case qt:case Zt:case Gt:case Qt:case tn:return!0;default:return!1}}toString(){return`${this.objType}:${cn(this.objHash)}`}toFilename(){return`${cn(this.objHash)}.${this.objType}`}toBase32(){return hn(this.toBytes())}toBytes(){const e=Mn(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 In{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 In(t.objType,t.objHash)}static fromObjId(e){return new In(e.objType,new Uint8Array(e.objHash))}static fromBytes(e){const t=_n.fromBytes(e);return new In(t.objType,t.objHash)}static fromHashResult(e,t){return new In(t,new Uint8Array(e))}static fromMixHashResult(e,t,n){return new In(n,In.mixLengthAndHashResult(e,t))}static fromMixHashResultByHashMethod(e,t,n){const i=vn.fromHashType(n,!0);return new In(i,In.mixLengthAndHashResult(e,t))}static fromSha256Result(e){return new In("sha256",new Uint8Array(e))}static fromMix256Result(e,t){return new In("mix256",In.mixLengthAndHashResult(e,t))}static mixLengthAndHashResult(e,t){const n=dn(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}:${cn(this.hashResult)}`}toBase32(){const e=Mn(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),hn(t)}toDidString(){return`did:${this.chunkType}:${cn(this.hashResult)}`}toBytes(){return this.toObjId().toBytes()}toJSON(){return this.toString()}getLength(){if(0===this.hashResult.length)return null;if(!vn.isMix(this.chunkType))return null;try{const[e]=fn(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 Sn{genObjId(){return kn(this.getObjType(),this.toJSON())}}function jn(e,t){const n=pn(t);return _n.fromRaw(e,n)}function kn(e,t){const n=bn(t);return[jn(e,n),n]}function On(e,t){const[n]=kn(e.objType,t);return e.equals(n)}function xn(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 En{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 Nn(){return Math.floor(Date.now()/1e3)}class Tn extends Sn{constructor(e,t,n){super(),this.content_obj=new En({name:e}),this.size=t,this.content=n,this.meta={}}static fromJSON(e){const t=new Tn("",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 En(n),t.meta=i,t}getObjType(){return Mt}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 Dn extends Sn{constructor(e,t,n,i){super();const r=Nn();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 Dn(t,n,i,r)}getObjType(){return Lt}toJSON(){return{path:this.path,uptime:this.uptime,target:this.target.toString(),exp:this.exp}}}class An extends Sn{constructor(e,t,n,i,r){super();const o=Nn();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 An(_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 zt}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 Jn={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 kn(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 Cn{constructor(){this.body=new Map}static fromJSON(e){const t=new Cn;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,Jn.fromJSON(r));return t}genObjIdWithRealObj(e,t){const n={};for(const[i,r]of this.body){const[e]=Jn.getObjId(r);n[i]=e.toString()}return t.body=n,kn(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]=Jn.toJSON(n);return{body:e}}}class Bn extends Sn{constructor(e){super(),this.content_obj=null!=e?new En({name:e}):new En,this.meta={},this.total_size=0,this.file_count=0,this.file_size=0,this.object_map=new Cn}static fromJSON(e){const t=new Bn,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,Jn.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 En(i),t}getObjType(){return Ut}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(Ut,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,Jn.fromObject(Mt,t))}addDirectory(e,t,n){if(t.objType!==Ut)throw new Pt("InvalidParam","dir_obj_id is not a directory");this.total_size+=n,this.object_map.set(e,Jn.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===Mt)}isDirectory(e){const t=this.object_map.get(e);if(!t)return!1;switch(t.kind){case"objId":return t.objId.objType===Ut;case"objectJwt":return t.objType===Ut;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 In.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]=kn(en,e),i=In.mixLengthAndHashResult(this.total_size,t.objHash);return[_n.fromRaw(en,i),n]}}class Hn extends Sn{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 Hn(_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 Hn(e,rn,t.target);case"partOf":return new Hn(e,on,t.target,{range:{start:t.range.start,end:t.range.end}})}}getLinkData(){switch(this.relation){case rn:return{kind:"sameAs",target:this.target};case on:{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 Ft}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 $n={fromObjData(e,t){switch(e.objType){case Ut:{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:Bn.fromJSON(e),objStr:t}}case Mt:{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:Tn.fromJSON(e),objStr:t}}case en: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]=Jn.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})))}}},Rn="undefined"!=typeof TextEncoder?new TextEncoder:null,Pn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Mn(e){if(Rn)return Rn.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 Un(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 Ln=Object.freeze(Object.defineProperty({__proto__:null,BaseContentObject:En,ChunkId:In,ChunkType:vn,DEFAULT_HASH_METHOD:"sha256",DirObject:Bn,FileObject:Tn,HashMethod:gn,InclusionProof:An,KnownStandardObject:$n,NamedObjectBase:Sn,NdnError:Pt,OBJ_TYPE_ACTION:"cyact",OBJ_TYPE_CHUNK_LIST:Qt,OBJ_TYPE_CHUNK_LIST_FIX_SIZE:tn,OBJ_TYPE_CHUNK_LIST_SIMPLE:en,OBJ_TYPE_CHUNK_LIST_SIMPLE_FIX_SIZE:nn,OBJ_TYPE_DIR:Ut,OBJ_TYPE_FILE:Mt,OBJ_TYPE_INCLUSION_PROOF:zt,OBJ_TYPE_LIST:Gt,OBJ_TYPE_LIST_SIMPLE:Vt,OBJ_TYPE_MSG:"cymsg",OBJ_TYPE_MSG_RECE:"cymsgr",OBJ_TYPE_OBJMAP:Zt,OBJ_TYPE_OBJMAP_SIMPLE:Xt,OBJ_TYPE_PACK:Yt,OBJ_TYPE_PATH:Lt,OBJ_TYPE_PKG:"pkg",OBJ_TYPE_RELATION:Ft,OBJ_TYPE_TRIE:qt,OBJ_TYPE_TRIE_SIMPLE:Wt,ObjId:_n,PathObject:Dn,RELATION_TYPE_PART_OF:on,RELATION_TYPE_SAME:rn,RelationObject:Hn,SimpleChunkList:Kn,SimpleMapItem:Jn,SimpleObjectMap:Cn,base32Decode:ln,base32Encode:hn,buildNamedObjectByJson:kn,buildObjId:jn,bytesToHex:cn,canonicalizeJson:yn,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:an,loadNamedObj:function(e){return xn(e)},loadNamedObjAndVerify:function(e,t){const n=xn(t);if(!On(e,n))throw new Pt("InvalidId",`verify named object failed for obj_id: ${e.toString()}`);return n},loadNamedObjectFromObjStr:xn,sha256Bytes:wn,sha256Utf8:pn,toCanonicalJsonString:bn,varintDecode:fn,varintEncode:dn,verifyNamedObject:On,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(!On(e,n))throw new Pt("InvalidId",`verify named object failed: ${t}`);return n}},Symbol.toStringTag,{value:"Module"}));exports.ChunkId=In,exports.DEFAULT_EXPIRE_TIME=ke,exports.DID=Ve,exports.DID_OBJECT_SERVICE_ID="#did-object",exports.DID_OBJECT_SERVICE_TYPE=de,exports.DirObject=Bn,exports.FileObject=Tn,exports.NODE_IDENTITY_SCHEMA_V2=fe,exports.ObjId=_n,exports.SimpleChunkList=Kn,exports.buckyosGetUnixTimestamp=Ee,exports.buildNamedObjectByJson=kn,exports.canonicalize=Rt,exports.cleanLocalAccountInfo=function(e){localStorage.removeItem(le(e)),localStorage.removeItem(ue),localStorage.removeItem(he);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.clearBrowserIdentity=function(){localStorage.removeItem(he)},exports.clearBrowserUserInfo=function(){localStorage.removeItem(ue)},exports.commonjsGlobal=Ht,exports.createJwkByX=Fe,exports.decodeJwtClaimWithoutVerify=qe,exports.deviceDocumentToOrderedJson=kt,exports.deviceMiniDocumentToJwt=gt,exports.encodeDeviceDocument=pt,exports.encodeZoneBootDocument=lt,exports.encodeZoneDocument=_t,exports.getBrowserIdentityRaw=function(){const e=localStorage.getItem(he);if(!e)return null;try{return JSON.parse(e)}catch{return null}},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=$t,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=Le,exports.getXFromJwk=ze,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=ve,exports.isBuckyOSDIDObjectCard=Ie,exports.isBuckyOSDeviceDocument=ge,exports.isBuckyOSDeviceMiniDocument=be,exports.isBuckyOSLocalNodeIdentityConfig=function(e){return we(e)&&e.schema===fe&&"string"==typeof e.zone_did&&"string"==typeof e.owner_did&&we(e.owner_public_key)&&"string"==typeof e.device_name&&"string"==typeof e.device_did&&"number"==typeof e.zone_iat},exports.isBuckyOSNodeIdentityConfig=function(e){return we(e)&&"string"==typeof e.zone_did&&we(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=ye,exports.isBuckyOSZoneBootDocument=function(e){return we(e)&&Array.isArray(e.oods)&&e.oods.every((e=>"string"==typeof e))&&"number"==typeof e.exp},exports.isBuckyOSZoneConfig=function(e){return we(e)&&"string"==typeof e.zone_document},exports.isBuckyOSZoneDocument=_e,exports.isW3CDIDDocumentBase=me,exports.namelib=Kt,exports.ndn_types=Ln,exports.newDeviceDocumentByJwk=ft,exports.newDeviceDocumentByMiniDocument=wt,exports.newDeviceMiniDocument=yt,exports.newDeviceMiniDocumentByDeviceDocument=bt,exports.newOwnerDocument=ot,exports.newZoneBootDocument=ht,exports.newZoneDocument=ut,exports.oodDescriptionToString=et,exports.ownerDocumentSetDefaultZoneDid=st,exports.ownerDocumentToOrderedJson=St,exports.parseBuckyOSDIDDocument=function(e){return ye(e)||ve(e)||ge(e)||_e(e)||Ie(e)?e:null},exports.parseBuckyOSDeviceMiniDocument=function(e){return be(e)?e:null},exports.parseBuckyOSOwnerDocument=function(e){return ye(e)?e:null},exports.parseOODDescription=Qe,exports.parseW3CDIDDocumentBase=function(e){return me(e)?e:null},exports.saveBrowserIdentity=function(e){localStorage.setItem(he,JSON.stringify(e))},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(le(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=wn,exports.signJwtEdDSA=Ye,exports.verifyJwtEdDSA=We,exports.zoneDocumentToOrderedJson=jt;
|
|
2
|
+
//# sourceMappingURL=ndn_types-324121ae.js.map
|