ipns
Version:
IPNS record definitions
3 lines • 150 kB
JavaScript
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Ipns = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var Ipns=(()=>{var Bu=Object.create;var Qr=Object.defineProperty;var Tu=Object.getOwnPropertyDescriptor;var _u=Object.getOwnPropertyNames;var Cu=Object.getPrototypeOf,Iu=Object.prototype.hasOwnProperty;var Fu=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},ge=(t,e)=>{for(var r in e)Qr(t,r,{get:e[r],enumerable:!0})},es=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _u(e))!Iu.call(t,o)&&o!==r&&Qr(t,o,{get:()=>e[o],enumerable:!(n=Tu(e,o))||n.enumerable});return t};var Uu=(t,e,r)=>(r=t!=null?Bu(Cu(t)):{},es(e||!t||!t.__esModule?Qr(r,"default",{value:t,enumerable:!0}):r,t)),Ru=t=>es(Qr({},"__esModule",{value:!0}),t);var ac=Fu((ug,Oi)=>{var cg=(function(){typeof Oi<"u"&&(Oi.exports=B);var t=86400,e=3200,r=146097*e/400,n=t*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,u="000000000",c=Math.trunc||function(E){var T=E-E%1;return T==0&&(E<0||E===0&&1/E!=1/0)?-0:T},f=B.prototype,l=(B.fromDate=function(E){return new B(+E)},B.fromInt64BE=N(0,1,2,3,0,4),B.fromInt64LE=N(3,2,1,0,4,0),B.fromString=function(_){var T,D=new B,_=(_+="").replace(/^\s*[+\-]?\d+/,function(y){var y=+y,S=1970+(y-1970)%400;return D.year=y-S,S}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(d,y,S){return y<0&&(S*=-1),T=6e4*(60*+y+ +S),""}).replace(/\.\d+$/,function(d){return D.nano=+(d+u).substr(1,9),""}).split(/\D+/);if(1<_.length?_[1]--:_[1]=0,D.time=T=Date.UTC.apply(Date,_)-(T||0),isNaN(T))throw new TypeError("Invalid Date");return p(D)},B.fromTimeT=function(E){return A(E,0)},f.year=0,f.time=0,f.nano=0,f.addNano=function(E){return this.nano+=+E||0,this},f.getNano=function(){var E=p(this);return(E.time%1e3*a+ +E.nano+1e9)%1e9},f.getTimeT=function(){var T=p(this),E=Math.floor(T.time/1e3),T=T.year;return T&&(E+=T*r*t/e),E},f.getYear=function(){return this.toDate().getUTCFullYear()+this.year},f.toDate=function(){return m(p(this).time)},f.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},f.toString=function(E){var T=this,D=T.toDate(),_={H:function(){return P(D.getUTCHours())},L:function(){return O(D.getUTCMilliseconds(),3)},M:function(){return P(D.getUTCMinutes())},N:function(){return O(T.getNano(),9)},S:function(){return P(D.getUTCSeconds())},Y:function(){var d=T.getYear();return 999999<d?"+"+d:9999<d?"+"+O(d,6):0<=d?O(d,4):-999999<=d?"-"+O(-d,6):d},a:function(){return w[D.getUTCDay()]},b:function(){return g[D.getUTCMonth()]},d:function(){return P(D.getUTCDate())},e:function(){return(function(d){return(9<d?"":" ")+(0|d)})(D.getUTCDate())},m:function(){return P(D.getUTCMonth()+1)}};return(function d(y){return y.replace(/%./g,function(S){var x=S[1],b=C[x],x=_[x];return b?d(b):x?x():S})})(E||l)},f.writeInt64BE=F(0,1,2,3,0,4),f.writeInt64LE=F(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),g=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],w=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],C={"%":"%",F:"%Y-%m-%d",n:`
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return B;function B(E,T,D){var _=this;if(!(_ instanceof B))return new B(E,T,D);_.time=+E||0,_.nano=+T||0,_.year=+D||0,p(_)}function p(E){var T,D,_,d=E.year,y=E.time,S=E.nano,b=((S<0||a<=S)&&(S-=(D=Math.floor(S/a))*a,y+=D,D=1),d%e);return(y<-i||i<y||b)&&((T=c(y/o))&&(d+=T*e,y-=T*o),(_=m(y)).setUTCFullYear(b+_.getUTCFullYear()),_=(y=+_)+(T=c((d-=b)/e))*o,T&&-i<=_&&_<=i&&(d-=T*e,y=_),D=1),D&&(E.year=d,E.time=y,E.nano=S),E}function m(E){var T=new Date(0);return T.setTime(E),T}function A(d,_){d=+d||0;var D=c((_=(_|0)*s)/n)+c(d/n),_=_%n+d%n,d=c(_/n);return d&&(D+=d,_-=d*n),new B(1e3*_,0,D*e)}function F(E,T,D,_,d,y){return function(b,x){var U=p(this);b=b||new Array(8),k(b,x|=0);var R=Math.floor(U.time/1e3),U=U.year*(r*t/e),v=c(U/s)+c(R/s),U=U%s+R%s,R=Math.floor(U/s);return R&&(v+=R,U-=R*s),S(b,x+d,v),S(b,x+y,U),b};function S(b,x,v){b[x+E]=v>>24&255,b[x+T]=v>>16&255,b[x+D]=v>>8&255,b[x+_]=255&v}}function N(E,T,D,_,d,y){return function(b,x){k(b,x|=0);var v=S(b,x+d);return A(S(b,x+y),v)};function S(b,x){return 16777216*b[x+E]+(b[x+T]<<16|b[x+D]<<8|b[x+_])}}function k(E,T){if(E=E&&E.length,E==null)throw new TypeError("Invalid Buffer");if(E<T+8)throw new RangeError("Out of range")}function P(E){return(9<E?"":"0")+(0|E)}function O(E,T){return(u+(0|E)).substr(-T)}})()});var xh={};ge(xh,{createIPNSRecord:()=>yh,createIPNSRecordWithExpiration:()=>gh,extractPublicKeyFromIPNSRecord:()=>hu,marshalIPNSRecord:()=>yu,multihashFromIPNSRoutingKey:()=>xu,multihashToIPNSRoutingKey:()=>bu,namespace:()=>Au,namespaceLength:()=>mh,unmarshalIPNSRecord:()=>gu});var ce=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Vt=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var en=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var tn=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var ao={};ge(ao,{base58btc:()=>ee,base58flickr:()=>Pu});var Sh=new Uint8Array(0);function rs(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Fe(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return Bt(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return Bt(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function ns(t){let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var ts=4096;function os(t){let e=t.length;if(e<=ts)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.subarray(n,n+=ts));return r}function Du(t){return t?.buffer instanceof ArrayBuffer}function Bt(t){return Du(t)?t:t.slice()}function Lu(t,e,r){if(t.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 i=0;i<t.length;i++){var s=t.charAt(i),a=s.charCodeAt(0);if(n[a]!==255)throw new TypeError(s+" is ambiguous");if(n[a]=i,r){var u=s.toLowerCase().charCodeAt(0),c=s.toUpperCase().charCodeAt(0);u!==a&&(n[u]=i),c!==a&&(n[c]=i)}}var f=t.length,l=t.charAt(0),g=Math.log(f)/Math.log(256),w=Math.log(256)/Math.log(f);function C(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var A=0,F=0,N=0,k=m.length;N!==k&&m[N]===0;)N++,A++;for(var P=(k-N)*w+1>>>0,O=new Uint8Array(P);N!==k;){for(var E=m[N],T=0,D=P-1;(E!==0||T<F)&&D!==-1;D--,T++)E+=256*O[D]>>>0,O[D]=E%f>>>0,E=E/f>>>0;if(E!==0)throw new Error("Non-zero carry");F=T,N++}for(var _=P-F;_!==P&&O[_]===0;)_++;for(var d=l.repeat(A);_<P;++_)d+=t.charAt(O[_]);return d}function B(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var A=0;if(m[A]!==" "){for(var F=0,N=0;m[A]===l;)F++,A++;for(var k=(m.length-A)*g+1>>>0,P=new Uint8Array(k);m[A];){var O=n[m.charCodeAt(A)];if(O===255)return;for(var E=0,T=k-1;(O!==0||E<N)&&T!==-1;T--,E++)O+=f*P[T]>>>0,P[T]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");N=E,A++}if(m[A]!==" "){for(var D=k-N;D!==k&&P[D]===0;)D++;for(var _=new Uint8Array(F+(k-D)),d=F;D!==k;)_[d++]=P[D++];return _}}}function p(m){var A=B(m);if(A)return A;throw new Error(`Non-${e} character`)}return{encode:C,decodeUnsafe:B,decode:p}}var ku=Lu,Ou=ku,ss=Ou;var no=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},oo=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.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 as(this,e)}},io=class{decoders;constructor(e){this.decoders=e}or(e){return as(this,e)}decode(e){let r=e[0],n=this.decoders[r];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`)}};function as(t,e){return new io({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var so=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new no(e,r,n),this.decoder=new oo(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function qt({name:t,prefix:e,encode:r,decode:n}){return new so(t,e,r,n)}function ot({name:t,prefix:e,alphabet:r,caseInsensitive:n=!1}){let{encode:o,decode:i}=ss(r,t,n);return qt({prefix:e,name:t,encode:o,decode:s=>Fe(i(s))})}function Nu(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,u=0;for(let c=0;c<o;++c){let f=e[t[c]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[u++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Ku(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let u=0;u<t.length;++u)for(a=a<<8|t[u],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Mu(t,e){let r={};for(let n=0;n<t.length;++n)if(r[t[n]]=n,e){let o=t[n].toLowerCase(),i=t[n].toUpperCase();o!==t[n]&&(r[o]=n),i!==t[n]&&(r[i]=n)}return r}function G({name:t,prefix:e,bitsPerChar:r,alphabet:n,caseInsensitive:o=!1}){let i=Mu(n,o);return qt({prefix:e,name:t,encode(s){return Ku(s,n,r)},decode(s){return Nu(s,i,r,t)}})}var ee=ot({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Pu=ot({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var co={};ge(co,{base32:()=>it,base32hex:()=>Hu,base32hexpad:()=>ju,base32hexpadupper:()=>Zu,base32hexupper:()=>zu,base32pad:()=>qu,base32padupper:()=>$u,base32upper:()=>Vu,base32z:()=>Yu});var it=G({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),Vu=G({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),qu=G({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),$u=G({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Hu=G({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),zu=G({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),ju=G({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),Zu=G({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),Yu=G({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var uo={};ge(uo,{base36:()=>st,base36upper:()=>Gu});var st=ot({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),Gu=ot({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var Xu=fs,cs=128,Wu=127,Ju=~Wu,Qu=Math.pow(2,31);function fs(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Qu;)e[r++]=t&255|cs,t/=128;for(;t&Ju;)e[r++]=t&255|cs,t>>>=7;return e[r]=t|0,fs.bytes=r-n+1,e}var ef=fo,tf=128,us=127;function fo(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw fo.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&us)<<o:(s&us)*Math.pow(2,o),o+=7}while(s>=tf);return fo.bytes=i-n,r}var rf=Math.pow(2,7),nf=Math.pow(2,14),of=Math.pow(2,21),sf=Math.pow(2,28),af=Math.pow(2,35),cf=Math.pow(2,42),uf=Math.pow(2,49),ff=Math.pow(2,56),lf=Math.pow(2,63),df=function(t){return t<rf?1:t<nf?2:t<of?3:t<sf?4:t<af?5:t<cf?6:t<uf?7:t<ff?8:t<lf?9:10},hf={encode:Xu,decode:ef,encodingLength:df},pf=hf,br=pf;function xr(t,e=0){let r=br.decode(t,e),n=br.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&t[e+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[r,n]}function $t(t,e,r=0){return br.encode(t,e,r),e}function Ht(t){return br.encodingLength(t)}function Ve(t,e){let r=e.byteLength,n=Ht(t),o=n+Ht(r),i=new Uint8Array(o+r);return $t(t,i,0),$t(r,i,n),i.set(e,o),new zt(t,r,e,i)}function nn(t){let e=Fe(t),[r,n]=xr(e),[o,i]=xr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new zt(r,o,s,e)}function ls(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&rs(t.bytes,r.bytes)}}var zt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=Bt(n),this.bytes=Bt(o)}};function ds(t,e){let{bytes:r,version:n}=t;return n===0?yf(r,lo(t),e??ee.encoder):gf(r,lo(t),e??it.encoder)}var hs=new WeakMap;function lo(t){let e=hs.get(t);if(e==null){let r=new Map;return hs.set(t,r),r}return e}var le=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=Bt(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:e,multihash:r}=this;if(e!==wr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==bf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:r}=this.multihash,n=Ve(e,r);return t.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 t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&ls(e.multihash,n.multihash)}toString(e){return ds(this,e)}toJSON(){return{"/":ds(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??ps(n,o,i.bytes))}else if(r[xf]===!0){let{version:n,multihash:o,code:i}=r,s=nn(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="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(r!==wr)throw new Error(`Version 0 CID must use dag-pb (code: ${wr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=ps(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,wr,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=Fe(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new zt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,g]=xr(e.subarray(r));return r+=g,l},o=n(),i=wr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),u=n(),c=r+u,f=c-s;return{version:o,codec:i,multihashCode:a,digestSize:u,multihashSize:f,size:c}}static parse(e,r){let[n,o]=mf(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return lo(i).set(n,e),i}};function mf(t,e){switch(t[0]){case"Q":{let r=e??ee;return[ee.prefix,r.decode(`${ee.prefix}${t}`)]}case ee.prefix:{let r=e??ee;return[ee.prefix,r.decode(t)]}case it.prefix:{let r=e??it;return[it.prefix,r.decode(t)]}case st.prefix:{let r=e??st;return[st.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function yf(t,e,r){let{prefix:n}=r;if(n!==ee.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function gf(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var wr=112,bf=18;function ps(t,e,r){let n=Ht(t),o=n+Ht(e),i=new Uint8Array(o+r.byteLength);return $t(t,i,0),$t(e,i,n),i.set(r,o),i}var xf=Symbol.for("@ipld/js-cid/CID");var ho={};ge(ho,{identity:()=>Tt});var ms=0,wf="identity",ys=Fe;function Ef(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Ve(ms,ys(t))}var Tt={code:ms,name:wf,encode:ys,digest:Ef};function be(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Sf(t){return t.buffer instanceof ArrayBuffer}function Ue(t){return Sf(t)?t:t.slice()}async function gs(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,Ue(e),Ue(r.subarray()));return n?.signal?.throwIfAborted(),i}function Ye(t=0){return new Uint8Array(t)}function Ee(t=0){return new Uint8Array(t)}function Af(t){return t?.buffer instanceof ArrayBuffer}function bs(t){if(Af(t))return t;let e=t.slice();return new Uint8Array(e.buffer,0,e.byteLength)}function at(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=Ee(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return bs(r)}var ws=Symbol.for("@achingbrain/uint8arraylist");function xs(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function on(t){return!!t?.[ws]}var Se=class t{bufs;length;[ws]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(on(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(on(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=xs(this.bufs,e);return r.buf[r.index]}set(e,r){let n=xs(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(on(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return at(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:at(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=n,i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,u=a+s.byteLength;if(o=u,e>=u)continue;let c=e>=a&&e<u,f=r>a&&r<=u;if(c&&f){if(e===a&&r===u){n.push(s);break}let l=e-a;n.push(s.subarray(l,l+(r-e)));break}if(c){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(f){if(r===u){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!on(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,u=this.byteLength-n.byteLength,c=n.byteLength-1,f;for(let l=r;l<=u;l+=f){f=0;for(let g=c;g>=0;g--){let w=this.get(l+g);if(n[g]!==w){f=Math.max(1,g-a[w]);break}}if(f===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=Ee(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=Ye(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=Ye(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=Ye(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Ee(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=Ye(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=Ye(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=Ye(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=Ye(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=Ye(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!be(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var po={};ge(po,{base10:()=>vf});var vf=ot({prefix:"9",name:"base10",alphabet:"0123456789"});var mo={};ge(mo,{base16:()=>Bf,base16upper:()=>Tf});var Bf=G({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),Tf=G({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var yo={};ge(yo,{base2:()=>_f});var _f=G({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var go={};ge(go,{base256emoji:()=>Rf});var Es=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}"),Cf=Es.reduce((t,e,r)=>(t[r]=e,t),[]),If=Es.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Ff(t){return t.reduce((e,r)=>(e+=Cf[r],e),"")}function Uf(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=If[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Rf=qt({prefix:"\u{1F680}",name:"base256emoji",encode:Ff,decode:Uf});var xo={};ge(xo,{base64:()=>bo,base64pad:()=>Df,base64url:()=>Lf,base64urlpad:()=>kf});var bo=G({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Df=G({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Lf=G({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kf=G({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var wo={};ge(wo,{base8:()=>Of});var Of=G({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Eo={};ge(Eo,{identity:()=>Nf});var Nf=qt({prefix:"\0",name:"identity",encode:t=>os(Fe(t)),decode:t=>Fe(ns(t))});var a0=new TextEncoder,c0=new TextDecoder;var Bo={};ge(Bo,{sha256:()=>vo,sha512:()=>Vf});var Pf=20;function Ao({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new So(t,e,r,n,o)}var So=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Pf,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.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?Ss(n,this.code,r?.truncate):n.then(o=>Ss(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Ss(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Ve(e,t)}function vs(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var vo=Ao({name:"sha2-256",code:18,encode:vs("SHA-256")}),Vf=Ao({name:"sha2-512",code:19,encode:vs("SHA-512")});var To={...Eo,...yo,...wo,...po,...mo,...co,...uo,...ao,...xo,...go},w0={...Bo,...ho};function Ts(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Bs=Ts("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),_o=Ts("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Ee(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),qf={utf8:Bs,"utf-8":Bs,hex:To.base16,latin1:_o,ascii:_o,binary:_o,...To},sn=qf;function Z(t,e="utf8"){let r=sn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function X(t,e="utf8"){let r=sn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var $f=parseInt("11111",2),Co=parseInt("10000000",2),Hf=parseInt("01111111",2),_s={0:Er,1:Er,2:zf,3:Yf,4:Gf,5:Zf,6:jf,16:Er,22:Er,48:Er};function Ge(t,e={offset:0}){let r=t[e.offset]&$f;if(e.offset++,_s[r]!=null)return _s[r](t,e);throw new Error("No decoder for tag "+r)}function Sr(t,e){let r=0;if((t[e.offset]&Co)===Co){let n=t[e.offset]&Hf,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++){if(e.offset>=t.byteLength)throw new Error("invalid DER element length");o+=t[e.offset].toString(16).padStart(2,"0")}r=parseInt(o,16)}else r=t[e.offset],e.offset++;if(!Number.isInteger(r)||r<0||r>t.byteLength-e.offset)throw new Error("invalid DER element length");return r}function Er(t,e){Sr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=Ge(t,e);if(n===null)break;r.push(n)}return r}function zf(t,e){let r=Sr(t,e),n=e.offset,o=e.offset+r,i=[];for(let s=n;s<o;s++)s===n&&t[s]===0||i.push(t[s]);return e.offset+=r,Uint8Array.from(i)}function jf(t,e){let r=Sr(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,u=[];for(;e.offset<n;){let c=t[e.offset];if(e.offset++,u.push(c&127),c<128){u.reverse();let f=0;for(let l=0;l<u.length;l++)f+=u[l]<<l*7;a+=`.${f}`,u=[]}}return a}function Zf(t,e){return e.offset++,null}function Yf(t,e){let r=Sr(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Gf(t,e){let r=Sr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function Xf(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new Se;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function Io(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=Xf(t.byteLength);return new Se(Uint8Array.from([e.byteLength|Co]),e)}function xe(t){let e=new Se,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new Se(Uint8Array.from([2]),Io(e),e)}function an(t){let e=Uint8Array.from([0]),r=new Se(e,t);return new Se(Uint8Array.from([3]),Io(r),r)}function ct(t,e=48){let r=new Se;for(let n of t)r.append(n);return new Se(Uint8Array.from([e]),Io(r),r)}var Wf=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Jf=Uint8Array.from([6,5,43,129,4,0,34]),Qf=Uint8Array.from([6,5,43,129,4,0,35]),el={ext:!0,kty:"EC",crv:"P-256"},tl={ext:!0,kty:"EC",crv:"P-384"},rl={ext:!0,kty:"EC",crv:"P-521"},Fo=32,Uo=48,Ro=66;function Cs(t){let e=Ge(t);return Is(e)}function Is(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===Fo*2+1)return n=X(e.subarray(r,r+Fo),"base64url"),o=X(e.subarray(r+Fo),"base64url"),new Zt({...el,key_ops:["verify"],x:n,y:o});if(e.byteLength===Uo*2+1)return n=X(e.subarray(r,r+Uo),"base64url"),o=X(e.subarray(r+Uo),"base64url"),new Zt({...tl,key_ops:["verify"],x:n,y:o});if(e.byteLength===Ro*2+1)return n=X(e.subarray(r,r+Ro),"base64url"),o=X(e.subarray(r+Ro),"base64url"),new Zt({...rl,key_ops:["verify"],x:n,y:o});throw new ce(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function Fs(t){return ct([xe(Uint8Array.from([1])),ct([nl(t.crv)],160),ct([an(new Se(Uint8Array.from([4]),Z(t.x??"","base64url"),Z(t.y??"","base64url")))],161)]).subarray()}function nl(t){if(t==="P-256")return Wf;if(t==="P-384")return Jf;if(t==="P-521")return Qf;throw new ce(`Invalid curve ${t}`)}var Zt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=Fs(this.jwk)),this._raw}toMultihash(){return Tt.digest(ut(this))}toCID(){return le.createV1(114,this.toMultihash())}toString(){return ee.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:be(this.raw,e.raw)}async verify(e,r,n){return gs(this.jwk,r,e,n)}};function Do(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function ft(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(`${r}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new RangeError(`${r}expected integer >= 0, got ${t}`)}}function Ae(t,e,r=""){let n=Do(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,a=i?` of length ${e}`:"",u=n?`length=${o}`:`type=${typeof t}`,c=s+"expected Uint8Array"+a+", got "+u;throw n?new RangeError(c):new TypeError(c)}return t}function cn(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(ft(t.outputLen),ft(t.blockLen),t.outputLen<1)throw new Error('"outputLen" must be >= 1');if(t.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Yt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function un(t,e){Ae(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function We(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function fn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Le(t,e){return t<<32-e|t>>>e}var Rs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ol=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ln(t){if(Ae(t),Rs)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=ol[t[r]];return e}var Xe={_0:48,_9:57,A:65,F:70,a:97,f:102};function Us(t){if(t>=Xe._0&&t<=Xe._9)return t-Xe._0;if(t>=Xe.A&&t<=Xe.F)return t-(Xe.A-10);if(t>=Xe.a&&t<=Xe.f)return t-(Xe.a-10)}function Ar(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(Rs)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,r=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Us(t.charCodeAt(i)),a=Us(t.charCodeAt(i+1));if(s===void 0||a===void 0){let u=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+u+'" at index '+i)}n[o]=s*16+a}return n}function Lo(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];Ae(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function ko(t,e={}){let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Ds(t=32){ft(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var Oo=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function Ls(t,e,r){return t&e^~t&r}function ks(t,e,r){return t&e^t&r^e&r}var vr=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=fn(this.buffer)}update(e){Yt(this),Ae(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let u=fn(e);for(;o<=i-s;s+=o)this.process(u,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Yt(this),un(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,We(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=fn(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let c=u/4,f=this.get();if(c>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<c;l++)a.setUint32(4*l,f[l],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Je=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var de=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var dn=BigInt(4294967295),Os=BigInt(32);function il(t,e=!1){return e?{h:Number(t&dn),l:Number(t>>Os&dn)}:{h:Number(t>>Os&dn)|0,l:Number(t&dn)|0}}function Ns(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=il(t[i],e);[n[i],o[i]]=[s,a]}return[n,o]}var No=(t,e,r)=>t>>>r,Ko=(t,e,r)=>t<<32-r|e>>>r,_t=(t,e,r)=>t>>>r|e<<32-r,Ct=(t,e,r)=>t<<32-r|e>>>r,Br=(t,e,r)=>t<<64-r|e>>>r-32,Tr=(t,e,r)=>t>>>r-32|e<<64-r;function qe(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var Ks=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Ms=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Ps=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Vs=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,qs=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),$s=(t,e,r,n,o,i)=>e+r+n+o+i+(t/2**32|0)|0;var al=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),lt=new Uint32Array(64),Mo=class extends vr{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:u}=this;return[e,r,n,o,i,s,a,u]}set(e,r,n,o,i,s,a,u){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=u|0}process(e,r){for(let l=0;l<16;l++,r+=4)lt[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let g=lt[l-15],w=lt[l-2],C=Le(g,7)^Le(g,18)^g>>>3,B=Le(w,17)^Le(w,19)^w>>>10;lt[l]=B+lt[l-7]+C+lt[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:u,G:c,H:f}=this;for(let l=0;l<64;l++){let g=Le(a,6)^Le(a,11)^Le(a,25),w=f+g+Ls(a,u,c)+al[l]+lt[l]|0,B=(Le(n,2)^Le(n,13)^Le(n,22))+ks(n,o,i)|0;f=c,c=u,u=a,a=s+w|0,s=i,i=o,o=n,n=w+B|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,c=c+this.G|0,f=f+this.H|0,this.set(n,o,i,s,a,u,c,f)}roundClean(){We(lt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),We(this.buffer)}},Po=class extends Mo{A=Je[0]|0;B=Je[1]|0;C=Je[2]|0;D=Je[3]|0;E=Je[4]|0;F=Je[5]|0;G=Je[6]|0;H=Je[7]|0;constructor(){super(32)}};var Hs=Ns(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),cl=Hs[0],ul=Hs[1],dt=new Uint32Array(80),ht=new Uint32Array(80),Vo=class extends vr{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:u,Eh:c,El:f,Fh:l,Fl:g,Gh:w,Gl:C,Hh:B,Hl:p}=this;return[e,r,n,o,i,s,a,u,c,f,l,g,w,C,B,p]}set(e,r,n,o,i,s,a,u,c,f,l,g,w,C,B,p){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=u|0,this.Eh=c|0,this.El=f|0,this.Fh=l|0,this.Fl=g|0,this.Gh=w|0,this.Gl=C|0,this.Hh=B|0,this.Hl=p|0}process(e,r){for(let F=0;F<16;F++,r+=4)dt[F]=e.getUint32(r),ht[F]=e.getUint32(r+=4);for(let F=16;F<80;F++){let N=dt[F-15]|0,k=ht[F-15]|0,P=_t(N,k,1)^_t(N,k,8)^No(N,k,7),O=Ct(N,k,1)^Ct(N,k,8)^Ko(N,k,7),E=dt[F-2]|0,T=ht[F-2]|0,D=_t(E,T,19)^Br(E,T,61)^No(E,T,6),_=Ct(E,T,19)^Tr(E,T,61)^Ko(E,T,6),d=Ps(O,_,ht[F-7],ht[F-16]),y=Vs(d,P,D,dt[F-7],dt[F-16]);dt[F]=y|0,ht[F]=d|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:u,Dh:c,Dl:f,Eh:l,El:g,Fh:w,Fl:C,Gh:B,Gl:p,Hh:m,Hl:A}=this;for(let F=0;F<80;F++){let N=_t(l,g,14)^_t(l,g,18)^Br(l,g,41),k=Ct(l,g,14)^Ct(l,g,18)^Tr(l,g,41),P=l&w^~l&B,O=g&C^~g&p,E=qs(A,k,O,ul[F],ht[F]),T=$s(E,m,N,P,cl[F],dt[F]),D=E|0,_=_t(n,o,28)^Br(n,o,34)^Br(n,o,39),d=Ct(n,o,28)^Tr(n,o,34)^Tr(n,o,39),y=n&i^n&a^i&a,S=o&s^o&u^s&u;m=B|0,A=p|0,B=w|0,p=C|0,w=l|0,C=g|0,{h:l,l:g}=qe(c|0,f|0,T|0,D|0),c=a|0,f=u|0,a=i|0,u=s|0,i=n|0,s=o|0;let b=Ks(D,d,S);n=Ms(b,T,_,y),o=b|0}({h:n,l:o}=qe(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=qe(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:u}=qe(this.Ch|0,this.Cl|0,a|0,u|0),{h:c,l:f}=qe(this.Dh|0,this.Dl|0,c|0,f|0),{h:l,l:g}=qe(this.Eh|0,this.El|0,l|0,g|0),{h:w,l:C}=qe(this.Fh|0,this.Fl|0,w|0,C|0),{h:B,l:p}=qe(this.Gh|0,this.Gl|0,B|0,p|0),{h:m,l:A}=qe(this.Hh|0,this.Hl|0,m|0,A|0),this.set(n,o,i,s,a,u,c,f,l,g,w,C,B,p,m,A)}roundClean(){We(dt,ht)}destroy(){this.destroyed=!0,We(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},qo=class extends Vo{Ah=de[0]|0;Al=de[1]|0;Bh=de[2]|0;Bl=de[3]|0;Ch=de[4]|0;Cl=de[5]|0;Dh=de[6]|0;Dl=de[7]|0;Eh=de[8]|0;El=de[9]|0;Fh=de[10]|0;Fl=de[11]|0;Gh=de[12]|0;Gl=de[13]|0;Hh=de[14]|0;Hl=de[15]|0;constructor(){super(64)}};var Gt=ko(()=>new Po,Oo(1));var hn=ko(()=>new qo,Oo(3));var H=(t,e,r)=>Ae(t,e,r),Ho=ft,Xt=ln,ne=(...t)=>Lo(...t),Wt=t=>Ar(t),It=Do,_r=t=>Ds(t),mn=BigInt(0),$o=BigInt(1);function ke(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new TypeError(r+"expected boolean, got type="+typeof t)}return t}function yn(t){if(typeof t=="bigint"){if(!pn(t))throw new RangeError("positive bigint expected, got "+t)}else Ho(t);return t}function Oe(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(r+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let r=e&&`"${e}" `;throw new RangeError(r+"expected safe integer, got "+t)}}function Cr(t){let e=yn(t).toString(16);return e.length&1?"0"+e:e}function zs(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?mn:BigInt("0x"+t)}function Ft(t){return zs(ln(t))}function $e(t){return zs(ln(Ir(Ae(t)).reverse()))}function gn(t,e){if(ft(e),e===0)throw new RangeError("zero length");t=yn(t);let r=t.toString(16);if(r.length>e*2)throw new RangeError("number too large");return Ar(r.padStart(e*2,"0"))}function zo(t,e){return gn(t,e).reverse()}function js(t,e){if(t=H(t),e=H(e),t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function Ir(t){return Uint8Array.from(H(t))}function bn(t){if(typeof t!="string")throw new TypeError("ascii string expected, got "+typeof t);return Uint8Array.from(t,(e,r)=>{let n=e.charCodeAt(0);if(e.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${t[r]}" with code ${n} at position ${r}`);return n})}var pn=t=>typeof t=="bigint"&&mn<=t;function fl(t,e,r){return pn(t)&&pn(e)&&pn(r)&&e<=t&&t<r}function Jt(t,e,r,n){if(!fl(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Qt(t){if(t<mn)throw new Error("expected non-negative bigint, got "+t);let e;for(e=0;t>mn;t>>=$o,e+=1);return e}var Fr=t=>($o<<BigInt(t))-$o;function Zs(t,e,r){if(ft(t,"hashLen"),ft(e,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=p=>new Uint8Array(p),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,u=n(t),c=n(t),f=0,l=()=>{u.fill(1),c.fill(0),f=0},g=(...p)=>r(c,ne(u,...p)),w=(p=o)=>{c=g(i,p),u=g(),p.length!==0&&(c=g(s,p),u=g())},C=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let p=0,m=[];for(;p<e;){u=g();let A=u.slice();m.push(A),p+=u.length}return ne(...m)};return(p,m)=>{l(),w(p);let A;for(;(A=m(C()))===void 0;)w();return l(),A}}function Ne(t,e={},r={}){if(Object.prototype.toString.call(t)!=="[object Object]")throw new TypeError("expected valid options object");function n(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(t,i))throw new TypeError(`param "${i}" is invalid: expected own property`);let u=t[i];if(a&&u===void 0)return;let c=typeof u;if(c!==s||u===null)throw new TypeError(`param "${i}" is invalid: expected ${s}, got ${c}`)}let o=(i,s)=>Object.entries(i).forEach(([a,u])=>n(a,u,s));o(e,!1),o(r,!0)}var jo=()=>{throw new Error("not implemented")};var he=BigInt(0),W=BigInt(1),Ut=BigInt(2),Ws=BigInt(3),Js=BigInt(4),Qs=BigInt(5),ll=BigInt(7),ea=BigInt(8),dl=BigInt(9),ta=BigInt(16);function Q(t,e){if(e<=he)throw new Error("mod: expected positive modulus, got "+e);let r=t%e;return r>=he?r:e+r}function Y(t,e,r){if(e<he)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >he;)n*=n,n%=r;return n}function Ys(t,e){if(t===he)throw new Error("invert: expected non-zero number");if(e<=he)throw new Error("invert: expected positive modulus, got "+e);let r=Q(t,e),n=e,o=he,i=W,s=W,a=he;for(;r!==he;){let c=n/r,f=n-r*c,l=o-s*c,g=i-a*c;n=r,r=f,o=s,i=a,s=l,a=g}if(n!==W)throw new Error("invert: does not exist");return Q(o,e)}function Zo(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function ra(t,e){let r=t,n=(r.ORDER+W)/Js,o=r.pow(e,n);return Zo(r,o,e),o}function hl(t,e)