@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.
@@ -1,4 +1,4 @@
1
- var ie=Object.defineProperty;var mr=(r,e,t)=>e in r?ie(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e)=>ie(r,"name",{value:e,configurable:!0});var m=(r,e)=>{for(var t in e)ie(r,t,{get:e[t],enumerable:!0})};var c=(r,e,t)=>mr(r,typeof e!="symbol"?e+"":e,t);function F(r=0){return new Uint8Array(r)}i(F,"allocUnsafe");function se(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=F(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}i(se,"concat");var le={};m(le,{base10:()=>Sr});var cn=new Uint8Array(0);function Fe(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}i(Fe,"equals");function B(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")}i(B,"coerce");function Ge(r){return new TextEncoder().encode(r)}i(Ge,"fromString");function Ve(r){return new TextDecoder().decode(r)}i(Ve,"toString");function br(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 o=0;o<r.length;o++){var s=r.charAt(o),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=o}var u=r.length,b=r.charAt(0),C=Math.log(u)/Math.log(256),P=Math.log(256)/Math.log(u);function oe(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 d=0,L=0,g=0,w=f.length;g!==w&&f[g]===0;)g++,d++;for(var E=(w-g)*P+1>>>0,l=new Uint8Array(E);g!==w;){for(var U=f[g],I=0,A=E-1;(U!==0||I<L)&&A!==-1;A--,I++)U+=256*l[A]>>>0,l[A]=U%u>>>0,U=U/u>>>0;if(U!==0)throw new Error("Non-zero carry");L=I,g++}for(var v=E-L;v!==E&&l[v]===0;)v++;for(var W=b.repeat(d);v<E;++v)W+=r.charAt(l[v]);return W}i(oe,"encode");function q(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var d=0;if(f[d]!==" "){for(var L=0,g=0;f[d]===b;)L++,d++;for(var w=(f.length-d)*C+1>>>0,E=new Uint8Array(w);f[d];){var l=t[f.charCodeAt(d)];if(l===255)return;for(var U=0,I=w-1;(l!==0||U<g)&&I!==-1;I--,U++)l+=u*E[I]>>>0,E[I]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");g=U,d++}if(f[d]!==" "){for(var A=w-g;A!==w&&E[A]===0;)A++;for(var v=new Uint8Array(L+(w-A)),W=L;A!==w;)v[W++]=E[A++];return v}}}i(q,"decodeUnsafe");function lr(f){var d=q(f);if(d)return d;throw new Error(`Non-${e} character`)}return i(lr,"decode"),{encode:oe,decodeUnsafe:q,decode:lr}}i(br,"base");var gr=br,Ar=gr,Xe=Ar;var ue=class ue{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")}};i(ue,"Encoder");var ae=ue,ye=class ye{constructor(e,t,n){c(this,"name");c(this,"prefix");c(this,"baseDecode");c(this,"prefixCodePoint");this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 je(this,e)}};i(ye,"Decoder");var ce=ye,de=class de{constructor(e){c(this,"decoders");this.decoders=e}or(e){return je(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`)}};i(de,"ComposedDecoder");var fe=de;function je(r,e){return new fe({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}i(je,"or");var he=class he{constructor(e,t,n,o){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=o,this.encoder=new ae(e,t,n),this.decoder=new ce(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};i(he,"Codec");var pe=he;function K({name:r,prefix:e,encode:t,decode:n}){return new pe(r,e,t,n)}i(K,"from");function T({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Xe(t,r);return K({prefix:e,name:r,encode:n,decode:i(s=>B(o(s)),"decode")})}i(T,"baseX");function wr(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),a=0,u=0,b=0;for(let C=0;C<o;++C){let P=e[r[C]];if(P===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<t|P,a+=t,a>=8&&(a-=8,s[b++]=255&u>>a)}if(a>=t||(255&u<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}i(wr,"decode");function Er(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",a=0,u=0;for(let b=0;b<r.length;++b)for(u=u<<8|r[b],a+=8;a>t;)a-=t,s+=e[o&u>>a];if(a!==0&&(s+=e[o&u<<t-a]),n)for(;(s.length*t&7)!==0;)s+="=";return s}i(Er,"encode");function Ur(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}i(Ur,"createAlphabetIdx");function p({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=Ur(n);return K({prefix:e,name:r,encode(s){return Er(s,n,t)},decode(s){return wr(s,o,t,r)}})}i(p,"rfc4648");var Sr=T({prefix:"9",name:"base10",alphabet:"0123456789"});var me={};m(me,{base16:()=>vr,base16upper:()=>Br});var vr=p({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Br=p({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var xe={};m(xe,{base2:()=>Dr});var Dr=p({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var be={};m(be,{base256emoji:()=>Pr});var qe=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}"),Cr=qe.reduce((r,e,t)=>(r[t]=e,r),[]),Ir=qe.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function Tr(r){return r.reduce((e,t)=>(e+=Cr[t],e),"")}i(Tr,"encode");function Lr(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=Ir[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}i(Lr,"decode");var Pr=K({prefix:"\u{1F680}",name:"base256emoji",encode:Tr,decode:Lr});var ge={};m(ge,{base32:()=>_,base32hex:()=>Rr,base32hexpad:()=>Or,base32hexpadupper:()=>Hr,base32hexupper:()=>kr,base32pad:()=>_r,base32padupper:()=>Mr,base32upper:()=>Kr,base32z:()=>zr});var _=p({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Kr=p({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_r=p({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Mr=p({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Rr=p({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kr=p({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Or=p({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hr=p({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zr=p({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ae={};m(Ae,{base36:()=>G,base36upper:()=>Nr});var G=T({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Nr=T({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var we={};m(we,{base58btc:()=>S,base58flickr:()=>Fr});var S=T({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fr=T({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ee={};m(Ee,{base64:()=>Gr,base64pad:()=>Vr,base64url:()=>$r,base64urlpad:()=>Xr});var Gr=p({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Vr=p({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$r=p({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xr=p({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ue={};m(Ue,{base8:()=>jr});var jr=p({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Se={};m(Se,{identity:()=>qr});var qr=K({prefix:"\0",name:"identity",encode:i(r=>Ve(r),"encode"),decode:i(r=>Ge(r),"decode")});var In=new TextEncoder,Tn=new TextDecoder;var De={};m(De,{identity:()=>xt});var Jr=Je,We=128,Qr=127,Zr=~Qr,et=Math.pow(2,31);function Je(r,e,t){e=e||[],t=t||0;for(var n=t;r>=et;)e[t++]=r&255|We,r/=128;for(;r&Zr;)e[t++]=r&255|We,r>>>=7;return e[t]=r|0,Je.bytes=t-n+1,e}i(Je,"encode");var rt=ve,tt=128,Ye=127;function ve(r,n){var t=0,n=n||0,o=0,s=n,a,u=r.length;do{if(s>=u)throw ve.bytes=0,new RangeError("Could not decode varint");a=r[s++],t+=o<28?(a&Ye)<<o:(a&Ye)*Math.pow(2,o),o+=7}while(a>=tt);return ve.bytes=s-n,t}i(ve,"read");var nt=Math.pow(2,7),ot=Math.pow(2,14),it=Math.pow(2,21),st=Math.pow(2,28),at=Math.pow(2,35),ct=Math.pow(2,42),ft=Math.pow(2,49),pt=Math.pow(2,56),ut=Math.pow(2,63),yt=i(function(r){return r<nt?1:r<ot?2:r<it?3:r<st?4:r<at?5:r<ct?6:r<ft?7:r<pt?8:r<ut?9:10},"length"),dt={encode:Jr,decode:rt,encodingLength:yt},ht=dt,V=ht;function $(r,e=0){return[V.decode(r,e),V.decode.bytes]}i($,"decode");function M(r,e,t=0){return V.encode(r,e,t),e}i(M,"encodeTo");function R(r){return V.encodingLength(r)}i(R,"encodingLength");function O(r,e){let t=e.byteLength,n=R(r),o=n+R(t),s=new Uint8Array(o+t);return M(r,s,0),M(t,s,n),s.set(e,o),new k(r,t,e,s)}i(O,"create");function Qe(r){let e=B(r),[t,n]=$(e),[o,s]=$(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new k(t,o,a,e)}i(Qe,"decode");function Ze(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Fe(r.bytes,t.bytes)}}i(Ze,"equals");var Be=class Be{constructor(e,t,n,o){c(this,"code");c(this,"size");c(this,"digest");c(this,"bytes");this.code=e,this.size=t,this.digest=n,this.bytes=o}};i(Be,"Digest");var k=Be;var er=0,lt="identity",rr=B;function mt(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 O(er,rr(r))}i(mt,"digest");var xt={code:er,name:lt,encode:rr,digest:mt};var Le={};m(Le,{sha256:()=>gt,sha512:()=>At});var bt=20;function Ie({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new Ce(r,e,t,n,o)}i(Ie,"from");var Te=class Te{constructor(e,t,n,o,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=o??bt,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?tr(n,this.code,t?.truncate):n.then(o=>tr(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};i(Te,"Hasher");var Ce=Te;function tr(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 O(e,r)}i(tr,"createDigest");function or(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}i(or,"sha");var gt=Ie({name:"sha2-256",code:18,encode:or("SHA-256")}),At=Ie({name:"sha2-512",code:19,encode:or("SHA-512")});function ir(r,e){let{bytes:t,version:n}=r;return n===0?Et(t,Pe(r),e??S.encoder):Ut(t,Pe(r),e??_.encoder)}i(ir,"format");var sr=new WeakMap;function Pe(r){let e=sr.get(r);if(e==null){let t=new Map;return sr.set(r,t),t}return e}i(Pe,"baseCache");var cr,y=class y{constructor(e,t,n,o){c(this,"code");c(this,"version");c(this,"multihash");c(this,"bytes");c(this,"/");c(this,cr,"CID");this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}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!==j)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==St)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return y.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=O(e,t);return y.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 y.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&Ze(e.multihash,n.multihash)}toString(e){return ir(this,e)}toJSON(){return{"/":ir(this)}}link(){return this}[(cr=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 y)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:a}=t;return new y(n,o,s,a??ar(n,o,s.bytes))}else if(t[vt]===!0){let{version:n,multihash:o,code:s}=t,a=Qe(o);return y.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!==j)throw new Error(`Version 0 CID must use dag-pb (code: ${j}) block encoding`);return new y(e,t,n,n.bytes)}case 1:{let o=ar(e,t,n.bytes);return new y(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return y.create(0,j,e)}static createV1(e,t){return y.create(1,e,t)}static decode(e){let[t,n]=y.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=y.inspectBytes(e),n=t.size-t.multihashSize,o=B(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),a=new k(t.multihashCode,t.digestSize,s,o);return[t.version===0?y.createV0(a):y.createV1(t.codec,a),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=i(()=>{let[oe,q]=$(e.subarray(t));return t+=q,oe},"next"),o=n(),s=j;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=t,u=n(),b=n(),C=t+b,P=C-a;return{version:o,codec:s,multihashCode:u,digestSize:b,multihashSize:P,size:C}}static parse(e,t){let[n,o]=wt(e,t),s=y.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Pe(s).set(n,e),s}};i(y,"CID");var J=y;function wt(r,e){switch(r[0]){case"Q":{let t=e??S;return[S.prefix,t.decode(`${S.prefix}${r}`)]}case S.prefix:{let t=e??S;return[S.prefix,t.decode(r)]}case _.prefix:{let t=e??_;return[_.prefix,t.decode(r)]}case G.prefix:{let t=e??G;return[G.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)]}}}i(wt,"parseCIDtoBytes");function Et(r,e,t){let{prefix:n}=t;if(n!==S.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}i(Et,"toStringV0");function Ut(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}i(Ut,"toStringV1");var j=112,St=18;function ar(r,e,t){let n=R(r),o=n+R(e),s=new Uint8Array(o+t.byteLength);return M(r,s,0),M(e,s,n),s.set(t,o),s}i(ar,"encodeCID");var vt=Symbol.for("@ipld/js-cid/CID");var Ke={...Se,...xe,...Ue,...le,...me,...ge,...Ae,...we,...Ee,...be},ao={...Le,...De};function pr(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}i(pr,"createCodec");var fr=pr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),_e=pr("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=F(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Bt={utf8:fr,"utf-8":fr,hex:Ke.base16,latin1:_e,ascii:_e,binary:_e,...Ke},Q=Bt;function D(r,e="utf8"){let t=Q[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}i(D,"fromString");function Z(r,e="utf8"){let t=Q[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}i(Z,"toString");var H="did:key:z";var Mo="X25519";var z="RSA-OAEP",N="RSASSA-PKCS1-v1_5",Me="SHA-256",Ct=new Uint8Array([0,245,2]),Ro=2048,Re="SHA-256",ee=8;var It=new Uint8Array([234,1]),Tt=new Uint8Array([237,1]);var $o=globalThis.crypto,ur=new Error("Invalid key use. Please use 'encryption' or 'signing"),Xo=new Error("Max must be less than 256 and greater than 0");function h(r){return new Uint8Array(r).buffer}i(h,"toArrayBuffer");function ke(r){let e=D(r,"base64pad");return h(e)}i(ke,"base64ToArrBuf");var Oe=i((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 yr(r){return Oe(r,ke)}i(yr,"normalizeBase64ToBuf");var Pt=i(r=>Oe(r,e=>h(new TextEncoder().encode(e))),"normalizeUtf8ToBuf");function Kt(r,e){let t=e===8?new Uint8Array(r.length):new Uint16Array(r.length);for(let n=0,o=r.length;n<o;n++)t[n]=r.charCodeAt(n);return t.buffer}i(Kt,"strToArrBuf");var _t=i(r=>Oe(r,e=>Kt(e,16)),"normalizeUtf16ToBuf");function re(r,e){return e===8?Pt(r):_t(r)}i(re,"normalizeUnicodeToBuf");var Mt={equal:i((r,e)=>{let t=new Uint8Array(r),n=new Uint8Array(e);if(t.length!==n.length)return!1;for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0},"equal")};function He(r,e){return Mt.equal(e,r.slice(0,e.byteLength))}i(He,"hasPrefix");var x=globalThis.crypto,te={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:i(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:hr},ed25519:{magicBytes:new Uint8Array([237,1]),verify:dr}}};async function Zo({message:r,did:e,signature:t}){let n=Rt(e),o=ne(e).publicKey;if(n==="ed25519")return dr({message:r,publicKey:o,signature:t});if(n==="rsa")return hr({message:r,publicKey:o,signature:t});throw new Error("Unknown key format")}i(Zo,"verify");function Rt(r){try{let{type:e}=ne(r);return e}catch{return"unknown"}}i(Rt,"getAlgorithm");async function dr({message:r,publicKey:e,signature:t}){let n=r;typeof r=="string"&&(n=D(r,"utf8"));let o=t;typeof t=="string"&&(o=D(t,"base64pad"));let s=e;if(typeof e=="string"&&(s=ne(e).publicKey),s.length!==32)throw new Error(`Invalid Ed25519 public key size: ${s.length} bytes, expected 32`);if(o.length!==64)throw new Error(`Invalid Ed25519 signature size: ${o.length} bytes, expected 64`);let a=await x.subtle.importKey("raw",h(s),{name:"Ed25519"},!1,["verify"]);return x.subtle.verify({name:"Ed25519"},a,h(o),h(n))}i(dr,"ed25519Verify");async function hr({message:r,publicKey:e,signature:t}){let n=e;return typeof e=="string"&&(n=ne(e).publicKey),kt.verify(r,t,await x.subtle.importKey("spki",h(n),{name:N,hash:Me},!1,["verify"]),8)}i(hr,"rsaVerify");var kt={verify:i(async function(e,t,n,o=ee,s=Re){return x.subtle.verify({name:N},typeof n=="string"?await ze(n,s,"signing"):n,yr(t),re(e,o))},"rsaVerify"),sign:i(async function(e,t,n=ee){return x.subtle.sign({name:N},t,re(e,n))},"sign"),encrypt:i(async function(e,t,n=ee,o=Re){let s;return typeof t=="string"?s=await ze(t,o,"exchange"):s=t instanceof Uint8Array?await ze(h(t),o,"exchange"):t,x.subtle.encrypt({name:z},s,re(e,n))},"rsaEncrypt"),decrypt:i(async function(e,t){let n=Nt(t)?t:await Ft(t,["decrypt"]),o;typeof e=="string"?o=D(e,"base64pad"):o=e;let s=await x.subtle.decrypt({name:z},n,o instanceof Uint8Array?h(o):o);return new Uint8Array(s)},"rsaDecrypt")};async function ze(r,e,t){Ot(t);let n=t==="exchange"?z:N,o=t==="exchange"?["encrypt"]:["verify"],s=typeof r=="string"?ke(zt(r)):r;return x.subtle.importKey("spki",s,{name:n,hash:{name:e}},!0,o)}i(ze,"rsaImportPublicKey");function Ot(r){Ht(r,["signing","exchange"],ur)}i(Ot,"checkValidKeyUse");function Ht(r,e,t){if(!e.some(o=>o===r))throw t}i(Ht,"checkValid");function zt(r){return r.replace(`-----BEGIN PUBLIC KEY-----
1
+ var se=Object.defineProperty;var Ur=(e,r,t)=>r in e?se(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var i=(e,r)=>se(e,"name",{value:r,configurable:!0});var g=(e,r)=>{for(var t in r)se(e,t,{get:r[t],enumerable:!0})};var c=(e,r,t)=>Ur(e,typeof r!="symbol"?r+"":r,t);function _(e=0){return new Uint8Array(e)}i(_,"allocUnsafe");function vr(e){return e?.buffer instanceof ArrayBuffer}i(vr,"isByteArrayWithArrayBuffer");function ae(e){if(vr(e))return e;let r=e.slice();return new Uint8Array(r.buffer,0,r.byteLength)}i(ae,"asUint8Array");function ce(e,r){r==null&&(r=e.reduce((o,s)=>o+s.length,0));let t=_(r),n=0;for(let o of e)t.set(o,n),n+=o.length;return ae(t)}i(ce,"concat");var ge={};g(ge,{base10:()=>Pr});var An=new Uint8Array(0);function Xe(e,r){if(e===r)return!0;if(e.byteLength!==r.byteLength)return!1;for(let t=0;t<e.byteLength;t++)if(e[t]!==r[t])return!1;return!0}i(Xe,"equals");function x(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return R(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return R(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}i(x,"coerce");function je(e){let r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r}i(je,"fromString");var $e=4096;function qe(e){let r=e.length;if(r<=$e)return String.fromCharCode.apply(String,e);let t="",n=0;for(;n<r;)t+=String.fromCharCode.apply(String,e.subarray(n,n+=$e));return t}i(qe,"toString");function Sr(e){return e?.buffer instanceof ArrayBuffer}i(Sr,"isByteArrayWithArrayBuffer");function R(e){return Sr(e)?e:e.slice()}i(R,"toArrayBufferBackedArray");function Br(e,r,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var s=0;s<e.length;s++){var a=e.charAt(s),p=a.charCodeAt(0);if(n[p]!==255)throw new TypeError(a+" is ambiguous");if(n[p]=s,t){var A=a.toLowerCase().charCodeAt(0),B=a.toUpperCase().charCodeAt(0);A!==p&&(n[A]=s),B!==p&&(n[B]=s)}}var E=e.length,Y=e.charAt(0),ie=Math.log(E)/Math.log(256),br=Math.log(256)/Math.log(E);function Ar(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 h=0,T=0,w=0,U=f.length;w!==U&&f[w]===0;)w++,h++;for(var v=(U-w)*br+1>>>0,L=new Uint8Array(v);w!==U;){for(var d=f[w],P=0,C=v-1;(d!==0||P<T)&&C!==-1;C--,P++)d+=256*L[C]>>>0,L[C]=d%E>>>0,d=d/E>>>0;if(d!==0)throw new Error("Non-zero carry");T=P,w++}for(var m=v-T;m!==v&&L[m]===0;)m++;for(var V=Y.repeat(h);m<v;++m)V+=e.charAt(L[m]);return V}i(Ar,"encode");function Ve(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var h=0;if(f[h]!==" "){for(var T=0,w=0;f[h]===Y;)T++,h++;for(var U=(f.length-h)*ie+1>>>0,v=new Uint8Array(U);f[h];){var L=f.charCodeAt(h);if(L>255)return;var d=n[L];if(d===255)return;for(var P=0,C=U-1;(d!==0||P<w)&&C!==-1;C--,P++)d+=E*v[C]>>>0,v[C]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");w=P,h++}if(f[h]!==" "){for(var m=U-w;m!==U&&v[m]===0;)m++;for(var V=new Uint8Array(T+(U-m)),Er=T;m!==U;)V[Er++]=v[m++];return V}}}i(Ve,"decodeUnsafe");function wr(f){var h=Ve(f);if(h)return h;throw new Error(`Non-${r} character`)}return i(wr,"decode"),{encode:Ar,decodeUnsafe:Ve,decode:wr}}i(Br,"base");var Cr=Br,Ir=Cr,Ye=Ir;var he=class he{constructor(r,t,n){c(this,"name");c(this,"prefix");c(this,"baseEncode");this.name=r,this.prefix=t,this.baseEncode=n}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}};i(he,"Encoder");var fe=he,de=class de{constructor(r,t,n){c(this,"name");c(this,"prefix");c(this,"baseDecode");c(this,"prefixCodePoint");this.name=r,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return Je(this,r)}};i(de,"Decoder");var ue=de,le=class le{constructor(r){c(this,"decoders");this.decoders=r}or(r){return Je(this,r)}decode(r){let t=r[0],n=this.decoders[t];if(n!=null)return n.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};i(le,"ComposedDecoder");var pe=le;function Je(e,r){return new pe({...e.decoders??{[e.prefix]:e},...r.decoders??{[r.prefix]:r}})}i(Je,"or");var me=class me{constructor(r,t,n,o){c(this,"name");c(this,"prefix");c(this,"baseEncode");c(this,"baseDecode");c(this,"encoder");c(this,"decoder");this.name=r,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new fe(r,t,n),this.decoder=new ue(r,t,o)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}};i(me,"Codec");var ye=me;function K({name:e,prefix:r,encode:t,decode:n}){return new ye(e,r,t,n)}i(K,"from");function D({name:e,prefix:r,alphabet:t,caseInsensitive:n=!1}){let{encode:o,decode:s}=Ye(t,e,n);return K({prefix:r,name:e,encode:o,decode:i(a=>x(s(a)),"decode")})}i(D,"baseX");function Dr(e,r,t,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),a=0,p=0,A=0;for(let B=0;B<o;++B){let E=r[e[B]];if(E===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<t|E,a+=t,a>=8&&(a-=8,s[A++]=255&p>>a)}if(a>=t||(255&p<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}i(Dr,"decode");function Tr(e,r,t){let n=r[r.length-1]==="=",o=(1<<t)-1,s="",a=0,p=0;for(let A=0;A<e.length;++A)for(p=p<<8|e[A],a+=8;a>t;)a-=t,s+=r[o&p>>a];if(a!==0&&(s+=r[o&p<<t-a]),n)for(;(s.length*t&7)!==0;)s+="=";return s}i(Tr,"encode");function Lr(e,r){let t={};for(let n=0;n<e.length;++n)if(e[n]!=="="&&(t[e[n]]=n,r)){let o=e[n].toLowerCase(),s=e[n].toUpperCase();o!==e[n]&&(t[o]=n),s!==e[n]&&(t[s]=n)}return t}i(Lr,"createAlphabetIdx");function u({name:e,prefix:r,bitsPerChar:t,alphabet:n,caseInsensitive:o=!1}){let s=Lr(n,o);return K({prefix:r,name:e,encode(a){return Tr(a,n,t)},decode(a){return Dr(a,s,t,e)}})}i(u,"rfc4648");var Pr=D({prefix:"9",name:"base10",alphabet:"0123456789"});var xe={};g(xe,{base16:()=>Rr,base16upper:()=>_r});var Rr=u({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),_r=u({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var be={};g(be,{base2:()=>Kr});var Kr=u({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ae={};g(Ae,{base256emoji:()=>Nr});var Qe=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}"),Mr=Qe.reduce((e,r,t)=>(e[t]=r,e),[]),kr=Qe.reduce((e,r,t)=>{let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);return e[n]=t,e},[]);function Or(e){return e.reduce((r,t)=>(r+=Mr[t],r),"")}i(Or,"encode");function Hr(e){let r=[];for(let t of e){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=kr[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);r.push(o)}return new Uint8Array(r)}i(Hr,"decode");var Nr=K({prefix:"\u{1F680}",name:"base256emoji",encode:Or,decode:Hr});var we={};g(we,{base32:()=>M,base32hex:()=>Vr,base32hexpad:()=>Xr,base32hexpadupper:()=>jr,base32hexupper:()=>$r,base32pad:()=>Gr,base32padupper:()=>Fr,base32upper:()=>zr,base32z:()=>qr});var M=u({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),zr=u({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),Gr=u({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Fr=u({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Vr=u({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),$r=u({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),Xr=u({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),jr=u({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),qr=u({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ee={};g(Ee,{base36:()=>$,base36upper:()=>Wr});var $=D({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),Wr=D({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var Ue={};g(Ue,{base58btc:()=>S,base58flickr:()=>Yr});var S=D({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Yr=D({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ve={};g(ve,{base64:()=>Jr,base64pad:()=>Qr,base64url:()=>Zr,base64urlpad:()=>et});var Jr=u({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qr=u({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zr=u({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),et=u({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Se={};g(Se,{base8:()=>rt});var rt=u({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Be={};g(Be,{identity:()=>tt});var tt=K({prefix:"\0",name:"identity",encode:i(e=>qe(x(e)),"encode"),decode:i(e=>x(je(e)),"decode")});var zn=new TextEncoder,Gn=new TextDecoder;var De={};g(De,{identity:()=>St});var it=rr,Ze=128,st=127,at=~st,ct=Math.pow(2,31);function rr(e,r,t){r=r||[],t=t||0;for(var n=t;e>=ct;)r[t++]=e&255|Ze,e/=128;for(;e&at;)r[t++]=e&255|Ze,e>>>=7;return r[t]=e|0,rr.bytes=t-n+1,r}i(rr,"encode");var ft=Ce,ut=128,er=127;function Ce(e,n){var t=0,n=n||0,o=0,s=n,a,p=e.length;do{if(s>=p)throw Ce.bytes=0,new RangeError("Could not decode varint");a=e[s++],t+=o<28?(a&er)<<o:(a&er)*Math.pow(2,o),o+=7}while(a>=ut);return Ce.bytes=s-n,t}i(Ce,"read");var pt=Math.pow(2,7),yt=Math.pow(2,14),ht=Math.pow(2,21),dt=Math.pow(2,28),lt=Math.pow(2,35),mt=Math.pow(2,42),gt=Math.pow(2,49),xt=Math.pow(2,56),bt=Math.pow(2,63),At=i(function(e){return e<pt?1:e<yt?2:e<ht?3:e<dt?4:e<lt?5:e<mt?6:e<gt?7:e<xt?8:e<bt?9:10},"length"),wt={encode:it,decode:ft,encodingLength:At},Et=wt,X=Et;function j(e,r=0){let t=X.decode(e,r),n=X.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&e[r+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[t,n]}i(j,"decode");function k(e,r,t=0){return X.encode(e,r,t),r}i(k,"encodeTo");function O(e){return X.encodingLength(e)}i(O,"encodingLength");function N(e,r){let t=r.byteLength,n=O(e),o=n+O(t),s=new Uint8Array(o+t);return k(e,s,0),k(t,s,n),s.set(r,o),new H(e,t,r,s)}i(N,"create");function tr(e){let r=x(e),[t,n]=j(r),[o,s]=j(r.subarray(n)),a=r.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new H(t,o,a,r)}i(tr,"decode");function nr(e,r){if(e===r)return!0;{let t=r;return e.code===t.code&&e.size===t.size&&t.bytes instanceof Uint8Array&&Xe(e.bytes,t.bytes)}}i(nr,"equals");var Ie=class Ie{constructor(r,t,n,o){c(this,"code");c(this,"size");c(this,"digest");c(this,"bytes");this.code=r,this.size=t,this.digest=R(n),this.bytes=R(o)}};i(Ie,"Digest");var H=Ie;var or=0,Ut="identity",ir=x;function vt(e,r){if(r?.truncate!=null&&r.truncate!==e.byteLength){if(r.truncate<0||r.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r.truncate)}return N(or,ir(e))}i(vt,"digest");var St={code:or,name:Ut,encode:ir,digest:vt};var Re={};g(Re,{sha256:()=>Ct,sha512:()=>It});var Bt=20;function Le({name:e,code:r,encode:t,minDigestLength:n,maxDigestLength:o}){return new Te(e,r,t,n,o)}i(Le,"from");var Pe=class Pe{constructor(r,t,n,o,s){c(this,"name");c(this,"code");c(this,"encode");c(this,"minDigestLength");c(this,"maxDigestLength");this.name=r,this.code=t,this.encode=n,this.minDigestLength=o??Bt,this.maxDigestLength=s}digest(r,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(r instanceof Uint8Array){let n=this.encode(r);return n instanceof Uint8Array?sr(n,this.code,t?.truncate):n.then(o=>sr(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};i(Pe,"Hasher");var Te=Pe;function sr(e,r,t){if(t!=null&&t!==e.byteLength){if(t>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t)}return N(r,e)}i(sr,"createDigest");function cr(e){return async r=>new Uint8Array(await crypto.subtle.digest(e,r))}i(cr,"sha");var Ct=Le({name:"sha2-256",code:18,encode:cr("SHA-256")}),It=Le({name:"sha2-512",code:19,encode:cr("SHA-512")});function fr(e,r){let{bytes:t,version:n}=e;return n===0?Tt(t,_e(e),r??S.encoder):Lt(t,_e(e),r??M.encoder)}i(fr,"format");var ur=new WeakMap;function _e(e){let r=ur.get(e);if(r==null){let t=new Map;return ur.set(e,t),t}return r}i(_e,"baseCache");var yr,y=class y{constructor(r,t,n,o){c(this,"code");c(this,"version");c(this,"multihash");c(this,"bytes");c(this,"/");c(this,yr,"CID");this.code=t,this.version=r,this.multihash=n,this.bytes=R(o),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:r,multihash:t}=this;if(r!==W)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Pt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return y.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:r,digest:t}=this.multihash,n=N(r,t);return y.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(r){return y.equals(this,r)}static equals(r,t){let n=t;return n!=null&&r.code===n.code&&r.version===n.version&&nr(r.multihash,n.multihash)}toString(r){return fr(this,r)}toJSON(){return{"/":fr(this)}}link(){return this}[(yr=Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"))](){return`CID(${this.toString()})`}static asCID(r){if(r==null)return null;let t=r;if(t instanceof y)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:a}=t;return new y(n,o,s,a??pr(n,o,s.bytes))}else if(t[Rt]===!0){let{version:n,multihash:o,code:s}=t,a=tr(o);return y.create(n,s,a)}else return null}static create(r,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(r){case 0:{if(t!==W)throw new Error(`Version 0 CID must use dag-pb (code: ${W}) block encoding`);return new y(r,t,n,n.bytes)}case 1:{let o=pr(r,t,n.bytes);return new y(r,t,n,o)}default:throw new Error("Invalid version")}}static createV0(r){return y.create(0,W,r)}static createV1(r,t){return y.create(1,r,t)}static decode(r){let[t,n]=y.decodeFirst(r);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(r){let t=y.inspectBytes(r),n=t.size-t.multihashSize,o=x(r.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),a=new H(t.multihashCode,t.digestSize,s,o);return[t.version===0?y.createV0(a):y.createV1(t.codec,a),r.subarray(t.size)]}static inspectBytes(r){let t=0,n=i(()=>{let[Y,ie]=j(r.subarray(t));return t+=ie,Y},"next"),o=n(),s=W;if(o===18)o=0,t=0;else if(o===1)s=n();else throw o===0?new RangeError("Invalid CID version, v0 is always implicit"):new RangeError(`Invalid CID version ${o}`);let a=t,p=n(),A=n(),B=t+A,E=B-a;return{version:o,codec:s,multihashCode:p,digestSize:A,multihashSize:E,size:B}}static parse(r,t){let[n,o]=Dt(r,t),s=y.decode(o);if(s.version===0&&r[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return _e(s).set(n,r),s}};i(y,"CID");var Q=y;function Dt(e,r){switch(e[0]){case"Q":{let t=r??S;return[S.prefix,t.decode(`${S.prefix}${e}`)]}case S.prefix:{let t=r??S;return[S.prefix,t.decode(e)]}case M.prefix:{let t=r??M;return[M.prefix,t.decode(e)]}case $.prefix:{let t=r??$;return[$.prefix,t.decode(e)]}default:{if(r==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],r.decode(e)]}}}i(Dt,"parseCIDtoBytes");function Tt(e,r,t){let{prefix:n}=t;if(n!==S.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=r.get(n);if(o==null){let s=t.encode(e).slice(1);return r.set(n,s),s}else return o}i(Tt,"toStringV0");function Lt(e,r,t){let{prefix:n}=t,o=r.get(n);if(o==null){let s=t.encode(e);return r.set(n,s),s}else return o}i(Lt,"toStringV1");var W=112,Pt=18;function pr(e,r,t){let n=O(e),o=n+O(r),s=new Uint8Array(o+t.byteLength);return k(e,s,0),k(r,s,n),s.set(t,o),s}i(pr,"encodeCID");var Rt=Symbol.for("@ipld/js-cid/CID");var Ke={...Be,...be,...Se,...ge,...xe,...we,...Ee,...Ue,...ve,...Ae},Ao={...Re,...De};function dr(e,r,t,n){return{name:e,prefix:r,encoder:{name:e,prefix:r,encode:t},decoder:{decode:n}}}i(dr,"createCodec");var hr=dr("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Me=dr("ascii","a",e=>{let r="a";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return r},e=>{e=e.substring(1);let r=_(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r}),_t={utf8:hr,"utf-8":hr,hex:Ke.base16,latin1:Me,ascii:Me,binary:Me,...Ke},Z=_t;function I(e,r="utf8"){let t=Z[r];if(t==null)throw new Error(`Unsupported encoding "${r}"`);return t.decoder.decode(`${t.prefix}${e}`)}i(I,"fromString");function ee(e,r="utf8"){let t=Z[r];if(t==null)throw new Error(`Unsupported encoding "${r}"`);return t.encoder.encode(e).substring(1)}i(ee,"toString");var z="did:key:z";var Zo="X25519";var G="RSA-OAEP",F="RSASSA-PKCS1-v1_5",ke="SHA-256",Mt=new Uint8Array([0,245,2]),ei=2048,Oe="SHA-256",re=8;var kt=new Uint8Array([234,1]),Ot=new Uint8Array([237,1]);var fi=globalThis.crypto,lr=new Error("Invalid key use. Please use 'encryption' or 'signing"),ui=new Error("Max must be less than 256 and greater than 0");function l(e){return new Uint8Array(e).buffer}i(l,"toArrayBuffer");function He(e){let r=I(e,"base64pad");return l(r)}i(He,"base64ToArrBuf");var Ne=i((e,r)=>{if(typeof e=="string")return r(e);if(typeof e=="object"&&e.byteLength!==void 0)return new Uint8Array(e).buffer;throw new Error("Improper value. Must be a string, ArrayBuffer, Uint8Array")},"normalizeToBuf");function mr(e){return Ne(e,He)}i(mr,"normalizeBase64ToBuf");var Nt=i(e=>Ne(e,r=>l(new TextEncoder().encode(r))),"normalizeUtf8ToBuf");function zt(e,r){let t=r===8?new Uint8Array(e.length):new Uint16Array(e.length);for(let n=0,o=e.length;n<o;n++)t[n]=e.charCodeAt(n);return t.buffer}i(zt,"strToArrBuf");var Gt=i(e=>Ne(e,r=>zt(r,16)),"normalizeUtf16ToBuf");function te(e,r){return r===8?Nt(e):Gt(e)}i(te,"normalizeUnicodeToBuf");var Ft={equal:i((e,r)=>{let t=new Uint8Array(e),n=new Uint8Array(r);if(t.length!==n.length)return!1;for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0},"equal")};function ze(e,r){return Ft.equal(r,e.slice(0,r.byteLength))}i(ze,"hasPrefix");var b=globalThis.crypto,ne={keyTypes:{"bls12-381":{magicBytes:new Uint8Array([234,1]),verify:i(()=>{throw new Error("Not implemented")},"verify")},rsa:{magicBytes:new Uint8Array([0,245,2]),verify:xr},ed25519:{magicBytes:new Uint8Array([237,1]),verify:gr}}};async function gi({message:e,did:r,signature:t}){let n=Vt(r),o=oe(r).publicKey;if(n==="ed25519")return gr({message:e,publicKey:o,signature:t});if(n==="rsa")return xr({message:e,publicKey:o,signature:t});throw new Error("Unknown key format")}i(gi,"verify");function Vt(e){try{let{type:r}=oe(e);return r}catch{return"unknown"}}i(Vt,"getAlgorithm");async function gr({message:e,publicKey:r,signature:t}){let n=e;typeof e=="string"&&(n=I(e,"utf8"));let o=t;typeof t=="string"&&(o=I(t,"base64pad"));let s=r;if(typeof r=="string"&&(s=oe(r).publicKey),s.length!==32)throw new Error(`Invalid Ed25519 public key size: ${s.length} bytes, expected 32`);if(o.length!==64)throw new Error(`Invalid Ed25519 signature size: ${o.length} bytes, expected 64`);let a=await b.subtle.importKey("raw",l(s),{name:"Ed25519"},!1,["verify"]);return b.subtle.verify({name:"Ed25519"},a,l(o),l(n))}i(gr,"ed25519Verify");async function xr({message:e,publicKey:r,signature:t}){let n=r;return typeof r=="string"&&(n=oe(r).publicKey),$t.verify(e,t,await b.subtle.importKey("spki",l(n),{name:F,hash:ke},!1,["verify"]),8)}i(xr,"rsaVerify");var $t={verify:i(async function(r,t,n,o=re,s=Oe){return b.subtle.verify({name:F},typeof n=="string"?await Ge(n,s,"signing"):n,mr(t),te(r,o))},"rsaVerify"),sign:i(async function(r,t,n=re){return b.subtle.sign({name:F},t,te(r,n))},"sign"),encrypt:i(async function(r,t,n=re,o=Oe){let s;return typeof t=="string"?s=await Ge(t,o,"exchange"):s=t instanceof Uint8Array?await Ge(l(t),o,"exchange"):t,b.subtle.encrypt({name:G},s,te(r,n))},"rsaEncrypt"),decrypt:i(async function(r,t){let n=Wt(t)?t:await Yt(t,["decrypt"]),o;typeof r=="string"?o=I(r,"base64pad"):o=r;let s=await b.subtle.decrypt({name:G},n,o instanceof Uint8Array?l(o):o);return new Uint8Array(s)},"rsaDecrypt")};async function Ge(e,r,t){Xt(t);let n=t==="exchange"?G:F,o=t==="exchange"?["encrypt"]:["verify"],s=typeof e=="string"?He(qt(e)):e;return b.subtle.importKey("spki",s,{name:n,hash:{name:r}},!0,o)}i(Ge,"rsaImportPublicKey");function Xt(e){jt(e,["signing","exchange"],lr)}i(Xt,"checkValidKeyUse");function jt(e,r,t){if(!r.some(o=>o===e))throw t}i(jt,"checkValid");function qt(e){return e.replace(`-----BEGIN PUBLIC KEY-----
2
2
  `,"").replace(`
3
- -----END PUBLIC KEY-----`,"")}i(zt,"stripKeyHeader");function Nt(r){return typeof CryptoKey<"u"?r instanceof CryptoKey:Ne(r,"algorithm")&&Ne(r,"extractable")&&Ne(r,"type")}i(Nt,"isCryptoKey");function Ne(r,e){return typeof r=="object"&&r!=null&&e in r}i(Ne,"hasProp");function Ft(r,e){return x.subtle.importKey("spki",r instanceof Uint8Array?h(r):r,{name:z,hash:Me},!1,e)}i(Ft,"importRsaKey");async function ei(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 x.subtle.exportKey(s,r);t=new Uint8Array(a)}else t=r;let n=te.keyTypes[e]?.magicBytes;if(!n)throw new Error(`Key type '${e}' not supported, available types: ${Object.keys(te.keyTypes).join(", ")}`);let o=se([n,t]);return H+Z(o,"base58btc")}i(ei,"publicKeyToDid");function ri(r){let e=r.substring(H.length),t=D(e,"base58btc"),n=Object.entries(te.keyTypes).find(([s,a])=>He(h(t),h(a.magicBytes)));if(!n)throw new Error("Invalid key type");let o=n[0];if(o!=="ed25519"&&o!=="rsa")throw new Error(`Unsupported key type: ${o}`);return o}i(ri,"keyTypeFromDid");async function Gt(r){return r instanceof CryptoKey?await x.subtle.exportKey("spki",r):await x.subtle.exportKey("spki",r.publicKey)}i(Gt,"getPublicKeyAsArrayBuffer");async function ti(r){let e=await Gt(r);return new Uint8Array(e)}i(ti,"getPublicKeyAsUint8Array");function ne(r){if(!r.startsWith(H))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let e=r.substring(H.length),t=D(e,"base58btc"),n=Object.entries(te.keyTypes).find(([s,a])=>He(h(t),h(a.magicBytes)));if(!n)throw new Error("Unsupported key algorithm.");let o=t.slice(n[1].magicBytes.length);return n[0]==="ed25519"&&o.length===44?{publicKey:o.slice(-32),type:n[0]}:{publicKey:o,type:n[0]}}i(ne,"didToPublicKey");export{Ot as checkValidKeyUse,te as did,ne as didToPublicKey,dr as ed25519Verify,Rt as getAlgorithm,Gt as getPublicKeyAsArrayBuffer,ti as getPublicKeyAsUint8Array,Ft as importRsaKey,Nt as isCryptoKey,ri as keyTypeFromDid,ei as publicKeyToDid,ze as rsaImportPublicKey,kt as rsaOperations,hr as rsaVerify,Zo as verify};
3
+ -----END PUBLIC KEY-----`,"")}i(qt,"stripKeyHeader");function Wt(e){return typeof CryptoKey<"u"?e instanceof CryptoKey:Fe(e,"algorithm")&&Fe(e,"extractable")&&Fe(e,"type")}i(Wt,"isCryptoKey");function Fe(e,r){return typeof e=="object"&&e!=null&&r in e}i(Fe,"hasProp");function Yt(e,r){return b.subtle.importKey("spki",e instanceof Uint8Array?l(e):e,{name:G,hash:ke},!1,r)}i(Yt,"importRsaKey");async function xi(e,r="rsa"){let t;if(e instanceof CryptoKey){r=e.algorithm.name.includes("RSA")?"rsa":"ed25519";let s=r==="ed25519"?"raw":"spki",a=await b.subtle.exportKey(s,e);t=new Uint8Array(a)}else t=e;let n=ne.keyTypes[r]?.magicBytes;if(!n)throw new Error(`Key type '${r}' not supported, available types: ${Object.keys(ne.keyTypes).join(", ")}`);let o=ce([n,t]);return z+ee(o,"base58btc")}i(xi,"publicKeyToDid");function bi(e){let r=e.substring(z.length),t=I(r,"base58btc"),n=Object.entries(ne.keyTypes).find(([s,a])=>ze(l(t),l(a.magicBytes)));if(!n)throw new Error("Invalid key type");let o=n[0];if(o!=="ed25519"&&o!=="rsa")throw new Error(`Unsupported key type: ${o}`);return o}i(bi,"keyTypeFromDid");async function Jt(e){return e instanceof CryptoKey?await b.subtle.exportKey("spki",e):await b.subtle.exportKey("spki",e.publicKey)}i(Jt,"getPublicKeyAsArrayBuffer");async function Ai(e){let r=await Jt(e);return new Uint8Array(r)}i(Ai,"getPublicKeyAsUint8Array");function oe(e){if(!e.startsWith(z))throw new Error("Please use a base58-encoded DID formatted `did:key:z...`");let r=e.substring(z.length),t=I(r,"base58btc"),n=Object.entries(ne.keyTypes).find(([s,a])=>ze(l(t),l(a.magicBytes)));if(!n)throw new Error("Unsupported key algorithm.");let o=t.slice(n[1].magicBytes.length);return n[0]==="ed25519"&&o.length===44?{publicKey:o.slice(-32),type:n[0]}:{publicKey:o,type:n[0]}}i(oe,"didToPublicKey");export{Xt as checkValidKeyUse,ne as did,oe as didToPublicKey,gr as ed25519Verify,Vt as getAlgorithm,Jt as getPublicKeyAsArrayBuffer,Ai as getPublicKeyAsUint8Array,Yt as importRsaKey,Wt as isCryptoKey,bi as keyTypeFromDid,xi as publicKeyToDid,Ge as rsaImportPublicKey,$t as rsaOperations,xr as rsaVerify,gi as verify};
4
4
  //# sourceMappingURL=crypto.min.js.map