@multiformats/multiaddr
Advanced tools
Comparing version 11.1.4 to 11.1.5
(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 Ht=Object.create;var re=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames;var Yt=Object.getPrototypeOf,er=Object.prototype.hasOwnProperty;var W=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),w=(r,e)=>{for(var t in e)re(r,t,{get:e[t],enumerable:!0})},He=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Zt(e))!er.call(r,o)&&o!==t&&re(r,o,{get:()=>e[o],enumerable:!(n=Kt(e,o))||n.enumerable});return r};var ne=(r,e,t)=>(t=r!=null?Ht(Yt(r)):{},He(e||!r||!r.__esModule?re(t,"default",{value:r,enumerable:!0}):t,r)),tr=r=>He(re({},"__esModule",{value:!0}),r);var Ut=W((Yo,Tt)=>{Tt.exports=Le;var Et=128,wn=127,gn=~wn,yn=Math.pow(2,31);function Le(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Le.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=yn;)e[t++]=r&255|Et,r/=128;for(;r&gn;)e[t++]=r&255|Et,r>>>=7;return e[t]=r|0,Le.bytes=t-n+1,e}});var Bt=W((es,Pt)=>{Pt.exports=De;var xn=128,Ct=127;function De(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a||o>49)throw De.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Ct)<<o:(i&Ct)*Math.pow(2,o),o+=7}while(i>=xn);return De.bytes=s-n,t}});var Nt=W((ts,It)=>{var vn=Math.pow(2,7),An=Math.pow(2,14),Sn=Math.pow(2,21),En=Math.pow(2,28),Tn=Math.pow(2,35),Un=Math.pow(2,42),Cn=Math.pow(2,49),Pn=Math.pow(2,56),Bn=Math.pow(2,63);It.exports=function(r){return r<vn?1:r<An?2:r<Sn?3:r<En?4:r<Tn?5:r<Un?6:r<Cn?7:r<Pn?8:r<Bn?9:10}});var fe=W((rs,zt)=>{zt.exports={encode:Ut(),decode:Bt(),encodingLength:Nt()}});var kt=W((As,qt)=>{"use strict";function jt(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Wn(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 jt(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),jt(new o,t)}}qt.exports=Wn});var Zn={};w(Zn,{fromNodeAddress:()=>Qn,isMultiaddr:()=>Qe,isName:()=>Hn,multiaddr:()=>Kn,protocols:()=>u,resolvers:()=>Xt});var oe=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",N=2**(8*o)-1;for(;;){let p=this.readAtomically(()=>{let U=this.readChar();if(U===void 0)return;let V=Number.parseInt(U,e);if(!Number.isNaN(V))return V});if(p===void 0)break;if(s*=e,s+=p,s>N||(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 Ke=45,rr=15,L=new oe;function Ze(r){if(!(r.length>rr))return L.new(r).parseWith(()=>L.readIPv4Addr())}function Ye(r){if(!(r.length>Ke))return L.new(r).parseWith(()=>L.readIPv6Addr())}function et(r){if(!(r.length>Ke))return L.new(r).parseWith(()=>L.readIPAddr())}function tt(r){return Boolean(Ze(r))}function rt(r){return Boolean(Ye(r))}function se(r){return Boolean(et(r))}var ge={};w(ge,{identity:()=>cr});function nr(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),N=Math.log(a)/Math.log(256),p=Math.log(256)/Math.log(a);function U(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,y=0,v=c.length;y!==v&&c[y]===0;)y++,h++;for(var A=(v-y)*p+1>>>0,g=new Uint8Array(A);y!==v;){for(var S=c[y],z=0,x=A-1;(S!==0||z<O)&&x!==-1;x--,z++)S+=256*g[x]>>>0,g[x]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");O=z,y++}for(var C=A-O;C!==A&&g[C]===0;)C++;for(var te=l.repeat(h);C<A;++C)te+=r.charAt(g[C]);return te}function V(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,y=0;c[h]===l;)O++,h++;for(var v=(c.length-h)*N+1>>>0,A=new Uint8Array(v);c[h];){var g=t[c.charCodeAt(h)];if(g===255)return;for(var S=0,z=v-1;(g!==0||S<y)&&z!==-1;z--,S++)g+=a*A[z]>>>0,A[z]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");y=S,h++}if(c[h]!==" "){for(var x=v-y;x!==v&&A[x]===0;)x++;for(var C=new Uint8Array(O+(v-x)),te=O;x!==v;)C[te++]=A[x++];return C}}}function Qt(c){var h=V(c);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:U,decodeUnsafe:V,decode:Qt}}var or=nr,sr=or,nt=sr;var io=new Uint8Array(0);var ot=(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},P=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 st=r=>new TextEncoder().encode(r),it=r=>new TextDecoder().decode(r);var he=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")}},me=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 ct(this,e)}},be=class{constructor(e){this.decoders=e}or(e){return ct(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`)}},ct=(r,e)=>new be({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),we=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new he(e,t,n),this.decoder=new me(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},D=({name:r,prefix:e,encode:t,decode:n})=>new we(r,e,t,n),M=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=nt(t,e);return D({prefix:r,name:e,encode:n,decode:s=>P(o(s))})},ir=(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,N=0;for(let p=0;p<s;++p){let U=o[r[p]];if(U===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<t|U,a+=t,a>=8&&(a-=8,i[N++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return i},ar=(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},f=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>D({prefix:e,name:r,encode(o){return ar(o,n,t)},decode(o){return ir(o,n,t,r)}});var cr=D({prefix:"\0",name:"identity",encode:r=>it(r),decode:r=>st(r)});var ye={};w(ye,{base2:()=>dr});var dr=f({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var xe={};w(xe,{base8:()=>fr});var fr=f({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ve={};w(ve,{base10:()=>ur});var ur=M({prefix:"9",name:"base10",alphabet:"0123456789"});var Ae={};w(Ae,{base16:()=>lr,base16upper:()=>pr});var lr=f({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),pr=f({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Se={};w(Se,{base32:()=>B,base32hex:()=>wr,base32hexpad:()=>yr,base32hexpadupper:()=>xr,base32hexupper:()=>gr,base32pad:()=>mr,base32padupper:()=>br,base32upper:()=>hr,base32z:()=>vr});var B=f({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),hr=f({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mr=f({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),br=f({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wr=f({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gr=f({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),yr=f({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xr=f({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vr=f({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ee={};w(Ee,{base36:()=>Ar,base36upper:()=>Sr});var Ar=M({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sr=M({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Te={};w(Te,{base58btc:()=>m,base58flickr:()=>Er});var m=M({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Er=M({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ue={};w(Ue,{base64:()=>Tr,base64pad:()=>Ur,base64url:()=>Cr,base64urlpad:()=>Pr});var Tr=f({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ur=f({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Cr=f({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pr=f({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ce={};w(Ce,{base256emoji:()=>Mr});var dt=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}"),Br=dt.reduce((r,e,t)=>(r[t]=e,r),[]),Ir=dt.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Nr(r){return r.reduce((e,t)=>(e+=Br[t],e),"")}function zr(r){let e=[];for(let t of r){let n=Ir[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Mr=D({prefix:"\u{1F680}",name:"base256emoji",encode:Nr,decode:zr});var Ne={};w(Ne,{sha256:()=>Zr,sha512:()=>Yr});var Vr=lt,ft=128,Or=127,$r=~Or,Lr=Math.pow(2,31);function lt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Lr;)e[t++]=r&255|ft,r/=128;for(;r&$r;)e[t++]=r&255|ft,r>>>=7;return e[t]=r|0,lt.bytes=t-n+1,e}var Dr=Pe,Fr=128,ut=127;function Pe(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Pe.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&ut)<<o:(i&ut)*Math.pow(2,o),o+=7}while(i>=Fr);return Pe.bytes=s-n,t}var jr=Math.pow(2,7),qr=Math.pow(2,14),kr=Math.pow(2,21),Rr=Math.pow(2,28),_r=Math.pow(2,35),Gr=Math.pow(2,42),Wr=Math.pow(2,49),Xr=Math.pow(2,56),Jr=Math.pow(2,63),Qr=function(r){return r<jr?1:r<qr?2:r<kr?3:r<Rr?4:r<_r?5:r<Gr?6:r<Wr?7:r<Xr?8:r<Jr?9:10},Hr={encode:Vr,decode:Dr,encodingLength:Qr},Kr=Hr,X=Kr;var J=(r,e=0)=>[X.decode(r,e),X.decode.bytes],F=(r,e,t=0)=>(X.encode(r,e,t),e),j=r=>X.encodingLength(r);var $=(r,e)=>{let t=e.byteLength,n=j(r),o=n+j(t),s=new Uint8Array(o+t);return F(r,s,0),F(t,s,n),s.set(e,o),new q(r,t,e,s)},ae=r=>{let e=P(r),[t,n]=J(e),[o,s]=J(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new q(t,o,i,e)},pt=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&ot(r.bytes,t.bytes)}},q=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Ie=({name:r,code:e,encode:t})=>new Be(r,e,t),Be=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?$(this.code,t):t.then(n=>$(this.code,n))}else throw Error("Unknown type, must be binary type")}};var mt=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Zr=Ie({name:"sha2-256",code:18,encode:mt("SHA-256")}),Yr=Ie({name:"sha2-512",code:19,encode:mt("SHA-512")});var ze={};w(ze,{identity:()=>rn});var bt=0,en="identity",wt=P,tn=r=>$(bt,wt(r)),rn={code:bt,name:en,encode:wt,digest:tn};var Po=new TextEncoder,Bo=new TextDecoder;var sn=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return cn(t,Me(r),e||m.encoder);default:return dn(t,Me(r),e||B.encoder)}},gt=new WeakMap,Me=r=>{let e=gt.get(r);if(e==null){let t=new Map;return gt.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!==Q)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==fn)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=$(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&&pt(e.multihash,n.multihash)}toString(e){return sn(this,e)}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}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||yt(n,o,s.bytes))}else if(t[un]===!0){let{version:n,multihash:o,code:s}=t,i=ae(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!==Q)throw new Error(`Version 0 CID must use dag-pb (code: ${Q}) block encoding`);return new d(e,t,n,n.bytes)}case 1:{let o=yt(e,t,n.bytes);return new d(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return d.create(0,Q,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=P(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 q(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[U,V]=J(e.subarray(t));return t+=V,U},o=n(),s=Q;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(),N=t+l,p=N-i;return{version:o,codec:s,multihashCode:a,digestSize:l,multihashSize:p,size:N}}static parse(e,t){let[n,o]=an(e,t),s=d.decode(o);return Me(s).set(n,e),s}},an=(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 B.prefix:{let t=e||B;return[B.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)]}}},cn=(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},dn=(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},Q=112,fn=18,yt=(r,e,t)=>{let n=j(r),o=n+j(e),s=new Uint8Array(o+t.byteLength);return F(r,s,0),F(e,s,n),s.set(t,o),s},un=Symbol.for("@ipld/js-cid/CID");var H={...ge,...ye,...xe,...ve,...Ae,...Se,...Ee,...Te,...Ue,...Ce},Fo={...Ne,...ze};function R(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ce(r=0){return globalThis.Buffer?.allocUnsafe!=null?R(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function vt(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var xt=vt("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ve=vt("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=ce(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ln={utf8:xt,"utf-8":xt,hex:H.base16,latin1:Ve,ascii:Ve,binary:Ve,...H},de=ln;function b(r,e="utf8"){let t=de[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 At=tt,pn=rt,Oe=function(r){let e=0;if(r=r.toString().trim(),At(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(pn(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=At(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")},St=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 K={},$e={},mn=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[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"]];mn.forEach(r=>{let e=bn(...r);$e[e.code]=e,K[e.name]=e});function bn(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:Boolean(n),path:Boolean(o)}}function u(r){if(typeof r=="number"){if($e[r]!=null)return $e[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(K[r]!=null)return K[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var E=ne(fe(),1);function Fe(r,e="utf8"){let t=de[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?R(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function I(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=ce(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return R(t)}function Ot(r,e){switch(u(r).code){case 4:case 41:return Nn(e);case 6:case 273:case 33:case 132:return Lt(e).toString();case 53:case 54:case 55:case 56:case 400:case 777:return Mn(e);case 421:return Ln(e);case 444:return Vt(e);case 445:return Vt(e);case 466:return $n(e);default:return b(e,"base16")}}function $t(r,e){switch(u(r).code){case 4:return Mt(e);case 41:return Mt(e);case 6:case 273:case 33:case 132:return qe(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return zn(e);case 421:return Vn(e);case 444:return Dn(e);case 445:return Fn(e);case 466:return On(e);default:return Fe(e,"base16")}}var je=Object.values(H).map(r=>r.decoder),In=function(){let r=je[0].or(je[1]);return je.slice(2).forEach(e=>r=r.or(e)),r}();function Mt(r){if(!se(r))throw new Error("invalid ip address");return Oe(r)}function Nn(r){let e=St(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!se(e))throw new Error("invalid ip address");return e}function qe(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Lt(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function zn(r){let e=Fe(r),t=Uint8Array.from(E.default.encode(e.length));return I([t,e],t.length+e.length)}function Mn(r){let e=E.default.decode(r);if(r=r.slice(E.default.decode.bytes),r.length!==e)throw new Error("inconsistent lengths");return b(r)}function Vn(r){let e;r[0]==="Q"||r[0]==="1"?e=ae(m.decode(`z${r}`)).bytes:e=d.parse(r).multihash.bytes;let t=Uint8Array.from(E.default.encode(e.length));return I([t,e],t.length+e.length)}function On(r){let e=In.decode(r),t=Uint8Array.from(E.default.encode(e.length));return I([t,e],t.length+e.length)}function $n(r){let e=E.default.decode(r),t=r.slice(E.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+b(t,"base64url")}function Ln(r){let e=E.default.decode(r),t=r.slice(E.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return b(t,"base58btc")}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!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=B.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=qe(n);return I([t,o],t.length+o.length)}function Fn(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=B.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=qe(n);return I([t,o],t.length+o.length)}function Vt(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=b(e,"base32"),o=Lt(t);return`${n}:${o}`}var _=ne(fe(),1);function jn(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=u(o);if(s.size===0){e.push([o]);continue}if(n++,n>=t.length)throw Ft("invalid address: "+r);if(s.path===!0){e.push([o,We(t.slice(n).join("/"))]);break}e.push([o,t[n]])}return e}function qn(r){let e=[];return r.map(t=>{let n=pe(t);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),We(e.join("/"))}function kn(r){return r.map(e=>{Array.isArray(e)||(e=[e]);let t=pe(e);return e.length>1?[t.code,$t(t.code,e[1])]:[t.code]})}function ke(r){return r.map(e=>{let t=pe(e);return e[1]!=null?[t.code,Ot(t.code,e[1])]:[t.code]})}function Re(r){return le(I(r.map(e=>{let t=pe(e),n=Uint8Array.from(_.default.encode(t.code));return e.length>1&&e[1]!=null&&(n=I([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 ue(r){let e=[],t=0;for(;t<r.length;){let n=_.default.decode(r,t),o=_.default.decode.bytes??0,s=u(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 Ft("Invalid address Uint8Array: "+b(r,"base16"));e.push([n,a])}return e}function Ge(r){let e=ue(r),t=ke(e);return qn(t)}function Rn(r){r=We(r);let e=jn(r),t=kn(e);return Re(t)}function Dt(r){return Rn(r)}function le(r){let e=_n(r);if(e!=null)throw e;return Uint8Array.from(r)}function _n(r){try{ue(r)}catch(e){return e}}function We(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Ft(r){return new Error("Error parsing address: "+r)}function pe(r){return u(r[0])}var Je=ne(fe(),1);var Wt=ne(kt(),1);function Rt(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 G=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},Z,Y,ee,_t,Xn=Symbol.for("nodejs.util.inspect.custom"),Gt=[u("dns").code,u("dns4").code,u("dns6").code,u("dnsaddr").code],Jn=[u("p2p").code,u("ipfs").code],Xt=new Map,Jt=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Qn(r,e){if(r==null)throw new Error("requires node address object");if(e==null)throw new Error("requires transport protocol");let t;switch(r.family){case 4:t="ip4";break;case 6:t="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new T("/"+[t,r.address,e,r.port].join("/"))}function Hn(r){return Qe(r)?r.protos().some(e=>e.resolvable):!1}function Qe(r){return Boolean(r?.[Jt])}var T=class{constructor(e){if(Z.set(this,void 0),Y.set(this,void 0),ee.set(this,void 0),this[_t]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=le(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Dt(e)}else if(Qe(e))this.bytes=le(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return G(this,Z,"f")==null&&Xe(this,Z,Ge(this.bytes),"f"),G(this,Z,"f")}toJSON(){return this.toString()}toOptions(){let e=this.protoCodes(),t=this.toString().split("/").slice(1),n,o;if(t.length>2)Gt.includes(e[0])&&Jn.includes(e[1])?(n=u("tcp").name,o=443):(n=u(t[2]).name,o=parseInt(t[3]));else if(Gt.includes(e[0]))n=u("tcp").name,o=443;else throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e[0]===41||e[0]===55?6:4,host:t[1],transport:n,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},u(e)))}protoCodes(){let e=[],t=this.bytes,n=0;for(;n<t.length;){let o=Je.default.decode(t,n),s=Je.default.decode.bytes??0,i=u(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 G(this,Y,"f")==null&&Xe(this,Y,ue(this.bytes),"f"),G(this,Y,"f")}stringTuples(){return G(this,ee,"f")==null&&Xe(this,ee,ke(this.tuples()),"f"),G(this,ee,"f")}encapsulate(e){return e=new T(e),new T(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 T(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 T(Re(t.slice(0,n)));return this}getPeerId(){try{let t=this.stringTuples().filter(n=>n[0]===K.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=>u(t[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return Rt(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=Xt.get(t.name);if(n==null)throw(0,Wt.default)(new Error(`no available resolver for ${t.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new T(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)}[(Z=new WeakMap,Y=new WeakMap,ee=new WeakMap,_t=Jt,Xn)](){return`Multiaddr(${Ge(this.bytes)})`}};function Kn(r){return new T(r)}return tr(Zn);})(); | ||
"use strict";var MultiformatsMultiaddr=(()=>{var Kt=Object.create;var re=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var J=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),w=(r,e)=>{for(var t in e)re(r,t,{get:e[t],enumerable:!0})},He=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Yt(e))!tr.call(r,o)&&o!==t&&re(r,o,{get:()=>e[o],enumerable:!(n=Zt(e,o))||n.enumerable});return r};var ne=(r,e,t)=>(t=r!=null?Kt(er(r)):{},He(e||!r||!r.__esModule?re(t,"default",{value:r,enumerable:!0}):t,r)),rr=r=>He(re({},"__esModule",{value:!0}),r);var Ct=J((Yo,Ut)=>{Ut.exports=Le;var Tt=128,wn=127,gn=~wn,yn=Math.pow(2,31);function Le(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Le.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=yn;)e[t++]=r&255|Tt,r/=128;for(;r&gn;)e[t++]=r&255|Tt,r>>>=7;return e[t]=r|0,Le.bytes=t-n+1,e}});var It=J((es,Bt)=>{Bt.exports=De;var xn=128,Pt=127;function De(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a||o>49)throw De.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Pt)<<o:(i&Pt)*Math.pow(2,o),o+=7}while(i>=xn);return De.bytes=s-n,t}});var zt=J((ts,Nt)=>{var vn=Math.pow(2,7),An=Math.pow(2,14),Sn=Math.pow(2,21),En=Math.pow(2,28),Tn=Math.pow(2,35),Un=Math.pow(2,42),Cn=Math.pow(2,49),Pn=Math.pow(2,56),Bn=Math.pow(2,63);Nt.exports=function(r){return r<vn?1:r<An?2:r<Sn?3:r<En?4:r<Tn?5:r<Un?6:r<Cn?7:r<Pn?8:r<Bn?9:10}});var fe=J((rs,Mt)=>{Mt.exports={encode:Ct(),decode:It(),encodingLength:zt()}});var Rt=J((As,kt)=>{"use strict";function qt(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Jn(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 qt(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),qt(new o,t)}}kt.exports=Jn});var Zn={};w(Zn,{fromNodeAddress:()=>Qn,isMultiaddr:()=>Qe,isName:()=>Hn,multiaddr:()=>Kn,protocols:()=>u,resolvers:()=>Xt});var oe=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",N=2**(8*o)-1;for(;;){let p=this.readAtomically(()=>{let U=this.readChar();if(U===void 0)return;let V=Number.parseInt(U,e);if(!Number.isNaN(V))return V});if(p===void 0)break;if(s*=e,s+=p,s>N||(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 Ke=45,nr=15,L=new oe;function Ze(r){if(!(r.length>nr))return L.new(r).parseWith(()=>L.readIPv4Addr())}function Ye(r){if(!(r.length>Ke))return L.new(r).parseWith(()=>L.readIPv6Addr())}function et(r){if(!(r.length>Ke))return L.new(r).parseWith(()=>L.readIPAddr())}function tt(r){return Boolean(Ze(r))}function rt(r){return Boolean(Ye(r))}function se(r){return Boolean(et(r))}var ge={};w(ge,{identity:()=>dr});function or(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),N=Math.log(a)/Math.log(256),p=Math.log(256)/Math.log(a);function U(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,y=0,v=c.length;y!==v&&c[y]===0;)y++,h++;for(var A=(v-y)*p+1>>>0,g=new Uint8Array(A);y!==v;){for(var S=c[y],z=0,x=A-1;(S!==0||z<O)&&x!==-1;x--,z++)S+=256*g[x]>>>0,g[x]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");O=z,y++}for(var C=A-O;C!==A&&g[C]===0;)C++;for(var te=l.repeat(h);C<A;++C)te+=r.charAt(g[C]);return te}function V(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,y=0;c[h]===l;)O++,h++;for(var v=(c.length-h)*N+1>>>0,A=new Uint8Array(v);c[h];){var g=t[c.charCodeAt(h)];if(g===255)return;for(var S=0,z=v-1;(g!==0||S<y)&&z!==-1;z--,S++)g+=a*A[z]>>>0,A[z]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");y=S,h++}if(c[h]!==" "){for(var x=v-y;x!==v&&A[x]===0;)x++;for(var C=new Uint8Array(O+(v-x)),te=O;x!==v;)C[te++]=A[x++];return C}}}function Ht(c){var h=V(c);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:U,decodeUnsafe:V,decode:Ht}}var sr=or,ir=sr,nt=ir;var io=new Uint8Array(0);var ot=(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},P=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 st=r=>new TextEncoder().encode(r),it=r=>new TextDecoder().decode(r);var he=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")}},me=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 ct(this,e)}},be=class{constructor(e){this.decoders=e}or(e){return ct(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`)}},ct=(r,e)=>new be({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),we=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new he(e,t,n),this.decoder=new me(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},D=({name:r,prefix:e,encode:t,decode:n})=>new we(r,e,t,n),M=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=nt(t,e);return D({prefix:r,name:e,encode:n,decode:s=>P(o(s))})},ar=(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,N=0;for(let p=0;p<s;++p){let U=o[r[p]];if(U===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<t|U,a+=t,a>=8&&(a-=8,i[N++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return i},cr=(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},f=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>D({prefix:e,name:r,encode(o){return cr(o,n,t)},decode(o){return ar(o,n,t,r)}});var dr=D({prefix:"\0",name:"identity",encode:r=>it(r),decode:r=>st(r)});var ye={};w(ye,{base2:()=>fr});var fr=f({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var xe={};w(xe,{base8:()=>ur});var ur=f({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ve={};w(ve,{base10:()=>lr});var lr=M({prefix:"9",name:"base10",alphabet:"0123456789"});var Ae={};w(Ae,{base16:()=>pr,base16upper:()=>hr});var pr=f({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hr=f({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Se={};w(Se,{base32:()=>B,base32hex:()=>gr,base32hexpad:()=>xr,base32hexpadupper:()=>vr,base32hexupper:()=>yr,base32pad:()=>br,base32padupper:()=>wr,base32upper:()=>mr,base32z:()=>Ar});var B=f({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mr=f({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),br=f({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wr=f({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),gr=f({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yr=f({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xr=f({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vr=f({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ar=f({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ee={};w(Ee,{base36:()=>Sr,base36upper:()=>Er});var Sr=M({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Er=M({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Te={};w(Te,{base58btc:()=>m,base58flickr:()=>Tr});var m=M({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Tr=M({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ue={};w(Ue,{base64:()=>Ur,base64pad:()=>Cr,base64url:()=>Pr,base64urlpad:()=>Br});var Ur=f({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Cr=f({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pr=f({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Br=f({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ce={};w(Ce,{base256emoji:()=>Vr});var dt=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}"),Ir=dt.reduce((r,e,t)=>(r[t]=e,r),[]),Nr=dt.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function zr(r){return r.reduce((e,t)=>(e+=Ir[t],e),"")}function Mr(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 Vr=D({prefix:"\u{1F680}",name:"base256emoji",encode:zr,decode:Mr});var Ne={};w(Ne,{sha256:()=>Yr,sha512:()=>en});var Or=lt,ft=128,$r=127,Lr=~$r,Dr=Math.pow(2,31);function lt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Dr;)e[t++]=r&255|ft,r/=128;for(;r&Lr;)e[t++]=r&255|ft,r>>>=7;return e[t]=r|0,lt.bytes=t-n+1,e}var Fr=Pe,jr=128,ut=127;function Pe(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Pe.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&ut)<<o:(i&ut)*Math.pow(2,o),o+=7}while(i>=jr);return Pe.bytes=s-n,t}var qr=Math.pow(2,7),kr=Math.pow(2,14),Rr=Math.pow(2,21),_r=Math.pow(2,28),Gr=Math.pow(2,35),Jr=Math.pow(2,42),Wr=Math.pow(2,49),Xr=Math.pow(2,56),Qr=Math.pow(2,63),Hr=function(r){return r<qr?1:r<kr?2:r<Rr?3:r<_r?4:r<Gr?5:r<Jr?6:r<Wr?7:r<Xr?8:r<Qr?9:10},Kr={encode:Or,decode:Fr,encodingLength:Hr},Zr=Kr,W=Zr;var X=(r,e=0)=>[W.decode(r,e),W.decode.bytes],F=(r,e,t=0)=>(W.encode(r,e,t),e),j=r=>W.encodingLength(r);var $=(r,e)=>{let t=e.byteLength,n=j(r),o=n+j(t),s=new Uint8Array(o+t);return F(r,s,0),F(t,s,n),s.set(e,o),new q(r,t,e,s)},ae=r=>{let e=P(r),[t,n]=X(e),[o,s]=X(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new q(t,o,i,e)},pt=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&ot(r.bytes,t.bytes)}},q=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Ie=({name:r,code:e,encode:t})=>new Be(r,e,t),Be=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?$(this.code,t):t.then(n=>$(this.code,n))}else throw Error("Unknown type, must be binary type")}};var mt=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Yr=Ie({name:"sha2-256",code:18,encode:mt("SHA-256")}),en=Ie({name:"sha2-512",code:19,encode:mt("SHA-512")});var ze={};w(ze,{identity:()=>nn});var bt=0,tn="identity",wt=P,rn=r=>$(bt,wt(r)),nn={code:bt,name:tn,encode:wt,digest:rn};var Po=new TextEncoder,Bo=new TextDecoder;var gt=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return cn(t,Me(r),e||m.encoder);default:return dn(t,Me(r),e||B.encoder)}};var yt=new WeakMap,Me=r=>{let e=yt.get(r);if(e==null){let t=new Map;return yt.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!==Q)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==fn)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=$(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&&pt(e.multihash,n.multihash)}toString(e){return gt(this,e)}toJSON(){return{"/":gt(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||xt(n,o,s.bytes))}else if(t[un]===!0){let{version:n,multihash:o,code:s}=t,i=ae(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!==Q)throw new Error(`Version 0 CID must use dag-pb (code: ${Q}) block encoding`);return new d(e,t,n,n.bytes)}case 1:{let o=xt(e,t,n.bytes);return new d(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return d.create(0,Q,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=P(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 q(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[U,V]=X(e.subarray(t));return t+=V,U},o=n(),s=Q;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(),N=t+l,p=N-i;return{version:o,codec:s,multihashCode:a,digestSize:l,multihashSize:p,size:N}}static parse(e,t){let[n,o]=an(e,t),s=d.decode(o);return Me(s).set(n,e),s}},an=(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 B.prefix:{let t=e||B;return[B.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)]}}},cn=(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},dn=(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},Q=112,fn=18,xt=(r,e,t)=>{let n=j(r),o=n+j(e),s=new Uint8Array(o+t.byteLength);return F(r,s,0),F(e,s,n),s.set(t,o),s},un=Symbol.for("@ipld/js-cid/CID");var H={...ge,...ye,...xe,...ve,...Ae,...Se,...Ee,...Te,...Ue,...Ce},Fo={...Ne,...ze};function R(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ce(r=0){return globalThis.Buffer?.allocUnsafe!=null?R(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function At(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var vt=At("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ve=At("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=ce(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ln={utf8:vt,"utf-8":vt,hex:H.base16,latin1:Ve,ascii:Ve,binary:Ve,...H},de=ln;function b(r,e="utf8"){let t=de[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 St=tt,pn=rt,Oe=function(r){let e=0;if(r=r.toString().trim(),St(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(pn(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=St(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")},Et=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 K={},$e={},mn=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[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"]];mn.forEach(r=>{let e=bn(...r);$e[e.code]=e,K[e.name]=e});function bn(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:Boolean(n),path:Boolean(o)}}function u(r){if(typeof r=="number"){if($e[r]!=null)return $e[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(K[r]!=null)return K[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var E=ne(fe(),1);function Fe(r,e="utf8"){let t=de[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?R(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function I(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=ce(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return R(t)}function $t(r,e){switch(u(r).code){case 4:case 41:return Nn(e);case 6:case 273:case 33:case 132:return Dt(e).toString();case 53:case 54:case 55:case 56:case 400:case 777:return Mn(e);case 421:return Ln(e);case 444:return Ot(e);case 445:return Ot(e);case 466:return $n(e);default:return b(e,"base16")}}function Lt(r,e){switch(u(r).code){case 4:return Vt(e);case 41:return Vt(e);case 6:case 273:case 33:case 132:return qe(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return zn(e);case 421:return Vn(e);case 444:return Dn(e);case 445:return Fn(e);case 466:return On(e);default:return Fe(e,"base16")}}var je=Object.values(H).map(r=>r.decoder),In=function(){let r=je[0].or(je[1]);return je.slice(2).forEach(e=>r=r.or(e)),r}();function Vt(r){if(!se(r))throw new Error("invalid ip address");return Oe(r)}function Nn(r){let e=Et(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!se(e))throw new Error("invalid ip address");return e}function qe(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Dt(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function zn(r){let e=Fe(r),t=Uint8Array.from(E.default.encode(e.length));return I([t,e],t.length+e.length)}function Mn(r){let e=E.default.decode(r);if(r=r.slice(E.default.decode.bytes),r.length!==e)throw new Error("inconsistent lengths");return b(r)}function Vn(r){let e;r[0]==="Q"||r[0]==="1"?e=ae(m.decode(`z${r}`)).bytes:e=d.parse(r).multihash.bytes;let t=Uint8Array.from(E.default.encode(e.length));return I([t,e],t.length+e.length)}function On(r){let e=In.decode(r),t=Uint8Array.from(E.default.encode(e.length));return I([t,e],t.length+e.length)}function $n(r){let e=E.default.decode(r),t=r.slice(E.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+b(t,"base64url")}function Ln(r){let e=E.default.decode(r),t=r.slice(E.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return b(t,"base58btc")}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!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=B.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=qe(n);return I([t,o],t.length+o.length)}function Fn(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=B.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=qe(n);return I([t,o],t.length+o.length)}function Ot(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=b(e,"base32"),o=Dt(t);return`${n}:${o}`}var _=ne(fe(),1);function jn(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=u(o);if(s.size===0){e.push([o]);continue}if(n++,n>=t.length)throw jt("invalid address: "+r);if(s.path===!0){e.push([o,Je(t.slice(n).join("/"))]);break}e.push([o,t[n]])}return e}function qn(r){let e=[];return r.map(t=>{let n=pe(t);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Je(e.join("/"))}function kn(r){return r.map(e=>{Array.isArray(e)||(e=[e]);let t=pe(e);return e.length>1?[t.code,Lt(t.code,e[1])]:[t.code]})}function ke(r){return r.map(e=>{let t=pe(e);return e[1]!=null?[t.code,$t(t.code,e[1])]:[t.code]})}function Re(r){return le(I(r.map(e=>{let t=pe(e),n=Uint8Array.from(_.default.encode(t.code));return e.length>1&&e[1]!=null&&(n=I([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 ue(r){let e=[],t=0;for(;t<r.length;){let n=_.default.decode(r,t),o=_.default.decode.bytes??0,s=u(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 jt("Invalid address Uint8Array: "+b(r,"base16"));e.push([n,a])}return e}function Ge(r){let e=ue(r),t=ke(e);return qn(t)}function Rn(r){r=Je(r);let e=jn(r),t=kn(e);return Re(t)}function Ft(r){return Rn(r)}function le(r){let e=_n(r);if(e!=null)throw e;return Uint8Array.from(r)}function _n(r){try{ue(r)}catch(e){return e}}function Je(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function jt(r){return new Error("Error parsing address: "+r)}function pe(r){return u(r[0])}var Xe=ne(fe(),1);var Wt=ne(Rt(),1);function _t(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 G=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)},We=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},Z,Y,ee,Gt,Wn=Symbol.for("nodejs.util.inspect.custom"),Jt=[u("dns").code,u("dns4").code,u("dns6").code,u("dnsaddr").code],Xn=[u("p2p").code,u("ipfs").code],Xt=new Map,Qt=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Qn(r,e){if(r==null)throw new Error("requires node address object");if(e==null)throw new Error("requires transport protocol");let t;switch(r.family){case 4:t="ip4";break;case 6:t="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new T("/"+[t,r.address,e,r.port].join("/"))}function Hn(r){return Qe(r)?r.protos().some(e=>e.resolvable):!1}function Qe(r){return Boolean(r?.[Qt])}var T=class{constructor(e){if(Z.set(this,void 0),Y.set(this,void 0),ee.set(this,void 0),this[Gt]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=le(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Ft(e)}else if(Qe(e))this.bytes=le(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return G(this,Z,"f")==null&&We(this,Z,Ge(this.bytes),"f"),G(this,Z,"f")}toJSON(){return this.toString()}toOptions(){let e=this.protoCodes(),t=this.toString().split("/").slice(1),n,o;if(t.length>2)Jt.includes(e[0])&&Xn.includes(e[1])?(n=u("tcp").name,o=443):(n=u(t[2]).name,o=parseInt(t[3]));else if(Jt.includes(e[0]))n=u("tcp").name,o=443;else throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e[0]===41||e[0]===55?6:4,host:t[1],transport:n,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},u(e)))}protoCodes(){let e=[],t=this.bytes,n=0;for(;n<t.length;){let o=Xe.default.decode(t,n),s=Xe.default.decode.bytes??0,i=u(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 G(this,Y,"f")==null&&We(this,Y,ue(this.bytes),"f"),G(this,Y,"f")}stringTuples(){return G(this,ee,"f")==null&&We(this,ee,ke(this.tuples()),"f"),G(this,ee,"f")}encapsulate(e){return e=new T(e),new T(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 T(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 T(Re(t.slice(0,n)));return this}getPeerId(){try{let t=this.stringTuples().filter(n=>n[0]===K.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=>u(t[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return _t(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=Xt.get(t.name);if(n==null)throw(0,Wt.default)(new Error(`no available resolver for ${t.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new T(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)}[(Z=new WeakMap,Y=new WeakMap,ee=new WeakMap,Gt=Qt,Wn)](){return`Multiaddr(${Ge(this.bytes)})`}};function Kn(r){return new T(r)}return rr(Zn);})(); | ||
return MultiformatsMultiaddr})); |
{ | ||
"name": "@multiformats/multiaddr", | ||
"version": "11.1.4", | ||
"version": "11.1.5", | ||
"description": "multiaddr implementation (binary + string representation of network addresses)", | ||
@@ -171,3 +171,3 @@ "license": "Apache-2.0 OR MIT", | ||
"err-code": "^3.0.1", | ||
"multiformats": "^10.0.0", | ||
"multiformats": "^11.0.0", | ||
"uint8arrays": "^4.0.2", | ||
@@ -178,3 +178,3 @@ "varint": "^6.0.0" | ||
"@types/varint": "^6.0.0", | ||
"aegir": "^37.7.2", | ||
"aegir": "^37.9.1", | ||
"sinon": "^15.0.0", | ||
@@ -181,0 +181,0 @@ "util": "^0.12.3" |
@@ -19,3 +19,3 @@ # @multiformats/multiaddr <!-- omit in toc --> | ||
- [License](#license) | ||
- [Contribute](#contribute) | ||
- [Contribution](#contribution) | ||
@@ -117,4 +117,4 @@ ## Install | ||
## Contribute | ||
## Contribution | ||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. |
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
167580
+ Addedmultiformats@11.0.2(transitive)
- Removedmultiformats@10.0.3(transitive)
Updatedmultiformats@^11.0.0