@libp2p/bootstrap 10.0.8 → 10.0.9
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/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 Ut=Object.defineProperty;var Pr=Object.getOwnPropertyDescriptor;var Cr=Object.getOwnPropertyNames;var Ur=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var r in t)Ut(e,r,{get:t[r],enumerable:!0})},Dr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Cr(t))!Ur.call(e,o)&&o!==r&&Ut(e,o,{get:()=>t[o],enumerable:!(n=Pr(t,o))||n.enumerable});return e};var Lr=e=>Dr(Ut({},"__esModule",{value:!0}),e);var Co={};v(Co,{bootstrap:()=>Po});var Do=Symbol.for("@libp2p/connection");var No=Symbol.for("@libp2p/content-routing");var ve=Symbol.for("@libp2p/peer-discovery");var Ee=Symbol.for("@libp2p/peer-id");var Bo=Symbol.for("@libp2p/peer-routing");var Ae;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(Ae||(Ae={}));var zo=Symbol.for("@libp2p/transport");var Ie;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(Ie||(Ie={}));var it=class extends Error{code;props;constructor(t,r,n){super(t),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var mt=class extends EventTarget{#t=new Map;listenerCount(t){let r=this.#t.get(t);return r==null?0:r.length}addEventListener(t,r,n){super.addEventListener(t,r,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,r,n){super.removeEventListener(t.toString(),r??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==r),this.#t.set(t,o))}dispatchEvent(t){let r=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),r}safeDispatchEvent(t,r){return this.dispatchEvent(new Nr(t,r))}},Dt=class extends Event{detail;constructor(t,r){super(t,r),this.detail=r?.detail}},Nr=globalThis.CustomEvent??Dt;var Mt={};v(Mt,{base58btc:()=>w,base58flickr:()=>Or});function Rr(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var p=e.length,d=e.charAt(0),b=Math.log(p)/Math.log(256),g=Math.log(256)/Math.log(p);function I(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var y=0,j=0,T=0,U=l.length;T!==U&&l[T]===0;)T++,y++;for(var D=(U-T)*g+1>>>0,A=new Uint8Array(D);T!==U;){for(var L=l[T],O=0,P=D-1;(L!==0||O<j)&&P!==-1;P--,O++)L+=256*A[P]>>>0,A[P]=L%p>>>0,L=L/p>>>0;if(L!==0)throw new Error("Non-zero carry");j=O,T++}for(var R=D-j;R!==D&&A[R]===0;)R++;for(var ht=d.repeat(y);R<D;++R)ht+=e.charAt(A[R]);return ht}function B(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var y=0;if(l[y]!==" "){for(var j=0,T=0;l[y]===d;)j++,y++;for(var U=(l.length-y)*b+1>>>0,D=new Uint8Array(U);l[y];){var A=r[l.charCodeAt(y)];if(A===255)return;for(var L=0,O=U-1;(A!==0||L<T)&&O!==-1;O--,L++)A+=p*D[O]>>>0,D[O]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");T=L,y++}if(l[y]!==" "){for(var P=U-T;P!==U&&D[P]===0;)P++;for(var R=new Uint8Array(j+(U-P)),ht=j;P!==U;)R[ht++]=D[P++];return R}}}function E(l){var y=B(l);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:I,decodeUnsafe:B,decode:E}}var Fr=Rr,Mr=Fr,Te=Mr;var ys=new Uint8Array(0);var Pe=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},F=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var Ce=e=>new TextEncoder().encode(e),Ue=e=>new TextDecoder().decode(e);var Lt=class{constructor(t,r,n){this.name=t,this.prefix=r,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{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 Le(this,t)}},Rt=class{constructor(t){this.decoders=t}or(t){return Le(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Le=(e,t)=>new Rt({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),Ft=class{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Lt(t,r,n),this.decoder=new Nt(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},X=({name:e,prefix:t,encode:r,decode:n})=>new Ft(e,t,r,n),_=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:o}=Te(r,t);return X({prefix:e,name:t,encode:n,decode:s=>F(o(s))})},kr=(e,t,r,n)=>{let o={};for(let g=0;g<t.length;++g)o[t[g]]=g;let s=e.length;for(;e[s-1]==="=";)--s;let a=new Uint8Array(s*r/8|0),p=0,d=0,b=0;for(let g=0;g<s;++g){let I=o[e[g]];if(I===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|I,p+=r,p>=8&&(p-=8,a[b++]=255&d>>p)}if(p>=r||255&d<<8-p)throw new SyntaxError("Unexpected end of data");return a},Br=(e,t,r)=>{let n=t[t.length-1]==="=",o=(1<<r)-1,s="",a=0,p=0;for(let d=0;d<e.length;++d)for(p=p<<8|e[d],a+=8;a>r;)a-=r,s+=t[o&p>>a];if(a&&(s+=t[o&p<<r-a]),n)for(;s.length*r&7;)s+="=";return s},h=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>X({prefix:t,name:e,encode(o){return Br(o,n,r)},decode(o){return kr(o,n,r,e)}});var w=_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Or=_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kt={};v(kt,{base10:()=>_r});var _r=_({prefix:"9",name:"base10",alphabet:"0123456789"});var Bt={};v(Bt,{base16:()=>Vr,base16upper:()=>zr});var Vr=h({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zr=h({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ot={};v(Ot,{base2:()=>$r});var $r=h({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _t={};v(_t,{base256emoji:()=>Kr});var Ne=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}"),jr=Ne.reduce((e,t,r)=>(e[r]=t,e),[]),qr=Ne.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function Gr(e){return e.reduce((t,r)=>(t+=jr[r],t),"")}function Wr(e){let t=[];for(let r of e){let n=qr[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n)}return new Uint8Array(t)}var Kr=X({prefix:"\u{1F680}",name:"base256emoji",encode:Gr,decode:Wr});var Vt={};v(Vt,{base32:()=>M,base32hex:()=>Qr,base32hexpad:()=>Zr,base32hexpadupper:()=>tn,base32hexupper:()=>Yr,base32pad:()=>Jr,base32padupper:()=>Xr,base32upper:()=>Hr,base32z:()=>en});var M=h({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Hr=h({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Jr=h({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Xr=h({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qr=h({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Yr=h({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Zr=h({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),tn=h({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),en=h({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var zt={};v(zt,{base36:()=>rn,base36upper:()=>nn});var rn=_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),nn=_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $t={};v($t,{base64:()=>on,base64pad:()=>sn,base64url:()=>an,base64urlpad:()=>cn});var on=h({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sn=h({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),an=h({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cn=h({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var jt={};v(jt,{base8:()=>pn});var pn=h({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qt={};v(qt,{identity:()=>ln});var ln=X({prefix:"\0",name:"identity",encode:e=>Ue(e),decode:e=>Ce(e)});var Ms=new TextEncoder,ks=new TextDecoder;var Wt={};v(Wt,{identity:()=>wt});var dn=Me,Re=128,hn=127,mn=~hn,gn=Math.pow(2,31);function Me(e,t,r){t=t||[],r=r||0;for(var n=r;e>=gn;)t[r++]=e&255|Re,e/=128;for(;e&mn;)t[r++]=e&255|Re,e>>>=7;return t[r]=e|0,Me.bytes=r-n+1,t}var wn=Gt,xn=128,Fe=127;function Gt(e,n){var r=0,n=n||0,o=0,s=n,a,p=e.length;do{if(s>=p)throw Gt.bytes=0,new RangeError("Could not decode varint");a=e[s++],r+=o<28?(a&Fe)<<o:(a&Fe)*Math.pow(2,o),o+=7}while(a>=xn);return Gt.bytes=s-n,r}var bn=Math.pow(2,7),yn=Math.pow(2,14),Sn=Math.pow(2,21),vn=Math.pow(2,28),En=Math.pow(2,35),An=Math.pow(2,42),In=Math.pow(2,49),Tn=Math.pow(2,56),Pn=Math.pow(2,63),Cn=function(e){return e<bn?1:e<yn?2:e<Sn?3:e<vn?4:e<En?5:e<An?6:e<In?7:e<Tn?8:e<Pn?9:10},Un={encode:dn,decode:wn,encodingLength:Cn},Dn=Un,at=Dn;var ct=(e,t=0)=>[at.decode(e,t),at.decode.bytes],Q=(e,t,r=0)=>(at.encode(e,t,r),t),Y=e=>at.encodingLength(e);var V=(e,t)=>{let r=t.byteLength,n=Y(e),o=n+Y(r),s=new Uint8Array(o+r);return Q(e,s,0),Q(r,s,n),s.set(t,o),new Z(e,r,t,s)},q=e=>{let t=F(e),[r,n]=ct(t),[o,s]=ct(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new Z(r,o,a,t)},ke=(e,t)=>{if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Pe(e.bytes,r.bytes)}},Z=class{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var Be=0,Ln="identity",Oe=F,Nn=e=>V(Be,Oe(e)),wt={code:Be,name:Ln,encode:Oe,digest:Nn};var Jt={};v(Jt,{sha256:()=>xt,sha512:()=>Rn});var Ht=({name:e,code:t,encode:r})=>new Kt(e,t,r),Kt=class{constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?V(this.code,r):r.then(n=>V(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Ve=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),xt=Ht({name:"sha2-256",code:18,encode:Ve("SHA-256")}),Rn=Ht({name:"sha2-512",code:19,encode:Ve("SHA-512")});var ze=(e,t)=>{let{bytes:r,version:n}=e;switch(n){case 0:return Mn(r,Xt(e),t||w.encoder);default:return kn(r,Xt(e),t||M.encoder)}};var $e=new WeakMap,Xt=e=>{let t=$e.get(e);if(t==null){let r=new Map;return $e.set(e,r),r}return t},C=class e{constructor(t,r,n,o){this.code=r,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:r}=this;if(t!==pt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Bn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=V(t,r);return e.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 e.equals(this,t)}static equals(t,r){let n=r;return n&&t.code===n.code&&t.version===n.version&&ke(t.multihash,n.multihash)}toString(t){return ze(this,t)}toJSON(){return{"/":ze(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new e(n,o,s,a||je(n,o,s.bytes))}else if(r[On]===!0){let{version:n,multihash:o,code:s}=r,a=q(o);return e.create(n,s,a)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==pt)throw new Error(`Version 0 CID must use dag-pb (code: ${pt}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=je(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,pt,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=F(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new Z(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[I,B]=ct(t.subarray(r));return r+=B,I},o=n(),s=pt;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,p=n(),d=n(),b=r+d,g=b-a;return{version:o,codec:s,multihashCode:p,digestSize:d,multihashSize:g,size:b}}static parse(t,r){let[n,o]=Fn(t,r),s=e.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}},Fn=(e,t)=>{switch(e[0]){case"Q":{let r=t||w;return[w.prefix,r.decode(`${w.prefix}${e}`)]}case w.prefix:{let r=t||w;return[w.prefix,r.decode(e)]}case M.prefix:{let r=t||M;return[M.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},Mn=(e,t,r)=>{let{prefix:n}=r;if(n!==w.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o},kn=(e,t,r)=>{let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o},pt=112,Bn=18,je=(e,t,r)=>{let n=Y(e),o=n+Y(t),s=new Uint8Array(o+r.byteLength);return Q(e,s,0),Q(t,s,n),s.set(r,o),s},On=Symbol.for("@ipld/js-cid/CID");var z={...qt,...Ot,...jt,...kt,...Bt,...Vt,...zt,...Mt,...$t,..._t},Ys={...Jt,...Wt};function Qt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}var _n=Symbol.for("nodejs.util.inspect.custom"),qe=Object.values(z).map(e=>e.decoder).reduce((e,t)=>e.or(t),z.identity.decoder),Ge=114,We=36,Ke=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()})`}[Ee]=!0;toString(){return this.string==null&&(this.string=w.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return C.createV1(Ge,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return Qt(this.multihash.bytes,t);if(typeof t=="string")return Yt(t).equals(this);if(t?.multihash?.bytes!=null)return Qt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[_n](){return`PeerId(${this.toString()})`}},ut=class extends lt{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},ft=class extends lt{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},dt=class extends lt{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function Yt(e,t){if(t=t??qe,e.charAt(0)==="1"||e.charAt(0)==="Q"){let r=q(w.decode(`z${e}`));return e.startsWith("12D")?new ft({multihash:r}):e.startsWith("16U")?new dt({multihash:r}):new ut({multihash:r})}return Vn(qe.decode(e))}function Vn(e){try{let t=q(e);if(t.code===wt.code){if(t.digest.length===We)return new ft({multihash:t});if(t.digest.length===Ke)return new dt({multihash:t})}if(t.code===xt.code)return new ut({multihash:t})}catch{return zn(C.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function zn(e){if(e==null||e.multihash==null||e.version==null||e.version===1&&e.code!==Ge)throw new Error("Supplied PeerID CID is invalid");let t=e.multihash;if(t.code===xt.code)return new ut({multihash:e.multihash});if(t.code===wt.code){if(t.digest.length===We)return new ft({multihash:e.multihash});if(t.digest.length===Ke)return new dt({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}function He(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function tt(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function bt(e=0){return globalThis.Buffer?.allocUnsafe!=null?tt(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Xe(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Je=Xe("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Zt=Xe("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=bt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),$n={utf8:Je,"utf-8":Je,hex:z.base16,latin1:Zt,ascii:Zt,binary:Zt,...z},yt=$n;function S(e,t="utf8"){let r=yt[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}function Qe(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Ye(e=0){return globalThis.Buffer?.allocUnsafe!=null?Qe(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}var jn=Math.pow(2,7),qn=Math.pow(2,14),Gn=Math.pow(2,21),te=Math.pow(2,28),ee=Math.pow(2,35),re=Math.pow(2,42),ne=Math.pow(2,49),u=128,x=127;function N(e){if(e<jn)return 1;if(e<qn)return 2;if(e<Gn)return 3;if(e<te)return 4;if(e<ee)return 5;if(e<re)return 6;if(e<ne)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Wn(e,t,r=0){switch(N(e)){case 8:t[r++]=e&255|u,e/=128;case 7:t[r++]=e&255|u,e/=128;case 6:t[r++]=e&255|u,e/=128;case 5:t[r++]=e&255|u,e/=128;case 4:t[r++]=e&255|u,e>>>=7;case 3:t[r++]=e&255|u,e>>>=7;case 2:t[r++]=e&255|u,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Kn(e,t,r=0){switch(N(e)){case 8:t.set(r++,e&255|u),e/=128;case 7:t.set(r++,e&255|u),e/=128;case 6:t.set(r++,e&255|u),e/=128;case 5:t.set(r++,e&255|u),e/=128;case 4:t.set(r++,e&255|u),e>>>=7;case 3:t.set(r++,e&255|u),e>>>=7;case 2:t.set(r++,e&255|u),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function Hn(e,t){let r=e[t],n=0;if(n+=r&x,r<u||(r=e[t+1],n+=(r&x)<<7,r<u)||(r=e[t+2],n+=(r&x)<<14,r<u)||(r=e[t+3],n+=(r&x)<<21,r<u)||(r=e[t+4],n+=(r&x)*te,r<u)||(r=e[t+5],n+=(r&x)*ee,r<u)||(r=e[t+6],n+=(r&x)*re,r<u)||(r=e[t+7],n+=(r&x)*ne,r<u))return n;throw new RangeError("Could not decode varint")}function Jn(e,t){let r=e.get(t),n=0;if(n+=r&x,r<u||(r=e.get(t+1),n+=(r&x)<<7,r<u)||(r=e.get(t+2),n+=(r&x)<<14,r<u)||(r=e.get(t+3),n+=(r&x)<<21,r<u)||(r=e.get(t+4),n+=(r&x)*te,r<u)||(r=e.get(t+5),n+=(r&x)*ee,r<u)||(r=e.get(t+6),n+=(r&x)*re,r<u)||(r=e.get(t+7),n+=(r&x)*ne,r<u))return n;throw new RangeError("Could not decode varint")}function et(e,t,r=0){return t==null&&(t=Ye(N(e))),t instanceof Uint8Array?Wn(e,t,r):Kn(e,t,r)}function W(e,t=0){return e instanceof Uint8Array?Hn(e,t):Jn(e,t)}function k(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=bt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return tt(r)}var St=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}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 r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let s=0,a=0,p=this.peekChar();if(p===void 0)return;let d=p==="0",b=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let I=this.readChar();if(I===void 0)return;let B=Number.parseInt(I,t);if(!Number.isNaN(B))return B});if(g===void 0)break;if(s*=t,s+=g,s>b||(a+=1,r!==void 0&&a>r))return}if(a!==0)return!n&&d&&a>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let a=this.readSeparator(":",n,()=>this.readIPv4Addr());if(a!==void 0)return r[o]=a[0],r[o+1]=a[1],r[o+2]=a[2],r[o+3]=a[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),a=16-(n+2),[p]=t(s.subarray(0,a));return r.set(s.subarray(0,p),16-p),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var tr=45,Xn=15,rt=new St;function oe(e){if(!(e.length>Xn))return rt.new(e).parseWith(()=>rt.readIPv4Addr())}function se(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>tr))return rt.new(e).parseWith(()=>rt.readIPv6Addr())}function vt(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>tr))return rt.new(e).parseWith(()=>rt.readIPAddr())}var Mi=parseInt("0xFFFF",16),ki=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ie(e,t="utf8"){let r=yt[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?tt(globalThis.Buffer.from(e,"utf-8")):r.decoder.decode(`${r.prefix}${e}`)}function nr(e){return!!oe(e)}function or(e){return!!se(e)}function Et(e){return!!vt(e)}var sr=nr,eo=or,ae=function(e){let t=0;if(e=e.toString().trim(),sr(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(eo(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let s=sr(r[n]),a;s&&(a=ae(r[n]),r[n]=S(a.slice(0,2),"base16")),a!=null&&++n<8&&r.splice(n,0,S(a.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},ir=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(e[t+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var nt={},ce={},no=[[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"],[777,-1,"memory"]];no.forEach(e=>{let t=oo(...e);ce[t.code]=t,nt[t.name]=t});function oo(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function f(e){if(typeof e=="number"){if(ce[e]!=null)return ce[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(nt[e]!=null)return nt[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var va=f("ip4"),Ea=f("ip6"),Aa=f("ipcidr");function le(e,t){switch(f(e).code){case 4:case 41:return io(t);case 42:return pr(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 pr(t);case 421:return lo(t);case 444:return lr(t);case 445:return lr(t);case 466:return po(t);default:return S(t,"base16")}}function ue(e,t){switch(f(e).code){case 4:return ar(t);case 41:return ar(t);case 42:return cr(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 cr(t);case 421:return ao(t);case 444:return uo(t);case 445:return fo(t);case 466:return co(t);default:return ie(t,"base16")}}var pe=Object.values(z).map(e=>e.decoder),so=function(){let e=pe[0].or(pe[1]);return pe.slice(2).forEach(t=>e=e.or(t)),e}();function ar(e){if(!Et(e))throw new Error("invalid ip address");return ae(e)}function io(e){let t=ir(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!Et(t))throw new Error("invalid ip address");return t}function fe(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function ur(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function cr(e){let t=ie(e),r=Uint8Array.from(et(t.length));return k([r,t],r.length+t.length)}function pr(e){let t=W(e);if(e=e.slice(N(t)),e.length!==t)throw new Error("inconsistent lengths");return S(e)}function ao(e){let t;e[0]==="Q"||e[0]==="1"?t=q(w.decode(`z${e}`)).bytes:t=C.parse(e).multihash.bytes;let r=Uint8Array.from(et(t.length));return k([r,t],r.length+t.length)}function co(e){let t=so.decode(e),r=Uint8Array.from(et(t.length));return k([r,t],r.length+t.length)}function po(e){let t=W(e),r=e.slice(N(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+S(r,"base64url")}function lo(e){let t=W(e),r=e.slice(N(t));if(r.length!==t)throw new Error("inconsistent lengths");return S(r,"base58btc")}function uo(e){let t=e.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 r=M.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([r,o],r.length+o.length)}function fo(e){let t=e.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 r=M.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([r,o],r.length+o.length)}function lr(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=S(t,"base32"),o=ur(r);return`${n}:${o}`}function fr(e){e=de(e);let t=[],r=[],n=null,o=e.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 a=o[s],p=f(a);if(p.size===0){t.push([p.code]),r.push([p.code]);continue}if(s++,s>=o.length)throw hr("invalid address: "+e);if(p.path===!0){n=de(o.slice(s).join("/")),t.push([p.code,ue(p.code,n)]),r.push([p.code,n]);break}let d=ue(p.code,o[s]);t.push([p.code,d]),r.push([p.code,le(p.code,d)])}return{string:dr(r),bytes:me(t),tuples:t,stringTuples:r,path:n}}function he(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let s=W(e,o),a=N(s),p=f(s),d=ho(p,e.slice(o+a));if(d===0){t.push([s]),r.push([s]),o+=a;continue}let b=e.slice(o+a,o+a+d);if(o+=d+a,o>e.length)throw hr("Invalid address Uint8Array: "+S(e,"base16"));t.push([s,b]);let g=le(s,b);if(r.push([s,g]),p.path===!0){n=g;break}}return{bytes:Uint8Array.from(e),string:dr(r),tuples:t,stringTuples:r,path:n}}function dr(e){let t=[];return e.map(r=>{let n=f(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),de(t.join("/"))}function me(e){return k(e.map(t=>{let r=f(t[0]),n=Uint8Array.from(et(r.code));return t.length>1&&t[1]!=null&&(n=k([n,t[1]])),n}))}function ho(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=W(t instanceof Uint8Array?t:Uint8Array.from(t));return r+N(r)}}function de(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}function hr(e){return new Error("Error parsing address: "+e)}var mo=Symbol.for("nodejs.util.inspect.custom"),ge=Symbol.for("@multiformats/js-multiaddr/multiaddr"),go=[f("dns").code,f("dns4").code,f("dns6").code,f("dnsaddr").code],At=class e{bytes;#t;#e;#r;#n;[ge]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=he(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=fr(t)}else if(gr(t))r=he(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#t=r.string,this.#e=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,r,n,o,s="",a=f("tcp"),p=f("udp"),d=f("ip4"),b=f("ip6"),g=f("dns6"),I=f("ip6zone");for(let[E,l]of this.stringTuples())E===I.code&&(s=`%${l??""}`),go.includes(E)&&(r=a.name,o=443,n=`${l??""}${s}`,t=E===g.code?6:4),(E===a.code||E===p.code)&&(r=f(E).name,o=parseInt(l??"")),(E===d.code||E===b.code)&&(r=f(E).name,n=`${l??""}${s}`,t=E===b.code?6:4);if(t==null||r==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:r,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},f(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>f(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new e(t),new e(this.toString()+t.toString())}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o))}decapsulateCode(t){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new e(me(r.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===nt.p2p.code&&t.push([n,o]),n===nt["p2p-circuit"].code&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?S(w.decode(`z${n}`),"base58btc"):S(C.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return He(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=mr.get(r.name);if(n==null)throw new it(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new e(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 r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[mo](){return`Multiaddr(${this.#t})`}};var mr=new Map;function gr(e){return!!e?.[ge]}function ot(e){return new At(e)}var wo=i("dns4"),xo=i("dns6"),bo=i("dnsaddr"),H=m(i("dns"),bo,wo,xo),Pt=m(i("ip4"),i("ip6")),st=m(c(Pt,i("tcp")),c(H,i("tcp"))),Ct=c(Pt,i("udp")),yo=c(Ct,i("utp")),So=c(Ct,i("quic")),vo=c(Ct,i("quic-v1")),we=m(c(st,i("ws")),c(H,i("ws"))),It=m(c(we,i("p2p")),we),xe=m(c(st,i("wss")),c(H,i("wss")),c(st,i("tls"),i("ws")),c(H,i("tls"),i("ws"))),Tt=m(c(xe,i("p2p")),xe),be=m(c(st,i("http")),c(Pt,i("http")),c(H,i("http"))),ye=m(c(st,i("https")),c(Pt,i("https")),c(H,i("https"))),wr=c(Ct,i("webrtc-direct"),i("certhash")),yr=m(c(wr,i("p2p")),wr),xr=c(vo,i("webtransport"),i("certhash"),i("certhash")),Sr=m(c(xr,i("p2p")),xr),vr=m(c(It,i("p2p-webrtc-star"),i("p2p")),c(Tt,i("p2p-webrtc-star"),i("p2p")),c(It,i("p2p-webrtc-star")),c(Tt,i("p2p-webrtc-star"))),Xa=m(c(It,i("p2p-websocket-star"),i("p2p")),c(Tt,i("p2p-websocket-star"),i("p2p")),c(It,i("p2p-websocket-star")),c(Tt,i("p2p-websocket-star"))),Er=m(c(be,i("p2p-webrtc-direct"),i("p2p")),c(ye,i("p2p-webrtc-direct"),i("p2p")),c(be,i("p2p-webrtc-direct")),c(ye,i("p2p-webrtc-direct"))),J=m(we,xe,be,ye,vr,Er,st,yo,So,H,yr,Sr),Qa=m(c(J,i("p2p-stardust"),i("p2p")),c(J,i("p2p-stardust"))),$=m(c(J,i("p2p")),vr,Er,yr,Sr,i("p2p")),br=m(c($,i("p2p-circuit"),$),c($,i("p2p-circuit")),c(i("p2p-circuit"),$),c(J,i("p2p-circuit")),c(i("p2p-circuit"),J),i("p2p-circuit")),Ar=()=>m(c(br,Ar),br),K=Ar(),Ir=m(c(K,$,K),c($,K),c(K,$),K,$);var Ya=m(c(K,i("webrtc"),i("p2p")),c(K,i("webrtc")),c(J,i("webrtc"),i("p2p")),c(J,i("webrtc")),i("webrtc"));function Tr(e){function t(r){let n;try{n=ot(r)}catch{return!1}let o=e(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function c(...e){function t(r){if(r.length<e.length)return null;let n=r;return e.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:Tr(t),partialMatch:t}}function m(...e){function t(n){let o=null;return e.some(s=>{let a=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return a!=null?(o=a,!0):!1}),o}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:Tr(t),partialMatch:t}}function i(e){let t=e;function r(o){let s;try{s=ot(o)}catch{return!1}let a=s.protoNames();return a.length===1&&a[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:r,partialMatch:n}}var Eo="bootstrap",Ao=50,Io=12e4,To=1e3,Se=class extends mt{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,r={list:[]}){if(r.list==null||r.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=r.timeout??To,this.list=[];for(let n of r.list){if(!Ir.matches(n)){this.log.error("Invalid multiaddr");continue}let o=ot(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let a={id:Yt(s),multiaddrs:[o]};this.list.push(a)}this._init=r}[ve]=this;[Symbol.toStringTag]="@libp2p/bootstrap";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??Eo]:{value:this._init.tagValue??Ao,ttl:this._init.tagTTL??Io}}}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function Po(e){return t=>new Se(t,e)}return Lr(Co);})();
|
|
2
|
+
"use strict";var Libp2PBootstrap=(()=>{var Ut=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Ir=Object.getOwnPropertyNames;var Tr=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var r in t)Ut(e,r,{get:t[r],enumerable:!0})},Pr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ir(t))!Tr.call(e,o)&&o!==r&&Ut(e,o,{get:()=>t[o],enumerable:!(n=Ar(t,o))||n.enumerable});return e};var Cr=e=>Pr(Ut({},"__esModule",{value:!0}),e);var Io={};v(Io,{bootstrap:()=>Ao});var Po=Symbol.for("@libp2p/connection");var Do=Symbol.for("@libp2p/content-routing");var ve=Symbol.for("@libp2p/peer-discovery");var Ee=Symbol.for("@libp2p/peer-id");var Fo=Symbol.for("@libp2p/peer-routing");var Ae;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(Ae||(Ae={}));var Oo=Symbol.for("@libp2p/transport");var Ie;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(Ie||(Ie={}));var at=class extends Error{code;props;constructor(t,r,n){super(t),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var gt=class extends EventTarget{#t=new Map;listenerCount(t){let r=this.#t.get(t);return r==null?0:r.length}addEventListener(t,r,n){super.addEventListener(t,r,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,r,n){super.removeEventListener(t.toString(),r??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#t.set(t,o))}dispatchEvent(t){let r=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),r}safeDispatchEvent(t,r){return this.dispatchEvent(new Dr(t,r))}},Nt=class extends Event{detail;constructor(t,r){super(t,r),this.detail=r?.detail}},Dr=globalThis.CustomEvent??Nt;var kt={};v(kt,{base58btc:()=>g,base58flickr:()=>Mr});var xi=new Uint8Array(0);function Te(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function F(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Pe(e){return new TextEncoder().encode(e)}function Ce(e){return new TextDecoder().decode(e)}function Ur(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var p=e.length,d=e.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,j=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 N=u[T],O=0,P=U-1;(N!==0||O<j)&&P!==-1;P--,O++)N+=256*A[P]>>>0,A[P]=N%p>>>0,N=N/p>>>0;if(N!==0)throw new Error("Non-zero carry");j=O,T++}for(var L=U-j;L!==U&&A[L]===0;)L++;for(var xt=d.repeat(y);L<U;++L)xt+=e.charAt(A[L]);return xt}function B(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 j=0,T=0;u[y]===d;)j++,y++;for(var D=(u.length-y)*b+1>>>0,U=new Uint8Array(D);u[y];){var A=r[u.charCodeAt(y)];if(A===255)return;for(var N=0,O=D-1;(A!==0||N<T)&&O!==-1;O--,N++)A+=p*U[O]>>>0,U[O]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");T=N,y++}if(u[y]!==" "){for(var P=D-T;P!==D&&U[P]===0;)P++;for(var L=new Uint8Array(j+(D-P)),xt=j;P!==D;)L[xt++]=U[P++];return L}}}function E(u){var y=B(u);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:I,decodeUnsafe:B,decode:E}}var Nr=Ur,Rr=Nr,Ue=Rr;var Rt=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Lt=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 r=t[0],n=this.decoders[r];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(e,t){return new Ft({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Mt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Rt(t,r,n),this.decoder=new Lt(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Q({name:e,prefix:t,encode:r,decode:n}){return new Mt(e,t,r,n)}function _({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Ue(r,e);return Q({prefix:t,name:e,encode:n,decode:i=>F(o(i))})}function Lr(e,t,r,n){let o={};for(let x=0;x<t.length;++x)o[t[x]]=x;let i=e.length;for(;e[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),p=0,d=0,b=0;for(let x=0;x<i;++x){let I=o[e[x]];if(I===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|I,p+=r,p>=8&&(p-=8,a[b++]=255&d>>p)}if(p>=r||255&d<<8-p)throw new SyntaxError("Unexpected end of data");return a}function Fr(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",a=0,p=0;for(let d=0;d<e.length;++d)for(p=p<<8|e[d],a+=8;a>r;)a-=r,i+=t[o&p>>a];if(a!==0&&(i+=t[o&p<<r-a]),n)for(;i.length*r&7;)i+="=";return i}function h({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Q({prefix:t,name:e,encode(o){return Fr(o,n,r)},decode(o){return Lr(o,n,r,e)}})}var g=_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Mr=_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bt={};v(Bt,{base10:()=>kr});var kr=_({prefix:"9",name:"base10",alphabet:"0123456789"});var Ot={};v(Ot,{base16:()=>Br,base16upper:()=>Or});var Br=h({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Or=h({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var _t={};v(_t,{base2:()=>_r});var _r=h({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var zt={};v(zt,{base256emoji:()=>qr});var Re=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),zr=Re.reduce((e,t,r)=>(e[r]=t,e),[]),Vr=Re.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function $r(e){return e.reduce((t,r)=>(t+=zr[r],t),"")}function jr(e){let t=[];for(let r of e){let n=Vr[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n)}return new Uint8Array(t)}var qr=Q({prefix:"\u{1F680}",name:"base256emoji",encode:$r,decode:jr});var Vt={};v(Vt,{base32:()=>M,base32hex:()=>Hr,base32hexpad:()=>Xr,base32hexpadupper:()=>Qr,base32hexupper:()=>Jr,base32pad:()=>Wr,base32padupper:()=>Kr,base32upper:()=>Gr,base32z:()=>Yr});var M=h({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gr=h({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Wr=h({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Kr=h({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Hr=h({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jr=h({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xr=h({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Qr=h({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yr=h({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $t={};v($t,{base36:()=>Zr,base36upper:()=>tn});var Zr=_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),tn=_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var jt={};v(jt,{base64:()=>en,base64pad:()=>rn,base64url:()=>nn,base64urlpad:()=>on});var en=h({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),rn=h({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),nn=h({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),on=h({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var qt={};v(qt,{base8:()=>sn});var sn=h({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gt={};v(Gt,{identity:()=>an});var an=Q({prefix:"\0",name:"identity",encode:e=>Ce(e),decode:e=>Pe(e)});var Ri=new TextEncoder,Li=new TextDecoder;var Kt={};v(Kt,{identity:()=>bt});var un=Me,Le=128,ln=127,fn=~ln,dn=Math.pow(2,31);function Me(e,t,r){t=t||[],r=r||0;for(var n=r;e>=dn;)t[r++]=e&255|Le,e/=128;for(;e&fn;)t[r++]=e&255|Le,e>>>=7;return t[r]=e|0,Me.bytes=r-n+1,t}var hn=Wt,mn=128,Fe=127;function Wt(e,n){var r=0,n=n||0,o=0,i=n,a,p=e.length;do{if(i>=p)throw Wt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&Fe)<<o:(a&Fe)*Math.pow(2,o),o+=7}while(a>=mn);return Wt.bytes=i-n,r}var xn=Math.pow(2,7),gn=Math.pow(2,14),wn=Math.pow(2,21),bn=Math.pow(2,28),yn=Math.pow(2,35),Sn=Math.pow(2,42),vn=Math.pow(2,49),En=Math.pow(2,56),An=Math.pow(2,63),In=function(e){return e<xn?1:e<gn?2:e<wn?3:e<bn?4:e<yn?5:e<Sn?6:e<vn?7:e<En?8:e<An?9:10},Tn={encode:un,decode:hn,encodingLength:In},Pn=Tn,ct=Pn;function pt(e,t=0){return[ct.decode(e,t),ct.decode.bytes]}function Y(e,t,r=0){return ct.encode(e,t,r),t}function Z(e){return ct.encodingLength(e)}function z(e,t){let r=t.byteLength,n=Z(e),o=n+Z(r),i=new Uint8Array(o+r);return Y(e,i,0),Y(r,i,n),i.set(t,o),new tt(e,r,t,i)}function q(e){let t=F(e),[r,n]=pt(t),[o,i]=pt(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new tt(r,o,a,t)}function ke(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Te(e.bytes,r.bytes)}}var tt=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var Be=0,Cn="identity",Oe=F;function Dn(e){return z(Be,Oe(e))}var bt={code:Be,name:Cn,encode:Oe,digest:Dn};var Xt={};v(Xt,{sha256:()=>yt,sha512:()=>Un});function Jt({name:e,code:t,encode:r}){return new Ht(e,t,r)}var Ht=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?z(this.code,r):r.then(n=>z(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ze(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var yt=Jt({name:"sha2-256",code:18,encode:ze("SHA-256")}),Un=Jt({name:"sha2-512",code:19,encode:ze("SHA-512")});function Ve(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Rn(r,Qt(e),t??g.encoder);default:return Ln(r,Qt(e),t??M.encoder)}}var $e=new WeakMap;function Qt(e){let t=$e.get(e);if(t==null){let r=new Map;return $e.set(e,r),r}return t}var C=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,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:r}=this;if(t!==ut)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Fn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=z(t,r);return e.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 e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&ke(t.multihash,n.multihash)}toString(t){return Ve(this,t)}toJSON(){return{"/":Ve(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 r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new e(n,o,i,a??je(n,o,i.bytes))}else if(r[Mn]===!0){let{version:n,multihash:o,code:i}=r,a=q(o);return e.create(n,i,a)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==ut)throw new Error(`Version 0 CID must use dag-pb (code: ${ut}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=je(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ut,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=F(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new tt(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[I,B]=pt(t.subarray(r));return r+=B,I},o=n(),i=ut;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,p=n(),d=n(),b=r+d,x=b-a;return{version:o,codec:i,multihashCode:p,digestSize:d,multihashSize:x,size:b}}static parse(t,r){let[n,o]=Nn(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Qt(i).set(n,t),i}};function Nn(e,t){switch(e[0]){case"Q":{let r=t??g;return[g.prefix,r.decode(`${g.prefix}${e}`)]}case g.prefix:{let r=t??g;return[g.prefix,r.decode(e)]}case M.prefix:{let r=t??M;return[M.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Rn(e,t,r){let{prefix:n}=r;if(n!==g.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Ln(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var ut=112,Fn=18;function je(e,t,r){let n=Z(e),o=n+Z(t),i=new Uint8Array(o+r.byteLength);return Y(e,i,0),Y(t,i,n),i.set(r,o),i}var Mn=Symbol.for("@ipld/js-cid/CID");var V={...Gt,..._t,...qt,...Bt,...Ot,...Vt,...$t,...kt,...jt,...zt},ts={...Xt,...Kt};function lt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}var kn=Symbol.for("nodejs.util.inspect.custom"),qe=Object.values(V).map(e=>e.decoder).reduce((e,t)=>e.or(t),V.identity.decoder),Ge=114,We=36,Ke=37,ft=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()})`}[Ee]=!0;toString(){return this.string==null&&(this.string=g.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return C.createV1(Ge,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return lt(this.multihash.bytes,t);if(typeof t=="string")return Yt(t).equals(this);if(t?.multihash?.bytes!=null)return lt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[kn](){return`PeerId(${this.toString()})`}},dt=class extends ft{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},ht=class extends ft{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},mt=class extends ft{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function Yt(e,t){if(t=t??qe,e.charAt(0)==="1"||e.charAt(0)==="Q"){let r=q(g.decode(`z${e}`));return e.startsWith("12D")?new ht({multihash:r}):e.startsWith("16U")?new mt({multihash:r}):new dt({multihash:r})}return Bn(qe.decode(e))}function Bn(e){try{let t=q(e);if(t.code===bt.code){if(t.digest.length===We)return new ht({multihash:t});if(t.digest.length===Ke)return new mt({multihash:t})}if(t.code===yt.code)return new dt({multihash:t})}catch{return On(C.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function On(e){if(e==null||e.multihash==null||e.version==null||e.version===1&&e.code!==Ge)throw new Error("Supplied PeerID CID is invalid");let t=e.multihash;if(t.code===yt.code)return new dt({multihash:e.multihash});if(t.code===bt.code){if(t.digest.length===We)return new ht({multihash:e.multihash});if(t.digest.length===Ke)return new mt({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}function W(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function et(e=0){return globalThis.Buffer?.allocUnsafe!=null?W(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Je(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var He=Je("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Zt=Je("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=et(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),_n={utf8:He,"utf-8":He,hex:V.base16,latin1:Zt,ascii:Zt,binary:Zt,...V},St=_n;function S(e,t="utf8"){let r=St[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}var zn=Math.pow(2,7),Vn=Math.pow(2,14),$n=Math.pow(2,21),te=Math.pow(2,28),ee=Math.pow(2,35),re=Math.pow(2,42),ne=Math.pow(2,49),l=128,w=127;function R(e){if(e<zn)return 1;if(e<Vn)return 2;if(e<$n)return 3;if(e<te)return 4;if(e<ee)return 5;if(e<re)return 6;if(e<ne)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function jn(e,t,r=0){switch(R(e)){case 8:t[r++]=e&255|l,e/=128;case 7:t[r++]=e&255|l,e/=128;case 6:t[r++]=e&255|l,e/=128;case 5:t[r++]=e&255|l,e/=128;case 4:t[r++]=e&255|l,e>>>=7;case 3:t[r++]=e&255|l,e>>>=7;case 2:t[r++]=e&255|l,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function qn(e,t,r=0){switch(R(e)){case 8:t.set(r++,e&255|l),e/=128;case 7:t.set(r++,e&255|l),e/=128;case 6:t.set(r++,e&255|l),e/=128;case 5:t.set(r++,e&255|l),e/=128;case 4:t.set(r++,e&255|l),e>>>=7;case 3:t.set(r++,e&255|l),e>>>=7;case 2:t.set(r++,e&255|l),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function Gn(e,t){let r=e[t],n=0;if(n+=r&w,r<l||(r=e[t+1],n+=(r&w)<<7,r<l)||(r=e[t+2],n+=(r&w)<<14,r<l)||(r=e[t+3],n+=(r&w)<<21,r<l)||(r=e[t+4],n+=(r&w)*te,r<l)||(r=e[t+5],n+=(r&w)*ee,r<l)||(r=e[t+6],n+=(r&w)*re,r<l)||(r=e[t+7],n+=(r&w)*ne,r<l))return n;throw new RangeError("Could not decode varint")}function Wn(e,t){let r=e.get(t),n=0;if(n+=r&w,r<l||(r=e.get(t+1),n+=(r&w)<<7,r<l)||(r=e.get(t+2),n+=(r&w)<<14,r<l)||(r=e.get(t+3),n+=(r&w)<<21,r<l)||(r=e.get(t+4),n+=(r&w)*te,r<l)||(r=e.get(t+5),n+=(r&w)*ee,r<l)||(r=e.get(t+6),n+=(r&w)*re,r<l)||(r=e.get(t+7),n+=(r&w)*ne,r<l))return n;throw new RangeError("Could not decode varint")}function rt(e,t,r=0){return t==null&&(t=et(R(e))),t instanceof Uint8Array?jn(e,t,r):qn(e,t,r)}function K(e,t=0){return e instanceof Uint8Array?Gn(e,t):Wn(e,t)}function k(e,t){if(globalThis.Buffer!=null)return W(globalThis.Buffer.concat(e,t));t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=et(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return W(r)}var vt=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}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 r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,a=0,p=this.peekChar();if(p===void 0)return;let d=p==="0",b=2**(8*o)-1;for(;;){let x=this.readAtomically(()=>{let I=this.readChar();if(I===void 0)return;let B=Number.parseInt(I,t);if(!Number.isNaN(B))return B});if(x===void 0)break;if(i*=t,i+=x,i>b||(a+=1,r!==void 0&&a>r))return}if(a!==0)return!n&&d&&a>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let a=this.readSeparator(":",n,()=>this.readIPv4Addr());if(a!==void 0)return r[o]=a[0],r[o+1]=a[1],r[o+2]=a[2],r[o+3]=a[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),a=16-(n+2),[p]=t(i.subarray(0,a));return r.set(i.subarray(0,p),16-p),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Qe=45,Kn=15,nt=new vt;function oe(e){if(!(e.length>Kn))return nt.new(e).parseWith(()=>nt.readIPv4Addr())}function ie(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Qe))return nt.new(e).parseWith(()=>nt.readIPv6Addr())}function Et(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Qe))return nt.new(e).parseWith(()=>nt.readIPAddr())}var Ls=parseInt("0xFFFF",16),Fs=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function se(e,t="utf8"){let r=St[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?W(globalThis.Buffer.from(e,"utf-8")):r.decoder.decode(`${r.prefix}${e}`)}function tr(e){return!!oe(e)}function er(e){return!!ie(e)}function At(e){return!!Et(e)}var rr=tr,Yn=er,ae=function(e){let t=0;if(e=e.toString().trim(),rr(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(Yn(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=rr(r[n]),a;i&&(a=ae(r[n]),r[n]=S(a.slice(0,2),"base16")),a!=null&&++n<8&&r.splice(n,0,S(a.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){let i=parseInt(r[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},nr=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let i=0;i<r;i++)o.push(e[t+i]);return o.join(".")}if(r===16){let o=[];for(let i=0;i<r;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={},ce={},to=[[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"],[777,-1,"memory"]];to.forEach(e=>{let t=eo(...e);ce[t.code]=t,ot[t.name]=t});function eo(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function f(e){if(typeof e=="number"){if(ce[e]!=null)return ce[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(ot[e]!=null)return ot[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var ya=f("ip4"),Sa=f("ip6"),va=f("ipcidr");function ue(e,t){switch(f(e).code){case 4:case 41:return no(t);case 42:return sr(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 sr(t);case 421:return ao(t);case 444:return ar(t);case 445:return ar(t);case 466:return so(t);default:return S(t,"base16")}}function le(e,t){switch(f(e).code){case 4:return or(t);case 41:return or(t);case 42:return ir(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 ir(t);case 421:return oo(t);case 444:return co(t);case 445:return po(t);case 466:return io(t);default:return se(t,"base16")}}var pe=Object.values(V).map(e=>e.decoder),ro=function(){let e=pe[0].or(pe[1]);return pe.slice(2).forEach(t=>e=e.or(t)),e}();function or(e){if(!At(e))throw new Error("invalid ip address");return ae(e)}function no(e){let t=nr(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!At(t))throw new Error("invalid ip address");return t}function fe(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function cr(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function ir(e){let t=se(e),r=Uint8Array.from(rt(t.length));return k([r,t],r.length+t.length)}function sr(e){let t=K(e);if(e=e.slice(R(t)),e.length!==t)throw new Error("inconsistent lengths");return S(e)}function oo(e){let t;e[0]==="Q"||e[0]==="1"?t=q(g.decode(`z${e}`)).bytes:t=C.parse(e).multihash.bytes;let r=Uint8Array.from(rt(t.length));return k([r,t],r.length+t.length)}function io(e){let t=ro.decode(e),r=Uint8Array.from(rt(t.length));return k([r,t],r.length+t.length)}function so(e){let t=K(e),r=e.slice(R(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+S(r,"base64url")}function ao(e){let t=K(e),r=e.slice(R(t));if(r.length!==t)throw new Error("inconsistent lengths");return S(r,"base58btc")}function co(e){let t=e.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 r=M.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([r,o],r.length+o.length)}function po(e){let t=e.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 r=M.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([r,o],r.length+o.length)}function ar(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=S(t,"base32"),o=cr(r);return`${n}:${o}`}function pr(e){e=de(e);let t=[],r=[],n=null,o=e.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 a=o[i],p=f(a);if(p.size===0){t.push([p.code]),r.push([p.code]);continue}if(i++,i>=o.length)throw lr("invalid address: "+e);if(p.path===!0){n=de(o.slice(i).join("/")),t.push([p.code,le(p.code,n)]),r.push([p.code,n]);break}let d=le(p.code,o[i]);t.push([p.code,d]),r.push([p.code,ue(p.code,d)])}return{string:ur(r),bytes:me(t),tuples:t,stringTuples:r,path:n}}function he(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let i=K(e,o),a=R(i),p=f(i),d=uo(p,e.slice(o+a));if(d===0){t.push([i]),r.push([i]),o+=a;continue}let b=e.slice(o+a,o+a+d);if(o+=d+a,o>e.length)throw lr("Invalid address Uint8Array: "+S(e,"base16"));t.push([i,b]);let x=ue(i,b);if(r.push([i,x]),p.path===!0){n=x;break}}return{bytes:Uint8Array.from(e),string:ur(r),tuples:t,stringTuples:r,path:n}}function ur(e){let t=[];return e.map(r=>{let n=f(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),de(t.join("/"))}function me(e){return k(e.map(t=>{let r=f(t[0]),n=Uint8Array.from(rt(r.code));return t.length>1&&t[1]!=null&&(n=k([n,t[1]])),n}))}function uo(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=K(t instanceof Uint8Array?t:Uint8Array.from(t));return r+R(r)}}function de(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}function lr(e){return new Error("Error parsing address: "+e)}var lo=Symbol.for("nodejs.util.inspect.custom"),xe=Symbol.for("@multiformats/js-multiaddr/multiaddr"),fo=[f("dns").code,f("dns4").code,f("dns6").code,f("dnsaddr").code],It=class e{bytes;#t;#e;#r;#n;[xe]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=he(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=pr(t)}else if(dr(t))r=he(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#t=r.string,this.#e=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,r,n,o,i="",a=f("tcp"),p=f("udp"),d=f("ip4"),b=f("ip6"),x=f("dns6"),I=f("ip6zone");for(let[E,u]of this.stringTuples())E===I.code&&(i=`%${u??""}`),fo.includes(E)&&(r=a.name,o=443,n=`${u??""}${i}`,t=E===x.code?6:4),(E===a.code||E===p.code)&&(r=f(E).name,o=parseInt(u??"")),(E===d.code||E===b.code)&&(r=f(E).name,n=`${u??""}${i}`,t=E===b.code?6:4);if(t==null||r==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:r,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},f(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>f(t).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(t){return t=new e(t),new e(this.toString()+t.toString())}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o))}decapsulateCode(t){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new e(me(r.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 r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?S(g.decode(`z${n}`),"base58btc"):S(C.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return lt(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=fr.get(r.name);if(n==null)throw new at(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(i=>new e(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 r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[lo](){return`Multiaddr(${this.#t})`}};var fr=new Map;function dr(e){return!!e?.[xe]}function it(e){return new It(e)}var ho=s("dns4"),mo=s("dns6"),xo=s("dnsaddr"),J=m(s("dns"),xo,ho,mo),Ct=m(s("ip4"),s("ip6")),st=m(c(Ct,s("tcp")),c(J,s("tcp"))),Dt=c(Ct,s("udp")),go=c(Dt,s("utp")),wo=c(Dt,s("quic")),bo=c(Dt,s("quic-v1")),ge=m(c(st,s("ws")),c(J,s("ws"))),Tt=m(c(ge,s("p2p")),ge),we=m(c(st,s("wss")),c(J,s("wss")),c(st,s("tls"),s("ws")),c(J,s("tls"),s("ws"))),Pt=m(c(we,s("p2p")),we),be=m(c(st,s("http")),c(Ct,s("http")),c(J,s("http"))),ye=m(c(st,s("https")),c(Ct,s("https")),c(J,s("https"))),hr=c(Dt,s("webrtc-direct"),s("certhash")),gr=m(c(hr,s("p2p")),hr),mr=c(bo,s("webtransport"),s("certhash"),s("certhash")),wr=m(c(mr,s("p2p")),mr),br=m(c(Tt,s("p2p-webrtc-star"),s("p2p")),c(Pt,s("p2p-webrtc-star"),s("p2p")),c(Tt,s("p2p-webrtc-star")),c(Pt,s("p2p-webrtc-star"))),Ha=m(c(Tt,s("p2p-websocket-star"),s("p2p")),c(Pt,s("p2p-websocket-star"),s("p2p")),c(Tt,s("p2p-websocket-star")),c(Pt,s("p2p-websocket-star"))),yr=m(c(be,s("p2p-webrtc-direct"),s("p2p")),c(ye,s("p2p-webrtc-direct"),s("p2p")),c(be,s("p2p-webrtc-direct")),c(ye,s("p2p-webrtc-direct"))),X=m(ge,we,be,ye,br,yr,st,go,wo,J,gr,wr),Ja=m(c(X,s("p2p-stardust"),s("p2p")),c(X,s("p2p-stardust"))),$=m(c(X,s("p2p")),br,yr,gr,wr,s("p2p")),xr=m(c($,s("p2p-circuit"),$),c($,s("p2p-circuit")),c(s("p2p-circuit"),$),c(X,s("p2p-circuit")),c(s("p2p-circuit"),X),s("p2p-circuit")),Sr=()=>m(c(xr,Sr),xr),H=Sr(),vr=m(c(H,$,H),c($,H),c(H,$),H,$);var Xa=m(c(H,s("webrtc"),s("p2p")),c(H,s("webrtc")),c(X,s("webrtc"),s("p2p")),c(X,s("webrtc")),s("webrtc"));function Er(e){function t(r){let n;try{n=it(r)}catch{return!1}let o=e(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function c(...e){function t(r){if(r.length<e.length)return null;let n=r;return e.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:Er(t),partialMatch:t}}function m(...e){function t(n){let o=null;return e.some(i=>{let a=typeof i=="function"?i().partialMatch(n):i.partialMatch(n);return a!=null?(o=a,!0):!1}),o}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:Er(t),partialMatch:t}}function s(e){let t=e;function r(o){let i;try{i=it(o)}catch{return!1}let a=i.protoNames();return a.length===1&&a[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:r,partialMatch:n}}var yo="bootstrap",So=50,vo=12e4,Eo=1e3,Se=class extends gt{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,r={list:[]}){if(r.list==null||r.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=r.timeout??Eo,this.list=[];for(let n of r.list){if(!vr.matches(n)){this.log.error("Invalid multiaddr");continue}let o=it(n),i=o.getPeerId();if(i==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let a={id:Yt(i),multiaddrs:[o]};this.list.push(a)}this._init=r}[ve]=this;[Symbol.toStringTag]="@libp2p/bootstrap";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??yo]:{value:this._init.tagValue??So,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 Ao(e){return t=>new Se(t,e)}return Cr(Io);})();
|
|
3
3
|
return Libp2PBootstrap}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/bootstrap",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.9",
|
|
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",
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
"test:electron-main": "aegir test -t electron-main"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@libp2p/interface": "^1.0
|
|
57
|
-
"@libp2p/peer-id": "^4.0.
|
|
56
|
+
"@libp2p/interface": "^1.1.0",
|
|
57
|
+
"@libp2p/peer-id": "^4.0.3",
|
|
58
58
|
"@multiformats/mafmt": "^12.1.6",
|
|
59
59
|
"@multiformats/multiaddr": "^12.1.10"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@libp2p/interface-compliance-tests": "^5.0
|
|
63
|
-
"@libp2p/logger": "^4.0.
|
|
62
|
+
"@libp2p/interface-compliance-tests": "^5.1.0",
|
|
63
|
+
"@libp2p/logger": "^4.0.3",
|
|
64
64
|
"aegir": "^41.0.2",
|
|
65
65
|
"sinon-ts": "^2.0.0"
|
|
66
66
|
}
|