@substrate-system/keys 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_base.min.js +2 -2
- package/dist/_base.min.js.map +4 -4
- package/dist/aes/index.min.js +2 -2
- package/dist/aes/index.min.js.map +3 -3
- package/dist/browser/index.js +118 -34
- package/dist/browser/index.min.js +2 -2
- package/dist/crypto.min.js +2 -2
- package/dist/crypto.min.js.map +4 -4
- package/dist/ecc/index.min.js +2 -2
- package/dist/ecc/index.min.js.map +4 -4
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +4 -4
- package/dist/rsa/index.min.js +2 -2
- package/dist/rsa/index.min.js.map +4 -4
- package/dist/util.d.ts +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.min.js +1 -1
- package/dist/util.min.js.map +3 -3
- package/package.json +2 -2
package/dist/_base.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var be=Object.defineProperty;var Vr=(r,e,t)=>e in r?be(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e)=>be(r,"name",{value:e,configurable:!0});var b=(r,e)=>{for(var t in e)be(r,t,{get:e[t],enumerable:!0})};var c=(r,e,t)=>Vr(r,typeof e!="symbol"?e+"":e,t);function re(r=0){return new Uint8Array(r)}o(re,"allocUnsafe");function we(r,e){e==null&&(e=r.reduce((i,s)=>i+s.length,0));let t=re(e),n=0;for(let i of r)t.set(i,n),n+=i.length;return t}o(we,"concat");var Te={};b(Te,{base10:()=>Zr});var Gn=new Uint8Array(0);function ur(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}o(ur,"equals");function T(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}o(T,"coerce");function lr(r){return new TextEncoder().encode(r)}o(lr,"fromString");function hr(r){return new TextDecoder().decode(r)}o(hr,"toString");function Wr(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<r.length;i++){var s=r.charAt(i),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=i}var y=r.length,h=r.charAt(0),d=Math.log(y)/Math.log(256),K=Math.log(256)/Math.log(y);function ee(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var m=0,L=0,E=0,S=f.length;E!==S&&f[E]===0;)E++,m++;for(var C=(S-E)*K+1>>>0,A=new Uint8Array(C);E!==S;){for(var P=f[E],I=0,U=C-1;(P!==0||I<L)&&U!==-1;U--,I++)P+=256*A[U]>>>0,A[U]=P%y>>>0,P=P/y>>>0;if(P!==0)throw new Error("Non-zero carry");L=I,E++}for(var B=C-L;B!==C&&A[B]===0;)B++;for(var fe=h.repeat(m);B<C;++B)fe+=r.charAt(A[B]);return fe}o(ee,"encode");function D(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var m=0;if(f[m]!==" "){for(var L=0,E=0;f[m]===h;)L++,m++;for(var S=(f.length-m)*d+1>>>0,C=new Uint8Array(S);f[m];){var A=t[f.charCodeAt(m)];if(A===255)return;for(var P=0,I=S-1;(A!==0||P<E)&&I!==-1;I--,P++)A+=y*C[I]>>>0,C[I]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");E=P,m++}if(f[m]!==" "){for(var U=S-E;U!==S&&C[U]===0;)U++;for(var B=new Uint8Array(L+(S-U)),fe=L;U!==S;)B[fe++]=C[U++];return B}}}o(D,"decodeUnsafe");function Fr(f){var m=D(f);if(m)return m;throw new Error(`Non-${e} character`)}return o(Fr,"decode"),{encode:ee,decodeUnsafe:D,decode:Fr}}o(Wr,"base");var Xr=Wr,Yr=Xr,mr=Yr;var Ce=class Ce{constructor(e,t,n){c(this,"name");c(this,"prefix");c(this,"baseEncode");this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};o(Ce,"Encoder");var Ke=Ce,Pe=class Pe{constructor(e,t,n){c(this,"name");c(this,"prefix");c(this,"baseDecode");c(this,"prefixCodePoint");this.name=e,this.prefix=t;let i=t.codePointAt(0);if(i===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return gr(this,e)}};o(Pe,"Decoder");var Ee=Pe,ve=class ve{constructor(e){c(this,"decoders");this.decoders=e}or(e){return gr(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};o(ve,"ComposedDecoder");var Ue=ve;function gr(r,e){return new Ue({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}o(gr,"or");var Be=class Be{constructor(e,t,n,i){c(this,"name");c(this,"prefix");c(this,"baseEncode");c(this,"baseDecode");c(this,"encoder");c(this,"decoder");this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new Ke(e,t,n),this.decoder=new Ee(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};o(Be,"Codec");var Se=Be;function O({name:r,prefix:e,encode:t,decode:n}){return new Se(r,e,t,n)}o(O,"from");function _({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=mr(t,r);return O({prefix:e,name:r,encode:n,decode:o(s=>T(i(s)),"decode")})}o(_,"baseX");function jr(r,e,t,n){let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),a=0,y=0,h=0;for(let d=0;d<i;++d){let K=e[r[d]];if(K===void 0)throw new SyntaxError(`Non-${n} character`);y=y<<t|K,a+=t,a>=8&&(a-=8,s[h++]=255&y>>a)}if(a>=t||(255&y<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}o(jr,"decode");function qr(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,s="",a=0,y=0;for(let h=0;h<r.length;++h)for(y=y<<8|r[h],a+=8;a>t;)a-=t,s+=e[i&y>>a];if(a!==0&&(s+=e[i&y<<t-a]),n)for(;(s.length*t&7)!==0;)s+="=";return s}o(qr,"encode");function Jr(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}o(Jr,"createAlphabetIdx");function p({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let i=Jr(n);return O({prefix:e,name:r,encode(s){return qr(s,n,t)},decode(s){return jr(s,i,t,r)}})}o(p,"rfc4648");var Zr=_({prefix:"9",name:"base10",alphabet:"0123456789"});var De={};b(De,{base16:()=>Qr,base16upper:()=>et});var Qr=p({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),et=p({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ie={};b(Ie,{base2:()=>rt});var rt=p({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _e={};b(_e,{base256emoji:()=>st});var xr=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),tt=xr.reduce((r,e,t)=>(r[t]=e,r),[]),nt=xr.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function it(r){return r.reduce((e,t)=>(e+=tt[t],e),"")}o(it,"encode");function ot(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let i=nt[n];if(i==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}o(ot,"decode");var st=O({prefix:"\u{1F680}",name:"base256emoji",encode:it,decode:ot});var Ne={};b(Ne,{base32:()=>z,base32hex:()=>ft,base32hexpad:()=>ut,base32hexpadupper:()=>lt,base32hexupper:()=>pt,base32pad:()=>ct,base32padupper:()=>yt,base32upper:()=>at,base32z:()=>ht});var z=p({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),at=p({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ct=p({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yt=p({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ft=p({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pt=p({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ut=p({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),lt=p({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ht=p({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Le={};b(Le,{base36:()=>te,base36upper:()=>dt});var te=_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),dt=_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Me={};b(Me,{base58btc:()=>v,base58flickr:()=>mt});var v=_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),mt=_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Re={};b(Re,{base64:()=>gt,base64pad:()=>xt,base64url:()=>At,base64urlpad:()=>bt});var gt=p({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xt=p({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),At=p({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),bt=p({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ke={};b(ke,{base8:()=>wt});var wt=p({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Oe={};b(Oe,{identity:()=>Kt});var Kt=O({prefix:"\0",name:"identity",encode:o(r=>hr(r),"encode"),decode:o(r=>lr(r),"decode")});var yi=new TextEncoder,fi=new TextDecoder;var Ge={};b(Ge,{identity:()=>$t});var St=wr,Ar=128,Ct=127,Pt=~Ct,vt=Math.pow(2,31);function wr(r,e,t){e=e||[],t=t||0;for(var n=t;r>=vt;)e[t++]=r&255|Ar,r/=128;for(;r&Pt;)e[t++]=r&255|Ar,r>>>=7;return e[t]=r|0,wr.bytes=t-n+1,e}o(wr,"encode");var Bt=ze,Tt=128,br=127;function ze(r,n){var t=0,n=n||0,i=0,s=n,a,y=r.length;do{if(s>=y)throw ze.bytes=0,new RangeError("Could not decode varint");a=r[s++],t+=i<28?(a&br)<<i:(a&br)*Math.pow(2,i),i+=7}while(a>=Tt);return ze.bytes=s-n,t}o(ze,"read");var Dt=Math.pow(2,7),It=Math.pow(2,14),_t=Math.pow(2,21),Nt=Math.pow(2,28),Lt=Math.pow(2,35),Mt=Math.pow(2,42),Rt=Math.pow(2,49),kt=Math.pow(2,56),Ot=Math.pow(2,63),zt=o(function(r){return r<Dt?1:r<It?2:r<_t?3:r<Nt?4:r<Lt?5:r<Mt?6:r<Rt?7:r<kt?8:r<Ot?9:10},"length"),Ht={encode:St,decode:Bt,encodingLength:zt},Gt=Ht,ne=Gt;function ie(r,e=0){return[ne.decode(r,e),ne.decode.bytes]}o(ie,"decode");function H(r,e,t=0){return ne.encode(r,e,t),e}o(H,"encodeTo");function G(r){return ne.encodingLength(r)}o(G,"encodingLength");function V(r,e){let t=e.byteLength,n=G(r),i=n+G(t),s=new Uint8Array(i+t);return H(r,s,0),H(t,s,n),s.set(e,i),new F(r,t,e,s)}o(V,"create");function Kr(r){let e=T(r),[t,n]=ie(e),[i,s]=ie(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==i)throw new Error("Incorrect length");return new F(t,i,a,e)}o(Kr,"decode");function Er(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&ur(r.bytes,t.bytes)}}o(Er,"equals");var He=class He{constructor(e,t,n,i){c(this,"code");c(this,"size");c(this,"digest");c(this,"bytes");this.code=e,this.size=t,this.digest=n,this.bytes=i}};o(He,"Digest");var F=He;var Ur=0,Ft="identity",Sr=T;function Vt(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return V(Ur,Sr(r))}o(Vt,"digest");var $t={code:Ur,name:Ft,encode:Sr,digest:Vt};var We={};b(We,{sha256:()=>Xt,sha512:()=>Yt});var Wt=20;function Ve({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:i}){return new Fe(r,e,t,n,i)}o(Ve,"from");var $e=class $e{constructor(e,t,n,i,s){c(this,"name");c(this,"code");c(this,"encode");c(this,"minDigestLength");c(this,"maxDigestLength");this.name=e,this.code=t,this.encode=n,this.minDigestLength=i??Wt,this.maxDigestLength=s}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Cr(n,this.code,t?.truncate):n.then(i=>Cr(i,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};o($e,"Hasher");var Fe=$e;function Cr(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return V(e,r)}o(Cr,"createDigest");function vr(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}o(vr,"sha");var Xt=Ve({name:"sha2-256",code:18,encode:vr("SHA-256")}),Yt=Ve({name:"sha2-512",code:19,encode:vr("SHA-512")});function Br(r,e){let{bytes:t,version:n}=r;return n===0?qt(t,Xe(r),e??v.encoder):Jt(t,Xe(r),e??z.encoder)}o(Br,"format");var Tr=new WeakMap;function Xe(r){let e=Tr.get(r);if(e==null){let t=new Map;return Tr.set(r,t),t}return e}o(Xe,"baseCache");var Ir,l=class l{constructor(e,t,n,i){c(this,"code");c(this,"version");c(this,"multihash");c(this,"bytes");c(this,"/");c(this,Ir,"CID");this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Zt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return l.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=V(e,t);return l.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return l.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&Er(e.multihash,n.multihash)}toString(e){return Br(this,e)}toJSON(){return{"/":Br(this)}}link(){return this}[(Ir=Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"))](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof l)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:s,bytes:a}=t;return new l(n,i,s,a??Dr(n,i,s.bytes))}else if(t[Qt]===!0){let{version:n,multihash:i,code:s}=t,a=Kr(i);return l.create(n,s,a)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==se)throw new Error(`Version 0 CID must use dag-pb (code: ${se}) block encoding`);return new l(e,t,n,n.bytes)}case 1:{let i=Dr(e,t,n.bytes);return new l(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return l.create(0,se,e)}static createV1(e,t){return l.create(1,e,t)}static decode(e){let[t,n]=l.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=l.inspectBytes(e),n=t.size-t.multihashSize,i=T(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=i.subarray(t.multihashSize-t.digestSize),a=new F(t.multihashCode,t.digestSize,s,i);return[t.version===0?l.createV0(a):l.createV1(t.codec,a),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=o(()=>{let[ee,D]=ie(e.subarray(t));return t+=D,ee},"next"),i=n(),s=se;if(i===18?(i=0,t=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let a=t,y=n(),h=n(),d=t+h,K=d-a;return{version:i,codec:s,multihashCode:y,digestSize:h,multihashSize:K,size:d}}static parse(e,t){let[n,i]=jt(e,t),s=l.decode(i);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Xe(s).set(n,e),s}};o(l,"CID");var ue=l;function jt(r,e){switch(r[0]){case"Q":{let t=e??v;return[v.prefix,t.decode(`${v.prefix}${r}`)]}case v.prefix:{let t=e??v;return[v.prefix,t.decode(r)]}case z.prefix:{let t=e??z;return[z.prefix,t.decode(r)]}case te.prefix:{let t=e??te;return[te.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}o(jt,"parseCIDtoBytes");function qt(r,e,t){let{prefix:n}=t;if(n!==v.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return i}o(qt,"toStringV0");function Jt(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let s=t.encode(r);return e.set(n,s),s}else return i}o(Jt,"toStringV1");var se=112,Zt=18;function Dr(r,e,t){let n=G(r),i=n+G(e),s=new Uint8Array(i+t.byteLength);return H(r,s,0),H(e,s,n),s.set(t,i),s}o(Dr,"encodeCID");var Qt=Symbol.for("@ipld/js-cid/CID");var Ye={...Oe,...Ie,...ke,...Te,...De,...Ne,...Le,...Me,...Re,..._e},Hi={...We,...Ge};function Nr(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}o(Nr,"createCodec");var _r=Nr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),je=Nr("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=re(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),en={utf8:_r,"utf-8":_r,hex:Ye.base16,latin1:je,ascii:je,binary:je,...Ye},le=en;function g(r,e="utf8"){let t=le[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}o(g,"fromString");function x(r,e="utf8"){let t=le[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}o(x,"toString");function he(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}o(he,"promisifyRequest");function rn(r,e){let t,n=o(()=>{if(t)return t;let i=indexedDB.open(r);return i.onupgradeneeded=()=>i.result.createObjectStore(e),t=he(i),t.then(s=>{s.onclose=()=>t=void 0},()=>{t=void 0}),t},"getDB");return(i,s)=>n().then(a=>s(a.transaction(e,i).objectStore(e)))}o(rn,"createStore");var qe;function Je(){return qe||(qe=rn("keyval-store","keyval")),qe}o(Je,"defaultGetStore");function ae(r,e=Je()){return e("readonly",t=>he(t.get(r)))}o(ae,"get");function Ze(r,e,t=Je()){return t("readwrite",n=>(n.put(e,r),he(n.transaction)))}o(Ze,"set");function Qe(r,e=Je()){return e("readwrite",t=>(r.forEach(n=>t.delete(n)),he(t.transaction)))}o(Qe,"delMany");var ce="did:key:z",go="Ed25519",xo="X25519",Ao="X25519",bo=32,nn={sign:["sign","verify"],encrypt:["deriveKey","deriveBits"]},$="RSA-OAEP",W="RSASSA-PKCS1-v1_5",er="SHA-256",on=new Uint8Array([0,245,2]),wo=2048,rr="SHA-256",X=8,Y="AES-GCM",j=Y,ye=256,de=12,Ko=16,sn=new Uint8Array([234,1]),an=new Uint8Array([237,1]),cn={RSA:"rsa",Edwards:"ed25519",BLS:"bls12-381"},Eo="rsa-exchange-key",Uo="rsa-write-key",So="ecc-exchange",Co="ecc-write",Po=16,vo=1;var me=globalThis.crypto,Mr=new Error("Invalid key use. Please use 'encryption' or 'signing"),yn=new Error("Max must be less than 256 and greater than 0");function u(r){return new Uint8Array(r).buffer}o(u,"toArrayBuffer");async function Rr(r){let e=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);return new Uint8Array(await me.subtle.digest("sha-256",e))}o(Rr,"sha256");function q(r){let e=g(r,"base64pad");return u(e)}o(q,"base64ToArrBuf");var tr=o((r,e)=>{if(typeof r=="string")return e(r);if(typeof r=="object"&&r.byteLength!==void 0)return new Uint8Array(r).buffer;throw new Error("Improper value. Must be a string, ArrayBuffer, Uint8Array")},"normalizeToBuf");function ge(r){return tr(r,q)}o(ge,"normalizeBase64ToBuf");var fn=o(r=>tr(r,e=>u(new TextEncoder().encode(e))),"normalizeUtf8ToBuf");function pn(r,e){let t=e===8?new Uint8Array(r.length):new Uint16Array(r.length);for(let n=0,i=r.length;n<i;n++)t[n]=r.charCodeAt(n);return t.buffer}o(pn,"strToArrBuf");var un=o(r=>tr(r,e=>pn(e,16)),"normalizeUtf16ToBuf");function J(r,e){return e===8?fn(r):un(r)}o(J,"normalizeUnicodeToBuf");var ln={equal:o((r,e)=>{let t=new Uint8Array(r),n=new Uint8Array(e);if(t.length!==n.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0},"equal")};function kr(r,e){return ln.equal(e,r.slice(0,e.byteLength))}o(kr,"hasPrefix");function M(r){return x(r instanceof ArrayBuffer?new Uint8Array(r):r,"base64pad")}o(M,"toBase64");async function nr(r,e){let t=typeof r=="string"?q(r):u(r);return me.subtle.importKey("raw",t,{name:e?.alg||j,length:e?.length||ye},e?.extractable??!0,["encrypt","decrypt"])}o(nr,"importKey");function Or(r,{max:e}={max:255}){if(e<1||e>255)throw yn;let t=new Uint8Array(r);if(e===255)return me.getRandomValues(t),t.buffer;let n=0,i=e+1,s=Math.floor(256/i)*i,a=new Uint8Array(1);for(;n<t.length;)me.getRandomValues(a),a[0]<s&&(t[n]=a[0]%i,n++);return t.buffer}o(Or,"randomBuf");function xe(r,e){let t=r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(u(r)),n=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(u(e)),i=new Uint8Array(t.length+n.length);return i.set(t),i.set(n,t.length),i.buffer}o(xe,"joinBufs");var w=globalThis.crypto,sr={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:o(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:dn},ed25519:{magicBytes:new Uint8Array([237,1]),verify:hn}}};async function hn({message:r,publicKey:e,signature:t}){let n=r;typeof r=="string"&&(n=g(r,"utf8"));let i=t;typeof t=="string"&&(i=g(t,"base64pad"));let s=e;if(typeof e=="string"&&(s=zr(e).publicKey),s.length!==32)throw new Error(`Invalid Ed25519 public key size: ${s.length} bytes, expected 32`);if(i.length!==64)throw new Error(`Invalid Ed25519 signature size: ${i.length} bytes, expected 64`);let a=await w.subtle.importKey("raw",u(s),{name:"Ed25519"},!1,["verify"]);return w.subtle.verify({name:"Ed25519"},a,u(i),u(n))}o(hn,"ed25519Verify");async function dn({message:r,publicKey:e,signature:t}){let n=e;return typeof e=="string"&&(n=zr(e).publicKey),ar.verify(r,t,await w.subtle.importKey("spki",u(n),{name:W,hash:er},!1,["verify"]),8)}o(dn,"rsaVerify");var ar={verify:o(async function(e,t,n,i=X,s=rr){return w.subtle.verify({name:W},typeof n=="string"?await ir(n,s,"signing"):n,ge(t),J(e,i))},"rsaVerify"),sign:o(async function(e,t,n=X){return w.subtle.sign({name:W},t,J(e,n))},"sign"),encrypt:o(async function(e,t,n=X,i=rr){let s;return typeof t=="string"?s=await ir(t,i,"exchange"):s=t instanceof Uint8Array?await ir(u(t),i,"exchange"):t,w.subtle.encrypt({name:$},s,J(e,n))},"rsaEncrypt"),decrypt:o(async function(e,t){let n=Ae(t)?t:await An(t,["decrypt"]),i;typeof e=="string"?i=g(e,"base64pad"):i=e;let s=await w.subtle.decrypt({name:$},n,i instanceof Uint8Array?u(i):i);return new Uint8Array(s)},"rsaDecrypt")};async function ir(r,e,t){mn(t);let n=t==="exchange"?$:W,i=t==="exchange"?["encrypt"]:["verify"],s=typeof r=="string"?q(xn(r)):r;return w.subtle.importKey("spki",s,{name:n,hash:{name:e}},!0,i)}o(ir,"rsaImportPublicKey");function mn(r){gn(r,["signing","exchange"],Mr)}o(mn,"checkValidKeyUse");function gn(r,e,t){if(!e.some(i=>i===r))throw t}o(gn,"checkValid");function xn(r){return r.replace(`-----BEGIN PUBLIC KEY-----
|
|
1
|
+
var we=Object.defineProperty;var Jr=(r,e,t)=>e in r?we(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e)=>we(r,"name",{value:e,configurable:!0});var K=(r,e)=>{for(var t in e)we(r,t,{get:e[t],enumerable:!0})};var c=(r,e,t)=>Jr(r,typeof e!="symbol"?e+"":e,t);function H(r=0){return new Uint8Array(r)}o(H,"allocUnsafe");function Zr(r){return r?.buffer instanceof ArrayBuffer}o(Zr,"isByteArrayWithArrayBuffer");function Ke(r){if(Zr(r))return r;let e=r.slice();return new Uint8Array(e.buffer,0,e.byteLength)}o(Ke,"asUint8Array");function Ee(r,e){e==null&&(e=r.reduce((i,s)=>i+s.length,0));let t=H(e),n=0;for(let i of r)t.set(i,n),n+=i.length;return Ke(t)}o(Ee,"concat");var De={};K(De,{base10:()=>st});var ei=new Uint8Array(0);function mr(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}o(mr,"equals");function E(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return M(r);if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return M(new Uint8Array(r.buffer,r.byteOffset,r.byteLength));throw new Error("Unknown type, must be binary type")}o(E,"coerce");function gr(r){let e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}o(gr,"fromString");var dr=4096;function Ar(r){let e=r.length;if(e<=dr)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.subarray(n,n+=dr));return t}o(Ar,"toString");function Qr(r){return r?.buffer instanceof ArrayBuffer}o(Qr,"isByteArrayWithArrayBuffer");function M(r){return Qr(r)?r:r.slice()}o(M,"toArrayBufferBackedArray");function et(r,e,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),i=0;i<n.length;i++)n[i]=255;for(var s=0;s<r.length;s++){var a=r.charAt(s),y=a.charCodeAt(0);if(n[y]!==255)throw new TypeError(a+" is ambiguous");if(n[y]=s,t){var h=a.toLowerCase().charCodeAt(0),d=a.toUpperCase().charCodeAt(0);h!==y&&(n[h]=s),d!==y&&(n[d]=s)}}var m=r.length,z=r.charAt(0),D=Math.log(m)/Math.log(256),$r=Math.log(256)/Math.log(m);function Yr(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var g=0,_=0,S=0,C=f.length;S!==C&&f[S]===0;)S++,g++;for(var v=(C-S)*$r+1>>>0,N=new Uint8Array(v);S!==C;){for(var A=f[S],L=0,B=v-1;(A!==0||L<_)&&B!==-1;B--,L++)A+=256*N[B]>>>0,N[B]=A%m>>>0,A=A/m>>>0;if(A!==0)throw new Error("Non-zero carry");_=L,S++}for(var x=v-_;x!==v&&N[x]===0;)x++;for(var ne=z.repeat(g);x<v;++x)ne+=r.charAt(N[x]);return ne}o(Yr,"encode");function hr(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var g=0;if(f[g]!==" "){for(var _=0,S=0;f[g]===z;)_++,g++;for(var C=(f.length-g)*D+1>>>0,v=new Uint8Array(C);f[g];){var N=f.charCodeAt(g);if(N>255)return;var A=n[N];if(A===255)return;for(var L=0,B=C-1;(A!==0||L<S)&&B!==-1;B--,L++)A+=m*v[B]>>>0,v[B]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");S=L,g++}if(f[g]!==" "){for(var x=C-S;x!==C&&v[x]===0;)x++;for(var ne=new Uint8Array(_+(C-x)),qr=_;x!==C;)ne[qr++]=v[x++];return ne}}}o(hr,"decodeUnsafe");function jr(f){var g=hr(f);if(g)return g;throw new Error(`Non-${e} character`)}return o(jr,"decode"),{encode:Yr,decodeUnsafe:hr,decode:jr}}o(et,"base");var rt=et,tt=rt,br=tt;var Pe=class Pe{constructor(e,t,n){c(this,"name");c(this,"prefix");c(this,"baseEncode");this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};o(Pe,"Encoder");var Ue=Pe,Be=class Be{constructor(e,t,n){c(this,"name");c(this,"prefix");c(this,"baseDecode");c(this,"prefixCodePoint");this.name=e,this.prefix=t;let i=t.codePointAt(0);if(i===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return wr(this,e)}};o(Be,"Decoder");var Se=Be,Ie=class Ie{constructor(e){c(this,"decoders");this.decoders=e}or(e){return wr(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};o(Ie,"ComposedDecoder");var Ce=Ie;function wr(r,e){return new Ce({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}o(wr,"or");var Te=class Te{constructor(e,t,n,i){c(this,"name");c(this,"prefix");c(this,"baseEncode");c(this,"baseDecode");c(this,"encoder");c(this,"decoder");this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new Ue(e,t,n),this.decoder=new Se(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};o(Te,"Codec");var ve=Te;function G({name:r,prefix:e,encode:t,decode:n}){return new ve(r,e,t,n)}o(G,"from");function I({name:r,prefix:e,alphabet:t,caseInsensitive:n=!1}){let{encode:i,decode:s}=br(t,r,n);return G({prefix:e,name:r,encode:i,decode:o(a=>E(s(a)),"decode")})}o(I,"baseX");function nt(r,e,t,n){let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),a=0,y=0,h=0;for(let d=0;d<i;++d){let m=e[r[d]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);y=y<<t|m,a+=t,a>=8&&(a-=8,s[h++]=255&y>>a)}if(a>=t||(255&y<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}o(nt,"decode");function it(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,s="",a=0,y=0;for(let h=0;h<r.length;++h)for(y=y<<8|r[h],a+=8;a>t;)a-=t,s+=e[i&y>>a];if(a!==0&&(s+=e[i&y<<t-a]),n)for(;(s.length*t&7)!==0;)s+="=";return s}o(it,"encode");function ot(r,e){let t={};for(let n=0;n<r.length;++n)if(r[n]!=="="&&(t[r[n]]=n,e)){let i=r[n].toLowerCase(),s=r[n].toUpperCase();i!==r[n]&&(t[i]=n),s!==r[n]&&(t[s]=n)}return t}o(ot,"createAlphabetIdx");function u({name:r,prefix:e,bitsPerChar:t,alphabet:n,caseInsensitive:i=!1}){let s=ot(n,i);return G({prefix:e,name:r,encode(a){return it(a,n,t)},decode(a){return nt(a,s,t,r)}})}o(u,"rfc4648");var st=I({prefix:"9",name:"base10",alphabet:"0123456789"});var _e={};K(_e,{base16:()=>at,base16upper:()=>ct});var at=u({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),ct=u({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var Ne={};K(Ne,{base2:()=>yt});var yt=u({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Le={};K(Le,{base256emoji:()=>ht});var Kr=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),ft=Kr.reduce((r,e,t)=>(r[t]=e,r),[]),ut=Kr.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function pt(r){return r.reduce((e,t)=>(e+=ft[t],e),"")}o(pt,"encode");function lt(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let i=ut[n];if(i==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}o(lt,"decode");var ht=G({prefix:"\u{1F680}",name:"base256emoji",encode:pt,decode:lt});var Me={};K(Me,{base32:()=>F,base32hex:()=>At,base32hexpad:()=>bt,base32hexpadupper:()=>wt,base32hexupper:()=>xt,base32pad:()=>mt,base32padupper:()=>gt,base32upper:()=>dt,base32z:()=>Kt});var F=u({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),dt=u({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),mt=u({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),gt=u({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),At=u({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),xt=u({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),bt=u({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),wt=u({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),Kt=u({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Re={};K(Re,{base36:()=>ie,base36upper:()=>Et});var ie=I({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),Et=I({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var ke={};K(ke,{base58btc:()=>P,base58flickr:()=>Ut});var P=I({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ut=I({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Oe={};K(Oe,{base64:()=>St,base64pad:()=>Ct,base64url:()=>vt,base64urlpad:()=>Pt});var St=u({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ct=u({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vt=u({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pt=u({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ze={};K(ze,{base8:()=>Bt});var Bt=u({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var He={};K(He,{identity:()=>It});var It=G({prefix:"\0",name:"identity",encode:o(r=>Ar(E(r)),"encode"),decode:o(r=>E(gr(r)),"decode")});var wi=new TextEncoder,Ki=new TextDecoder;var Ve={};K(Ve,{identity:()=>Qt});var _t=Sr,Er=128,Nt=127,Lt=~Nt,Mt=Math.pow(2,31);function Sr(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Mt;)e[t++]=r&255|Er,r/=128;for(;r≪)e[t++]=r&255|Er,r>>>=7;return e[t]=r|0,Sr.bytes=t-n+1,e}o(Sr,"encode");var Rt=Ge,kt=128,Ur=127;function Ge(r,n){var t=0,n=n||0,i=0,s=n,a,y=r.length;do{if(s>=y)throw Ge.bytes=0,new RangeError("Could not decode varint");a=r[s++],t+=i<28?(a&Ur)<<i:(a&Ur)*Math.pow(2,i),i+=7}while(a>=kt);return Ge.bytes=s-n,t}o(Ge,"read");var Ot=Math.pow(2,7),zt=Math.pow(2,14),Ht=Math.pow(2,21),Gt=Math.pow(2,28),Ft=Math.pow(2,35),Vt=Math.pow(2,42),Wt=Math.pow(2,49),Xt=Math.pow(2,56),$t=Math.pow(2,63),Yt=o(function(r){return r<Ot?1:r<zt?2:r<Ht?3:r<Gt?4:r<Ft?5:r<Vt?6:r<Wt?7:r<Xt?8:r<$t?9:10},"length"),jt={encode:_t,decode:Rt,encodingLength:Yt},qt=jt,oe=qt;function se(r,e=0){let t=oe.decode(r,e),n=oe.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&r[e+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[t,n]}o(se,"decode");function V(r,e,t=0){return oe.encode(r,e,t),e}o(V,"encodeTo");function W(r){return oe.encodingLength(r)}o(W,"encodingLength");function $(r,e){let t=e.byteLength,n=W(r),i=n+W(t),s=new Uint8Array(i+t);return V(r,s,0),V(t,s,n),s.set(e,i),new X(r,t,e,s)}o($,"create");function Cr(r){let e=E(r),[t,n]=se(e),[i,s]=se(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==i)throw new Error("Incorrect length");return new X(t,i,a,e)}o(Cr,"decode");function vr(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&mr(r.bytes,t.bytes)}}o(vr,"equals");var Fe=class Fe{constructor(e,t,n,i){c(this,"code");c(this,"size");c(this,"digest");c(this,"bytes");this.code=e,this.size=t,this.digest=M(n),this.bytes=M(i)}};o(Fe,"Digest");var X=Fe;var Pr=0,Jt="identity",Br=E;function Zt(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return $(Pr,Br(r))}o(Zt,"digest");var Qt={code:Pr,name:Jt,encode:Br,digest:Zt};var Ye={};K(Ye,{sha256:()=>rn,sha512:()=>tn});var en=20;function Xe({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:i}){return new We(r,e,t,n,i)}o(Xe,"from");var $e=class $e{constructor(e,t,n,i,s){c(this,"name");c(this,"code");c(this,"encode");c(this,"minDigestLength");c(this,"maxDigestLength");this.name=e,this.code=t,this.encode=n,this.minDigestLength=i??en,this.maxDigestLength=s}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Ir(n,this.code,t?.truncate):n.then(i=>Ir(i,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};o($e,"Hasher");var We=$e;function Ir(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return $(e,r)}o(Ir,"createDigest");function Dr(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}o(Dr,"sha");var rn=Xe({name:"sha2-256",code:18,encode:Dr("SHA-256")}),tn=Xe({name:"sha2-512",code:19,encode:Dr("SHA-512")});function _r(r,e){let{bytes:t,version:n}=r;return n===0?on(t,je(r),e??P.encoder):sn(t,je(r),e??F.encoder)}o(_r,"format");var Nr=new WeakMap;function je(r){let e=Nr.get(r);if(e==null){let t=new Map;return Nr.set(r,t),t}return e}o(je,"baseCache");var Mr,l=class l{constructor(e,t,n,i){c(this,"code");c(this,"version");c(this,"multihash");c(this,"bytes");c(this,"/");c(this,Mr,"CID");this.code=t,this.version=e,this.multihash=n,this.bytes=M(i),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==ce)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==an)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return l.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=$(e,t);return l.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return l.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&vr(e.multihash,n.multihash)}toString(e){return _r(this,e)}toJSON(){return{"/":_r(this)}}link(){return this}[(Mr=Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"))](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof l)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:s,bytes:a}=t;return new l(n,i,s,a??Lr(n,i,s.bytes))}else if(t[cn]===!0){let{version:n,multihash:i,code:s}=t,a=Cr(i);return l.create(n,s,a)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==ce)throw new Error(`Version 0 CID must use dag-pb (code: ${ce}) block encoding`);return new l(e,t,n,n.bytes)}case 1:{let i=Lr(e,t,n.bytes);return new l(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return l.create(0,ce,e)}static createV1(e,t){return l.create(1,e,t)}static decode(e){let[t,n]=l.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=l.inspectBytes(e),n=t.size-t.multihashSize,i=E(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=i.subarray(t.multihashSize-t.digestSize),a=new X(t.multihashCode,t.digestSize,s,i);return[t.version===0?l.createV0(a):l.createV1(t.codec,a),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=o(()=>{let[z,D]=se(e.subarray(t));return t+=D,z},"next"),i=n(),s=ce;if(i===18)i=0,t=0;else if(i===1)s=n();else throw i===0?new RangeError("Invalid CID version, v0 is always implicit"):new RangeError(`Invalid CID version ${i}`);let a=t,y=n(),h=n(),d=t+h,m=d-a;return{version:i,codec:s,multihashCode:y,digestSize:h,multihashSize:m,size:d}}static parse(e,t){let[n,i]=nn(e,t),s=l.decode(i);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return je(s).set(n,e),s}};o(l,"CID");var le=l;function nn(r,e){switch(r[0]){case"Q":{let t=e??P;return[P.prefix,t.decode(`${P.prefix}${r}`)]}case P.prefix:{let t=e??P;return[P.prefix,t.decode(r)]}case F.prefix:{let t=e??F;return[F.prefix,t.decode(r)]}case ie.prefix:{let t=e??ie;return[ie.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}o(nn,"parseCIDtoBytes");function on(r,e,t){let{prefix:n}=t;if(n!==P.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return i}o(on,"toStringV0");function sn(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let s=t.encode(r);return e.set(n,s),s}else return i}o(sn,"toStringV1");var ce=112,an=18;function Lr(r,e,t){let n=W(r),i=n+W(e),s=new Uint8Array(i+t.byteLength);return V(r,s,0),V(e,s,n),s.set(t,i),s}o(Lr,"encodeCID");var cn=Symbol.for("@ipld/js-cid/CID");var qe={...He,...Ne,...ze,...De,..._e,...Me,...Re,...ke,...Oe,...Le},Qi={...Ye,...Ve};function kr(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}o(kr,"createCodec");var Rr=kr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Je=kr("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=H(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),yn={utf8:Rr,"utf-8":Rr,hex:qe.base16,latin1:Je,ascii:Je,binary:Je,...qe},he=yn;function b(r,e="utf8"){let t=he[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}o(b,"fromString");function w(r,e="utf8"){let t=he[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}o(w,"toString");function de(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}o(de,"promisifyRequest");function fn(r,e){let t,n=o(()=>{if(t)return t;let i=indexedDB.open(r);return i.onupgradeneeded=()=>i.result.createObjectStore(e),t=de(i),t.then(s=>{s.onclose=()=>t=void 0},()=>{t=void 0}),t},"getDB");return(i,s)=>n().then(a=>s(a.transaction(e,i).objectStore(e)))}o(fn,"createStore");var Ze;function Qe(){return Ze||(Ze=fn("keyval-store","keyval")),Ze}o(Qe,"defaultGetStore");function ye(r,e=Qe()){return e("readonly",t=>de(t.get(r)))}o(ye,"get");function er(r,e,t=Qe()){return t("readwrite",n=>(n.put(e,r),de(n.transaction)))}o(er,"set");function rr(r,e=Qe()){return e("readwrite",t=>(r.forEach(n=>t.delete(n)),de(t.transaction)))}o(rr,"delMany");var fe="did:key:z",Lo="Ed25519",Mo="X25519",Ro="X25519",ko=32,pn={sign:["sign","verify"],encrypt:["deriveKey","deriveBits"]},Y="RSA-OAEP",j="RSASSA-PKCS1-v1_5",tr="SHA-256",ln=new Uint8Array([0,245,2]),Oo=2048,nr="SHA-256",q=8,J="AES-GCM",Z=J,ue=256,me=12,zo=16,hn=new Uint8Array([234,1]),dn=new Uint8Array([237,1]),mn={RSA:"rsa",Edwards:"ed25519",BLS:"bls12-381"},Ho="rsa-exchange-key",Go="rsa-write-key",Fo="ecc-exchange",Vo="ecc-write",Wo=16,Xo=1;var ge=globalThis.crypto,zr=new Error("Invalid key use. Please use 'encryption' or 'signing"),gn=new Error("Max must be less than 256 and greater than 0");function p(r){return new Uint8Array(r).buffer}o(p,"toArrayBuffer");async function Hr(r){let e=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);return new Uint8Array(await ge.subtle.digest("sha-256",e))}o(Hr,"sha256");function Q(r){let e=b(r,"base64pad");return p(e)}o(Q,"base64ToArrBuf");var ir=o((r,e)=>{if(typeof r=="string")return e(r);if(typeof r=="object"&&r.byteLength!==void 0)return new Uint8Array(r).buffer;throw new Error("Improper value. Must be a string, ArrayBuffer, Uint8Array")},"normalizeToBuf");function Ae(r){return ir(r,Q)}o(Ae,"normalizeBase64ToBuf");var An=o(r=>ir(r,e=>p(new TextEncoder().encode(e))),"normalizeUtf8ToBuf");function xn(r,e){let t=e===8?new Uint8Array(r.length):new Uint16Array(r.length);for(let n=0,i=r.length;n<i;n++)t[n]=r.charCodeAt(n);return t.buffer}o(xn,"strToArrBuf");var bn=o(r=>ir(r,e=>xn(e,16)),"normalizeUtf16ToBuf");function ee(r,e){return e===8?An(r):bn(r)}o(ee,"normalizeUnicodeToBuf");var wn={equal:o((r,e)=>{let t=new Uint8Array(r),n=new Uint8Array(e);if(t.length!==n.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0},"equal")};function Gr(r,e){return wn.equal(e,r.slice(0,e.byteLength))}o(Gr,"hasPrefix");function R(r){return w(r instanceof ArrayBuffer?new Uint8Array(r):r,"base64pad")}o(R,"toBase64");async function or(r,e){let t=typeof r=="string"?Q(r):p(r);return ge.subtle.importKey("raw",t,{name:e?.alg||Z,length:e?.length||ue},e?.extractable??!0,["encrypt","decrypt"])}o(or,"importKey");function Fr(r,{max:e}={max:255}){if(e<1||e>255)throw gn;let t=new Uint8Array(r);if(e===255)return ge.getRandomValues(t),t.buffer;let n=0,i=e+1,s=Math.floor(256/i)*i,a=new Uint8Array(1);for(;n<t.length;)ge.getRandomValues(a),a[0]<s&&(t[n]=a[0]%i,n++);return t.buffer}o(Fr,"randomBuf");function xe(r,e){let t=r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(p(r)),n=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(p(e)),i=new Uint8Array(t.length+n.length);return i.set(t),i.set(n,t.length),i.buffer}o(xe,"joinBufs");var U=globalThis.crypto,cr={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:o(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:En},ed25519:{magicBytes:new Uint8Array([237,1]),verify:Kn}}};async function Kn({message:r,publicKey:e,signature:t}){let n=r;typeof r=="string"&&(n=b(r,"utf8"));let i=t;typeof t=="string"&&(i=b(t,"base64pad"));let s=e;if(typeof e=="string"&&(s=Vr(e).publicKey),s.length!==32)throw new Error(`Invalid Ed25519 public key size: ${s.length} bytes, expected 32`);if(i.length!==64)throw new Error(`Invalid Ed25519 signature size: ${i.length} bytes, expected 64`);let a=await U.subtle.importKey("raw",p(s),{name:"Ed25519"},!1,["verify"]);return U.subtle.verify({name:"Ed25519"},a,p(i),p(n))}o(Kn,"ed25519Verify");async function En({message:r,publicKey:e,signature:t}){let n=e;return typeof e=="string"&&(n=Vr(e).publicKey),yr.verify(r,t,await U.subtle.importKey("spki",p(n),{name:j,hash:tr},!1,["verify"]),8)}o(En,"rsaVerify");var yr={verify:o(async function(e,t,n,i=q,s=nr){return U.subtle.verify({name:j},typeof n=="string"?await sr(n,s,"signing"):n,Ae(t),ee(e,i))},"rsaVerify"),sign:o(async function(e,t,n=q){return U.subtle.sign({name:j},t,ee(e,n))},"sign"),encrypt:o(async function(e,t,n=q,i=nr){let s;return typeof t=="string"?s=await sr(t,i,"exchange"):s=t instanceof Uint8Array?await sr(p(t),i,"exchange"):t,U.subtle.encrypt({name:Y},s,ee(e,n))},"rsaEncrypt"),decrypt:o(async function(e,t){let n=be(t)?t:await vn(t,["decrypt"]),i;typeof e=="string"?i=b(e,"base64pad"):i=e;let s=await U.subtle.decrypt({name:Y},n,i instanceof Uint8Array?p(i):i);return new Uint8Array(s)},"rsaDecrypt")};async function sr(r,e,t){Un(t);let n=t==="exchange"?Y:j,i=t==="exchange"?["encrypt"]:["verify"],s=typeof r=="string"?Q(Cn(r)):r;return U.subtle.importKey("spki",s,{name:n,hash:{name:e}},!0,i)}o(sr,"rsaImportPublicKey");function Un(r){Sn(r,["signing","exchange"],zr)}o(Un,"checkValidKeyUse");function Sn(r,e,t){if(!e.some(i=>i===r))throw t}o(Sn,"checkValid");function Cn(r){return r.replace(`-----BEGIN PUBLIC KEY-----
|
|
2
2
|
`,"").replace(`
|
|
3
|
-
-----END PUBLIC KEY-----`,"")}o(
|
|
3
|
+
-----END PUBLIC KEY-----`,"")}o(Cn,"stripKeyHeader");function be(r){return typeof CryptoKey<"u"?r instanceof CryptoKey:ar(r,"algorithm")&&ar(r,"extractable")&&ar(r,"type")}o(be,"isCryptoKey");function ar(r,e){return typeof r=="object"&&r!=null&&e in r}o(ar,"hasProp");function vn(r,e){return U.subtle.importKey("spki",r instanceof Uint8Array?p(r):r,{name:Y,hash:tr},!1,e)}o(vn,"importRsaKey");async function fr(r,e="rsa"){let t;if(r instanceof CryptoKey){e=r.algorithm.name.includes("RSA")?"rsa":"ed25519";let s=e==="ed25519"?"raw":"spki",a=await U.subtle.exportKey(s,r);t=new Uint8Array(a)}else t=r;let n=cr.keyTypes[e]?.magicBytes;if(!n)throw new Error(`Key type '${e}' not supported, available types: ${Object.keys(cr.keyTypes).join(", ")}`);let i=Ee([n,t]);return fe+w(i,"base58btc")}o(fr,"publicKeyToDid");async function re(r){return r instanceof CryptoKey?await U.subtle.exportKey("spki",r):await U.subtle.exportKey("spki",r.publicKey)}o(re,"getPublicKeyAsArrayBuffer");async function Pn(r){let e=await re(r);return new Uint8Array(e)}o(Pn,"getPublicKeyAsUint8Array");function Vr(r){if(!r.startsWith(fe))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let e=r.substring(fe.length),t=b(e,"base58btc"),n=Object.entries(cr.keyTypes).find(([s,a])=>Gr(p(t),p(a.magicBytes)));if(!n)throw new Error("Unsupported key algorithm.");let i=t.slice(n[1].magicBytes.length);return n[0]==="ed25519"&&i.length===44?{publicKey:i.slice(-32),type:n[0]}:{publicKey:i,type:n[0]}}o(Vr,"didToPublicKey");var k=globalThis.crypto,O={create(r={alg:Z,length:ue}){let e=r.length||ue,t=r.alg||Z,n=r.extractable??!0;return k.subtle.generateKey({name:t,length:e},n,["encrypt","decrypt"])},export:Object.assign(async r=>{let e=await k.subtle.exportKey("raw",r);return new Uint8Array(e)},{asString:o(async(r,e)=>{let t=await O.export(r);return e?w(t,e):R(t)},"asString")}),import(r,e){return ur(typeof r=="string"?Q(r):r,void 0,e)},async exportAsString(r){let e=await O.export(r);return R(e)},encrypt:Bn,async decrypt(r,e,t){let n=be(e)?e:await ur(e),i=t?await k.subtle.decrypt({name:J,iv:p(t)},n,typeof r=="string"?p(b(r,"base64pad")):r instanceof Uint8Array?p(r):r):await Tn(r,n);return new Uint8Array(i)}};function ur(r,e,t=!0){return k.subtle.importKey("raw",r instanceof Uint8Array?p(r):r,{name:J,length:e||256},t,["encrypt","decrypt"])}o(ur,"importAesKey");async function Bn(r,e,t,n){let i=be(e)?e:await ur(e),s=n?await k.subtle.encrypt({name:J,iv:p(n)},i,r instanceof ArrayBuffer?r:p(typeof r=="string"?b(r):r)):await In(r,i);return t&&t==="arraybuffer"?s:new Uint8Array(s)}o(Bn,"encrypt");async function In(r,e,t){let n=ee(r,t?.charsize??q),i=typeof e=="string"?await or(e,t):e,s=t?.iv||Fr(me),a=await k.subtle.encrypt({name:J,iv:s},i,n);return xe(s,a)}o(In,"encryptBytes");async function Tn(r,e,t){let n=Ae(r),i=typeof e=="string"?await or(e,t):e,s=n.slice(0,me),a=n.slice(me);return await k.subtle.decrypt({name:Z,iv:s},i,a)}o(Tn,"decryptBytes");var ds=new Error("Key does not exist. Make sure you properly instantiated the keystore."),ms=new Error("Retrieved a symmetric key when an asymmetric keypair was expected. Please use a different key name."),gs=new Error("Retrieved an asymmetric keypair when an symmetric key was expected. Please use a different key name."),As=new Error("ECC is not enabled for this browser. Please use RSA instead."),xs=new Error("Cryptosystem not supported. Please use ECC or RSA"),bs=new Error("Invalid key use. Please use 'exchange' or 'write'"),ws=new Error("Max must be less than 256 and greater than 0"),pr=class pr extends Error{constructor(e){super(e||"These keys were deleted"),this.name="KeysDeletedError"}};o(pr,"KeysDeletedError");var te=pr;var T=class T{constructor(e){c(this,"DID");c(this,"hasPersisted");c(this,"isSessionOnly");c(this,"destroyed");c(this,"exchangeKeyName");c(this,"writeKeyName");c(this,"_exchangeKey");c(this,"_writeKey");let{keys:t}=e,n=this.constructor;this.DID=e.did,this._exchangeKey=t.exchange,this._writeKey=t.write,this.hasPersisted=e.hasPersisted,this.isSessionOnly=!!e.isSessionOnly,this.destroyed=!1,this.exchangeKeyName=e.exchangeKeyName||n.EXCHANGE_KEY_NAME,this.writeKeyName=e.writeKeyName||n.WRITE_KEY_NAME}get exchangeKey(){if(this.destroyed||!this._exchangeKey)throw new te;return this._exchangeKey}get writeKey(){if(this.destroyed||!this._writeKey)throw new te;return this._writeKey}publicExchangeKeyAsString(e){return this.publicExchangeKey.asString(e)}publicWriteKeyAsString(e){return this.publicWriteKey.asString(e)}get publicWriteKey(){let e=this.writeKey.publicKey;return Object.assign(e,{asString:o(async t=>{let n=await re(this.writeKey),i=new Uint8Array(n);return t?w(i,t):R(i)},"asString")})}get publicExchangeKey(){let e=this.exchangeKey.publicKey;return Object.assign(e,{asString:o(async t=>{let n=await re(this.exchangeKey),i=new Uint8Array(n);return t?w(i,t):R(i)},"asString")})}get privateWriteKey(){return this.writeKey.privateKey}get privateExchangeKey(){return this.exchangeKey.privateKey}get deviceName(){return T.deviceName(this.DID)}static deviceName(e){return Dn(e)}async persist(){if(this.destroyed)throw new te;this.isSessionOnly||(await Promise.all([er(this.exchangeKeyName,this.exchangeKey),er(this.writeKeyName,this.writeKey)]),this.hasPersisted=!0)}async delete(){let e=this.exchangeKeyName,t=this.writeKeyName;await rr([e,t]),this.constructor._invalidate(e,t),this._destroy()}_destroy(){this.destroyed=!0,this.hasPersisted=!1,this._exchangeKey=null,this._writeKey=null}static _invalidate(e,t){let n=this._instance;n&&n.exchangeKeyName===e&&n.writeKeyName===t&&(n._destroy(),this._instance=null)}static async delete(e={}){let t=e.encryptionKeyName||this.EXCHANGE_KEY_NAME,n=e.writeKeyName||this.WRITE_KEY_NAME;await rr([t,n]),this._invalidate(t,n)}async getDeviceName(){return T.deviceName(this.DID)}static _createExchangeKeys(e){throw new Error("The child should implement this")}static _createWriteKeys(e){throw new Error("The child should implement this")}static _keyNames(e){return e?{exchangeKeyName:`${e}.${this.EXCHANGE_KEY_NAME}`,writeKeyName:`${e}.${this.WRITE_KEY_NAME}`}:{exchangeKeyName:this.EXCHANGE_KEY_NAME,writeKeyName:this.WRITE_KEY_NAME}}static async create(e,t,n){let i=n?.exchangeKeys||await this._createExchangeKeys(t),s=n?.writeKeys||await this._createWriteKeys(t),a=await re(s),y=await fr(new Uint8Array(a),this.TYPE==="ecc"?"ed25519":"rsa"),{exchangeKeyName:h,writeKeyName:d}=this._keyNames(n?.dbKey),m=new this({keys:{exchange:i,write:s},did:y,hasPersisted:!1,isSessionOnly:!!e,exchangeKeyName:h,writeKeyName:d});return this._instance=m,m}static async exist(e={}){let t=await ye(e.writeKeyName||this.WRITE_KEY_NAME),n=await ye(e.encryptionKeyName||this.EXCHANGE_KEY_NAME);return!(!t||!n)}static async load(e={session:!1}){let t=e.persist!==!1,n=this._keyNames(e.dbKey),i=e.encryptionKeyName||n.exchangeKeyName,s=e.writeKeyName||n.writeKeyName,a=this._instance;if(a&&!a.destroyed&&a.exchangeKeyName===i&&a.writeKeyName===s)return t&&!a.hasPersisted&&await a.persist(),a;let y=!0,h=await ye(i),d=await ye(s);h||(y=!1,h=await this._createExchangeKeys(e.extractable)),d||(y=!1,d=await this._createWriteKeys(e.extractable));let m=await re(d),z=await fr(new Uint8Array(m),this.TYPE==="ecc"?"ed25519":"rsa"),D=new this({keys:{exchange:h,write:d},did:z,hasPersisted:y,isSessionOnly:!!e.session,exchangeKeyName:i,writeKeyName:s});return this._instance=D,t&&!y&&await D.persist(),D}};o(T,"AbstractKeys"),c(T,"EXCHANGE_KEY_NAME"),c(T,"WRITE_KEY_NAME"),c(T,"_instance");var Wr=T;async function Xr(r,e){let{content:t,publicKey:n}=r,i=e||await O.create(),s=await O.encrypt(typeof t=="string"?b(t):t,typeof i=="string"?await O.import(i):i),a=await lr({key:i,publicKey:n});return xe(a,s)}o(Xr,"encryptTo");Xr.asString=async function(r,e){let t=await Xr(r,e);return w(new Uint8Array(t),"base64pad")};async function lr({key:r,publicKey:e},t){let n;r instanceof CryptoKey?n=await O.export(r):n=r;let i=await yr.encrypt(n,e);return t&&t==="arraybuffer"?i:new Uint8Array(i)}o(lr,"encryptKeyTo");lr.asString=async function({key:r,publicKey:e},t){let n=await lr({key:r,publicKey:e});return t?w(n,t):R(n)};async function Dn(r){let e=await Hr(new TextEncoder().encode(r.normalize("NFD")));return w(e,"base32").slice(0,32)}o(Dn,"getDeviceName");export{J as AES_GCM,zo as AES_GCM_TAG_LENGTH,Wr as AbstractKeys,fe as BASE58_DID_PREFIX,hn as BLS_DID_PREFIX,q as DEFAULT_CHAR_SIZE,Fo as DEFAULT_ECC_EXCHANGE,Ro as DEFAULT_ECC_EXCHANGE_CURVE,Vo as DEFAULT_ECC_WRITE,nr as DEFAULT_HASH_ALGORITHM,Ho as DEFAULT_RSA_EXCHANGE,Oo as DEFAULT_RSA_SIZE,Go as DEFAULT_RSA_WRITE,Z as DEFAULT_SYMM_ALGORITHM,ue as DEFAULT_SYMM_LENGTH,Mo as ECC_EXCHANGE_ALGORITHM,Lo as ECC_WRITE_ALGORITHM,dn as EDWARDS_DID_PREFIX,me as IV_LENGTH,mn as KEY_TYPE,pn as KEY_USE,te as KeysDeletedError,Y as RSA_ALGORITHM,ln as RSA_DID_PREFIX,tr as RSA_HASHING_ALGORITHM,j as RSA_SIGN_ALGORITHM,Wo as SALT_LENGTH,Xo as WRAP_FORMAT_VERSION,ko as X25519_PUBLIC_KEY_LENGTH,lr as encryptKeyTo,Xr as encryptTo,Dn as getDeviceName,re as getPublicKeyAsArrayBuffer,Pn as getPublicKeyAsUint8Array,fr as publicKeyToDid};
|
|
4
4
|
//# sourceMappingURL=_base.min.js.map
|