@libp2p/bootstrap 10.1.0 → 10.1.1-ce6da9896
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/package.json +5 -5
- package/dist/typedoc-urls.json +0 -8
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PBootstrap = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PBootstrap=(()=>{var Dt=Object.defineProperty;var Sr=Object.getOwnPropertyDescriptor;var Ar=Object.getOwnPropertyNames;var Ir=Object.prototype.hasOwnProperty;var E=(r,t)=>{for(var e in t)Dt(r,e,{get:t[e],enumerable:!0})},Tr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ar(t))!Ir.call(r,o)&&o!==e&&Dt(r,o,{get:()=>t[o],enumerable:!(n=Sr(t,o))||n.enumerable});return r};var Pr=r=>Tr(Dt({},"__esModule",{value:!0}),r);var Ao={};E(Ao,{bootstrap:()=>So});var Se=Symbol.for("@libp2p/peer-discovery");var Ae=Symbol.for("@libp2p/peer-id");var mt=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Ie=(r,...t)=>{try{[...t]}catch{}};var xt=class extends EventTarget{#t=new Map;constructor(){super(),Ie(1/0,this)}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new Cr(t,e))}},Ut=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},Cr=globalThis.CustomEvent??Ut;var Te=Symbol.for("@libp2p/service-capabilities"),No=Symbol.for("@libp2p/service-dependencies");var Lt={};E(Lt,{base58btc:()=>g,base58flickr:()=>Mr});var rs=new Uint8Array(0);function Pe(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function M(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")}function Ce(r){return new TextEncoder().encode(r)}function De(r){return new TextDecoder().decode(r)}function Dr(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),c=s.charCodeAt(0);if(e[c]!==255)throw new TypeError(s+" is ambiguous");e[c]=o}var p=r.length,f=r.charAt(0),b=Math.log(p)/Math.log(256),x=Math.log(256)/Math.log(p);function I(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";for(var y=0,q=0,T=0,D=u.length;T!==D&&u[T]===0;)T++,y++;for(var U=(D-T)*x+1>>>0,A=new Uint8Array(U);T!==D;){for(var R=u[T],O=0,P=U-1;(R!==0||O<q)&&P!==-1;P--,O++)R+=256*A[P]>>>0,A[P]=R%p>>>0,R=R/p>>>0;if(R!==0)throw new Error("Non-zero carry");q=O,T++}for(var F=U-q;F!==U&&A[F]===0;)F++;for(var ht=f.repeat(y);F<U;++F)ht+=r.charAt(A[F]);return ht}function z(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var y=0;if(u[y]!==" "){for(var q=0,T=0;u[y]===f;)q++,y++;for(var D=(u.length-y)*b+1>>>0,U=new Uint8Array(D);u[y];){var A=e[u.charCodeAt(y)];if(A===255)return;for(var R=0,O=D-1;(A!==0||R<T)&&O!==-1;O--,R++)A+=p*U[O]>>>0,U[O]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");T=R,y++}if(u[y]!==" "){for(var P=D-T;P!==D&&U[P]===0;)P++;for(var F=new Uint8Array(q+(D-P)),ht=q;P!==D;)F[ht++]=U[P++];return F}}}function S(u){var y=z(u);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:I,decodeUnsafe:z,decode:S}}var Ur=Dr,Rr=Ur,Re=Rr;var Rt=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Nt=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Ne(this,t)}},Ft=class{decoders;constructor(t){this.decoders=t}or(t){return Ne(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ne(r,t){return new Ft({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Mt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Rt(t,e,n),this.decoder=new Nt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Q({name:r,prefix:t,encode:e,decode:n}){return new Mt(r,t,e,n)}function V({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Re(e,r);return Q({prefix:t,name:r,encode:n,decode:s=>M(o(s))})}function Nr(r,t,e,n){let o={};for(let x=0;x<t.length;++x)o[t[x]]=x;let s=r.length;for(;r[s-1]==="=";)--s;let c=new Uint8Array(s*e/8|0),p=0,f=0,b=0;for(let x=0;x<s;++x){let I=o[r[x]];if(I===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<e|I,p+=e,p>=8&&(p-=8,c[b++]=255&f>>p)}if(p>=e||255&f<<8-p)throw new SyntaxError("Unexpected end of data");return c}function Fr(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",c=0,p=0;for(let f=0;f<r.length;++f)for(p=p<<8|r[f],c+=8;c>e;)c-=e,s+=t[o&p>>c];if(c!==0&&(s+=t[o&p<<e-c]),n)for(;s.length*e&7;)s+="=";return s}function h({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Q({prefix:t,name:r,encode(o){return Fr(o,n,e)},decode(o){return Nr(o,n,e,r)}})}var g=V({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Mr=V({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kt={};E(kt,{base10:()=>Lr});var Lr=V({prefix:"9",name:"base10",alphabet:"0123456789"});var zt={};E(zt,{base16:()=>kr,base16upper:()=>zr});var kr=h({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zr=h({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ot={};E(Ot,{base2:()=>Or});var Or=h({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Vt={};E(Vt,{base256emoji:()=>jr});var Fe=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}"),Vr=Fe.reduce((r,t,e)=>(r[e]=t,r),[]),Br=Fe.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function _r(r){return r.reduce((t,e)=>(t+=Vr[e],t),"")}function $r(r){let t=[];for(let e of r){let n=Br[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var jr=Q({prefix:"\u{1F680}",name:"base256emoji",encode:_r,decode:$r});var Bt={};E(Bt,{base32:()=>L,base32hex:()=>Hr,base32hexpad:()=>Jr,base32hexpadupper:()=>Xr,base32hexupper:()=>Kr,base32pad:()=>Gr,base32padupper:()=>Wr,base32upper:()=>qr,base32z:()=>Qr});var L=h({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qr=h({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gr=h({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Wr=h({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Hr=h({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Kr=h({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Jr=h({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Xr=h({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Qr=h({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _t={};E(_t,{base36:()=>Yr,base36upper:()=>Zr});var Yr=V({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zr=V({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $t={};E($t,{base64:()=>tn,base64pad:()=>en,base64url:()=>rn,base64urlpad:()=>nn});var tn=h({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),en=h({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),rn=h({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),nn=h({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var jt={};E(jt,{base8:()=>on});var on=h({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qt={};E(qt,{identity:()=>sn});var sn=Q({prefix:"\0",name:"identity",encode:r=>De(r),decode:r=>Ce(r)});var ws=new TextEncoder,bs=new TextDecoder;var Wt={};E(Wt,{identity:()=>wt});var pn=ke,Me=128,un=127,dn=~un,ln=Math.pow(2,31);function ke(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ln;)t[e++]=r&255|Me,r/=128;for(;r&dn;)t[e++]=r&255|Me,r>>>=7;return t[e]=r|0,ke.bytes=e-n+1,t}var fn=Gt,hn=128,Le=127;function Gt(r,n){var e=0,n=n||0,o=0,s=n,c,p=r.length;do{if(s>=p)throw Gt.bytes=0,new RangeError("Could not decode varint");c=r[s++],e+=o<28?(c&Le)<<o:(c&Le)*Math.pow(2,o),o+=7}while(c>=hn);return Gt.bytes=s-n,e}var mn=Math.pow(2,7),xn=Math.pow(2,14),gn=Math.pow(2,21),wn=Math.pow(2,28),bn=Math.pow(2,35),yn=Math.pow(2,42),vn=Math.pow(2,49),En=Math.pow(2,56),Sn=Math.pow(2,63),An=function(r){return r<mn?1:r<xn?2:r<gn?3:r<wn?4:r<bn?5:r<yn?6:r<vn?7:r<En?8:r<Sn?9:10},In={encode:pn,decode:fn,encodingLength:An},Tn=In,it=Tn;function ct(r,t=0){return[it.decode(r,t),it.decode.bytes]}function Y(r,t,e=0){return it.encode(r,t,e),t}function Z(r){return it.encodingLength(r)}function B(r,t){let e=t.byteLength,n=Z(r),o=n+Z(e),s=new Uint8Array(o+e);return Y(r,s,0),Y(e,s,n),s.set(t,o),new tt(r,e,t,s)}function G(r){let t=M(r),[e,n]=ct(t),[o,s]=ct(t.subarray(n)),c=t.subarray(n+s);if(c.byteLength!==o)throw new Error("Incorrect length");return new tt(e,o,c,t)}function ze(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Pe(r.bytes,e.bytes)}}var tt=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Oe=0,Pn="identity",Ve=M;function Cn(r){return B(Oe,Ve(r))}var wt={code:Oe,name:Pn,encode:Ve,digest:Cn};var Jt={};E(Jt,{sha256:()=>bt,sha512:()=>Dn});function Kt({name:r,code:t,encode:e}){return new Ht(r,t,e)}var Ht=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?B(this.code,e):e.then(n=>B(this.code,n))}else throw Error("Unknown type, must be binary type")}};function _e(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var bt=Kt({name:"sha2-256",code:18,encode:_e("SHA-256")}),Dn=Kt({name:"sha2-512",code:19,encode:_e("SHA-512")});function $e(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Rn(e,Xt(r),t??g.encoder);default:return Nn(e,Xt(r),t??L.encoder)}}var je=new WeakMap;function Xt(r){let t=je.get(r);if(t==null){let e=new Map;return je.set(r,e),e}return t}var C=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,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:t,multihash:e}=this;if(t!==at)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Fn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:t,digest:e}=this.multihash,n=B(t,e);return r.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(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&ze(t.multihash,n.multihash)}toString(t){return $e(this,t)}toJSON(){return{"/":$e(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:c}=e;return new r(n,o,s,c??qe(n,o,s.bytes))}else if(e[Mn]===!0){let{version:n,multihash:o,code:s}=e,c=G(o);return r.create(n,s,c)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==at)throw new Error(`Version 0 CID must use dag-pb (code: ${at}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=qe(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,at,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=M(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),c=new tt(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(c):r.createV1(e.codec,c),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[I,z]=ct(t.subarray(e));return e+=z,I},o=n(),s=at;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let c=e,p=n(),f=n(),b=e+f,x=b-c;return{version:o,codec:s,multihashCode:p,digestSize:f,multihashSize:x,size:b}}static parse(t,e){let[n,o]=Un(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Xt(s).set(n,t),s}};function Un(r,t){switch(r[0]){case"Q":{let e=t??g;return[g.prefix,e.decode(`${g.prefix}${r}`)]}case g.prefix:{let e=t??g;return[g.prefix,e.decode(r)]}case L.prefix:{let e=t??L;return[L.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Rn(r,t,e){let{prefix:n}=e;if(n!==g.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Nn(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var at=112,Fn=18;function qe(r,t,e){let n=Z(r),o=n+Z(t),s=new Uint8Array(o+e.byteLength);return Y(r,s,0),Y(t,s,n),s.set(e,o),s}var Mn=Symbol.for("@ipld/js-cid/CID");var _={...qt,...Ot,...jt,...kt,...zt,...Bt,..._t,...Lt,...$t,...Vt},Bs={...Jt,...Wt};function pt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Ln=Symbol.for("nodejs.util.inspect.custom"),Ge=Object.values(_).map(r=>r.decoder).reduce((r,t)=>r.or(t),_.identity.decoder),We=114,He=36,Ke=37,ut=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ae]=!0;toString(){return this.string==null&&(this.string=g.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return C.createV1(We,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return pt(this.multihash.bytes,t);if(typeof t=="string")return Qt(t).equals(this);if(t?.multihash?.bytes!=null)return pt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Ln](){return`PeerId(${this.toString()})`}},dt=class extends ut{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},lt=class extends ut{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},ft=class extends ut{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function Qt(r,t){if(t=t??Ge,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=G(g.decode(`z${r}`));return r.startsWith("12D")?new lt({multihash:e}):r.startsWith("16U")?new ft({multihash:e}):new dt({multihash:e})}return kn(Ge.decode(r))}function kn(r){try{let t=G(r);if(t.code===wt.code){if(t.digest.length===He)return new lt({multihash:t});if(t.digest.length===Ke)return new ft({multihash:t})}if(t.code===bt.code)return new dt({multihash:t})}catch{return zn(C.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function zn(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==We)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===bt.code)return new dt({multihash:r.multihash});if(t.code===wt.code){if(t.digest.length===He)return new lt({multihash:r.multihash});if(t.digest.length===Ke)return new ft({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}function et(r=0){return new Uint8Array(r)}function Xe(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Je=Xe("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yt=Xe("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=et(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),On={utf8:Je,"utf-8":Je,hex:_.base16,latin1:Yt,ascii:Yt,binary:Yt,..._},yt=On;function v(r,t="utf8"){let e=yt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Vn=Math.pow(2,7),Bn=Math.pow(2,14),_n=Math.pow(2,21),Zt=Math.pow(2,28),te=Math.pow(2,35),ee=Math.pow(2,42),re=Math.pow(2,49),d=128,w=127;function N(r){if(r<Vn)return 1;if(r<Bn)return 2;if(r<_n)return 3;if(r<Zt)return 4;if(r<te)return 5;if(r<ee)return 6;if(r<re)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function $n(r,t,e=0){switch(N(r)){case 8:t[e++]=r&255|d,r/=128;case 7:t[e++]=r&255|d,r/=128;case 6:t[e++]=r&255|d,r/=128;case 5:t[e++]=r&255|d,r/=128;case 4:t[e++]=r&255|d,r>>>=7;case 3:t[e++]=r&255|d,r>>>=7;case 2:t[e++]=r&255|d,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function jn(r,t,e=0){switch(N(r)){case 8:t.set(e++,r&255|d),r/=128;case 7:t.set(e++,r&255|d),r/=128;case 6:t.set(e++,r&255|d),r/=128;case 5:t.set(e++,r&255|d),r/=128;case 4:t.set(e++,r&255|d),r>>>=7;case 3:t.set(e++,r&255|d),r>>>=7;case 2:t.set(e++,r&255|d),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function qn(r,t){let e=r[t],n=0;if(n+=e&w,e<d||(e=r[t+1],n+=(e&w)<<7,e<d)||(e=r[t+2],n+=(e&w)<<14,e<d)||(e=r[t+3],n+=(e&w)<<21,e<d)||(e=r[t+4],n+=(e&w)*Zt,e<d)||(e=r[t+5],n+=(e&w)*te,e<d)||(e=r[t+6],n+=(e&w)*ee,e<d)||(e=r[t+7],n+=(e&w)*re,e<d))return n;throw new RangeError("Could not decode varint")}function Gn(r,t){let e=r.get(t),n=0;if(n+=e&w,e<d||(e=r.get(t+1),n+=(e&w)<<7,e<d)||(e=r.get(t+2),n+=(e&w)<<14,e<d)||(e=r.get(t+3),n+=(e&w)<<21,e<d)||(e=r.get(t+4),n+=(e&w)*Zt,e<d)||(e=r.get(t+5),n+=(e&w)*te,e<d)||(e=r.get(t+6),n+=(e&w)*ee,e<d)||(e=r.get(t+7),n+=(e&w)*re,e<d))return n;throw new RangeError("Could not decode varint")}function rt(r,t,e=0){return t==null&&(t=et(N(r))),t instanceof Uint8Array?$n(r,t,e):jn(r,t,e)}function H(r,t=0){return r instanceof Uint8Array?qn(r,t):Gn(r,t)}function k(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=et(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var vt=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}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(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,c=0,p=this.peekChar();if(p===void 0)return;let f=p==="0",b=2**(8*o)-1;for(;;){let x=this.readAtomically(()=>{let I=this.readChar();if(I===void 0)return;let z=Number.parseInt(I,t);if(!Number.isNaN(z))return z});if(x===void 0)break;if(s*=t,s+=x,s>b||(c+=1,e!==void 0&&c>e))return}if(c!==0)return!n&&f&&c>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let c=this.readSeparator(":",n,()=>this.readIPv4Addr());if(c!==void 0)return e[o]=c[0],e[o+1]=c[1],e[o+2]=c[2],e[o+3]=c[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),c=16-(n+2),[p]=t(s.subarray(0,c));return e.set(s.subarray(0,p),16-p),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ye=45,Wn=15,nt=new vt;function ne(r){if(!(r.length>Wn))return nt.new(r).parseWith(()=>nt.readIPv4Addr())}function oe(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ye))return nt.new(r).parseWith(()=>nt.readIPv6Addr())}function Et(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ye))return nt.new(r).parseWith(()=>nt.readIPAddr())}var wi=parseInt("0xFFFF",16),bi=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function se(r,t="utf8"){let e=yt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function er(r){return!!ne(r)}function rr(r){return!!oe(r)}function St(r){return!!Et(r)}var nr=er,Qn=rr,ie=function(r){let t=0;if(r=r.toString().trim(),nr(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Qn(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=nr(e[n]),c;s&&(c=ie(e[n]),e[n]=v(c.slice(0,2),"base16")),c!=null&&++n<8&&e.splice(n,0,v(c.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},or=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var ot={},ce={},Zn=[[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-direct"],[281,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"],[449,-1,"sni"],[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"],[481,-1,"http-path"],[777,-1,"memory"]];Zn.forEach(r=>{let t=to(...r);ce[t.code]=t,ot[t.name]=t});function to(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function l(r){if(typeof r=="number"){if(ce[r]!=null)return ce[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ot[r]!=null)return ot[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var oc=l("ip4"),sc=l("ip6"),ic=l("ipcidr");function de(r,t){switch(l(r).code){case 4:case 41:return ro(t);case 42:return ue(t);case 6:case 273:case 33:case 132:return cr(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ue(t);case 421:return io(t);case 444:return ir(t);case 445:return ir(t);case 466:return so(t);case 481:return globalThis.encodeURIComponent(ue(t));default:return v(t,"base16")}}function le(r,t){switch(l(r).code){case 4:return sr(t);case 41:return sr(t);case 42:return pe(t);case 6:case 273:case 33:case 132:return fe(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return pe(t);case 421:return no(t);case 444:return co(t);case 445:return ao(t);case 466:return oo(t);case 481:return pe(globalThis.decodeURIComponent(t));default:return se(t,"base16")}}var ae=Object.values(_).map(r=>r.decoder),eo=function(){let r=ae[0].or(ae[1]);return ae.slice(2).forEach(t=>r=r.or(t)),r}();function sr(r){if(!St(r))throw new Error("invalid ip address");return ie(r)}function ro(r){let t=or(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!St(t))throw new Error("invalid ip address");return t}function fe(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function cr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function pe(r){let t=se(r),e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function ue(r){let t=H(r);if(r=r.slice(N(t)),r.length!==t)throw new Error("inconsistent lengths");return v(r)}function no(r){let t;r[0]==="Q"||r[0]==="1"?t=G(g.decode(`z${r}`)).bytes:t=C.parse(r).multihash.bytes;let e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function oo(r){let t=eo.decode(r),e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function so(r){let t=H(r),e=r.slice(N(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+v(e,"base64url")}function io(r){let t=H(r),e=r.slice(N(t));if(e.length!==t)throw new Error("inconsistent lengths");return v(e,"base58btc")}function co(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=L.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=fe(n);return k([e,o],e.length+o.length)}function ao(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=L.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=fe(n);return k([e,o],e.length+o.length)}function ir(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=v(t,"base32"),o=cr(e);return`${n}:${o}`}function ar(r){r=he(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let c=o[s],p=l(c);if(p.size===0){t.push([p.code]),e.push([p.code]);continue}if(s++,s>=o.length)throw ur("invalid address: "+r);if(p.path===!0){n=he(o.slice(s).join("/")),t.push([p.code,le(p.code,n)]),e.push([p.code,n]);break}let f=le(p.code,o[s]);t.push([p.code,f]),e.push([p.code,de(p.code,f)])}return{string:pr(e),bytes:xe(t),tuples:t,stringTuples:e,path:n}}function me(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=H(r,o),c=N(s),p=l(s),f=po(p,r.slice(o+c));if(f===0){t.push([s]),e.push([s]),o+=c;continue}let b=r.slice(o+c,o+c+f);if(o+=f+c,o>r.length)throw ur("Invalid address Uint8Array: "+v(r,"base16"));t.push([s,b]);let x=de(s,b);if(e.push([s,x]),p.path===!0){n=x;break}}return{bytes:Uint8Array.from(r),string:pr(e),tuples:t,stringTuples:e,path:n}}function pr(r){let t=[];return r.map(e=>{let n=l(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),he(t.join("/"))}function xe(r){return k(r.map(t=>{let e=l(t[0]),n=Uint8Array.from(rt(e.code));return t.length>1&&t[1]!=null&&(n=k([n,t[1]])),n}))}function po(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=H(t instanceof Uint8Array?t:Uint8Array.from(t));return e+N(e)}}function he(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function ur(r){return new Error("Error parsing address: "+r)}var uo=Symbol.for("nodejs.util.inspect.custom"),ge=Symbol.for("@multiformats/js-multiaddr/multiaddr"),lo=[l("dns").code,l("dns4").code,l("dns6").code,l("dnsaddr").code],At=class r{bytes;#t;#e;#r;#n;[ge]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=me(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=ar(t)}else if(lr(t))e=me(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",c=l("tcp"),p=l("udp"),f=l("ip4"),b=l("ip6"),x=l("dns6"),I=l("ip6zone");for(let[S,u]of this.stringTuples())S===I.code&&(s=`%${u??""}`),lo.includes(S)&&(e=c.name,o=443,n=`${u??""}${s}`,t=S===x.code?6:4),(S===c.code||S===p.code)&&(e=l(S).name,o=parseInt(u??"")),(S===f.code||S===b.code)&&(e=l(S).name,n=`${u??""}${s}`,t=S===b.code?6:4);if(t==null||e==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:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},l(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>l(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(xe(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===ot.p2p.code&&t.push([n,o]),n===ot["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?v(g.decode(`z${n}`),"base58btc"):v(C.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return pt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=dr.get(e.name);if(n==null)throw new mt(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>$(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[uo](){return`Multiaddr(${this.#t})`}};var dr=new Map;function lr(r){return!!r?.[ge]}function $(r){return new At(r)}var fo=i("dns4"),ho=i("dns6"),mo=i("dnsaddr"),J=m(i("dns"),mo,fo,ho),Pt=m(i("ip4"),i("ip6")),st=m(a(Pt,i("tcp")),a(J,i("tcp"))),Ct=a(Pt,i("udp")),xo=a(Ct,i("utp")),go=a(Ct,i("quic")),wo=a(Ct,i("quic-v1")),we=m(a(st,i("ws")),a(J,i("ws"))),It=m(a(we,i("p2p")),we),be=m(a(st,i("wss")),a(J,i("wss")),a(st,i("tls"),i("ws")),a(J,i("tls"),i("ws"))),Tt=m(a(be,i("p2p")),be),ye=m(a(st,i("http")),a(Pt,i("http")),a(J,i("http"))),ve=m(a(st,i("https")),a(Pt,i("https")),a(J,i("https"))),fr=a(Ct,i("webrtc-direct"),i("certhash")),xr=m(a(fr,i("p2p")),fr),hr=a(wo,i("webtransport"),i("certhash"),i("certhash")),gr=m(a(hr,i("p2p")),hr),wr=m(a(It,i("p2p-webrtc-star"),i("p2p")),a(Tt,i("p2p-webrtc-star"),i("p2p")),a(It,i("p2p-webrtc-star")),a(Tt,i("p2p-webrtc-star"))),Nc=m(a(It,i("p2p-websocket-star"),i("p2p")),a(Tt,i("p2p-websocket-star"),i("p2p")),a(It,i("p2p-websocket-star")),a(Tt,i("p2p-websocket-star"))),br=m(a(ye,i("p2p-webrtc-direct"),i("p2p")),a(ve,i("p2p-webrtc-direct"),i("p2p")),a(ye,i("p2p-webrtc-direct")),a(ve,i("p2p-webrtc-direct"))),X=m(we,be,ye,ve,wr,br,st,xo,go,J,xr,gr),Fc=m(a(X,i("p2p-stardust"),i("p2p")),a(X,i("p2p-stardust"))),j=m(a(X,i("p2p")),wr,br,xr,gr,i("p2p")),mr=m(a(j,i("p2p-circuit"),j),a(j,i("p2p-circuit")),a(i("p2p-circuit"),j),a(X,i("p2p-circuit")),a(i("p2p-circuit"),X),i("p2p-circuit")),yr=()=>m(a(mr,yr),mr),K=yr(),vr=m(a(K,j,K),a(j,K),a(K,j),K,j);var Mc=m(a(K,i("webrtc"),i("p2p")),a(K,i("webrtc")),a(X,i("webrtc"),i("p2p")),a(X,i("webrtc")),i("webrtc"));function Er(r){function t(e){let n;try{n=$(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function a(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Er(t),partialMatch:t}}function m(...r){function t(n){let o=null;return r.some(s=>{let c=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return c!=null?(o=c,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Er(t),partialMatch:t}}function i(r){let t=r;function e(o){let s;try{s=$(o)}catch{return!1}let c=s.protoNames();return c.length===1&&c[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var bo="bootstrap",yo=50,vo=12e4,Eo=1e3,Ee=class extends xt{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??Eo,this.list=[];for(let n of e.list){if(!vr.matches(n)){this.log.error("Invalid multiaddr");continue}let o=$(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let c={id:Qt(s),multiaddrs:[o]};this.list.push(c)}this._init=e}[Se]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Te]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??bo]:{value:this._init.tagValue??yo,ttl:this._init.tagTTL??vo}}}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function So(r){return t=>new Ee(t,r)}return Pr(Ao);})();
|
|
2
|
+
"use strict";var Libp2PBootstrap=(()=>{var Ut=Object.defineProperty;var Tr=Object.getOwnPropertyDescriptor;var Pr=Object.getOwnPropertyNames;var Cr=Object.prototype.hasOwnProperty;var E=(r,t)=>{for(var e in t)Ut(r,e,{get:t[e],enumerable:!0})},Dr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Pr(t))!Cr.call(r,o)&&o!==e&&Ut(r,o,{get:()=>t[o],enumerable:!(n=Tr(t,o))||n.enumerable});return r};var Ur=r=>Dr(Ut({},"__esModule",{value:!0}),r);var To={};E(To,{bootstrap:()=>Io});var Te=Symbol.for("@libp2p/peer-discovery");var Rt=Symbol.for("@libp2p/peer-id");var xt=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Pe=(r,...t)=>{try{[...t]}catch{}};var wt=class extends EventTarget{#t=new Map;constructor(){super(),Pe(1/0,this)}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:i})=>i!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new Rr(t,e))}},Nt=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},Rr=globalThis.CustomEvent??Nt;var Ce=Symbol.for("@libp2p/service-capabilities"),Mo=Symbol.for("@libp2p/service-dependencies");var _t={};E(_t,{base58btc:()=>x,base58flickr:()=>_r});var oi=new Uint8Array(0);function De(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function M(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")}function Ue(r){return new TextEncoder().encode(r)}function Re(r){return new TextDecoder().decode(r)}function Nr(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),c=i.charCodeAt(0);if(e[c]!==255)throw new TypeError(i+" is ambiguous");e[c]=o}var p=r.length,f=r.charAt(0),y=Math.log(p)/Math.log(256),g=Math.log(256)/Math.log(p);function T(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";for(var v=0,q=0,P=0,D=u.length;P!==D&&u[P]===0;)P++,v++;for(var U=(D-P)*g+1>>>0,A=new Uint8Array(U);P!==D;){for(var R=u[P],z=0,C=U-1;(R!==0||z<q)&&C!==-1;C--,z++)R+=256*A[C]>>>0,A[C]=R%p>>>0,R=R/p>>>0;if(R!==0)throw new Error("Non-zero carry");q=z,P++}for(var F=U-q;F!==U&&A[F]===0;)F++;for(var gt=f.repeat(v);F<U;++F)gt+=r.charAt(A[F]);return gt}function _(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var v=0;if(u[v]!==" "){for(var q=0,P=0;u[v]===f;)q++,v++;for(var D=(u.length-v)*y+1>>>0,U=new Uint8Array(D);u[v];){var A=e[u.charCodeAt(v)];if(A===255)return;for(var R=0,z=D-1;(A!==0||R<P)&&z!==-1;z--,R++)A+=p*U[z]>>>0,U[z]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");P=R,v++}if(u[v]!==" "){for(var C=D-P;C!==D&&U[C]===0;)C++;for(var F=new Uint8Array(q+(D-C)),gt=q;C!==D;)F[gt++]=U[C++];return F}}}function S(u){var v=_(u);if(v)return v;throw new Error(`Non-${t} character`)}return{encode:T,decodeUnsafe:_,decode:S}}var Fr=Nr,Mr=Fr,Fe=Mr;var Ft=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Mt=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Me(this,t)}},Lt=class{decoders;constructor(t){this.decoders=t}or(t){return Me(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Me(r,t){return new Lt({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var kt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ft(t,e,n),this.decoder=new Mt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Q({name:r,prefix:t,encode:e,decode:n}){return new kt(r,t,e,n)}function O({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Fe(e,r);return Q({prefix:t,name:r,encode:n,decode:i=>M(o(i))})}function Lr(r,t,e,n){let o={};for(let g=0;g<t.length;++g)o[t[g]]=g;let i=r.length;for(;r[i-1]==="=";)--i;let c=new Uint8Array(i*e/8|0),p=0,f=0,y=0;for(let g=0;g<i;++g){let T=o[r[g]];if(T===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<e|T,p+=e,p>=8&&(p-=8,c[y++]=255&f>>p)}if(p>=e||255&f<<8-p)throw new SyntaxError("Unexpected end of data");return c}function kr(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",c=0,p=0;for(let f=0;f<r.length;++f)for(p=p<<8|r[f],c+=8;c>e;)c-=e,i+=t[o&p>>c];if(c!==0&&(i+=t[o&p<<e-c]),n)for(;i.length*e&7;)i+="=";return i}function h({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Q({prefix:t,name:r,encode(o){return kr(o,n,e)},decode(o){return Lr(o,n,e,r)}})}var x=O({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_r=O({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var zt={};E(zt,{base10:()=>zr});var zr=O({prefix:"9",name:"base10",alphabet:"0123456789"});var Ot={};E(Ot,{base16:()=>Or,base16upper:()=>Vr});var Or=h({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Vr=h({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Vt={};E(Vt,{base2:()=>Br});var Br=h({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Bt={};E(Bt,{base256emoji:()=>Wr});var Le=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}"),$r=Le.reduce((r,t,e)=>(r[e]=t,r),[]),jr=Le.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function qr(r){return r.reduce((t,e)=>(t+=$r[e],t),"")}function Gr(r){let t=[];for(let e of r){let n=jr[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Wr=Q({prefix:"\u{1F680}",name:"base256emoji",encode:qr,decode:Gr});var $t={};E($t,{base32:()=>L,base32hex:()=>Xr,base32hexpad:()=>Yr,base32hexpadupper:()=>Zr,base32hexupper:()=>Qr,base32pad:()=>Hr,base32padupper:()=>Jr,base32upper:()=>Kr,base32z:()=>tn});var L=h({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Kr=h({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Hr=h({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Jr=h({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xr=h({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qr=h({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yr=h({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zr=h({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),tn=h({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var jt={};E(jt,{base36:()=>en,base36upper:()=>rn});var en=O({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rn=O({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var qt={};E(qt,{base64:()=>nn,base64pad:()=>on,base64url:()=>sn,base64urlpad:()=>cn});var nn=h({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),on=h({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),sn=h({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cn=h({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Gt={};E(Gt,{base8:()=>an});var an=h({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wt={};E(Wt,{identity:()=>pn});var pn=Q({prefix:"\0",name:"identity",encode:r=>Re(r),decode:r=>Ue(r)});var yi=new TextEncoder,vi=new TextDecoder;var Ht={};E(Ht,{identity:()=>at});var ln=ze,ke=128,fn=127,hn=~fn,mn=Math.pow(2,31);function ze(r,t,e){t=t||[],e=e||0;for(var n=e;r>=mn;)t[e++]=r&255|ke,r/=128;for(;r&hn;)t[e++]=r&255|ke,r>>>=7;return t[e]=r|0,ze.bytes=e-n+1,t}var gn=Kt,xn=128,_e=127;function Kt(r,n){var e=0,n=n||0,o=0,i=n,c,p=r.length;do{if(i>=p)throw Kt.bytes=0,new RangeError("Could not decode varint");c=r[i++],e+=o<28?(c&_e)<<o:(c&_e)*Math.pow(2,o),o+=7}while(c>=xn);return Kt.bytes=i-n,e}var wn=Math.pow(2,7),bn=Math.pow(2,14),yn=Math.pow(2,21),vn=Math.pow(2,28),En=Math.pow(2,35),Sn=Math.pow(2,42),An=Math.pow(2,49),In=Math.pow(2,56),Tn=Math.pow(2,63),Pn=function(r){return r<wn?1:r<bn?2:r<yn?3:r<vn?4:r<En?5:r<Sn?6:r<An?7:r<In?8:r<Tn?9:10},Cn={encode:ln,decode:gn,encodingLength:Pn},Dn=Cn,st=Dn;function ct(r,t=0){return[st.decode(r,t),st.decode.bytes]}function Y(r,t,e=0){return st.encode(r,t,e),t}function Z(r){return st.encodingLength(r)}function V(r,t){let e=t.byteLength,n=Z(r),o=n+Z(e),i=new Uint8Array(o+e);return Y(r,i,0),Y(e,i,n),i.set(t,o),new tt(r,e,t,i)}function G(r){let t=M(r),[e,n]=ct(t),[o,i]=ct(t.subarray(n)),c=t.subarray(n+i);if(c.byteLength!==o)throw new Error("Incorrect length");return new tt(e,o,c,t)}function Oe(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&De(r.bytes,e.bytes)}}var tt=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Ve=0,Un="identity",Be=M;function Rn(r){return V(Ve,Be(r))}var at={code:Ve,name:Un,encode:Be,digest:Rn};var Qt={};E(Qt,{sha256:()=>yt,sha512:()=>Nn});function Xt({name:r,code:t,encode:e}){return new Jt(r,t,e)}var Jt=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?V(this.code,e):e.then(n=>V(this.code,n))}else throw Error("Unknown type, must be binary type")}};function je(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var yt=Xt({name:"sha2-256",code:18,encode:je("SHA-256")}),Nn=Xt({name:"sha2-512",code:19,encode:je("SHA-512")});function qe(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Mn(e,Yt(r),t??x.encoder);default:return Ln(e,Yt(r),t??L.encoder)}}var Ge=new WeakMap;function Yt(r){let t=Ge.get(r);if(t==null){let e=new Map;return Ge.set(r,e),e}return t}var I=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,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:t,multihash:e}=this;if(t!==pt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==kn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:t,digest:e}=this.multihash,n=V(t,e);return r.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(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Oe(t.multihash,n.multihash)}toString(t){return qe(this,t)}toJSON(){return{"/":qe(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:c}=e;return new r(n,o,i,c??We(n,o,i.bytes))}else if(e[_n]===!0){let{version:n,multihash:o,code:i}=e,c=G(o);return r.create(n,i,c)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==pt)throw new Error(`Version 0 CID must use dag-pb (code: ${pt}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=We(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,pt,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=M(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),c=new tt(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(c):r.createV1(e.codec,c),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[T,_]=ct(t.subarray(e));return e+=_,T},o=n(),i=pt;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let c=e,p=n(),f=n(),y=e+f,g=y-c;return{version:o,codec:i,multihashCode:p,digestSize:f,multihashSize:g,size:y}}static parse(t,e){let[n,o]=Fn(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Yt(i).set(n,t),i}};function Fn(r,t){switch(r[0]){case"Q":{let e=t??x;return[x.prefix,e.decode(`${x.prefix}${r}`)]}case x.prefix:{let e=t??x;return[x.prefix,e.decode(r)]}case L.prefix:{let e=t??L;return[L.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Mn(r,t,e){let{prefix:n}=e;if(n!==x.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function Ln(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o}var pt=112,kn=18;function We(r,t,e){let n=Z(r),o=n+Z(t),i=new Uint8Array(o+e.byteLength);return Y(r,i,0),Y(t,i,n),i.set(e,o),i}var _n=Symbol.for("@ipld/js-cid/CID");var B={...Wt,...Vt,...Gt,...zt,...Ot,...$t,...jt,..._t,...qt,...Bt},$i={...Qt,...Ht};function ut(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function et(r=0){return new Uint8Array(r)}function He(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Ke=He("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Zt=He("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=et(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),zn={utf8:Ke,"utf-8":Ke,hex:B.base16,latin1:Zt,ascii:Zt,binary:Zt,...B},vt=zn;function dt(r,t="utf8"){let e=vt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function w(r,t="utf8"){let e=vt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Xe=Symbol.for("nodejs.util.inspect.custom"),Je=Object.values(B).map(r=>r.decoder).reduce((r,t)=>r.or(t),B.identity.decoder),Qe=114,Ye=36,Ze=37,lt=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Rt]=!0;toString(){return this.string==null&&(this.string=x.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return I.createV1(Qe,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ut(this.multihash.bytes,t);if(typeof t=="string")return re(t).equals(this);if(t?.multihash?.bytes!=null)return ut(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Xe](){return`PeerId(${this.toString()})`}},ft=class extends lt{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},ht=class extends lt{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},mt=class extends lt{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}},te=2336,ee=class{type="url";multihash;privateKey;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=at.digest(dt(this.url))}[Xe](){return`PeerId(${this.url})`}[Rt]=!0;toString(){return this.toCID().toString()}toCID(){return I.createV1(te,this.multihash)}toBytes(){return this.toCID().bytes}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=w(t)),t.toString()===this.toString())}};function re(r,t){if(t=t??Je,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=G(x.decode(`z${r}`));return r.startsWith("12D")?new ht({multihash:e}):r.startsWith("16U")?new mt({multihash:e}):new ft({multihash:e})}return On(Je.decode(r))}function On(r){try{let t=G(r);if(t.code===at.code){if(t.digest.length===Ye)return new ht({multihash:t});if(t.digest.length===Ze)return new mt({multihash:t})}if(t.code===yt.code)return new ft({multihash:t})}catch{return Vn(I.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Vn(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Qe&&r.code!==te)throw new Error("Supplied PeerID CID is invalid");if(r.code===te){let e=w(r.multihash.digest);return new ee(new URL(e))}let t=r.multihash;if(t.code===yt.code)return new ft({multihash:r.multihash});if(t.code===at.code){if(t.digest.length===Ye)return new ht({multihash:r.multihash});if(t.digest.length===Ze)return new mt({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var Bn=Math.pow(2,7),$n=Math.pow(2,14),jn=Math.pow(2,21),ne=Math.pow(2,28),oe=Math.pow(2,35),ie=Math.pow(2,42),se=Math.pow(2,49),d=128,b=127;function N(r){if(r<Bn)return 1;if(r<$n)return 2;if(r<jn)return 3;if(r<ne)return 4;if(r<oe)return 5;if(r<ie)return 6;if(r<se)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function qn(r,t,e=0){switch(N(r)){case 8:t[e++]=r&255|d,r/=128;case 7:t[e++]=r&255|d,r/=128;case 6:t[e++]=r&255|d,r/=128;case 5:t[e++]=r&255|d,r/=128;case 4:t[e++]=r&255|d,r>>>=7;case 3:t[e++]=r&255|d,r>>>=7;case 2:t[e++]=r&255|d,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Gn(r,t,e=0){switch(N(r)){case 8:t.set(e++,r&255|d),r/=128;case 7:t.set(e++,r&255|d),r/=128;case 6:t.set(e++,r&255|d),r/=128;case 5:t.set(e++,r&255|d),r/=128;case 4:t.set(e++,r&255|d),r>>>=7;case 3:t.set(e++,r&255|d),r>>>=7;case 2:t.set(e++,r&255|d),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Wn(r,t){let e=r[t],n=0;if(n+=e&b,e<d||(e=r[t+1],n+=(e&b)<<7,e<d)||(e=r[t+2],n+=(e&b)<<14,e<d)||(e=r[t+3],n+=(e&b)<<21,e<d)||(e=r[t+4],n+=(e&b)*ne,e<d)||(e=r[t+5],n+=(e&b)*oe,e<d)||(e=r[t+6],n+=(e&b)*ie,e<d)||(e=r[t+7],n+=(e&b)*se,e<d))return n;throw new RangeError("Could not decode varint")}function Kn(r,t){let e=r.get(t),n=0;if(n+=e&b,e<d||(e=r.get(t+1),n+=(e&b)<<7,e<d)||(e=r.get(t+2),n+=(e&b)<<14,e<d)||(e=r.get(t+3),n+=(e&b)<<21,e<d)||(e=r.get(t+4),n+=(e&b)*ne,e<d)||(e=r.get(t+5),n+=(e&b)*oe,e<d)||(e=r.get(t+6),n+=(e&b)*ie,e<d)||(e=r.get(t+7),n+=(e&b)*se,e<d))return n;throw new RangeError("Could not decode varint")}function rt(r,t,e=0){return t==null&&(t=et(N(r))),t instanceof Uint8Array?qn(r,t,e):Gn(r,t,e)}function K(r,t=0){return r instanceof Uint8Array?Wn(r,t):Kn(r,t)}function k(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=et(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Et=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}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(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let i=0,c=0,p=this.peekChar();if(p===void 0)return;let f=p==="0",y=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let T=this.readChar();if(T===void 0)return;let _=Number.parseInt(T,t);if(!Number.isNaN(_))return _});if(g===void 0)break;if(i*=t,i+=g,i>y||(c+=1,e!==void 0&&c>e))return}if(c!==0)return!n&&f&&c>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let c=this.readSeparator(":",n,()=>this.readIPv4Addr());if(c!==void 0)return e[o]=c[0],e[o+1]=c[1],e[o+2]=c[2],e[o+3]=c[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];e[o]=i>>8,e[o+1]=i&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),c=16-(n+2),[p]=t(i.subarray(0,c));return e.set(i.subarray(0,p),16-p),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var er=45,Hn=15,nt=new Et;function ce(r){if(!(r.length>Hn))return nt.new(r).parseWith(()=>nt.readIPv4Addr())}function ae(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>er))return nt.new(r).parseWith(()=>nt.readIPv6Addr())}function St(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>er))return nt.new(r).parseWith(()=>nt.readIPAddr())}var As=parseInt("0xFFFF",16),Is=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function or(r){return!!ce(r)}function ir(r){return!!ae(r)}function At(r){return!!St(r)}var sr=or,Zn=ir,pe=function(r){let t=0;if(r=r.toString().trim(),sr(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Zn(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=sr(e[n]),c;i&&(c=pe(e[n]),e[n]=w(c.slice(0,2),"base16")),c!=null&&++n<8&&e.splice(n,0,w(c.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},cr=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var ot={},ue={},eo=[[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-direct"],[281,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"],[449,-1,"sni"],[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"],[481,-1,"http-path"],[777,-1,"memory"]];eo.forEach(r=>{let t=ro(...r);ue[t.code]=t,ot[t.name]=t});function ro(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function l(r){if(typeof r=="number"){if(ue[r]!=null)return ue[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ot[r]!=null)return ot[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var ac=l("ip4"),pc=l("ip6"),uc=l("ipcidr");function he(r,t){switch(l(r).code){case 4:case 41:return oo(t);case 42:return fe(t);case 6:case 273:case 33:case 132:return ur(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return fe(t);case 421:return ao(t);case 444:return pr(t);case 445:return pr(t);case 466:return co(t);case 481:return globalThis.encodeURIComponent(fe(t));default:return w(t,"base16")}}function me(r,t){switch(l(r).code){case 4:return ar(t);case 41:return ar(t);case 42:return le(t);case 6:case 273:case 33:case 132:return ge(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return le(t);case 421:return io(t);case 444:return po(t);case 445:return uo(t);case 466:return so(t);case 481:return le(globalThis.decodeURIComponent(t));default:return dt(t,"base16")}}var de=Object.values(B).map(r=>r.decoder),no=function(){let r=de[0].or(de[1]);return de.slice(2).forEach(t=>r=r.or(t)),r}();function ar(r){if(!At(r))throw new Error("invalid ip address");return pe(r)}function oo(r){let t=cr(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!At(t))throw new Error("invalid ip address");return t}function ge(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function ur(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function le(r){let t=dt(r),e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function fe(r){let t=K(r);if(r=r.slice(N(t)),r.length!==t)throw new Error("inconsistent lengths");return w(r)}function io(r){let t;r[0]==="Q"||r[0]==="1"?t=G(x.decode(`z${r}`)).bytes:t=I.parse(r).multihash.bytes;let e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function so(r){let t=no.decode(r),e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function co(r){let t=K(r),e=r.slice(N(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+w(e,"base64url")}function ao(r){let t=K(r),e=r.slice(N(t));if(e.length!==t)throw new Error("inconsistent lengths");return w(e,"base58btc")}function po(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=L.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ge(n);return k([e,o],e.length+o.length)}function uo(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=L.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ge(n);return k([e,o],e.length+o.length)}function pr(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=w(t,"base32"),o=ur(e);return`${n}:${o}`}function dr(r){r=xe(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let c=o[i],p=l(c);if(p.size===0){t.push([p.code]),e.push([p.code]);continue}if(i++,i>=o.length)throw fr("invalid address: "+r);if(p.path===!0){n=xe(o.slice(i).join("/")),t.push([p.code,me(p.code,n)]),e.push([p.code,n]);break}let f=me(p.code,o[i]);t.push([p.code,f]),e.push([p.code,he(p.code,f)])}return{string:lr(e),bytes:be(t),tuples:t,stringTuples:e,path:n}}function we(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=K(r,o),c=N(i),p=l(i),f=lo(p,r.slice(o+c));if(f===0){t.push([i]),e.push([i]),o+=c;continue}let y=r.slice(o+c,o+c+f);if(o+=f+c,o>r.length)throw fr("Invalid address Uint8Array: "+w(r,"base16"));t.push([i,y]);let g=he(i,y);if(e.push([i,g]),p.path===!0){n=g;break}}return{bytes:Uint8Array.from(r),string:lr(e),tuples:t,stringTuples:e,path:n}}function lr(r){let t=[];return r.map(e=>{let n=l(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),xe(t.join("/"))}function be(r){return k(r.map(t=>{let e=l(t[0]),n=Uint8Array.from(rt(e.code));return t.length>1&&t[1]!=null&&(n=k([n,t[1]])),n}))}function lo(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=K(t instanceof Uint8Array?t:Uint8Array.from(t));return e+N(e)}}function xe(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function fr(r){return new Error("Error parsing address: "+r)}var fo=Symbol.for("nodejs.util.inspect.custom"),ye=Symbol.for("@multiformats/js-multiaddr/multiaddr"),ho=[l("dns").code,l("dns4").code,l("dns6").code,l("dnsaddr").code],It=class r{bytes;#t;#e;#r;#n;[ye]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=we(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=dr(t)}else if(mr(t))e=we(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",c=l("tcp"),p=l("udp"),f=l("ip4"),y=l("ip6"),g=l("dns6"),T=l("ip6zone");for(let[S,u]of this.stringTuples())S===T.code&&(i=`%${u??""}`),ho.includes(S)&&(e=c.name,o=443,n=`${u??""}${i}`,t=S===g.code?6:4),(S===c.code||S===p.code)&&(e=l(S).name,o=parseInt(u??"")),(S===f.code||S===y.code)&&(e=l(S).name,n=`${u??""}${i}`,t=S===y.code?6:4);if(t==null||e==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:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},l(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>l(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(be(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===ot.p2p.code&&t.push([n,o]),n===ot["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?w(x.decode(`z${n}`),"base58btc"):w(I.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return ut(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=hr.get(e.name);if(n==null)throw new xt(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(i=>$(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[fo](){return`Multiaddr(${this.#t})`}};var hr=new Map;function mr(r){return!!r?.[ye]}function $(r){return new It(r)}var mo=s("dns4"),go=s("dns6"),xo=s("dnsaddr"),J=m(s("dns"),xo,mo,go),Ct=m(s("ip4"),s("ip6")),it=m(a(Ct,s("tcp")),a(J,s("tcp"))),Dt=a(Ct,s("udp")),wo=a(Dt,s("utp")),bo=a(Dt,s("quic")),yo=a(Dt,s("quic-v1")),ve=m(a(it,s("ws")),a(J,s("ws"))),Tt=m(a(ve,s("p2p")),ve),Ee=m(a(it,s("wss")),a(J,s("wss")),a(it,s("tls"),s("ws")),a(J,s("tls"),s("ws"))),Pt=m(a(Ee,s("p2p")),Ee),Se=m(a(it,s("http")),a(Ct,s("http")),a(J,s("http"))),Ae=m(a(it,s("https")),a(Ct,s("https")),a(J,s("https"))),gr=a(Dt,s("webrtc-direct"),s("certhash")),br=m(a(gr,s("p2p")),gr),xr=a(yo,s("webtransport"),s("certhash"),s("certhash")),yr=m(a(xr,s("p2p")),xr),vr=m(a(Tt,s("p2p-webrtc-star"),s("p2p")),a(Pt,s("p2p-webrtc-star"),s("p2p")),a(Tt,s("p2p-webrtc-star")),a(Pt,s("p2p-webrtc-star"))),kc=m(a(Tt,s("p2p-websocket-star"),s("p2p")),a(Pt,s("p2p-websocket-star"),s("p2p")),a(Tt,s("p2p-websocket-star")),a(Pt,s("p2p-websocket-star"))),Er=m(a(Se,s("p2p-webrtc-direct"),s("p2p")),a(Ae,s("p2p-webrtc-direct"),s("p2p")),a(Se,s("p2p-webrtc-direct")),a(Ae,s("p2p-webrtc-direct"))),X=m(ve,Ee,Se,Ae,vr,Er,it,wo,bo,J,br,yr),_c=m(a(X,s("p2p-stardust"),s("p2p")),a(X,s("p2p-stardust"))),j=m(a(X,s("p2p")),vr,Er,br,yr,s("p2p")),wr=m(a(j,s("p2p-circuit"),j),a(j,s("p2p-circuit")),a(s("p2p-circuit"),j),a(X,s("p2p-circuit")),a(s("p2p-circuit"),X),s("p2p-circuit")),Sr=()=>m(a(wr,Sr),wr),H=Sr(),Ar=m(a(H,j,H),a(j,H),a(H,j),H,j);var zc=m(a(H,s("webrtc"),s("p2p")),a(H,s("webrtc")),a(X,s("webrtc"),s("p2p")),a(X,s("webrtc")),s("webrtc"));function Ir(r){function t(e){let n;try{n=$(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function a(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Ir(t),partialMatch:t}}function m(...r){function t(n){let o=null;return r.some(i=>{let c=typeof i=="function"?i().partialMatch(n):i.partialMatch(n);return c!=null?(o=c,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Ir(t),partialMatch:t}}function s(r){let t=r;function e(o){let i;try{i=$(o)}catch{return!1}let c=i.protoNames();return c.length===1&&c[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var vo="bootstrap",Eo=50,So=12e4,Ao=1e3,Ie=class extends wt{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??Ao,this.list=[];for(let n of e.list){if(!Ar.matches(n)){this.log.error("Invalid multiaddr");continue}let o=$(n),i=o.getPeerId();if(i==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let c={id:re(i),multiaddrs:[o]};this.list.push(c)}this._init=e}[Te]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Ce]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??vo]:{value:this._init.tagValue??Eo,ttl:this._init.tagTTL??So}}}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function Io(r){return t=>new Ie(t,r)}return Ur(To);})();
|
|
3
3
|
return Libp2PBootstrap}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/bootstrap",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.1-ce6da9896",
|
|
4
4
|
"description": "Peer discovery via a list of bootstrap peers",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap#readme",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
"test:electron-main": "aegir test -t electron-main"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@libp2p/interface": "
|
|
58
|
-
"@libp2p/peer-id": "
|
|
57
|
+
"@libp2p/interface": "1.6.0-ce6da9896",
|
|
58
|
+
"@libp2p/peer-id": "4.2.0-ce6da9896",
|
|
59
59
|
"@multiformats/mafmt": "^12.1.6",
|
|
60
60
|
"@multiformats/multiaddr": "^12.2.3"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@libp2p/interface-compliance-tests": "
|
|
64
|
-
"@libp2p/logger": "
|
|
63
|
+
"@libp2p/interface-compliance-tests": "5.4.8-ce6da9896",
|
|
64
|
+
"@libp2p/logger": "4.0.16-ce6da9896",
|
|
65
65
|
"aegir": "^43.0.1",
|
|
66
66
|
"sinon-ts": "^2.0.0"
|
|
67
67
|
},
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"BootstrapComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapComponents.html",
|
|
3
|
-
".:BootstrapComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapComponents.html",
|
|
4
|
-
"BootstrapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapInit.html",
|
|
5
|
-
".:BootstrapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapInit.html",
|
|
6
|
-
"bootstrap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_bootstrap.bootstrap.html",
|
|
7
|
-
".:bootstrap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_bootstrap.bootstrap.html"
|
|
8
|
-
}
|