@libp2p/bootstrap 10.1.4 → 10.1.5
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 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?.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);})();
|
|
2
|
+
"use strict";var Libp2PBootstrap=(()=>{var Ut=Object.defineProperty;var Ir=Object.getOwnPropertyDescriptor;var Tr=Object.getOwnPropertyNames;var Pr=Object.prototype.hasOwnProperty;var E=(r,t)=>{for(var e in t)Ut(r,e,{get:t[e],enumerable:!0})},Cr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Tr(t))!Pr.call(r,o)&&o!==e&&Ut(r,o,{get:()=>t[o],enumerable:!(n=Ir(t,o))||n.enumerable});return r};var Dr=r=>Cr(Ut({},"__esModule",{value:!0}),r);var Io={};E(Io,{bootstrap:()=>Ao});var Ie=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 Te=(r,...t)=>{try{[...t]}catch{}};var wt=class extends EventTarget{#t=new Map;constructor(){super(),Te(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 Ur(t,e))}},Ur=globalThis.CustomEvent;var Pe=Symbol.for("@libp2p/service-capabilities"),Fo=Symbol.for("@libp2p/service-dependencies");var kt={};E(kt,{base58btc:()=>x,base58flickr:()=>kr});var ni=new Uint8Array(0);function Ce(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 De(r){return new TextEncoder().encode(r)}function Ue(r){return new TextDecoder().decode(r)}function Rr(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 Nr=Rr,Fr=Nr,Ne=Fr;var Nt=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")}},Ft=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 Fe(this,t)}},Mt=class{decoders;constructor(t){this.decoders=t}or(t){return Fe(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 Fe(r,t){return new Mt({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Lt=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 Nt(t,e,n),this.decoder=new Ft(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 Lt(r,t,e,n)}function O({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ne(e,r);return Q({prefix:t,name:r,encode:n,decode:i=>M(o(i))})}function Mr(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 Lr(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 Lr(o,n,e)},decode(o){return Mr(o,n,e,r)}})}var x=O({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),kr=O({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var _t={};E(_t,{base10:()=>_r});var _r=O({prefix:"9",name:"base10",alphabet:"0123456789"});var zt={};E(zt,{base16:()=>zr,base16upper:()=>Or});var zr=h({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Or=h({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ot={};E(Ot,{base2:()=>Vr});var Vr=h({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Vt={};E(Vt,{base256emoji:()=>Gr});var Me=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Br=Me.reduce((r,t,e)=>(r[e]=t,r),[]),$r=Me.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function jr(r){return r.reduce((t,e)=>(t+=Br[e],t),"")}function qr(r){let t=[];for(let e of r){let n=$r[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Gr=Q({prefix:"\u{1F680}",name:"base256emoji",encode:jr,decode:qr});var Bt={};E(Bt,{base32:()=>L,base32hex:()=>Jr,base32hexpad:()=>Qr,base32hexpadupper:()=>Yr,base32hexupper:()=>Xr,base32pad:()=>Kr,base32padupper:()=>Hr,base32upper:()=>Wr,base32z:()=>Zr});var L=h({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wr=h({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Kr=h({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hr=h({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jr=h({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xr=h({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qr=h({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Yr=h({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zr=h({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $t={};E($t,{base36:()=>tn,base36upper:()=>en});var tn=O({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),en=O({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var jt={};E(jt,{base64:()=>rn,base64pad:()=>nn,base64url:()=>on,base64urlpad:()=>sn});var rn=h({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),nn=h({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),on=h({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sn=h({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var qt={};E(qt,{base8:()=>cn});var cn=h({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gt={};E(Gt,{identity:()=>an});var an=Q({prefix:"\0",name:"identity",encode:r=>Ue(r),decode:r=>De(r)});var bi=new TextEncoder,yi=new TextDecoder;var Kt={};E(Kt,{identity:()=>at});var dn=_e,Le=128,ln=127,fn=~ln,hn=Math.pow(2,31);function _e(r,t,e){t=t||[],e=e||0;for(var n=e;r>=hn;)t[e++]=r&255|Le,r/=128;for(;r&fn;)t[e++]=r&255|Le,r>>>=7;return t[e]=r|0,_e.bytes=e-n+1,t}var mn=Wt,gn=128,ke=127;function Wt(r,n){var e=0,n=n||0,o=0,i=n,c,p=r.length;do{if(i>=p)throw Wt.bytes=0,new RangeError("Could not decode varint");c=r[i++],e+=o<28?(c&ke)<<o:(c&ke)*Math.pow(2,o),o+=7}while(c>=gn);return Wt.bytes=i-n,e}var xn=Math.pow(2,7),wn=Math.pow(2,14),bn=Math.pow(2,21),yn=Math.pow(2,28),vn=Math.pow(2,35),En=Math.pow(2,42),Sn=Math.pow(2,49),An=Math.pow(2,56),In=Math.pow(2,63),Tn=function(r){return r<xn?1:r<wn?2:r<bn?3:r<yn?4:r<vn?5:r<En?6:r<Sn?7:r<An?8:r<In?9:10},Pn={encode:dn,decode:mn,encodingLength:Tn},Cn=Pn,st=Cn;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 ze(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Ce(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,Dn="identity",Ve=M;function Un(r){return V(Oe,Ve(r))}var at={code:Oe,name:Dn,encode:Ve,digest:Un};var Xt={};E(Xt,{sha256:()=>yt,sha512:()=>Rn});function Jt({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?V(this.code,e):e.then(n=>V(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 yt=Jt({name:"sha2-256",code:18,encode:$e("SHA-256")}),Rn=Jt({name:"sha2-512",code:19,encode:$e("SHA-512")});function je(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Fn(e,Qt(r),t??x.encoder);default:return Mn(e,Qt(r),t??L.encoder)}}var qe=new WeakMap;function Qt(r){let t=qe.get(r);if(t==null){let e=new Map;return qe.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!==Ln)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&&ze(t.multihash,n.multihash)}toString(t){return je(this,t)}toJSON(){return{"/":je(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??Ge(n,o,i.bytes))}else if(e[kn]===!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=Ge(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]=Nn(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 Qt(i).set(n,t),i}};function Nn(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 Fn(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 Mn(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,Ln=18;function Ge(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 kn=Symbol.for("@ipld/js-cid/CID");var B={...Gt,...Ot,...qt,..._t,...zt,...Bt,...$t,...kt,...jt,...Vt},Bi={...Xt,...Kt};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 Ke(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var We=Ke("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yt=Ke("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}),_n={utf8:We,"utf-8":We,hex:B.base16,latin1:Yt,ascii:Yt,binary:Yt,...B},vt=_n;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 Je=Symbol.for("nodejs.util.inspect.custom"),He=Object.values(B).map(r=>r.decoder).reduce((r,t)=>r.or(t),B.identity.decoder),Xe=114,Qe=36,Ye=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(Xe,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 ee(t).equals(this);if(t?.multihash?.bytes!=null)return ut(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Je](){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}},Zt=2336,te=class{type="url";multihash;privateKey;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=at.digest(dt(this.url))}[Je](){return`PeerId(${this.url})`}[Rt]=!0;toString(){return this.toCID().toString()}toCID(){return I.createV1(Zt,this.multihash)}toBytes(){return this.toCID().bytes}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=w(t)),t.toString()===this.toString())}};function ee(r,t){if(t=t??He,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 zn(He.decode(r))}function zn(r){try{let t=G(r);if(t.code===at.code){if(t.digest.length===Qe)return new ht({multihash:t});if(t.digest.length===Ye)return new mt({multihash:t})}if(t.code===yt.code)return new ft({multihash:t})}catch{return On(I.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function On(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Xe&&r.code!==Zt)throw new Error("Supplied PeerID CID is invalid");if(r.code===Zt){let e=w(r.multihash.digest);return new te(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===Qe)return new ht({multihash:r.multihash});if(t.digest.length===Ye)return new mt({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var Vn=Math.pow(2,7),Bn=Math.pow(2,14),$n=Math.pow(2,21),re=Math.pow(2,28),ne=Math.pow(2,35),oe=Math.pow(2,42),ie=Math.pow(2,49),d=128,b=127;function N(r){if(r<Vn)return 1;if(r<Bn)return 2;if(r<$n)return 3;if(r<re)return 4;if(r<ne)return 5;if(r<oe)return 6;if(r<ie)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function jn(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 qn(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 Gn(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)*re,e<d)||(e=r[t+5],n+=(e&b)*ne,e<d)||(e=r[t+6],n+=(e&b)*oe,e<d)||(e=r[t+7],n+=(e&b)*ie,e<d))return n;throw new RangeError("Could not decode varint")}function Wn(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)*re,e<d)||(e=r.get(t+5),n+=(e&b)*ne,e<d)||(e=r.get(t+6),n+=(e&b)*oe,e<d)||(e=r.get(t+7),n+=(e&b)*ie,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?jn(r,t,e):qn(r,t,e)}function K(r,t=0){return r instanceof Uint8Array?Gn(r,t):Wn(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 tr=45,Kn=15,nt=new Et;function se(r){if(!(r.length>Kn))return nt.new(r).parseWith(()=>nt.readIPv4Addr())}function ce(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>tr))return nt.new(r).parseWith(()=>nt.readIPv6Addr())}function St(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>tr))return nt.new(r).parseWith(()=>nt.readIPAddr())}var Ss=parseInt("0xFFFF",16),As=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function nr(r){return!!se(r)}function or(r){return!!ce(r)}function At(r){return!!St(r)}var ir=nr,Yn=or,ae=function(r){let t=0;if(r=r.toString().trim(),ir(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Yn(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=ir(e[n]),c;i&&(c=ae(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")},sr=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={},pe={},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"],[481,-1,"http-path"],[777,-1,"memory"]];to.forEach(r=>{let t=eo(...r);pe[t.code]=t,ot[t.name]=t});function eo(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function l(r){if(typeof r=="number"){if(pe[r]!=null)return pe[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 cc=l("ip4"),ac=l("ip6"),pc=l("ipcidr");function fe(r,t){switch(l(r).code){case 4:case 41:return no(t);case 42:return le(t);case 6:case 273:case 33:case 132:return pr(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return le(t);case 421:return co(t);case 444:return ar(t);case 445:return ar(t);case 466:return so(t);case 481:return globalThis.encodeURIComponent(le(t));default:return w(t,"base16")}}function he(r,t){switch(l(r).code){case 4:return cr(t);case 41:return cr(t);case 42:return de(t);case 6:case 273:case 33:case 132:return me(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return de(t);case 421:return oo(t);case 444:return ao(t);case 445:return po(t);case 466:return io(t);case 481:return de(globalThis.decodeURIComponent(t));default:return dt(t,"base16")}}var ue=Object.values(B).map(r=>r.decoder),ro=function(){let r=ue[0].or(ue[1]);return ue.slice(2).forEach(t=>r=r.or(t)),r}();function cr(r){if(!At(r))throw new Error("invalid ip address");return ae(r)}function no(r){let t=sr(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 me(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function pr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function de(r){let t=dt(r),e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function le(r){let t=K(r);if(r=r.slice(N(t)),r.length!==t)throw new Error("inconsistent lengths");return w(r)}function oo(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 io(r){let t=ro.decode(r),e=Uint8Array.from(rt(t.length));return k([e,t],e.length+t.length)}function so(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 co(r){let t=K(r),e=r.slice(N(t));if(e.length!==t)throw new Error("inconsistent lengths");return w(e,"base58btc")}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!==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=me(n);return k([e,o],e.length+o.length)}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!==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=me(n);return k([e,o],e.length+o.length)}function ar(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=w(t,"base32"),o=pr(e);return`${n}:${o}`}function ur(r){r=ge(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 lr("invalid address: "+r);if(p.path===!0){n=ge(o.slice(i).join("/")),t.push([p.code,he(p.code,n)]),e.push([p.code,n]);break}let f=he(p.code,o[i]);t.push([p.code,f]),e.push([p.code,fe(p.code,f)])}return{string:dr(e),bytes:we(t),tuples:t,stringTuples:e,path:n}}function xe(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=K(r,o),c=N(i),p=l(i),f=uo(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 lr("Invalid address Uint8Array: "+w(r,"base16"));t.push([i,y]);let g=fe(i,y);if(e.push([i,g]),p.path===!0){n=g;break}}return{bytes:Uint8Array.from(r),string:dr(e),tuples:t,stringTuples:e,path:n}}function dr(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}),ge(t.join("/"))}function we(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 uo(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 ge(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function lr(r){return new Error("Error parsing address: "+r)}var lo=Symbol.for("nodejs.util.inspect.custom"),be=Symbol.for("@multiformats/js-multiaddr/multiaddr"),fo=[l("dns").code,l("dns4").code,l("dns6").code,l("dnsaddr").code],It=class r{bytes;#t;#e;#r;#n;[be]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=xe(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=ur(t)}else if(hr(t))e=xe(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??""}`),fo.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(we(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=fr.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)}[lo](){return`Multiaddr(${this.#t})`}};var fr=new Map;function hr(r){return!!r?.[be]}function $(r){return new It(r)}var ho=s("dns4"),mo=s("dns6"),go=s("dnsaddr"),J=m(s("dns"),go,ho,mo),Ct=m(s("ip4"),s("ip6")),it=m(a(Ct,s("tcp")),a(J,s("tcp"))),Dt=a(Ct,s("udp")),xo=a(Dt,s("utp")),wo=a(Dt,s("quic")),bo=a(Dt,s("quic-v1")),ye=m(a(it,s("ws")),a(J,s("ws"))),Tt=m(a(ye,s("p2p")),ye),ve=m(a(it,s("wss")),a(J,s("wss")),a(it,s("tls"),s("ws")),a(J,s("tls"),s("ws"))),Pt=m(a(ve,s("p2p")),ve),Ee=m(a(it,s("http")),a(Ct,s("http")),a(J,s("http"))),Se=m(a(it,s("https")),a(Ct,s("https")),a(J,s("https"))),mr=a(Dt,s("webrtc-direct"),s("certhash")),wr=m(a(mr,s("p2p")),mr),gr=a(bo,s("webtransport"),s("certhash"),s("certhash")),br=m(a(gr,s("p2p")),gr),yr=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"))),Lc=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"))),vr=m(a(Ee,s("p2p-webrtc-direct"),s("p2p")),a(Se,s("p2p-webrtc-direct"),s("p2p")),a(Ee,s("p2p-webrtc-direct")),a(Se,s("p2p-webrtc-direct"))),X=m(ye,ve,Ee,Se,yr,vr,it,xo,wo,J,wr,br),kc=m(a(X,s("p2p-stardust"),s("p2p")),a(X,s("p2p-stardust"))),j=m(a(X,s("p2p")),yr,vr,wr,br,s("p2p")),xr=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")),Er=()=>m(a(xr,Er),xr),H=Er(),Sr=m(a(H,j,H),a(j,H),a(H,j),H,j);var _c=m(a(H,s("webrtc"),s("p2p")),a(H,s("webrtc")),a(X,s("webrtc"),s("p2p")),a(X,s("webrtc")),s("webrtc"));function Ar(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:Ar(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:Ar(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 yo="bootstrap",vo=50,Eo=12e4,So=1e3,Ae=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??So,this.list=[];for(let n of e.list){if(!Sr.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:ee(i),multiaddrs:[o]};this.list.push(c)}this._init=e}[Ie]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Pe]=["@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??yo]:{value:this._init.tagValue??vo,ttl:this._init.tagTTL??Eo}}}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function Ao(r){return t=>new Ae(t,r)}return Dr(Io);})();
|
|
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.5",
|
|
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": "^1.
|
|
58
|
-
"@libp2p/peer-id": "^4.2.
|
|
57
|
+
"@libp2p/interface": "^1.7.0",
|
|
58
|
+
"@libp2p/peer-id": "^4.2.4",
|
|
59
59
|
"@multiformats/mafmt": "^12.1.6",
|
|
60
60
|
"@multiformats/multiaddr": "^12.2.3"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@libp2p/interface-compliance-tests": "^5.4.
|
|
64
|
-
"@libp2p/logger": "^4.0.
|
|
63
|
+
"@libp2p/interface-compliance-tests": "^5.4.12",
|
|
64
|
+
"@libp2p/logger": "^4.0.20",
|
|
65
65
|
"aegir": "^44.0.1",
|
|
66
66
|
"sinon-ts": "^2.0.0"
|
|
67
67
|
},
|