@multiformats/multiaddr
Advanced tools
Comparing version 11.3.0 to 11.4.0
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.MultiformatsMultiaddr = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var MultiformatsMultiaddr=(()=>{var Zt=Object.create;var ne=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty;var W=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),w=(r,e)=>{for(var t in e)ne(r,t,{get:e[t],enumerable:!0})},Ke=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of er(e))!rr.call(r,o)&&o!==t&&ne(r,o,{get:()=>e[o],enumerable:!(n=Yt(e,o))||n.enumerable});return r};var oe=(r,e,t)=>(t=r!=null?Zt(tr(r)):{},Ke(e||!r||!r.__esModule?ne(t,"default",{value:r,enumerable:!0}):t,r)),nr=r=>Ke(ne({},"__esModule",{value:!0}),r);var Pt=W((Zo,Ct)=>{Ct.exports=De;var Ut=128,gn=127,yn=~gn,xn=Math.pow(2,31);function De(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw De.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=xn;)e[t++]=r&255|Ut,r/=128;for(;r&yn;)e[t++]=r&255|Ut,r>>>=7;return e[t]=r|0,De.bytes=t-n+1,e}});var zt=W((Yo,It)=>{It.exports=Fe;var vn=128,Bt=127;function Fe(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a||o>49)throw Fe.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Bt)<<o:(i&Bt)*Math.pow(2,o),o+=7}while(i>=vn);return Fe.bytes=s-n,t}});var Mt=W((es,Nt)=>{var An=Math.pow(2,7),Sn=Math.pow(2,14),En=Math.pow(2,21),Tn=Math.pow(2,28),Un=Math.pow(2,35),Cn=Math.pow(2,42),Pn=Math.pow(2,49),Bn=Math.pow(2,56),In=Math.pow(2,63);Nt.exports=function(r){return r<An?1:r<Sn?2:r<En?3:r<Tn?4:r<Un?5:r<Cn?6:r<Pn?7:r<Bn?8:r<In?9:10}});var ue=W((ts,Vt)=>{Vt.exports={encode:Pt(),decode:zt(),encodingLength:Mt()}});var Jt=W((vs,_t)=>{"use strict";function Gt(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function _n(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Gt(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Gt(new o,t)}}_t.exports=_n});var Kn={};w(Kn,{fromNodeAddress:()=>Xn,isMultiaddr:()=>He,isName:()=>Qn,multiaddr:()=>Hn,protocols:()=>f,resolvers:()=>Ht});var se=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let l=a==="0",x=2**(8*o)-1;for(;;){let p=this.readAtomically(()=>{let v=this.readChar();if(v===void 0)return;let M=Number.parseInt(v,e);if(!Number.isNaN(M))return M});if(p===void 0)break;if(s*=e,s+=p,s>x||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&l&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ze=45,or=15,D=new se;function Ye(r){if(!(r.length>or))return D.new(r).parseWith(()=>D.readIPv4Addr())}function et(r){if(!(r.length>Ze))return D.new(r).parseWith(()=>D.readIPv6Addr())}function tt(r){if(!(r.length>Ze))return D.new(r).parseWith(()=>D.readIPAddr())}function rt(r){return Boolean(Ye(r))}function nt(r){return Boolean(et(r))}function ie(r){return Boolean(tt(r))}var ye={};w(ye,{identity:()=>fr});function sr(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),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,l=r.charAt(0),x=Math.log(a)/Math.log(256),p=Math.log(256)/Math.log(a);function v(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";for(var h=0,O=0,A=0,E=c.length;A!==E&&c[A]===0;)A++,h++;for(var T=(E-A)*p+1>>>0,y=new Uint8Array(T);A!==E;){for(var U=c[A],V=0,S=T-1;(U!==0||V<O)&&S!==-1;S--,V++)U+=256*y[S]>>>0,y[S]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");O=V,A++}for(var B=T-O;B!==T&&y[B]===0;)B++;for(var re=l.repeat(h);B<T;++B)re+=r.charAt(y[B]);return re}function M(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;var h=0;if(c[h]!==" "){for(var O=0,A=0;c[h]===l;)O++,h++;for(var E=(c.length-h)*x+1>>>0,T=new Uint8Array(E);c[h];){var y=t[c.charCodeAt(h)];if(y===255)return;for(var U=0,V=E-1;(y!==0||U<A)&&V!==-1;V--,U++)y+=a*T[V]>>>0,T[V]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");A=U,h++}if(c[h]!==" "){for(var S=E-A;S!==E&&T[S]===0;)S++;for(var B=new Uint8Array(O+(E-S)),re=O;S!==E;)B[re++]=T[S++];return B}}}function g(c){var h=M(c);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:M,decode:g}}var ir=sr,ar=ir,ot=ar;var so=new Uint8Array(0);var st=(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=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")};var it=r=>new TextEncoder().encode(r),at=r=>new TextDecoder().decode(r);var me=class{constructor(e,t,n){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")}},be=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),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 dt(this,e)}},we=class{constructor(e){this.decoders=e}or(e){return dt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},dt=(r,e)=>new we({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ge=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new me(e,t,n),this.decoder=new be(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},F=({name:r,prefix:e,encode:t,decode:n})=>new ge(r,e,t,n),$=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=ot(t,e);return F({prefix:r,name:e,encode:n,decode:s=>I(o(s))})},cr=(r,e,t,n)=>{let o={};for(let p=0;p<e.length;++p)o[e[p]]=p;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,l=0,x=0;for(let p=0;p<s;++p){let v=o[r[p]];if(v===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<t|v,a+=t,a>=8&&(a-=8,i[x++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return i},dr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let l=0;l<r.length;++l)for(a=a<<8|r[l],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},u=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>F({prefix:e,name:r,encode(o){return dr(o,n,t)},decode(o){return cr(o,n,t,r)}});var fr=F({prefix:"\0",name:"identity",encode:r=>at(r),decode:r=>it(r)});var xe={};w(xe,{base2:()=>ur});var ur=u({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ve={};w(ve,{base8:()=>lr});var lr=u({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ae={};w(Ae,{base10:()=>pr});var pr=$({prefix:"9",name:"base10",alphabet:"0123456789"});var Se={};w(Se,{base16:()=>hr,base16upper:()=>mr});var hr=u({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),mr=u({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ee={};w(Ee,{base32:()=>z,base32hex:()=>yr,base32hexpad:()=>vr,base32hexpadupper:()=>Ar,base32hexupper:()=>xr,base32pad:()=>wr,base32padupper:()=>gr,base32upper:()=>br,base32z:()=>Sr});var z=u({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),br=u({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wr=u({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gr=u({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yr=u({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xr=u({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vr=u({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ar=u({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Sr=u({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Te={};w(Te,{base36:()=>Er,base36upper:()=>Tr});var Er=$({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Tr=$({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ue={};w(Ue,{base58btc:()=>m,base58flickr:()=>Ur});var m=$({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ur=$({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ce={};w(Ce,{base64:()=>Cr,base64pad:()=>Pr,base64url:()=>Br,base64urlpad:()=>Ir});var Cr=u({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Pr=u({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Br=u({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ir=u({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pe={};w(Pe,{base256emoji:()=>$r});var ft=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}"),zr=ft.reduce((r,e,t)=>(r[t]=e,r),[]),Nr=ft.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Mr(r){return r.reduce((e,t)=>(e+=zr[t],e),"")}function Vr(r){let e=[];for(let t of r){let n=Nr[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var $r=F({prefix:"\u{1F680}",name:"base256emoji",encode:Mr,decode:Vr});var Ne={};w(Ne,{sha256:()=>en,sha512:()=>tn});var Or=pt,ut=128,Lr=127,Dr=~Lr,Fr=Math.pow(2,31);function pt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Fr;)e[t++]=r&255|ut,r/=128;for(;r&Dr;)e[t++]=r&255|ut,r>>>=7;return e[t]=r|0,pt.bytes=t-n+1,e}var jr=Be,qr=128,lt=127;function Be(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Be.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i<)<<o:(i<)*Math.pow(2,o),o+=7}while(i>=qr);return Be.bytes=s-n,t}var kr=Math.pow(2,7),Rr=Math.pow(2,14),Gr=Math.pow(2,21),_r=Math.pow(2,28),Jr=Math.pow(2,35),Wr=Math.pow(2,42),Xr=Math.pow(2,49),Qr=Math.pow(2,56),Hr=Math.pow(2,63),Kr=function(r){return r<kr?1:r<Rr?2:r<Gr?3:r<_r?4:r<Jr?5:r<Wr?6:r<Xr?7:r<Qr?8:r<Hr?9:10},Zr={encode:Or,decode:jr,encodingLength:Kr},Yr=Zr,X=Yr;var Q=(r,e=0)=>[X.decode(r,e),X.decode.bytes],j=(r,e,t=0)=>(X.encode(r,e,t),e),q=r=>X.encodingLength(r);var L=(r,e)=>{let t=e.byteLength,n=q(r),o=n+q(t),s=new Uint8Array(o+t);return j(r,s,0),j(t,s,n),s.set(e,o),new k(r,t,e,s)},ce=r=>{let e=I(r),[t,n]=Q(e),[o,s]=Q(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new k(t,o,i,e)},ht=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&st(r.bytes,t.bytes)}},k=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var ze=({name:r,code:e,encode:t})=>new Ie(r,e,t),Ie=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?L(this.code,t):t.then(n=>L(this.code,n))}else throw Error("Unknown type, must be binary type")}};var bt=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),en=ze({name:"sha2-256",code:18,encode:bt("SHA-256")}),tn=ze({name:"sha2-512",code:19,encode:bt("SHA-512")});var Me={};w(Me,{identity:()=>on});var wt=0,rn="identity",gt=I,nn=r=>L(wt,gt(r)),on={code:wt,name:rn,encode:gt,digest:nn};var Co=new TextEncoder,Po=new TextDecoder;var yt=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return dn(t,Ve(r),e||m.encoder);default:return fn(t,Ve(r),e||z.encoder)}};var xt=new WeakMap,Ve=r=>{let e=xt.get(r);if(e==null){let t=new Map;return xt.set(r,t),t}return e},d=class{constructor(e,t,n,o){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!==H)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==un)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return d.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=L(e,t);return d.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 d.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&ht(e.multihash,n.multihash)}toString(e){return yt(this,e)}toJSON(){return{"/":yt(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof d)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new d(n,o,s,i||vt(n,o,s.bytes))}else if(t[ln]===!0){let{version:n,multihash:o,code:s}=t,i=ce(o);return d.create(n,s,i)}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!==H)throw new Error(`Version 0 CID must use dag-pb (code: ${H}) block encoding`);return new d(e,t,n,n.bytes)}case 1:{let o=vt(e,t,n.bytes);return new d(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return d.create(0,H,e)}static createV1(e,t){return d.create(1,e,t)}static decode(e){let[t,n]=d.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=d.inspectBytes(e),n=t.size-t.multihashSize,o=I(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new k(t.multihashCode,t.digestSize,s,o);return[t.version===0?d.createV0(i):d.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[v,M]=Q(e.subarray(t));return t+=M,v},o=n(),s=H;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),l=n(),x=t+l,p=x-i;return{version:o,codec:s,multihashCode:a,digestSize:l,multihashSize:p,size:x}}static parse(e,t){let[n,o]=cn(e,t),s=d.decode(o);return Ve(s).set(n,e),s}},cn=(r,e)=>{switch(r[0]){case"Q":{let t=e||m;return[m.prefix,t.decode(`${m.prefix}${r}`)]}case m.prefix:{let t=e||m;return[m.prefix,t.decode(r)]}case z.prefix:{let t=e||z;return[z.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},dn=(r,e,t)=>{let{prefix:n}=t;if(n!==m.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},fn=(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},H=112,un=18,vt=(r,e,t)=>{let n=q(r),o=n+q(e),s=new Uint8Array(o+t.byteLength);return j(r,s,0),j(e,s,n),s.set(t,o),s},ln=Symbol.for("@ipld/js-cid/CID");var K={...ye,...xe,...ve,...Ae,...Se,...Ee,...Te,...Ue,...Ce,...Pe},Do={...Ne,...Me};function G(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function de(r=0){return globalThis.Buffer?.allocUnsafe!=null?G(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function St(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var At=St("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$e=St("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=de(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),pn={utf8:At,"utf-8":At,hex:K.base16,latin1:$e,ascii:$e,binary:$e,...K},fe=pn;function b(r,e="utf8"){let t=fe[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Et=rt,hn=nt,Oe=function(r){let e=0;if(r=r.toString().trim(),Et(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(hn(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=Et(t[n]),i;s&&(i=Oe(t[n]),t[n]=b(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,b(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},Tt=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Z={},Le={},bn=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];bn.forEach(r=>{let e=wn(...r);Le[e.code]=e,Z[e.name]=e});function wn(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:Boolean(n),path:Boolean(o)}}function f(r){if(typeof r=="number"){if(Le[r]!=null)return Le[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Z[r]!=null)return Z[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var C=oe(ue(),1);function je(r,e="utf8"){let t=fe[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?G(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function N(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=de(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return G(t)}function Ft(r,e){switch(f(r).code){case 4:case 41:return Nn(e);case 42:return Lt(e);case 6:case 273:case 33:case 132:return qt(e).toString();case 53:case 54:case 55:case 56:case 400:case 777:return Lt(e);case 421:return On(e);case 444:return Dt(e);case 445:return Dt(e);case 466:return $n(e);default:return b(e,"base16")}}function jt(r,e){switch(f(r).code){case 4:return $t(e);case 41:return $t(e);case 42:return Ot(e);case 6:case 273:case 33:case 132:return ke(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return Ot(e);case 421:return Mn(e);case 444:return Ln(e);case 445:return Dn(e);case 466:return Vn(e);default:return je(e,"base16")}}var qe=Object.values(K).map(r=>r.decoder),zn=function(){let r=qe[0].or(qe[1]);return qe.slice(2).forEach(e=>r=r.or(e)),r}();function $t(r){if(!ie(r))throw new Error("invalid ip address");return Oe(r)}function Nn(r){let e=Tt(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!ie(e))throw new Error("invalid ip address");return e}function ke(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function qt(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Ot(r){let e=je(r),t=Uint8Array.from(C.default.encode(e.length));return N([t,e],t.length+e.length)}function Lt(r){let e=C.default.decode(r);if(r=r.slice(C.default.decode.bytes),r.length!==e)throw new Error("inconsistent lengths");return b(r)}function Mn(r){let e;r[0]==="Q"||r[0]==="1"?e=ce(m.decode(`z${r}`)).bytes:e=d.parse(r).multihash.bytes;let t=Uint8Array.from(C.default.encode(e.length));return N([t,e],t.length+e.length)}function Vn(r){let e=zn.decode(r),t=Uint8Array.from(C.default.encode(e.length));return N([t,e],t.length+e.length)}function $n(r){let e=C.default.decode(r),t=r.slice(C.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+b(t,"base64url")}function On(r){let e=C.default.decode(r),t=r.slice(C.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return b(t,"base58btc")}function Ln(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=z.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ke(n);return N([t,o],t.length+o.length)}function Dn(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=z.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ke(n);return N([t,o],t.length+o.length)}function Dt(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=b(e,"base32"),o=qt(t);return`${n}:${o}`}var _=oe(ue(),1);function Fn(r){let e=[],t=r.split("/").slice(1);if(t.length===1&&t[0]==="")return[];for(let n=0;n<t.length;n++){let o=t[n],s=f(o);if(s.size===0){e.push([o]);continue}if(n++,n>=t.length)throw Rt("invalid address: "+r);if(s.path===!0){e.push([o,We(t.slice(n).join("/"))]);break}e.push([o,t[n]])}return e}function jn(r){let e=[];return r.map(t=>{let n=he(t);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),We(e.join("/"))}function qn(r){return r.map(e=>{Array.isArray(e)||(e=[e]);let t=he(e);return e.length>1?[t.code,jt(t.code,e[1])]:[t.code]})}function Re(r){return r.map(e=>{let t=he(e);return e[1]!=null?[t.code,Ft(t.code,e[1])]:[t.code]})}function Ge(r){return pe(N(r.map(e=>{let t=he(e),n=Uint8Array.from(_.default.encode(t.code));return e.length>1&&e[1]!=null&&(n=N([n,e[1]])),n})))}function _e(r,e){return r.size>0?r.size/8:r.size===0?0:_.default.decode(e)+(_.default.decode.bytes??0)}function le(r){let e=[],t=0;for(;t<r.length;){let n=_.default.decode(r,t),o=_.default.decode.bytes??0,s=f(n),i=_e(s,r.slice(t+o));if(i===0){e.push([n]),t+=o;continue}let a=r.slice(t+o,t+o+i);if(t+=i+o,t>r.length)throw Rt("Invalid address Uint8Array: "+b(r,"base16"));e.push([n,a])}return e}function Je(r){let e=le(r),t=Re(e);return jn(t)}function kn(r){r=We(r);let e=Fn(r),t=qn(e);return Ge(t)}function kt(r){return kn(r)}function pe(r){let e=Rn(r);if(e!=null)throw e;return Uint8Array.from(r)}function Rn(r){try{le(r)}catch(e){return e}}function We(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Rt(r){return new Error("Error parsing address: "+r)}function he(r){return f(r[0])}var Qe=oe(ue(),1);var Qt=oe(Jt(),1);function Wt(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}var J=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Xe=function(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t},Y,ee,te,Xt,Jn=Symbol.for("nodejs.util.inspect.custom"),Wn=[f("dns").code,f("dns4").code,f("dns6").code,f("dnsaddr").code],Ht=new Map,Kt=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Xn(r,e){if(r==null)throw new Error("requires node address object");if(e==null)throw new Error("requires transport protocol");let t,n=r.address;switch(r.family){case 4:t="ip4";break;case 6:if(t="ip6",n.includes("%")){let o=n.split("%");if(o.length!==2)throw Error("Multiple ip6 zones in multiaddr");n=o[0],t=`/ip6zone/${o[1]}/ip6`}break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new P("/"+[t,n,e,r.port].join("/"))}function Qn(r){return He(r)?r.protos().some(e=>e.resolvable):!1}function He(r){return Boolean(r?.[Kt])}var P=class{constructor(e){if(Y.set(this,void 0),ee.set(this,void 0),te.set(this,void 0),this[Xt]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=pe(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=kt(e)}else if(He(e))this.bytes=pe(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return J(this,Y,"f")==null&&Xe(this,Y,Je(this.bytes),"f"),J(this,Y,"f")}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=f("tcp"),a=f("udp"),l=f("ip4"),x=f("ip6"),p=f("dns6"),v=f("ip6zone");for(let[g,c]of this.stringTuples())g===v.code&&(s=`%${c??""}`),Wn.includes(g)&&(t=i.name,o=443,n=`${c??""}${s}`,e=g===p.code?6:4),(g===i.code||g===a.code)&&(t=f(g).name,o=parseInt(c??"")),(g===l.code||g===x.code)&&(t=f(g).name,n=`${c??""}${s}`,e=g===x.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},f(e)))}protoCodes(){let e=[],t=this.bytes,n=0;for(;n<t.length;){let o=Qe.default.decode(t,n),s=Qe.default.decode.bytes??0,i=f(o),a=_e(i,t.slice(n+s));n+=a+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return J(this,ee,"f")==null&&Xe(this,ee,le(this.bytes),"f"),J(this,ee,"f")}stringTuples(){return J(this,te,"f")==null&&Xe(this,te,Re(this.tuples()),"f"),J(this,te,"f")}encapsulate(e){return e=new P(e),new P(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new P(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new P(Ge(t.slice(0,n)));return this}getPeerId(){try{let t=this.stringTuples().filter(n=>n[0]===Z.ipfs.code).pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?b(m.decode(`z${n}`),"base58btc"):b(d.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(t=>f(t[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return Wt(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=Ht.get(t.name);if(n==null)throw(0,Qt.default)(new Error(`no available resolver for ${t.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new P(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[(Y=new WeakMap,ee=new WeakMap,te=new WeakMap,Xt=Kt,Jn)](){return`Multiaddr(${Je(this.bytes)})`}};function Hn(r){return new P(r)}return nr(Kn);})(); | ||
"use strict";var MultiformatsMultiaddr=(()=>{var Zt=Object.create;var ne=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty;var W=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),w=(r,e)=>{for(var t in e)ne(r,t,{get:e[t],enumerable:!0})},Ke=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of er(e))!rr.call(r,o)&&o!==t&&ne(r,o,{get:()=>e[o],enumerable:!(n=Yt(e,o))||n.enumerable});return r};var oe=(r,e,t)=>(t=r!=null?Zt(tr(r)):{},Ke(e||!r||!r.__esModule?ne(t,"default",{value:r,enumerable:!0}):t,r)),nr=r=>Ke(ne({},"__esModule",{value:!0}),r);var Pt=W((Zo,Ct)=>{Ct.exports=De;var Ut=128,gn=127,yn=~gn,xn=Math.pow(2,31);function De(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw De.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=xn;)e[t++]=r&255|Ut,r/=128;for(;r&yn;)e[t++]=r&255|Ut,r>>>=7;return e[t]=r|0,De.bytes=t-n+1,e}});var zt=W((Yo,It)=>{It.exports=Fe;var vn=128,Bt=127;function Fe(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a||o>49)throw Fe.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Bt)<<o:(i&Bt)*Math.pow(2,o),o+=7}while(i>=vn);return Fe.bytes=s-n,t}});var Mt=W((es,Nt)=>{var An=Math.pow(2,7),Sn=Math.pow(2,14),En=Math.pow(2,21),Tn=Math.pow(2,28),Un=Math.pow(2,35),Cn=Math.pow(2,42),Pn=Math.pow(2,49),Bn=Math.pow(2,56),In=Math.pow(2,63);Nt.exports=function(r){return r<An?1:r<Sn?2:r<En?3:r<Tn?4:r<Un?5:r<Cn?6:r<Pn?7:r<Bn?8:r<In?9:10}});var ue=W((ts,Vt)=>{Vt.exports={encode:Pt(),decode:zt(),encodingLength:Mt()}});var Jt=W((vs,_t)=>{"use strict";function Gt(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function _n(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Gt(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Gt(new o,t)}}_t.exports=_n});var Kn={};w(Kn,{fromNodeAddress:()=>Xn,isMultiaddr:()=>He,isName:()=>Qn,multiaddr:()=>Hn,protocols:()=>f,resolvers:()=>Ht});var se=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let l=a==="0",x=2**(8*o)-1;for(;;){let p=this.readAtomically(()=>{let v=this.readChar();if(v===void 0)return;let M=Number.parseInt(v,e);if(!Number.isNaN(M))return M});if(p===void 0)break;if(s*=e,s+=p,s>x||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&l&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ze=45,or=15,D=new se;function Ye(r){if(!(r.length>or))return D.new(r).parseWith(()=>D.readIPv4Addr())}function et(r){if(!(r.length>Ze))return D.new(r).parseWith(()=>D.readIPv6Addr())}function tt(r){if(!(r.length>Ze))return D.new(r).parseWith(()=>D.readIPAddr())}function rt(r){return Boolean(Ye(r))}function nt(r){return Boolean(et(r))}function ie(r){return Boolean(tt(r))}var ye={};w(ye,{identity:()=>fr});function sr(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),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,l=r.charAt(0),x=Math.log(a)/Math.log(256),p=Math.log(256)/Math.log(a);function v(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";for(var h=0,O=0,A=0,E=c.length;A!==E&&c[A]===0;)A++,h++;for(var T=(E-A)*p+1>>>0,y=new Uint8Array(T);A!==E;){for(var U=c[A],V=0,S=T-1;(U!==0||V<O)&&S!==-1;S--,V++)U+=256*y[S]>>>0,y[S]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");O=V,A++}for(var B=T-O;B!==T&&y[B]===0;)B++;for(var re=l.repeat(h);B<T;++B)re+=r.charAt(y[B]);return re}function M(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;var h=0;if(c[h]!==" "){for(var O=0,A=0;c[h]===l;)O++,h++;for(var E=(c.length-h)*x+1>>>0,T=new Uint8Array(E);c[h];){var y=t[c.charCodeAt(h)];if(y===255)return;for(var U=0,V=E-1;(y!==0||U<A)&&V!==-1;V--,U++)y+=a*T[V]>>>0,T[V]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");A=U,h++}if(c[h]!==" "){for(var S=E-A;S!==E&&T[S]===0;)S++;for(var B=new Uint8Array(O+(E-S)),re=O;S!==E;)B[re++]=T[S++];return B}}}function g(c){var h=M(c);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:M,decode:g}}var ir=sr,ar=ir,ot=ar;var so=new Uint8Array(0);var st=(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=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")};var it=r=>new TextEncoder().encode(r),at=r=>new TextDecoder().decode(r);var me=class{constructor(e,t,n){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")}},be=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),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 dt(this,e)}},we=class{constructor(e){this.decoders=e}or(e){return dt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},dt=(r,e)=>new we({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ge=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new me(e,t,n),this.decoder=new be(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},F=({name:r,prefix:e,encode:t,decode:n})=>new ge(r,e,t,n),$=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=ot(t,e);return F({prefix:r,name:e,encode:n,decode:s=>I(o(s))})},cr=(r,e,t,n)=>{let o={};for(let p=0;p<e.length;++p)o[e[p]]=p;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,l=0,x=0;for(let p=0;p<s;++p){let v=o[r[p]];if(v===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<t|v,a+=t,a>=8&&(a-=8,i[x++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return i},dr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let l=0;l<r.length;++l)for(a=a<<8|r[l],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},u=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>F({prefix:e,name:r,encode(o){return dr(o,n,t)},decode(o){return cr(o,n,t,r)}});var fr=F({prefix:"\0",name:"identity",encode:r=>at(r),decode:r=>it(r)});var xe={};w(xe,{base2:()=>ur});var ur=u({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ve={};w(ve,{base8:()=>lr});var lr=u({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ae={};w(Ae,{base10:()=>pr});var pr=$({prefix:"9",name:"base10",alphabet:"0123456789"});var Se={};w(Se,{base16:()=>hr,base16upper:()=>mr});var hr=u({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),mr=u({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ee={};w(Ee,{base32:()=>z,base32hex:()=>yr,base32hexpad:()=>vr,base32hexpadupper:()=>Ar,base32hexupper:()=>xr,base32pad:()=>wr,base32padupper:()=>gr,base32upper:()=>br,base32z:()=>Sr});var z=u({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),br=u({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wr=u({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gr=u({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yr=u({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xr=u({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vr=u({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ar=u({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Sr=u({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Te={};w(Te,{base36:()=>Er,base36upper:()=>Tr});var Er=$({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Tr=$({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ue={};w(Ue,{base58btc:()=>m,base58flickr:()=>Ur});var m=$({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ur=$({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ce={};w(Ce,{base64:()=>Cr,base64pad:()=>Pr,base64url:()=>Br,base64urlpad:()=>Ir});var Cr=u({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Pr=u({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Br=u({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ir=u({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pe={};w(Pe,{base256emoji:()=>$r});var ft=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}"),zr=ft.reduce((r,e,t)=>(r[t]=e,r),[]),Nr=ft.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Mr(r){return r.reduce((e,t)=>(e+=zr[t],e),"")}function Vr(r){let e=[];for(let t of r){let n=Nr[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var $r=F({prefix:"\u{1F680}",name:"base256emoji",encode:Mr,decode:Vr});var Ne={};w(Ne,{sha256:()=>en,sha512:()=>tn});var Or=pt,ut=128,Lr=127,Dr=~Lr,Fr=Math.pow(2,31);function pt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Fr;)e[t++]=r&255|ut,r/=128;for(;r&Dr;)e[t++]=r&255|ut,r>>>=7;return e[t]=r|0,pt.bytes=t-n+1,e}var jr=Be,qr=128,lt=127;function Be(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Be.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i<)<<o:(i<)*Math.pow(2,o),o+=7}while(i>=qr);return Be.bytes=s-n,t}var kr=Math.pow(2,7),Rr=Math.pow(2,14),Gr=Math.pow(2,21),_r=Math.pow(2,28),Jr=Math.pow(2,35),Wr=Math.pow(2,42),Xr=Math.pow(2,49),Qr=Math.pow(2,56),Hr=Math.pow(2,63),Kr=function(r){return r<kr?1:r<Rr?2:r<Gr?3:r<_r?4:r<Jr?5:r<Wr?6:r<Xr?7:r<Qr?8:r<Hr?9:10},Zr={encode:Or,decode:jr,encodingLength:Kr},Yr=Zr,X=Yr;var Q=(r,e=0)=>[X.decode(r,e),X.decode.bytes],j=(r,e,t=0)=>(X.encode(r,e,t),e),q=r=>X.encodingLength(r);var L=(r,e)=>{let t=e.byteLength,n=q(r),o=n+q(t),s=new Uint8Array(o+t);return j(r,s,0),j(t,s,n),s.set(e,o),new k(r,t,e,s)},ce=r=>{let e=I(r),[t,n]=Q(e),[o,s]=Q(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new k(t,o,i,e)},ht=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&st(r.bytes,t.bytes)}},k=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var ze=({name:r,code:e,encode:t})=>new Ie(r,e,t),Ie=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?L(this.code,t):t.then(n=>L(this.code,n))}else throw Error("Unknown type, must be binary type")}};var bt=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),en=ze({name:"sha2-256",code:18,encode:bt("SHA-256")}),tn=ze({name:"sha2-512",code:19,encode:bt("SHA-512")});var Me={};w(Me,{identity:()=>on});var wt=0,rn="identity",gt=I,nn=r=>L(wt,gt(r)),on={code:wt,name:rn,encode:gt,digest:nn};var Co=new TextEncoder,Po=new TextDecoder;var yt=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return dn(t,Ve(r),e||m.encoder);default:return fn(t,Ve(r),e||z.encoder)}};var xt=new WeakMap,Ve=r=>{let e=xt.get(r);if(e==null){let t=new Map;return xt.set(r,t),t}return e},d=class{constructor(e,t,n,o){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!==H)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==un)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return d.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=L(e,t);return d.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 d.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&ht(e.multihash,n.multihash)}toString(e){return yt(this,e)}toJSON(){return{"/":yt(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof d)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new d(n,o,s,i||vt(n,o,s.bytes))}else if(t[ln]===!0){let{version:n,multihash:o,code:s}=t,i=ce(o);return d.create(n,s,i)}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!==H)throw new Error(`Version 0 CID must use dag-pb (code: ${H}) block encoding`);return new d(e,t,n,n.bytes)}case 1:{let o=vt(e,t,n.bytes);return new d(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return d.create(0,H,e)}static createV1(e,t){return d.create(1,e,t)}static decode(e){let[t,n]=d.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=d.inspectBytes(e),n=t.size-t.multihashSize,o=I(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new k(t.multihashCode,t.digestSize,s,o);return[t.version===0?d.createV0(i):d.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[v,M]=Q(e.subarray(t));return t+=M,v},o=n(),s=H;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),l=n(),x=t+l,p=x-i;return{version:o,codec:s,multihashCode:a,digestSize:l,multihashSize:p,size:x}}static parse(e,t){let[n,o]=cn(e,t),s=d.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ve(s).set(n,e),s}},cn=(r,e)=>{switch(r[0]){case"Q":{let t=e||m;return[m.prefix,t.decode(`${m.prefix}${r}`)]}case m.prefix:{let t=e||m;return[m.prefix,t.decode(r)]}case z.prefix:{let t=e||z;return[z.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},dn=(r,e,t)=>{let{prefix:n}=t;if(n!==m.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},fn=(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},H=112,un=18,vt=(r,e,t)=>{let n=q(r),o=n+q(e),s=new Uint8Array(o+t.byteLength);return j(r,s,0),j(e,s,n),s.set(t,o),s},ln=Symbol.for("@ipld/js-cid/CID");var K={...ye,...xe,...ve,...Ae,...Se,...Ee,...Te,...Ue,...Ce,...Pe},Do={...Ne,...Me};function G(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function de(r=0){return globalThis.Buffer?.allocUnsafe!=null?G(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function St(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var At=St("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$e=St("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=de(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),pn={utf8:At,"utf-8":At,hex:K.base16,latin1:$e,ascii:$e,binary:$e,...K},fe=pn;function b(r,e="utf8"){let t=fe[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Et=rt,hn=nt,Oe=function(r){let e=0;if(r=r.toString().trim(),Et(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(hn(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=Et(t[n]),i;s&&(i=Oe(t[n]),t[n]=b(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,b(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},Tt=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Z={},Le={},bn=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];bn.forEach(r=>{let e=wn(...r);Le[e.code]=e,Z[e.name]=e});function wn(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:Boolean(n),path:Boolean(o)}}function f(r){if(typeof r=="number"){if(Le[r]!=null)return Le[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Z[r]!=null)return Z[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var C=oe(ue(),1);function je(r,e="utf8"){let t=fe[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?G(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function N(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=de(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return G(t)}function Ft(r,e){switch(f(r).code){case 4:case 41:return Nn(e);case 42:return Lt(e);case 6:case 273:case 33:case 132:return qt(e).toString();case 53:case 54:case 55:case 56:case 400:case 777:return Lt(e);case 421:return On(e);case 444:return Dt(e);case 445:return Dt(e);case 466:return $n(e);default:return b(e,"base16")}}function jt(r,e){switch(f(r).code){case 4:return $t(e);case 41:return $t(e);case 42:return Ot(e);case 6:case 273:case 33:case 132:return ke(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return Ot(e);case 421:return Mn(e);case 444:return Ln(e);case 445:return Dn(e);case 466:return Vn(e);default:return je(e,"base16")}}var qe=Object.values(K).map(r=>r.decoder),zn=function(){let r=qe[0].or(qe[1]);return qe.slice(2).forEach(e=>r=r.or(e)),r}();function $t(r){if(!ie(r))throw new Error("invalid ip address");return Oe(r)}function Nn(r){let e=Tt(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!ie(e))throw new Error("invalid ip address");return e}function ke(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function qt(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Ot(r){let e=je(r),t=Uint8Array.from(C.default.encode(e.length));return N([t,e],t.length+e.length)}function Lt(r){let e=C.default.decode(r);if(r=r.slice(C.default.decode.bytes),r.length!==e)throw new Error("inconsistent lengths");return b(r)}function Mn(r){let e;r[0]==="Q"||r[0]==="1"?e=ce(m.decode(`z${r}`)).bytes:e=d.parse(r).multihash.bytes;let t=Uint8Array.from(C.default.encode(e.length));return N([t,e],t.length+e.length)}function Vn(r){let e=zn.decode(r),t=Uint8Array.from(C.default.encode(e.length));return N([t,e],t.length+e.length)}function $n(r){let e=C.default.decode(r),t=r.slice(C.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+b(t,"base64url")}function On(r){let e=C.default.decode(r),t=r.slice(C.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return b(t,"base58btc")}function Ln(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=z.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ke(n);return N([t,o],t.length+o.length)}function Dn(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=z.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ke(n);return N([t,o],t.length+o.length)}function Dt(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=b(e,"base32"),o=qt(t);return`${n}:${o}`}var _=oe(ue(),1);function Fn(r){let e=[],t=r.split("/").slice(1);if(t.length===1&&t[0]==="")return[];for(let n=0;n<t.length;n++){let o=t[n],s=f(o);if(s.size===0){e.push([o]);continue}if(n++,n>=t.length)throw Rt("invalid address: "+r);if(s.path===!0){e.push([o,We(t.slice(n).join("/"))]);break}e.push([o,t[n]])}return e}function jn(r){let e=[];return r.map(t=>{let n=he(t);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),We(e.join("/"))}function qn(r){return r.map(e=>{Array.isArray(e)||(e=[e]);let t=he(e);return e.length>1?[t.code,jt(t.code,e[1])]:[t.code]})}function Re(r){return r.map(e=>{let t=he(e);return e[1]!=null?[t.code,Ft(t.code,e[1])]:[t.code]})}function Ge(r){return pe(N(r.map(e=>{let t=he(e),n=Uint8Array.from(_.default.encode(t.code));return e.length>1&&e[1]!=null&&(n=N([n,e[1]])),n})))}function _e(r,e){return r.size>0?r.size/8:r.size===0?0:_.default.decode(e)+(_.default.decode.bytes??0)}function le(r){let e=[],t=0;for(;t<r.length;){let n=_.default.decode(r,t),o=_.default.decode.bytes??0,s=f(n),i=_e(s,r.slice(t+o));if(i===0){e.push([n]),t+=o;continue}let a=r.slice(t+o,t+o+i);if(t+=i+o,t>r.length)throw Rt("Invalid address Uint8Array: "+b(r,"base16"));e.push([n,a])}return e}function Je(r){let e=le(r),t=Re(e);return jn(t)}function kn(r){r=We(r);let e=Fn(r),t=qn(e);return Ge(t)}function kt(r){return kn(r)}function pe(r){let e=Rn(r);if(e!=null)throw e;return Uint8Array.from(r)}function Rn(r){try{le(r)}catch(e){return e}}function We(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Rt(r){return new Error("Error parsing address: "+r)}function he(r){return f(r[0])}var Qe=oe(ue(),1);var Qt=oe(Jt(),1);function Wt(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}var J=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Xe=function(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t},Y,ee,te,Xt,Jn=Symbol.for("nodejs.util.inspect.custom"),Wn=[f("dns").code,f("dns4").code,f("dns6").code,f("dnsaddr").code],Ht=new Map,Kt=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Xn(r,e){if(r==null)throw new Error("requires node address object");if(e==null)throw new Error("requires transport protocol");let t,n=r.address;switch(r.family){case 4:t="ip4";break;case 6:if(t="ip6",n.includes("%")){let o=n.split("%");if(o.length!==2)throw Error("Multiple ip6 zones in multiaddr");n=o[0],t=`/ip6zone/${o[1]}/ip6`}break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new P("/"+[t,n,e,r.port].join("/"))}function Qn(r){return He(r)?r.protos().some(e=>e.resolvable):!1}function He(r){return Boolean(r?.[Kt])}var P=class{constructor(e){if(Y.set(this,void 0),ee.set(this,void 0),te.set(this,void 0),this[Xt]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=pe(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=kt(e)}else if(He(e))this.bytes=pe(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return J(this,Y,"f")==null&&Xe(this,Y,Je(this.bytes),"f"),J(this,Y,"f")}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=f("tcp"),a=f("udp"),l=f("ip4"),x=f("ip6"),p=f("dns6"),v=f("ip6zone");for(let[g,c]of this.stringTuples())g===v.code&&(s=`%${c??""}`),Wn.includes(g)&&(t=i.name,o=443,n=`${c??""}${s}`,e=g===p.code?6:4),(g===i.code||g===a.code)&&(t=f(g).name,o=parseInt(c??"")),(g===l.code||g===x.code)&&(t=f(g).name,n=`${c??""}${s}`,e=g===x.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},f(e)))}protoCodes(){let e=[],t=this.bytes,n=0;for(;n<t.length;){let o=Qe.default.decode(t,n),s=Qe.default.decode.bytes??0,i=f(o),a=_e(i,t.slice(n+s));n+=a+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return J(this,ee,"f")==null&&Xe(this,ee,le(this.bytes),"f"),J(this,ee,"f")}stringTuples(){return J(this,te,"f")==null&&Xe(this,te,Re(this.tuples()),"f"),J(this,te,"f")}encapsulate(e){return e=new P(e),new P(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new P(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new P(Ge(t.slice(0,n)));return this}getPeerId(){try{let t=this.stringTuples().filter(n=>n[0]===Z.ipfs.code).pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?b(m.decode(`z${n}`),"base58btc"):b(d.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(t=>f(t[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return Wt(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=Ht.get(t.name);if(n==null)throw(0,Qt.default)(new Error(`no available resolver for ${t.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new P(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[(Y=new WeakMap,ee=new WeakMap,te=new WeakMap,Xt=Kt,Jn)](){return`Multiaddr(${Je(this.bytes)})`}};function Hn(r){return new P(r)}return nr(Kn);})(); | ||
return MultiformatsMultiaddr})); |
@@ -35,2 +35,3 @@ const V = -1; | ||
[446, V, 'garlic64'], | ||
[448, 0, 'tls'], | ||
[460, 0, 'quic'], | ||
@@ -37,0 +38,0 @@ [461, 0, 'quic-v1'], |
{ | ||
"name": "@multiformats/multiaddr", | ||
"version": "11.3.0", | ||
"version": "11.4.0", | ||
"description": "multiaddr implementation (binary + string representation of network addresses)", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -38,2 +38,3 @@ import type { Protocol } from './index.js' | ||
[446, V, 'garlic64'], | ||
[448, 0, 'tls'], | ||
[460, 0, 'quic'], | ||
@@ -40,0 +41,0 @@ [461, 0, 'quic-v1'], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171086
3019