buckyos 0.7.154 → 0.7.155

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.
Files changed (58) hide show
  1. package/cli/core/app.ts +2 -0
  2. package/cli/core/task.ts +2 -1
  3. package/cli/dist/cli.mjs +235 -94
  4. package/cli/dist/cli.mjs.map +1 -1
  5. package/cli/modules/obj.ts +163 -0
  6. package/cli/version.ts +1 -1
  7. package/dist/aiworkspace_client.d.ts +9 -0
  8. package/dist/aiworkspace_client.d.ts.map +1 -1
  9. package/dist/browser.cjs +1 -1
  10. package/dist/browser.cjs.map +1 -1
  11. package/dist/browser.d.ts +1 -0
  12. package/dist/browser.d.ts.map +1 -1
  13. package/dist/browser.mjs +183 -182
  14. package/dist/browser.mjs.map +1 -1
  15. package/dist/executor_client-022a19b9.js +13 -0
  16. package/dist/executor_client-022a19b9.js.map +1 -0
  17. package/dist/{executor_client-dde508e1.mjs → executor_client-78ad0749.mjs} +597 -188
  18. package/dist/executor_client-78ad0749.mjs.map +1 -0
  19. package/dist/hybrid_sso.d.ts +2 -1
  20. package/dist/hybrid_sso.d.ts.map +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.mjs +188 -185
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/msg_center_client.d.ts +4 -3
  28. package/dist/msg_center_client.d.ts.map +1 -1
  29. package/dist/{ndn_types-bbb1f6a6.mjs → namelib-b41b10cc.mjs} +2683 -2683
  30. package/dist/namelib-b41b10cc.mjs.map +1 -0
  31. package/dist/namelib-f8ff0045.js +2 -0
  32. package/dist/namelib-f8ff0045.js.map +1 -0
  33. package/dist/node.cjs +1 -1
  34. package/dist/node.cjs.map +1 -1
  35. package/dist/node.d.ts +1 -0
  36. package/dist/node.d.ts.map +1 -1
  37. package/dist/node.mjs +183 -182
  38. package/dist/node.mjs.map +1 -1
  39. package/dist/object_url.d.ts +65 -0
  40. package/dist/object_url.d.ts.map +1 -0
  41. package/dist/provision.cjs +1 -1
  42. package/dist/provision.cjs.map +1 -1
  43. package/dist/provision.mjs +1 -1
  44. package/dist/sdk_core.d.ts +1 -1
  45. package/dist/sdk_core.d.ts.map +1 -1
  46. package/dist/task_mgr_client.d.ts +2 -0
  47. package/dist/task_mgr_client.d.ts.map +1 -1
  48. package/dist/{tus_client-d313689e.mjs → tus_client-04080b1e.mjs} +2 -2
  49. package/dist/{tus_client-d313689e.mjs.map → tus_client-04080b1e.mjs.map} +1 -1
  50. package/dist/{tus_client-65c5fc5e.js → tus_client-4f7254e9.js} +2 -2
  51. package/dist/{tus_client-65c5fc5e.js.map → tus_client-4f7254e9.js.map} +1 -1
  52. package/package.json +1 -1
  53. package/dist/executor_client-cafb8a35.js +0 -13
  54. package/dist/executor_client-cafb8a35.js.map +0 -1
  55. package/dist/executor_client-dde508e1.mjs.map +0 -1
  56. package/dist/ndn_types-08dc9ef1.js +0 -2
  57. package/dist/ndn_types-08dc9ef1.js.map +0 -1
  58. package/dist/ndn_types-bbb1f6a6.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="user_info",ue="buckyos.identity";function he(e){return`buckyos.account_info.${e}`}var le="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function de(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const fe=de((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 we extends Error{constructor(e,t){super(`${e}: ${t}`),this.kind=e,this.name="NdnError"}}const pe="cyfile",me="cydir",ye="cypath",be="cyinc",ge="cyrel",ve="cypack",_e="cytrie",Ie="cytrie-s",Se="cymap-mtp",je="cymap",ke="cylist-mtree",Oe="cylist",xe="cl",Ee="clist",Ne="clist-fix",Te="cl-sf",De="same",Ae="part_of",Je="0123456789abcdef";function Ce(e){let t="";for(let n=0;n<e.length;n++){const i=e[n];t+=Je[i>>>4&15],t+=Je[15&i]}return t}function Be(e){if(e.length%2!=0)throw new we("InvalidId",`invalid hex length: ${e.length}`);const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){const i=Je.indexOf(e[2*n].toLowerCase()),r=Je.indexOf(e[2*n+1].toLowerCase());if(i<0||r<0)throw new we("InvalidId","invalid hex char at offset "+2*n);t[n]=i<<4|r}return t}const Ke="abcdefghijklmnopqrstuvwxyz234567";function He(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+=Ke[n>>>t&31];return t>0&&(i+=Ke[n<<5-t&31]),i}function $e(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=Ke.indexOf(e);if(s<0)throw new we("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 Re(e){if(!Number.isFinite(e)||e<0)throw new we("InvalidParam",`varint must be non-negative finite: ${e}`);if(!Number.isSafeInteger(e))throw new we("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 Pe(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 we("InvalidData","varint exceeds safe integer range");if(!(128&t))return[n,o];if(i*=128,o>10)throw new we("InvalidData","varint too long")}throw new we("InvalidData","varint truncated")}function Me(e){const t=new ce("SHA-256","UINT8ARRAY");return t.update(e),t.getHash("UINT8ARRAY")}function Ue(e){const t=new ce("SHA-256","TEXT",{encoding:"UTF8"});return t.update(e),t.getHash("UINT8ARRAY")}function Le(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 we("InvalidData","JSON string contains lone surrogate")}}}function ze(e){if(function(e){switch(typeof e){case"string":return void Le(e);case"number":if(!Number.isFinite(e))throw new we("InvalidData","JSON number MUST be finite for JCS");if(Object.is(e,-0))throw new we("InvalidData","JSON number MUST NOT be negative zero for JCS");return;case"boolean":case"object":return;case"undefined":throw new we("InvalidData","undefined is not a valid JSON value");case"bigint":throw new we("InvalidData","bigint is not a valid JSON value");case"function":throw new we("InvalidData","function is not a valid JSON value");case"symbol":throw new we("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 we("InvalidData","sparse arrays are not valid JSON values");t[n]=ze(e[n])}return t}const t=Object.keys(e).sort(),n={};for(const i of t)Le(i),n[i]=ze(e[i]);return n}function Fe(e){const t=ze(e),n=fe(t);if(void 0===n)throw new we("InvalidData","failed to canonicalize JSON value");return n}const Ye={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[Ye.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 we("InvalidData",`Invalid hash method: ${e}`)}}},qe={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 we("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 we("InvalidObjType",`invalid chunk type: ${e}`)}}};class We{constructor(e,t){this.objType=e,this.objHash=t}static fromString(e){const t=e.split(":");if(1===t.length){const e=$e(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 we("InvalidId","separator ':' not found");const i=pt(e.subarray(0,n)),r=e.slice(n+1);return new We(i,r)}if(2===t.length)return new We(t[0],Be(t[1]));throw new we("InvalidId",e)}static fromBytes(e){if(e.length<3)throw new we("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 we("InvalidId","separator ':' not found");const n=pt(e.subarray(0,t)),i=e.slice(t+1);return new We(n,i)}static fromValue(e){if("string"==typeof e)return We.fromString(e);throw new we("InvalidData","ObjId MUST be string")}static fromHostname(e){const t=e.split(".")[0];return We.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=We.fromString(e);return n<t.length-1?{objId:i,subPath:"/"+t.slice(n+1).join("/")}:{objId:i,subPath:null}}catch{}}throw new we("InvalidId",`no objid found in path: ${e}`)}static fromRaw(e,t){return new We(e,t)}isChunk(){return qe.isChunkType(this.objType)}isChunkList(){return this.objType===Ee}isJson(){return!this.isChunk()&&!this.isContainer()&&this.objType!==ve}isDirObject(){return this.objType===me}isFileObject(){return this.objType===pe}isContainer(){switch(this.objType){case me:case _e:case Ie:case Se:case je:case ke:case Oe:case xe:case Ee:case Ne:case Te:return!0;default:return!1}}isBigContainer(){switch(this.objType){case _e:case Se:case ke:case xe:case Ne:return!0;default:return!1}}toString(){return`${this.objType}:${Ce(this.objHash)}`}toFilename(){return`${Ce(this.objHash)}.${this.objType}`}toBase32(){return He(this.toBytes())}toBytes(){const e=wt(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 Ze{constructor(e,t){this.chunkType=e,this.hashResult=t}static defaultChunkType(){return"mix256"}static fromString(e){const t=We.fromString(e);if(!t.isChunk())throw new we("InvalidId",`invalid chunk id: ${e}`);return new Ze(t.objType,t.objHash)}static fromObjId(e){return new Ze(e.objType,new Uint8Array(e.objHash))}static fromBytes(e){const t=We.fromBytes(e);return new Ze(t.objType,t.objHash)}static fromHashResult(e,t){return new Ze(t,new Uint8Array(e))}static fromMixHashResult(e,t,n){return new Ze(n,Ze.mixLengthAndHashResult(e,t))}static fromMixHashResultByHashMethod(e,t,n){const i=qe.fromHashType(n,!0);return new Ze(i,Ze.mixLengthAndHashResult(e,t))}static fromSha256Result(e){return new Ze("sha256",new Uint8Array(e))}static fromMix256Result(e,t){return new Ze("mix256",Ze.mixLengthAndHashResult(e,t))}static mixLengthAndHashResult(e,t){const n=Re(e),i=new Uint8Array(n.length+t.length);return i.set(n,0),i.set(t,n.length),i}toObjId(){return new We(this.chunkType,new Uint8Array(this.hashResult))}toString(){return`${this.chunkType}:${Ce(this.hashResult)}`}toBase32(){const e=wt(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),He(t)}toDidString(){return`did:${this.chunkType}:${Ce(this.hashResult)}`}toBytes(){return this.toObjId().toBytes()}toJSON(){return this.toString()}getLength(){if(0===this.hashResult.length)return null;if(!qe.isMix(this.chunkType))return null;try{const[e]=Pe(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 Xe{genObjId(){return Ve(this.getObjType(),this.toJSON())}}function Ge(e,t){const n=Ue(t);return We.fromRaw(e,n)}function Ve(e,t){const n=Fe(t);return[Ge(e,n),n]}function Qe(e,t){const[n]=Ve(e.objType,t);return e.equals(n)}function et(e){if(e.indexOf("{")>=0)try{return JSON.parse(e)}catch(t){throw new we("InvalidId",`failed to parse obj_str: ${t.message}`)}throw new we("Unsupported","JWT-encoded named objects are not supported in this TypeScript port")}class tt{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 nt(){return Math.floor(Date.now()/1e3)}class it extends Xe{constructor(e,t,n){super(),this.content_obj=new tt({name:e}),this.size=t,this.content=n,this.meta={}}static fromJSON(e){const t=new it("",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=We.fromString(s):n[o]=s:i[o]=s;return t.content_obj=new tt(n),t.meta=i,t}getObjType(){return pe}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 rt extends Xe{constructor(e,t,n,i){super();const r=nt();this.path=e,this.target=t,this.uptime=n??r,this.exp=i??r+94608e3}static fromJSON(e){const t=String(e.path??""),n=We.fromString(String(e.target??"")),i=Number(e.uptime??0),r=Number(e.exp??0);return new rt(t,n,i,r)}getObjType(){return ye}toJSON(){return{path:this.path,uptime:this.uptime,target:this.target.toString(),exp:this.exp}}}class ot extends Xe{constructor(e,t,n,i,r){super();const o=nt();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 ot(We.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 be}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 st={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 Ve(e.objType,e.obj);case"objectJwt":throw new we("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:We.fromString(e)};if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e,n=t.obj_type;if("string"!=typeof n)throw new we("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 we("InvalidData","SimpleMapItem must have body or jwt field")}throw new we("InvalidData","SimpleMapItem must be string or object")}};class ct{constructor(){this.body=new Map}static fromJSON(e){const t=new ct;if(!e||"object"!=typeof e)throw new we("InvalidData","SimpleObjectMap must be an object");const n=e.body;if(null==n)return t;if("object"!=typeof n||Array.isArray(n))throw new we("InvalidData","SimpleObjectMap.body must be an object");for(const[i,r]of Object.entries(n))t.body.set(i,st.fromJSON(r));return t}genObjIdWithRealObj(e,t){const n={};for(const[i,r]of this.body){const[e]=st.getObjId(r);n[i]=e.toString()}return t.body=n,Ve(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]=st.toJSON(n);return{body:e}}}class at extends Xe{constructor(e){super(),this.content_obj=null!=e?new tt({name:e}):new tt,this.meta={},this.total_size=0,this.file_count=0,this.file_size=0,this.object_map=new ct}static fromJSON(e){const t=new at,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,st.fromJSON(i))}else n.has(r)&&("base_on"===r&&"string"==typeof o?i.base_on=We.fromString(o):i[r]=o);return t.content_obj=new tt(i),t}getObjType(){return me}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(me,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,st.fromObject(pe,t))}addDirectory(e,t,n){if(t.objType!==me)throw new we("InvalidParam","dir_obj_id is not a directory");this.total_size+=n,this.object_map.set(e,st.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===pe)}isDirectory(e){const t=this.object_map.get(e);if(!t)return!1;switch(t.kind){case"objId":return t.objId.objType===me;case"objectJwt":return t.objType===me;default:return!1}}}class ut{constructor(){this.total_size=0,this.body=[]}static fromChunkList(e){const t=new ut;for(const n of e){const e=n.getLength();if(null==e)throw new we("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 we("InvalidParam",`parse chunk list from json failed: ${n.message}`)}return ut.fromJsonValue(t)}static fromJsonValue(e){if(!Array.isArray(e))throw new we("InvalidParam","chunk list must be a JSON array");const t=e.map((e=>{if("string"!=typeof e)throw new we("InvalidParam","chunk list item must be a string");return Ze.fromString(e)}));return ut.fromChunkList(t)}appendChunk(e){const t=e.getLength();if(null==t)throw new we("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]=Ve(Ee,e),i=Ze.mixLengthAndHashResult(this.total_size,t.objHash);return[We.fromRaw(Ee,i),n]}}class ht extends Xe{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 ht(We.fromString(String(e.source??"")),String(e.relation??""),We.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 ht(e,De,t.target);case"partOf":return new ht(e,Ae,t.target,{range:{start:t.range.start,end:t.range.end}})}}getLinkData(){switch(this.relation){case De:return{kind:"sameAs",target:this.target};case Ae:{const e=this.body.range;if(!e||"number"!=typeof e.start||"number"!=typeof e.end)throw new we("InvalidLink",`invalid range: ${JSON.stringify(this.body.range)}`);return{kind:"partOf",target:this.target,range:{start:e.start,end:e.end}}}default:throw new we("InvalidLink",`invalid relation: ${this.relation}`)}}getObjType(){return ge}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 lt={fromObjData(e,t){switch(e.objType){case me:{let e;try{e=JSON.parse(t)}catch(n){throw new we("InvalidParam",`parse dir object from json failed: ${n.message}`)}return{kind:"dir",obj:at.fromJSON(e),objStr:t}}case pe:{let e;try{e=JSON.parse(t)}catch(n){throw new we("InvalidParam",`parse file object from json failed: ${n.message}`)}return{kind:"file",obj:it.fromJSON(e),objStr:t}}case Ee:return{kind:"chunkList",obj:ut.fromJson(t),objStr:t};default:throw new we("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]=st.getObjId(n);t.push({objId:e,objStr:i.length>0?i:null})}return t}case"file":return 0===e.obj.content.length?[]:[{objId:We.fromString(e.obj.content),objStr:null}];case"chunkList":return e.obj.body.map((e=>({objId:e.toObjId(),objStr:null})))}}},dt="undefined"!=typeof TextEncoder?new TextEncoder:null,ft="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function wt(e){if(dt)return dt.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 pt(e){if(ft)return ft.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 mt=Object.freeze(Object.defineProperty({__proto__:null,BaseContentObject:tt,ChunkId:Ze,ChunkType:qe,DEFAULT_HASH_METHOD:"sha256",DirObject:at,FileObject:it,HashMethod:Ye,InclusionProof:ot,KnownStandardObject:lt,NamedObjectBase:Xe,NdnError:we,OBJ_TYPE_ACTION:"cyact",OBJ_TYPE_CHUNK_LIST:xe,OBJ_TYPE_CHUNK_LIST_FIX_SIZE:Ne,OBJ_TYPE_CHUNK_LIST_SIMPLE:Ee,OBJ_TYPE_CHUNK_LIST_SIMPLE_FIX_SIZE:Te,OBJ_TYPE_DIR:me,OBJ_TYPE_FILE:pe,OBJ_TYPE_INCLUSION_PROOF:be,OBJ_TYPE_LIST:ke,OBJ_TYPE_LIST_SIMPLE:Oe,OBJ_TYPE_MSG:"cymsg",OBJ_TYPE_MSG_RECE:"cymsgr",OBJ_TYPE_OBJMAP:Se,OBJ_TYPE_OBJMAP_SIMPLE:je,OBJ_TYPE_PACK:ve,OBJ_TYPE_PATH:ye,OBJ_TYPE_PKG:"pkg",OBJ_TYPE_RELATION:ge,OBJ_TYPE_TRIE:_e,OBJ_TYPE_TRIE_SIMPLE:Ie,ObjId:We,PathObject:rt,RELATION_TYPE_PART_OF:Ae,RELATION_TYPE_SAME:De,RelationObject:ht,SimpleChunkList:ut,SimpleMapItem:st,SimpleObjectMap:ct,base32Decode:$e,base32Encode:He,buildNamedObjectByJson:Ve,buildObjId:Ge,bytesToHex:Ce,canonicalizeJson:ze,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 we("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 we("InvalidParam",`objid path not found: ${t}`);i=i[e]}else{if("object"!=typeof i)throw new we("InvalidParam",`objid path not found: ${t}`);if(!(o in i))throw new we("InvalidParam",`objid path not found: ${t}`);i=i[o]}}try{return We.fromValue(i)}catch(r){throw new we("InvalidData",`invalid objid at path ${t}: ${r.message}`)}},hexToBytes:Be,loadNamedObj:function(e){return et(e)},loadNamedObjAndVerify:function(e,t){const n=et(t);if(!Qe(e,n))throw new we("InvalidId",`verify named object failed for obj_id: ${e.toString()}`);return n},loadNamedObjectFromObjStr:et,sha256Bytes:Me,sha256Utf8:Ue,toCanonicalJsonString:Fe,varintDecode:Pe,varintEncode:Re,verifyNamedObject:Qe,verifyNamedObjectFromStr:function(e,t){let n;try{n=JSON.parse(t)}catch(i){throw new we("InvalidId",`failed to parse obj_str: ${i.message}`)}if(!Qe(e,n))throw new we("InvalidId",`verify named object failed: ${t}`);return n}},Symbol.toStringTag,{value:"Module"})),yt="DIDObjectService",bt="buckyos.node_identity.v2";function gt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function vt(e){return"string"==typeof e||Array.isArray(e)&&e.every((e=>"string"==typeof e))}function _t(e){return!!gt(e)&&(vt(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 It(e){return _t(e)&&"string"==typeof e.name&&("string"==typeof e.display_name||"string"==typeof e.displayName||"string"==typeof e.full_name)}function St(e){return gt(e)&&"string"==typeof e.n&&"string"==typeof e.x&&"number"==typeof e.exp}function jt(e){return _t(e)&&"string"==typeof e.owner&&"string"==typeof e.device_type&&"string"==typeof e.name}function kt(e){return _t(e)&&"string"==typeof e.owner&&gt(e.httpServicePorts)}function Ot(e){return _t(e)&&"string"==typeof e.hostname&&"string"==typeof e.owner&&Array.isArray(e.oods)&&"string"==typeof e.boot_jwt}function xt(e){if(!gt(e)||!vt(e["@context"])||"string"!=typeof e.id)return!1;const t=e.service;return Array.isArray(t)&&t.some((e=>gt(e)&&e.type===yt))}const Et="https://www.w3.org/ns/did/v1",Nt="https://buckyos.org/ns",Tt=15768e4,Dt=31536e4;function At(e){return[Et,`${Nt}/${e}/v1`]}function Jt(){return Math.floor(Date.now()/1e3)}const Ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Bt(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+=Ct[i>>2],t+=Ct[(3&i)<<4|r>>4],t+=n+1<e.length?Ct[(15&r)<<2|o>>6]:"=",t+=n+2<e.length?Ct[63&o]:"="}return t}function Kt(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=Ct.indexOf(t[o]),n=Ct.indexOf(t[o+1]),s=o+2<t.length?Ct.indexOf(t[o+2]):-1,c=o+3<t.length?Ct.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 Ht(e){return Bt(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function $t(e){return Kt(e.replace(/-/g,"+").replace(/_/g,"/"))}function Rt(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 Pt(e){return Ht(Rt(e))}function Mt(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}($t(e))}async function Ut(){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 Lt(){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 zt=new Uint8Array([48,42,48,5,6,3,43,101,112,3,33,0]);function Ft(e){return Kt(e.replace(/-----BEGIN [^-]+-----/g,"").replace(/-----END [^-]+-----/g,"").replace(/\s+/g,""))}function Yt(e){const t=Bt(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 qt(e){const t=$t(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}(zt,t)}async function Wt(e){const t=await Ut();if(t){const n=t.createPrivateKey({key:e,format:"pem"});return t.createPublicKey(n).export({format:"jwk"}).x}const n=Lt(),i=Ft(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 Zt(e){const t=e.x;if("string"!=typeof t||0===t.length)throw new Error("namelib: invalid jwk, missing x");return t}function Xt(e){return{kty:"OKP",crv:"Ed25519",x:e}}async function Gt(e,t,n){const i=`${Pt(JSON.stringify(n??{alg:"EdDSA"}))}.${Pt(JSON.stringify(e))}`,r=await async function(e,t){const n=await Ut();if(n){const i=n.createPrivateKey({key:t,format:"pem"});return new Uint8Array(n.sign(null,e,i))}const i=Lt(),r=Ft(t),o=await i.importKey("pkcs8",r,{name:"Ed25519"},!1,["sign"]),s=await i.sign({name:"Ed25519"},o,e);return new Uint8Array(s)}(Rt(i),t);return`${i}.${Ht(r)}`}function Vt(e){const t=e.split(".");if(3!==t.length)throw new Error("namelib: invalid jwt, parts.len != 3");return JSON.parse(Mt(t[1]))}async function Qt(e,t){const n=e.split(".");if(3!==n.length)throw new Error("namelib: invalid jwt, parts.len != 3");const i=JSON.parse(Mt(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 Ut();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=Lt(),o=qt(n),s=await r.importKey("spki",o,{name:"Ed25519"},!1,["verify"]);return r.verify({name:"Ed25519"},s,t,e)}(Rt(r),$t(n[2]),t);if(!o)throw new Error("namelib: jwt signature verify failed");return JSON.parse(Mt(n[1]))}function en(e){return e.startsWith("{")||e.startsWith("[")?{type:"json",value:JSON.parse(e)}:{type:"jwt",jwt:e}}function tn(e){return"jwt"===e.type?Vt(e.jwt):e.value}let nn=null;class rn{constructor(e,t){this.method=e,this.id=t}static undefined(){return new rn("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=rn.fromHostName(e);if(t)return t;throw new Error(`namelib: invalid did ${e}`)}return new rn(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 rn(t.slice(n+1),t.slice(0,n))}if(nn)for(const t of Object.keys(nn)){const n=nn[t];if(e.endsWith(n)){if(e===n)break;const i=e.slice(0,e.length-n.length-1);return new rn(t,i)}}return new rn("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 rn(t,i)}if(e.endsWith(".did")){const t=e.slice(0,-4),n=t.lastIndexOf(".");if(n>0&&n<t.length-1)return new rn(t.slice(n+1),t.slice(0,n))}return new rn("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(an(e))return null;const t=e.indexOf(".");if(t<0)return null;const n=e.slice(t+1);return n.includes(".")?new rn("web",n):null}case"bns":{const t=e.indexOf(".");return t<0?null:new rn("bns",e.slice(t+1))}default:return null}}toFilename(){const e="0123456789ABCDEF",t=Rt(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?$t(this.id):null}getAuthKeyJwk(){return"dev"===this.method?Xt(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(nn){const t=nn[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 on(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),!an(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 un({name:c,nodeType:n,netId:t,ip:o})}function sn(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 cn(e){return"Gateway"===e||"OOD"===e}function an(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 un(e){for(const t of Object.keys(e))void 0===e[t]&&delete e[t];return e}function hn(e){return e instanceof rn?e:rn.fromStr(e)}function ln(e){const t=hn(e.did),n=e.now??Jt(),i=t.toString();return{"@context":At("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+Dt,iat:n,version_seq:0,name:e.name,display_name:e.displayName,zone_binding_model_version:2}}function dn(e,t){const n=hn(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,fn(e)}function fn(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=hn(n);r.push({id:i,type:"DIDDoc",serviceEndpoint:`https://${t.toHostName()}/resolve/${e.id}`})}e.service=r}function wn(e,t){const n=hn(t).toString();return(e.binded_zone_list??[]).includes(n)}function pn(e){const t=hn(e.id),n=hn(e.ownerDid),i=e.now??Jt(),r=t.toString();return{"@context":At("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+Dt,iat:i,version_seq:0,hostname:t.toHostName(),owner:n.toString(),oods:[],boot_jwt:""}}function mn(e){return un({id:void 0!==e.id?hn(e.id).toString():void 0,oods:[...e.oods],sn:e.sn,exp:e.exp,owner:void 0!==e.owner?hn(e.owner).toString():void 0,owner_key:e.ownerKey})}async function yn(e,t){const{id:n,oods:i,sn:r,exp:o,owner:s,owner_key:c,...a}=e;return Gt(un({id:n,oods:i,sn:r,exp:o,owner:s,...a,owner_key:c}),t)}function bn(e){const t=e.now??Jt(),n=`did:dev:${e.pkx}`;return{"@context":At("device"),id:n,verificationMethod:[{type:"Ed25519VerificationKey2020",id:"#main_key",controller:n,publicKeyJwk:Xt(e.pkx)}],authentication:["#main_key"],assertion_method:["#main_key"],capabilityInvocation:["#main_key"],exp:t+Tt,iat:t,version_seq:0,owner:rn.undefined().toString(),device_type:"ood",name:e.name}}function gn(e,t,n){return bn({name:e,pkx:Zt(t),now:n})}function vn(e,t,n,i){const r=`did:dev:${t.x}`,o={"@context":At("device"),id:r,verificationMethod:[{type:"Ed25519VerificationKey2020",id:"#main_key",controller:r,publicKeyJwk:Xt(t.x)}],authentication:["#main_key"],assertion_method:["#main_key"],capabilityInvocation:["#main_key"],exp:t.exp,iat:t.exp-Tt,version_seq:0,zone_did:hn(n).toString(),owner:hn(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 _n(e,t){if(void 0===e.version_seq)throw new Error("namelib: DeviceDocument version_seq is required when encoding as JWT");return Gt(In(e),t)}function In(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 un({"@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 Sn(e){return un({n:e.name,x:e.x,p:e.rtcpPort,exp:e.exp})}function jn(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 Sn({name:e.name,x:Zt(t.publicKeyJwk),rtcpPort:e.rtcp_port,exp:e.exp})}async function kn(e,t){const{n:n,x:i,p:r,exp:o,...s}=e;return Gt(un({n:n,x:i,p:r,exp:o,...s}),t)}function On(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 un({"@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 xn(e,t){if(void 0===e.version_seq)throw new Error("namelib: ZoneDocument version_seq is required when encoding as JWT");return Gt(En(e),t)}function En(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 un({"@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 Nn(e){return On(e)}function Tn(e){return En(e)}function Dn(e){return In(e)}function An(e){return e.keyScope??e["buckyos:scopes"]??{}}function Jn(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 Cn(e,t){return An(e)[t]??null}function Bn(e){return Object.keys(An(e)).length>0}function Kn(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(xt(e)){const t=e.assertionMethod;if(Array.isArray(t)&&t.length>0)return t}return null}function Hn(e,t){const n=e.id;if(t.startsWith(n)){const e=t.slice(n.length);if(e.startsWith("#"))return e}return t}function $n(e,t){return t.startsWith("#")?`${e.id}${t}`:t}function Rn(e,t,n){return t===n||Hn(e,t)===Hn(e,n)||$n(e,t)===$n(e,n)}function Pn(e,t){for(const n of t){const t=Jn(e,Hn(e,n));if(t)return[n,t]}return null}function Mn(e){const t="string"==typeof e?en(e):e,n="jwt"===t.type,i=tn(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)===yt)))return r("DIDObjectCard"),{docType:"did-object",doc:i};throw new Error("namelib: unknown did document")}const Un=Object.freeze(Object.defineProperty({__proto__:null,BUCKYOS_CONTEXT_BASE:Nt,DEFAULT_EXPIRE_TIME:Tt,DID:rn,DID_CORE_CONTEXT:Et,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:$t,base64UrlDecodeToString:Mt,base64UrlEncodeBytes:Ht,base64UrlEncodeString:Pt,buckyosContext:At,buckyosGetUnixTimestamp:Jt,createJwkByX:Xt,decodeDeviceDocument:async function(e,t){const n=t?await Qt(e,t):Vt(e);if(void 0===n.version_seq)throw new Error("namelib: DeviceDocument version_seq is required when decoding from JWT");return n},decodeJwtClaimWithoutVerify:Vt,decodeJwtHeaderWithoutVerify:function(e){const t=e.split(".");if(3!==t.length)throw new Error("namelib: invalid jwt, parts.len != 3");return JSON.parse(Mt(t[0]))},decodeZoneBootDocument:async function(e,t){return t?await Qt(e,t):Vt(e)},derToPkcs8Pem:Yt,deviceDocumentToOrderedJson:Dn,deviceMiniDocumentFromJwt:async function(e,t){return t?await Qt(e,t):Vt(e)},deviceMiniDocumentToJwt:kn,encodeDeviceDocument:_n,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 Gt(On(e),t)},encodeZoneBootDocument:yn,encodeZoneDocument:xn,encodedDocumentFromStr:en,encodedDocumentToJsonValue:tn,encodedDocumentToString:function(e){return"jwt"===e.type?e.jwt:JSON.stringify(e.value)},expandLocalKeyId:$n,generateEd25519KeyPair:async function(){const e=await Ut();if(e){const{privateKey:t,publicKey:n}=e.generateKeyPairSync("ed25519");return{privateKeyPem:t.export({type:"pkcs8",format:"pem"}).toString(),publicKeyJwk:Xt(n.export({format:"jwk"}).x)}}const t=Lt(),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:Yt(i),publicKeyJwk:Xt(r.x)}},getDeviceDidFromJwk:function(e){return`did:dev:${Zt(e)}`},getDidDocType:function(e){return e.docType},getDocumentAuthKey:Jn,getDocumentDefaultKey:function(e){const t=(e.verificationMethod??[]).find((e=>"#main_key"===e.id));return t?t.publicKeyJwk:null},getDocumentKeyScope:An,getKeyByScope:function(e,t){const n=Cn(e,t);if(n)return Pn(e,n);if(Bn(e))return null;const i=Kn(e);if(i){const t=Pn(e,i);if(t)return t}const r=Jn(e);return r?["",r]:null},getKeyFromKeyIds:Pn,getKeyIdsByScope:Cn,getKnownWeb3BridgeConfig:function(){return nn},getPublicKeyXFromPrivatePem:Wt,getStandardScopeKeyIds:Kn,getXFromJwk:Zt,hasKeyScope:Bn,isKeyAllowedInScope:function(e,t,n){const i=Cn(e,t);if(i)return i.some((t=>Rn(e,t,n)));if(Bn(e))return!1;const r=Kn(e);return r?r.some((t=>Rn(e,t,n))):null!==Jn(e,Hn(e,n))},isSameDocumentKeyId:Rn,newDeviceDocument:bn,newDeviceDocumentByJwk:gn,newDeviceDocumentByMiniDocument:vn,newDeviceMiniDocument:Sn,newDeviceMiniDocumentByDeviceDocument:jn,newOwnerDocument:ln,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!==$t(i).length)throw new Error("namelib: invalid pkx: x length must be 32 bytes");const r=Xt(i);if(1===n.length){const e=rn.fromStr(t),n=e.id;return ln({did:e,name:n,displayName:`${n}@${t}`,publicKeyJwk:r})}if(n.length>=3){const e=n[2];return ln({did:new rn(n[1],n[2]),name:e,displayName:`${e}@${t}`,publicKeyJwk:r})}throw new Error(`namelib: invalid pkx: ${e}`)},newZoneBootDocument:mn,newZoneDocument:pn,normalizeKeyIdForLocalLookup:Hn,oodDescriptionToString:sn,oodNodeTypeIsGateway:cn,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":wn(e,t)?"bound_v2":"unbound_v2"},ownerDocumentIsBoundToZone:wn,ownerDocumentRemoveBoundZone:function(e,t){var n;const i=hn(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,fn(e),o},ownerDocumentSetDefaultZoneDid:dn,ownerDocumentToOrderedJson:Nn,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=tn(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:Mn,parseDidDocAs:function(e,t){const n=Mn(e);if(n.docType!==t)throw new Error(`namelib: expected ${t} document, got ${n.docType}`);return n.doc},parseOODDescription:on,pemToDer:Ft,resetKnownWeb3BridgeConfigForTest:function(){nn=null},setKnownWeb3BridgeConfig:function(e){return null===nn&&(nn={...e},!0)},signJwtEdDSA:Gt,verifyJwtEdDSA:Qt,zoneBootDocumentGetGatewayName:function(e){for(const t of e.oods){const e=on(t);if(cn(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?rn.fromStr(e.owner):rn.undefined(),i=pn({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-Tt,i.version_seq=0,i.owner=e.owner??rn.undefined().toString(),i},zoneDocumentGetDefaultGateway:function(e){for(const t of e.oods){const e=on(t);if(cn(e.nodeType))return e.name}return null},zoneDocumentGetSnApiUrl:function(e){return void 0!==e.sn?`https://${e.sn}/kapi/sn`:null},zoneDocumentToOrderedJson:Tn},Symbol.toStringTag,{value:"Module"}));exports.ChunkId=Ze,exports.DEFAULT_EXPIRE_TIME=Tt,exports.DID=rn,exports.DID_OBJECT_SERVICE_ID="#did-object",exports.DID_OBJECT_SERVICE_TYPE=yt,exports.DirObject=at,exports.FileObject=it,exports.NODE_IDENTITY_SCHEMA_V2=bt,exports.ObjId=We,exports.SimpleChunkList=ut,exports.buckyosGetUnixTimestamp=Jt,exports.buildNamedObjectByJson=Ve,exports.canonicalize=fe,exports.cleanLocalAccountInfo=function(e){localStorage.removeItem(he(e)),localStorage.removeItem(ae),localStorage.removeItem(ue);let t={path:"/",expires:new Date(0),secure:!0,sameSite:"Lax"};document.cookie=`${e}_token=; ${Object.entries(t).map((([e,t])=>`${e}=${t}`)).join("; ")}`},exports.clearBrowserIdentity=function(){localStorage.removeItem(ue)},exports.clearBrowserUserInfo=function(){localStorage.removeItem(ae)},exports.commonjsGlobal=le,exports.createJwkByX=Xt,exports.decodeJwtClaimWithoutVerify=Vt,exports.deviceDocumentToOrderedJson=Dn,exports.deviceMiniDocumentToJwt=kn,exports.encodeDeviceDocument=_n,exports.encodeZoneBootDocument=yn,exports.encodeZoneDocument=xn,exports.getBrowserIdentityRaw=function(){const e=localStorage.getItem(ue);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(ae))},exports.getDefaultExportFromCjs=de,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=Wt,exports.getXFromJwk=Zt,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=kt,exports.isBuckyOSDIDObjectCard=xt,exports.isBuckyOSDeviceDocument=jt,exports.isBuckyOSDeviceMiniDocument=St,exports.isBuckyOSLocalNodeIdentityConfig=function(e){return gt(e)&&e.schema===bt&&"string"==typeof e.zone_did&&"string"==typeof e.owner_did&&gt(e.owner_public_key)&&"string"==typeof e.device_name&&"string"==typeof e.device_did&&"number"==typeof e.zone_iat},exports.isBuckyOSOwnerDocument=It,exports.isBuckyOSZoneBootDocument=function(e){return gt(e)&&Array.isArray(e.oods)&&e.oods.every((e=>"string"==typeof e))&&"number"==typeof e.exp},exports.isBuckyOSZoneConfig=function(e){return gt(e)&&"string"==typeof e.zone_document},exports.isBuckyOSZoneDocument=Ot,exports.isW3CDIDDocumentBase=_t,exports.namelib=Un,exports.ndn_types=mt,exports.newDeviceDocumentByJwk=gn,exports.newDeviceDocumentByMiniDocument=vn,exports.newDeviceMiniDocument=Sn,exports.newDeviceMiniDocumentByDeviceDocument=jn,exports.newOwnerDocument=ln,exports.newZoneBootDocument=mn,exports.newZoneDocument=pn,exports.oodDescriptionToString=sn,exports.ownerDocumentSetDefaultZoneDid=dn,exports.ownerDocumentToOrderedJson=Nn,exports.parseBuckyOSDIDDocument=function(e){return It(e)||kt(e)||jt(e)||Ot(e)||xt(e)?e:null},exports.parseBuckyOSDeviceMiniDocument=function(e){return St(e)?e:null},exports.parseBuckyOSOwnerDocument=function(e){return It(e)?e:null},exports.parseOODDescription=on,exports.parseW3CDIDDocumentBase=function(e){return _t(e)?e:null},exports.saveBrowserIdentity=function(e){localStorage.setItem(ue,JSON.stringify(e))},exports.saveBrowserUserInfo=function(e){localStorage.setItem(ae,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=Me,exports.signJwtEdDSA=Gt,exports.verifyJwtEdDSA=Qt,exports.zoneDocumentToOrderedJson=Tn;
2
+ //# sourceMappingURL=namelib-f8ff0045.js.map