diff --git a/patches/@libp2p+tcp+10.0.6.patch b/patches/@libp2p+tcp+10.0.6.patch index a2119d9..8a6bf4d 100644 --- a/patches/@libp2p+tcp+10.0.6.patch +++ b/patches/@libp2p+tcp+10.0.6.patch @@ -1,11 +1,11 @@ diff --git a/node_modules/@libp2p/tcp/dist/index.min.js b/node_modules/@libp2p/tcp/dist/index.min.js -index d8da222..db2e557 100644 +index d8da222..efe7618 100644 --- a/node_modules/@libp2p/tcp/dist/index.min.js +++ b/node_modules/@libp2p/tcp/dist/index.min.js @@ -1,3 +1,3 @@ (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PTcp = factory()}(typeof self !== 'undefined' ? self : this, function () { -"use strict";var Libp2PTcp=(()=>{var Nr=Object.create;var ge=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Lr=Object.getOwnPropertyNames;var $r=Object.getPrototypeOf,Or=Object.prototype.hasOwnProperty;var F=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var U=(r,e)=>{for(var t in e)ge(r,t,{get:e[t],enumerable:!0})},Ut=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Lr(e))!Or.call(r,o)&&o!==t&&ge(r,o,{get:()=>e[o],enumerable:!(n=Fr(e,o))||n.enumerable});return r};var de=(r,e,t)=>(t=r!=null?Nr($r(r)):{},Ut(e||!r||!r.__esModule?ge(t,"default",{value:r,enumerable:!0}):t,r)),zr=r=>Ut(ge({},"__esModule",{value:!0}),r);var Oo={};U(Oo,{tcp:()=>$o});var Mr=de(F("net"),1);var Dt=Symbol.for("@libp2p/transport");var kt;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(kt||(kt={}));var q=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var z=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}};var ee=class extends Error{static name="TimeoutError";constructor(e="Timed out"){super(e),this.name="TimeoutError"}},we=class extends Error{static name="NotStartedError";constructor(e="Not started"){super(e),this.name="NotStartedError"}},be=class extends Error{static name="AlreadyStartedError";constructor(e="Already started"){super(e),this.name="AlreadyStartedError"}};var Mt=F("events"),Nt=(r,...e)=>{try{(0,Mt.setMaxListeners)(r,...e)}catch{}};var ye=class extends EventTarget{#e=new Map;constructor(){super(),Nt(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var Ft=Symbol.for("@libp2p/service-capabilities"),qo=Symbol.for("@libp2p/service-dependencies");var Be={};U(Be,{base58btc:()=>T,base58flickr:()=>qr});var hs=new Uint8Array(0);function Lt(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n>>0,k=new Uint8Array($);g!==v;){for(var O=d[g],j=0,N=$-1;(O!==0||j>>0,k[N]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");S=j,g++}for(var B=$-S;B!==$&&k[B]===0;)B++;for(var xe=p.repeat(x);B<$;++B)xe+=r.charAt(k[B]);return xe}function I(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var x=0;if(d[x]!==" "){for(var S=0,g=0;d[x]===p;)S++,x++;for(var v=(d.length-x)*w+1>>>0,$=new Uint8Array(v);d[x];){var k=t[d.charCodeAt(x)];if(k===255)return;for(var O=0,j=v-1;(k!==0||O>>0,$[j]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");g=O,x++}if(d[x]!==" "){for(var N=v-g;N!==v&&$[N]===0;)N++;for(var B=new Uint8Array(S+(v-N)),xe=S;N!==v;)B[xe++]=$[N++];return B}}}function f(d){var x=I(d);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:E,decodeUnsafe:I,decode:f}}var Br=Vr,Rr=Br,Vt=Rr;var $e=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Oe=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Bt(this,e)}},ze=class{decoders;constructor(e){this.decoders=e}or(e){return Bt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Bt(r,e){return new ze({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ve=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new $e(e,t,n),this.decoder=new Oe(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function te({name:r,prefix:e,encode:t,decode:n}){return new Ve(r,e,t,n)}function W({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Vt(t,r);return te({prefix:e,name:r,encode:n,decode:s=>D(o(s))})}function _r(r,e,t,n){let o={};for(let u=0;u=8&&(a-=8,i[w++]=255&p>>a)}if(a>=t||255&p<<8-a)throw new SyntaxError("Unexpected end of data");return i}function jr(r,e,t){let n=e[e.length-1]==="=",o=(1<t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<R,base32hex:()=>Jr,base32hexpad:()=>Qr,base32hexpadupper:()=>Kr,base32hexupper:()=>Xr,base32pad:()=>Gr,base32padupper:()=>Hr,base32upper:()=>Wr,base32z:()=>Zr});var R=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wr=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gr=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hr=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jr=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xr=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qr=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Kr=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zr=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _e={};U(_e,{base36:()=>ue,base36upper:()=>Yr});var ue=W({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yr=W({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var en=jt,Rt=128,tn=127,rn=~tn,nn=Math.pow(2,31);function jt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=nn;)e[t++]=r&255|Rt,r/=128;for(;r&rn;)e[t++]=r&255|Rt,r>>>=7;return e[t]=r|0,jt.bytes=t-n+1,e}var on=je,sn=128,_t=127;function je(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw je.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&_t)<=sn);return je.bytes=s-n,t}var cn=Math.pow(2,7),an=Math.pow(2,14),ln=Math.pow(2,21),dn=Math.pow(2,28),un=Math.pow(2,35),pn=Math.pow(2,42),fn=Math.pow(2,49),hn=Math.pow(2,56),mn=Math.pow(2,63),xn=function(r){return r{let[E,I]=fe(e.subarray(t));return t+=I,E},o=n(),s=he;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),p=n(),w=t+p,u=w-i;return{version:o,codec:s,multihashCode:a,digestSize:p,multihashSize:u,size:w}}static parse(e,t){let[n,o]=bn(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qe(s).set(n,e),s}};function bn(r,e){switch(r[0]){case"Q":{let t=e??T;return[T.prefix,t.decode(`${T.prefix}${r}`)]}case T.prefix:{let t=e??T;return[T.prefix,t.decode(r)]}case R.prefix:{let t=e??R;return[R.prefix,t.decode(r)]}case ue.prefix:{let t=e??ue;return[ue.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function yn(r,e,t){let{prefix:n}=t;if(n!==T.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function vn(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var he=112,En=18;function Ht(r,e,t){let n=ne(r),o=n+ne(e),s=new Uint8Array(o+t.byteLength);return re(r,s,0),re(e,s,n),s.set(t,o),s}var An=Symbol.for("@ipld/js-cid/CID");function Jt(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;tIn});var In=W({prefix:"9",name:"base10",alphabet:"0123456789"});var Ge={};U(Ge,{base16:()=>Cn,base16upper:()=>Sn});var Cn=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sn=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var He={};U(He,{base2:()=>Tn});var Tn=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Je={};U(Je,{base256emoji:()=>Mn});var Xt=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}"),Pn=Xt.reduce((r,e,t)=>(r[t]=e,r),[]),Un=Xt.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function kn(r){return r.reduce((e,t)=>(e+=Pn[t],e),"")}function Dn(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=Un[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var Mn=te({prefix:"\u{1F680}",name:"base256emoji",encode:kn,decode:Dn});var Xe={};U(Xe,{base64:()=>Nn,base64pad:()=>Fn,base64url:()=>Ln,base64urlpad:()=>$n});var Nn=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fn=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ln=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$n=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Qe={};U(Qe,{base8:()=>On});var On=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ke={};U(Ke,{identity:()=>zn});var zn=te({prefix:"\0",name:"identity",encode:r=>Ot(r),decode:r=>$t(r)});var Bs=new TextEncoder,Rs=new TextDecoder;var Ze={};U(Ze,{identity:()=>jn});var Qt=0,Rn="identity",Kt=D;function _n(r){return X(Qt,Kt(r))}var jn={code:Qt,name:Rn,encode:Kt,digest:_n};var rt={};U(rt,{sha256:()=>qn,sha512:()=>Wn});var tt=de(F("crypto"),1);function et({name:r,code:e,encode:t}){return new Ye(r,e,t)}var Ye=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?X(this.code,t):t.then(n=>X(this.code,n))}else throw Error("Unknown type, must be binary type")}};var qn=et({name:"sha2-256",code:18,encode:r=>D(tt.default.createHash("sha256").update(r).digest())}),Wn=et({name:"sha2-512",code:19,encode:r=>D(tt.default.createHash("sha512").update(r).digest())});var me={...Ke,...He,...Qe,...We,...Ge,...Re,..._e,...Be,...Xe,...Je},ti={...rt,...Ze};var Yt=F("node:buffer");function ie(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Ae(r=0){return ie(Yt.Buffer.allocUnsafe(r))}function tr(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var er=tr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),nt=tr("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=Ae(r.length);for(let t=0;tNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Qn(r,e,t=0){switch(V(r)){case 8:e[t++]=r&255|h,r/=128;case 7:e[t++]=r&255|h,r/=128;case 6:e[t++]=r&255|h,r/=128;case 5:e[t++]=r&255|h,r/=128;case 4:e[t++]=r&255|h,r>>>=7;case 3:e[t++]=r&255|h,r>>>=7;case 2:e[t++]=r&255|h,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Kn(r,e,t=0){switch(V(r)){case 8:e.set(t++,r&255|h),r/=128;case 7:e.set(t++,r&255|h),r/=128;case 6:e.set(t++,r&255|h),r/=128;case 5:e.set(t++,r&255|h),r/=128;case 4:e.set(t++,r&255|h),r>>>=7;case 3:e.set(t++,r&255|h),r>>>=7;case 2:e.set(t++,r&255|h),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Zn(r,e){let t=r[e],n=0;if(n+=t&C,t=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let p=a==="0",w=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let E=this.readChar();if(E===void 0)return;let I=Number.parseInt(E,e);if(!Number.isNaN(I))return I});if(u===void 0)break;if(s*=e,s+=u,s>w||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&p&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;tthis.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;nthis.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var xi=new Ce;var Ii=parseInt("0xFFFF",16),Ci=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var cr=F("node:buffer");function at(r,e="utf8"){let t=Ie[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ie(cr.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var M=F("node:net");function Se(r){return!!(0,M.isIP)(r)}var ar=M.isIPv4,so=M.isIPv6,lt=function(r){let e=0;if(r=r.toString().trim(),ar(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(so(r)){let t=r.split(":",8),n;for(n=0;n0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},lr=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s{let e=ao(...r);dt[e.code]=e,ae[e.name]=e});function ao(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function m(r){if(typeof r=="number"){if(dt[r]!=null)return dt[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ae[r]!=null)return ae[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var pc=m("ip4"),fc=m("ip6"),hc=m("ipcidr");function ht(r,e){switch(m(r).code){case 4:case 41:return uo(e);case 42:return ft(e);case 6:case 273:case 33:case 132:return pr(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ft(e);case 421:return mo(e);case 444:return ur(e);case 445:return ur(e);case 466:return ho(e);case 481:return globalThis.encodeURIComponent(ft(e));default:return P(e,"base16")}}function mt(r,e){switch(m(r).code){case 4:return dr(e);case 41:return dr(e);case 42:return pt(e);case 6:case 273:case 33:case 132:return xt(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return pt(e);case 421:return po(e);case 444:return xo(e);case 445:return go(e);case 466:return fo(e);case 481:return pt(globalThis.decodeURIComponent(e));default:return at(e,"base16")}}var ut=Object.values(me).map(r=>r.decoder),lo=function(){let r=ut[0].or(ut[1]);return ut.slice(2).forEach(e=>r=r.or(e)),r}();function dr(r){if(!Se(r))throw new Error("invalid ip address");return lt(r)}function uo(r){let e=lr(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Se(e))throw new Error("invalid ip address");return e}function xt(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function pr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function pt(r){let e=at(r),t=Uint8Array.from(ce(e.length));return _([t,e],t.length+e.length)}function ft(r){let e=Q(r);if(r=r.slice(V(e)),r.length!==e)throw new Error("inconsistent lengths");return P(r)}function po(r){let e;r[0]==="Q"||r[0]==="1"?e=Ee(T.decode(`z${r}`)).bytes:e=G.parse(r).multihash.bytes;let t=Uint8Array.from(ce(e.length));return _([t,e],t.length+e.length)}function fo(r){let e=lo.decode(r),t=Uint8Array.from(ce(e.length));return _([t,e],t.length+e.length)}function ho(r){let e=Q(r),t=r.slice(V(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+P(t,"base64url")}function mo(r){let e=Q(r),t=r.slice(V(e));if(t.length!==e)throw new Error("inconsistent lengths");return P(t,"base58btc")}function xo(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=R.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=xt(n);return _([t,o],t.length+o.length)}function go(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=R.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=xt(n);return _([t,o],t.length+o.length)}function ur(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=P(e,"base32"),o=pr(t);return`${n}:${o}`}function fr(r){r=gt(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s=o.length)throw mr("invalid address: "+r);if(a.path===!0){n=gt(o.slice(s).join("/")),e.push([a.code,mt(a.code,n)]),t.push([a.code,n]);break}let p=mt(a.code,o[s]);e.push([a.code,p]),t.push([a.code,ht(a.code,p)])}return{string:hr(t),bytes:bt(e),tuples:e,stringTuples:t,path:n}}function wt(r){let e=[],t=[],n=null,o=0;for(;or.length)throw mr("Invalid address Uint8Array: "+P(r,"base16"));e.push([s,w]);let u=ht(s,w);if(t.push([s,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:hr(t),tuples:e,stringTuples:t,path:n}}function hr(r){let e=[];return r.map(t=>{let n=m(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),gt(e.join("/"))}function bt(r){return _(r.map(e=>{let t=m(e[0]),n=Uint8Array.from(ce(t.code));return e.length>1&&e[1]!=null&&(n=_([n,e[1]])),n}))}function wo(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Q(e instanceof Uint8Array?e:Uint8Array.from(e));return t+V(t)}}function gt(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function mr(r){return new Error("Error parsing address: "+r)}var bo=Symbol.for("nodejs.util.inspect.custom"),vt=Symbol.for("@multiformats/js-multiaddr/multiaddr"),yo=[m("dns").code,m("dns4").code,m("dns6").code,m("dnsaddr").code],yt=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Te=class r{bytes;#e;#t;#r;#n;[vt]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=wt(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=fr(e)}else if(gr(e))t=wt(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=m("tcp"),a=m("udp"),p=m("ip4"),w=m("ip6"),u=m("dns6"),E=m("ip6zone");for(let[f,d]of this.stringTuples())f===E.code&&(s=`%${d??""}`),yo.includes(f)&&(t=i.name,o=443,n=`${d??""}${s}`,e=f===u.code?6:4),(f===i.code||f===a.code)&&(t=m(f).name,o=parseInt(d??"")),(f===p.code||f===w.code)&&(t=m(f).name,n=`${d??""}${s}`,e=f===w.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},m(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>m(e).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(bt(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===ae.p2p.code&&e.push([n,o]),n===ae["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?P(T.decode(`z${n}`),"base58btc"):P(G.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Jt(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=xr.get(t.name);if(n==null)throw new yt(`no available resolver for ${t.name}`);return(await n(this,e)).map(s=>L(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[bo](){return`Multiaddr(${this.#e})`}};var xr=new Map;function gr(r){return!!r?.[vt]}function L(r){return new Te(r)}var vo=c("dns4"),Eo=c("dns6"),Ao=c("dnsaddr"),Z=y(c("dns"),Ao,vo,Eo),ke=y(c("ip4"),c("ip6")),J=y(l(ke,c("tcp")),l(Z,c("tcp"))),De=l(ke,c("udp")),Io=l(De,c("utp")),Co=l(De,c("quic")),So=l(De,c("quic-v1")),Et=y(l(J,c("ws")),l(Z,c("ws"))),Pe=y(l(Et,c("p2p")),Et),At=y(l(J,c("wss")),l(Z,c("wss")),l(J,c("tls"),c("ws")),l(Z,c("tls"),c("ws"))),Ue=y(l(At,c("p2p")),At),It=y(l(J,c("http")),l(ke,c("http")),l(Z,c("http"))),Ct=y(l(J,c("https")),l(ke,c("https")),l(Z,c("https"))),wr=l(De,c("webrtc-direct"),c("certhash")),vr=y(l(wr,c("p2p")),wr),br=l(So,c("webtransport"),c("certhash"),c("certhash")),Er=y(l(br,c("p2p")),br),Ar=y(l(Pe,c("p2p-webrtc-star"),c("p2p")),l(Ue,c("p2p-webrtc-star"),c("p2p")),l(Pe,c("p2p-webrtc-star")),l(Ue,c("p2p-webrtc-star"))),Vc=y(l(Pe,c("p2p-websocket-star"),c("p2p")),l(Ue,c("p2p-websocket-star"),c("p2p")),l(Pe,c("p2p-websocket-star")),l(Ue,c("p2p-websocket-star"))),Ir=y(l(It,c("p2p-webrtc-direct"),c("p2p")),l(Ct,c("p2p-webrtc-direct"),c("p2p")),l(It,c("p2p-webrtc-direct")),l(Ct,c("p2p-webrtc-direct"))),Y=y(Et,At,It,Ct,Ar,Ir,J,Io,Co,Z,vr,Er),Bc=y(l(Y,c("p2p-stardust"),c("p2p")),l(Y,c("p2p-stardust"))),H=y(l(Y,c("p2p")),Ar,Ir,vr,Er,c("p2p")),yr=y(l(H,c("p2p-circuit"),H),l(H,c("p2p-circuit")),l(c("p2p-circuit"),H),l(Y,c("p2p-circuit")),l(c("p2p-circuit"),Y),c("p2p-circuit")),Cr=()=>y(l(yr,Cr),yr),K=Cr(),Rc=y(l(K,H,K),l(H,K),l(K,H),K,H);var _c=y(l(K,c("webrtc"),c("p2p")),l(K,c("webrtc")),l(Y,c("webrtc"),c("p2p")),l(Y,c("webrtc")),c("webrtc"));function Sr(r){function e(t){let n;try{n=L(t)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function l(...r){function e(t){if(t.length(n=typeof o=="function"?o().partialMatch(t):o.partialMatch(t),Array.isArray(n)&&(t=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Sr(e),partialMatch:e}}function y(...r){function e(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Sr(e),partialMatch:e}}function c(r){let e=r;function t(o){let s;try{s=L(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:t,partialMatch:n}}var Me=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var Dr=de(F("net"),1);function Tr(r,e){if(typeof r!="string")throw new z(`invalid ip provided: ${r}`);if(typeof e=="string"&&(e=parseInt(e)),isNaN(e))throw new z(`invalid port provided: ${e}`);if((0,M.isIPv4)(r))return L(`/ip4/${r}/tcp/${e}`);if((0,M.isIPv6)(r))return L(`/ip6/${r}/tcp/${e}`);throw new z(`invalid ip:port for creating a multiaddr: ${r}:${e}`)}function Pr(r){if(Uo(r))return async function*(){let e=r.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)return;yield n}}finally{e.releaseLock()}}();if(Po(r))return r;throw new Error("unknown stream")}function Po(r){return r[Symbol.asyncIterator]!=null}function Uo(r){return typeof r?.getReader=="function"}function Ur(r){return async e=>{let t=async()=>{ko(e)&&await e.return(void 0)},n,o,s=g=>{n=g,t().catch(v=>{v=new AggregateError([n,v],"The Writable emitted an error, additionally an error occurred while ending the Source")}).finally(()=>{o?.(g)})},i,a=!1,p=()=>{a=!0,i?.()},w,u=!1,E=()=>{u=!0,w?.()},I,f=()=>{I?.()},d=async()=>new Promise((g,v)=>{i=I=g,o=v,r.once("drain",f)}),x=async()=>(await t(),new Promise((g,v)=>{if(a||u||n!=null){g();return}w=i=g,o=v})),S=()=>{r.removeListener("error",s),r.removeListener("close",p),r.removeListener("finish",E),r.removeListener("drain",f)};r.once("error",s),r.once("close",p),r.once("finish",E);try{for await(let g of e){if(!r.writable||r.destroyed||n!=null)break;r.write(g)||await d()}}catch(g){n==null&&r.destroy(g),n=g}try{if(r.writable&&r.end(),await x(),n!=null)throw n}finally{S()}}}function ko(r){return r.return!=null}function St(r){return{sink:Ur(r),source:Pr(r)}}var Tt=de(F("os"),1),kr=de(F("path"),1);var Do={ip4:"IPv4",ip6:"IPv6"};function le(r,e={}){let t=r.getPath();return t!=null?Tt.default.platform()==="win32"?{path:kr.default.join("\\\\.\\pipe\\",t)}:{path:t}:{...e,...r.toOptions()}}function Pt(r,e,t){let n=o=>L(`/${r}/${o}/tcp/${t}`);return(Mo(e)?Fo(Do[r]):[e]).map(n)}function Mo(r){return["0.0.0.0","::"].includes(r)}var No=Tt.default.networkInterfaces();function Fo(r){let e=[];for(let[,t]of Object.entries(No))if(t!=null)for(let n of t)n.family===r&&e.push(n.address);return e}var Ne=(r,e)=>{let t=null,n=e.logger.forComponent("libp2p:tcp:socket"),o=e.metrics,s=e.metricPrefix??"",i=e.socketInactivityTimeout??3e5,a=e.socketCloseTimeout??500;e.listeningAddr?.getPath()!=null&&(e.remoteAddr=e.listeningAddr),e.remoteAddr?.getPath()!=null&&(e.localAddr=e.remoteAddr);let p;if(e.remoteAddr!=null)p=e.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null)throw new z("Could not determine remote address or port");p=Tr(r.remoteAddress,r.remotePort)}let w=le(p),u=w.path??`${w.host??""}:${w.port??""}`,{sink:E,source:I}=St(r);r.setTimeout(i,()=>{n("%s socket read timeout",u),o?.increment({[`${s}timeout`]:!0});let d;r.readable&&(d=new ee("Socket read timeout")),r.destroy(d)}),r.once("close",()=>{n("%s socket close",u),o?.increment({[`${s}close`]:!0}),f.timeline.close==null&&(f.timeline.close=Date.now())}),r.once("end",()=>{n("%s socket end",u),o?.increment({[`${s}end`]:!0})});let f={async sink(d){try{await E(async function*(){for await(let x of d)x instanceof Uint8Array?yield x:yield x.subarray()}())}catch(x){x.type!=="aborted"&&n.error("%s error in sink",u,x)}r.end()},source:I,remoteAddr:p,timeline:{open:Date.now()},async close(d={}){if(r.closed){n("The %s socket is already closed",u);return}if(r.destroyed){n("The %s socket is already destroyed",u);return}let x=()=>{r.destroy(new q("Destroying socket after timeout"))};try{if(t!=null){n("The %s socket is already closing",u),await t;return}if(d.signal==null){let S=AbortSignal.timeout(a);d={...d,signal:S}}d.signal?.addEventListener("abort",x),n("%s closing socket",u),t=new Promise((S,g)=>{r.once("close",()=>{n("%s socket closed",u),S()}),r.once("error",v=>{n("%s socket error",u,v),r.destroyed||g(v)}),r.setTimeout(a),r.end(),r.writableLength>0?r.once("drain",()=>{n("%s socket drained",u),r.destroy()}):r.destroy()}),await t}catch(S){this.abort(S)}finally{d.signal?.removeEventListener("abort",x)}},abort:d=>{n("%s socket abort due to error",u,d),r.destroyed||r.destroy(d),f.timeline.close==null&&(f.timeline.close=Date.now())},log:n};return f};var A;(function(r){r[r.INACTIVE=0]="INACTIVE",r[r.ACTIVE=1]="ACTIVE",r[r.PAUSED=2]="PAUSED"})(A||(A={}));var Fe=class extends ye{context;server;connections=new Set;status={code:A.INACTIVE};metrics;addr;log;constructor(e){if(super(),this.context=e,e.keepAlive=e.keepAlive??!0,e.noDelay=e.noDelay??!0,this.log=e.logger.forComponent("libp2p:tcp:listener"),this.addr="unknown",this.server=Dr.default.createServer(e,this.onSocket.bind(this)),e.maxConnections!==void 0&&(this.server.maxConnections=e.maxConnections),e.closeServerOnMaxConnections!=null&&e.closeServerOnMaxConnections.closeAbove= listenBelow");this.server.on("listening",()=>{if(e.metrics!=null){let t=this.server.address();t==null?this.addr="unknown":typeof t=="string"?this.addr=t:this.addr=`${t.address}:${t.port}`,e.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:e.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:e.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:e.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:A.ACTIVE})}this.safeDispatchEvent("listening")}).on("error",t=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.safeDispatchEvent("error",{detail:t})}).on("close",()=>{this.metrics?.status.update({[this.addr]:this.status.code}),this.status.code!==A.PAUSED&&this.safeDispatchEvent("close")})}onSocket(e){if(this.status.code!==A.ACTIVE)throw e.destroy(),new we("Server is not listening yet");e.on("error",n=>{this.log("socket error",n),this.metrics?.events.increment({[`${this.addr} error`]:!0})});let t;try{t=Ne(e,{listeningAddr:this.status.listeningAddr,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `,logger:this.context.logger})}catch(n){this.log.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}this.log("new inbound connection %s",t.remoteAddr),this.context.upgrader.upgradeInbound(t).then(n=>{this.log("inbound connection upgraded %s",t.remoteAddr),this.connections.add(t),e.once("close",()=>{this.connections.delete(t),this.context.closeServerOnMaxConnections!=null&&this.connections.size{this.log.error("error attempting to listen server once connection count under limit",o),this.context.closeServerOnMaxConnections?.onListenError?.(o)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.pause(!1).catch(o=>{this.log.error("error attempting to close server once connection count over limit",o)}),this.safeDispatchEvent("connection",{detail:n})}).catch(async n=>{this.log.error("inbound connection upgrade failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),t.abort(n)})}getAddrs(){if(this.status.code===A.INACTIVE)return[];let e=[],t=this.server.address(),{listeningAddr:n,peerId:o}=this.status;if(t==null)return[];if(typeof t=="string")e=[n];else try{n.toString().startsWith("/ip4")?e=e.concat(Pt("ip4",t.address,t.port)):t.family==="IPv6"&&(e=e.concat(Pt("ip6",t.address,t.port)))}catch(s){this.log.error("could not turn %s:%s into multiaddr",t.address,t.port,s)}return e.map(s=>o!=null?s.encapsulate(`/p2p/${o}`):s)}async listen(e){if(this.status.code===A.ACTIVE||this.status.code===A.PAUSED)throw new be("server is already listening");let t=e.getPeerId(),n=t==null?e.decapsulateCode(421):e,{backlog:o}=this.context;try{this.status={code:A.ACTIVE,listeningAddr:n,peerId:t,netConfig:le(n,{backlog:o})},await this.resume()}catch(s){throw this.status={code:A.INACTIVE},s}}async close(){let e=new q("Listener is closing");this.connections.forEach(t=>{t.abort(e)}),await this.pause(!0)}async resume(){if(this.server.listening||this.status.code===A.INACTIVE)return;let e=this.status.netConfig;await new Promise((t,n)=>{this.server.once("error",n),this.server.listen(e,t)}),this.status={...this.status,code:A.ACTIVE},this.log("listening on %s",this.server.address())}async pause(e){if(!this.server.listening&&this.status.code===A.PAUSED&&e){this.status={code:A.INACTIVE};return}!this.server.listening||this.status.code!==A.ACTIVE||(this.log("closing server on %s",this.server.address()),this.status=e?{code:A.INACTIVE}:{...this.status,code:A.PAUSED},await new Promise((t,n)=>{this.server.close(o=>{if(o!=null){n(o);return}t()})}))}};var Le=class{opts;metrics;components;log;constructor(e,t={}){this.log=e.logger.forComponent("libp2p:tcp"),this.opts=t,this.components=e,e.metrics!=null&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[Dt]=!0;[Symbol.toStringTag]="@libp2p/tcp";[Ft]=["@libp2p/transport"];async dial(e,t){t.keepAlive=t.keepAlive??!0,t.noDelay=t.noDelay??!0;let n=await this._connect(e,t);n.on("error",s=>{this.log("socket error",s)});let o=Ne(n,{remoteAddr:e,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents,logger:this.components.logger});try{return this.log("new outbound connection %s",o.remoteAddr),await t.upgrader.upgradeOutbound(o,t)}catch(s){throw this.log.error("error upgrading outbound connection",s),o.abort(s),s}}async _connect(e,t){return t.signal?.throwIfAborted(),t.onProgress?.(new Me("tcp:open-connection")),new Promise((n,o)=>{let s=Date.now(),i=le(e,{...this.opts.dialOpts??{},...t});this.log("dialing %a",e);let a=Mr.default.connect(i),p=f=>{let d=i.path??`${i.host??""}:${i.port}`;f.message=`connection error ${d}: ${f.message}`,this.metrics?.dialerEvents.increment({error:!0}),I(f)},w=()=>{this.log("connection timeout %a",e),this.metrics?.dialerEvents.increment({timeout:!0});let f=new ee(`connection timeout after ${Date.now()-s}ms`);a.emit("error",f)},u=()=>{this.log("connection opened %a",e),this.metrics?.dialerEvents.increment({connect:!0}),I()},E=()=>{this.log("connection aborted %a",e),this.metrics?.dialerEvents.increment({abort:!0}),a.destroy(),I(new q)},I=f=>{if(a.removeListener("error",p),a.removeListener("timeout",w),a.removeListener("connect",u),t.signal!=null&&t.signal.removeEventListener("abort",E),f!=null){o(f);return}n(a)};a.on("error",p),a.on("timeout",w),a.on("connect",u),t.signal!=null&&t.signal.addEventListener("abort",E)})}createListener(e){return new Fe({...this.opts.listenOpts??{},...e,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics,logger:this.components.logger})}listenFilter(e){return e=Array.isArray(e)?e:[e],e.filter(t=>t.protoCodes().includes(290)?!1:t.protoCodes().includes(400)?!0:J.matches(t.decapsulateCode(421)))}dialFilter(e){return this.listenFilter(e)}};function $o(r={}){return e=>new Le(e,r)}return zr(Oo);})(); -+"use strict";var Libp2PTcp=(()=>{var Nr=Object.create;var ge=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Lr=Object.getOwnPropertyNames;var $r=Object.getPrototypeOf,Or=Object.prototype.hasOwnProperty;var F=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var U=(r,e)=>{for(var t in e)ge(r,t,{get:e[t],enumerable:!0})},Ut=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Lr(e))!Or.call(r,o)&&o!==t&&ge(r,o,{get:()=>e[o],enumerable:!(n=Fr(e,o))||n.enumerable});return r};var le=(r,e,t)=>(t=r!=null?Nr($r(r)):{},Ut(e||!r||!r.__esModule?ge(t,"default",{value:r,enumerable:!0}):t,r)),zr=r=>Ut(ge({},"__esModule",{value:!0}),r);var Oo={};U(Oo,{tcp:()=>$o});var kr=le(F("net"),1);var Mt=Symbol.for("@libp2p/transport");var Dt;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Dt||(Dt={}));var q=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var z=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}};var ee=class extends Error{static name="TimeoutError";constructor(e="Timed out"){super(e),this.name="TimeoutError"}},we=class extends Error{static name="NotStartedError";constructor(e="Not started"){super(e),this.name="NotStartedError"}},be=class extends Error{static name="AlreadyStartedError";constructor(e="Already started"){super(e),this.name="AlreadyStartedError"}};var kt=F("events"),Nt=(r,...e)=>{try{(0,kt.setMaxListeners)(r,...e)}catch{}};var ye=class extends EventTarget{#e=new Map;constructor(){super(),Nt(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var Ft=Symbol.for("@libp2p/service-capabilities"),qo=Symbol.for("@libp2p/service-dependencies");var Be={};U(Be,{base58btc:()=>T,base58flickr:()=>qr});var hs=new Uint8Array(0);function Lt(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n>>0,D=new Uint8Array($);g!==v;){for(var O=d[g],j=0,N=$-1;(O!==0||j>>0,D[N]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");S=j,g++}for(var B=$-S;B!==$&&D[B]===0;)B++;for(var xe=p.repeat(x);B<$;++B)xe+=r.charAt(D[B]);return xe}function I(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var x=0;if(d[x]!==" "){for(var S=0,g=0;d[x]===p;)S++,x++;for(var v=(d.length-x)*w+1>>>0,$=new Uint8Array(v);d[x];){var D=t[d.charCodeAt(x)];if(D===255)return;for(var O=0,j=v-1;(D!==0||O>>0,$[j]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");g=O,x++}if(d[x]!==" "){for(var N=v-g;N!==v&&$[N]===0;)N++;for(var B=new Uint8Array(S+(v-N)),xe=S;N!==v;)B[xe++]=$[N++];return B}}}function f(d){var x=I(d);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:E,decodeUnsafe:I,decode:f}}var Br=Vr,Rr=Br,Vt=Rr;var $e=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Oe=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Bt(this,e)}},ze=class{decoders;constructor(e){this.decoders=e}or(e){return Bt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Bt(r,e){return new ze({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ve=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new $e(e,t,n),this.decoder=new Oe(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function te({name:r,prefix:e,encode:t,decode:n}){return new Ve(r,e,t,n)}function W({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Vt(t,r);return te({prefix:e,name:r,encode:n,decode:s=>M(o(s))})}function _r(r,e,t,n){let o={};for(let u=0;u=8&&(a-=8,i[w++]=255&p>>a)}if(a>=t||255&p<<8-a)throw new SyntaxError("Unexpected end of data");return i}function jr(r,e,t){let n=e[e.length-1]==="=",o=(1<t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<R,base32hex:()=>Jr,base32hexpad:()=>Qr,base32hexpadupper:()=>Kr,base32hexupper:()=>Xr,base32pad:()=>Gr,base32padupper:()=>Hr,base32upper:()=>Wr,base32z:()=>Zr});var R=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wr=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gr=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hr=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jr=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xr=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qr=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Kr=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zr=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _e={};U(_e,{base36:()=>ue,base36upper:()=>Yr});var ue=W({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yr=W({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var en=jt,Rt=128,tn=127,rn=~tn,nn=Math.pow(2,31);function jt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=nn;)e[t++]=r&255|Rt,r/=128;for(;r&rn;)e[t++]=r&255|Rt,r>>>=7;return e[t]=r|0,jt.bytes=t-n+1,e}var on=je,sn=128,_t=127;function je(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw je.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&_t)<=sn);return je.bytes=s-n,t}var cn=Math.pow(2,7),an=Math.pow(2,14),dn=Math.pow(2,21),ln=Math.pow(2,28),un=Math.pow(2,35),pn=Math.pow(2,42),fn=Math.pow(2,49),hn=Math.pow(2,56),mn=Math.pow(2,63),xn=function(r){return r{let[E,I]=fe(e.subarray(t));return t+=I,E},o=n(),s=he;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),p=n(),w=t+p,u=w-i;return{version:o,codec:s,multihashCode:a,digestSize:p,multihashSize:u,size:w}}static parse(e,t){let[n,o]=bn(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qe(s).set(n,e),s}};function bn(r,e){switch(r[0]){case"Q":{let t=e??T;return[T.prefix,t.decode(`${T.prefix}${r}`)]}case T.prefix:{let t=e??T;return[T.prefix,t.decode(r)]}case R.prefix:{let t=e??R;return[R.prefix,t.decode(r)]}case ue.prefix:{let t=e??ue;return[ue.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function yn(r,e,t){let{prefix:n}=t;if(n!==T.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function vn(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var he=112,En=18;function Ht(r,e,t){let n=ne(r),o=n+ne(e),s=new Uint8Array(o+t.byteLength);return re(r,s,0),re(e,s,n),s.set(t,o),s}var An=Symbol.for("@ipld/js-cid/CID");function Jt(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;tIn});var In=W({prefix:"9",name:"base10",alphabet:"0123456789"});var Ge={};U(Ge,{base16:()=>Cn,base16upper:()=>Sn});var Cn=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sn=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var He={};U(He,{base2:()=>Tn});var Tn=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Je={};U(Je,{base256emoji:()=>kn});var Xt=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}"),Pn=Xt.reduce((r,e,t)=>(r[t]=e,r),[]),Un=Xt.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function Dn(r){return r.reduce((e,t)=>(e+=Pn[t],e),"")}function Mn(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=Un[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var kn=te({prefix:"\u{1F680}",name:"base256emoji",encode:Dn,decode:Mn});var Xe={};U(Xe,{base64:()=>Nn,base64pad:()=>Fn,base64url:()=>Ln,base64urlpad:()=>$n});var Nn=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fn=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ln=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$n=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Qe={};U(Qe,{base8:()=>On});var On=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ke={};U(Ke,{identity:()=>zn});var zn=te({prefix:"\0",name:"identity",encode:r=>Ot(r),decode:r=>$t(r)});var Bs=new TextEncoder,Rs=new TextDecoder;var Ze={};U(Ze,{identity:()=>jn});var Qt=0,Rn="identity",Kt=M;function _n(r){return X(Qt,Kt(r))}var jn={code:Qt,name:Rn,encode:Kt,digest:_n};var rt={};U(rt,{sha256:()=>qn,sha512:()=>Wn});var tt=le(F("crypto"),1);function et({name:r,code:e,encode:t}){return new Ye(r,e,t)}var Ye=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?X(this.code,t):t.then(n=>X(this.code,n))}else throw Error("Unknown type, must be binary type")}};var qn=et({name:"sha2-256",code:18,encode:r=>M(tt.default.createHash("sha256").update(r).digest())}),Wn=et({name:"sha2-512",code:19,encode:r=>M(tt.default.createHash("sha512").update(r).digest())});var me={...Ke,...He,...Qe,...We,...Ge,...Re,..._e,...Be,...Xe,...Je},ti={...rt,...Ze};var Yt=F("node:buffer");function ie(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Ae(r=0){return ie(Yt.Buffer.allocUnsafe(r))}function tr(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var er=tr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),nt=tr("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=Ae(r.length);for(let t=0;tNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Qn(r,e,t=0){switch(V(r)){case 8:e[t++]=r&255|h,r/=128;case 7:e[t++]=r&255|h,r/=128;case 6:e[t++]=r&255|h,r/=128;case 5:e[t++]=r&255|h,r/=128;case 4:e[t++]=r&255|h,r>>>=7;case 3:e[t++]=r&255|h,r>>>=7;case 2:e[t++]=r&255|h,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Kn(r,e,t=0){switch(V(r)){case 8:e.set(t++,r&255|h),r/=128;case 7:e.set(t++,r&255|h),r/=128;case 6:e.set(t++,r&255|h),r/=128;case 5:e.set(t++,r&255|h),r/=128;case 4:e.set(t++,r&255|h),r>>>=7;case 3:e.set(t++,r&255|h),r>>>=7;case 2:e.set(t++,r&255|h),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Zn(r,e){let t=r[e],n=0;if(n+=t&C,t=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let p=a==="0",w=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let E=this.readChar();if(E===void 0)return;let I=Number.parseInt(E,e);if(!Number.isNaN(I))return I});if(u===void 0)break;if(s*=e,s+=u,s>w||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&p&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;tthis.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;nthis.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var xi=new Ce;var Ii=parseInt("0xFFFF",16),Ci=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var cr=F("node:buffer");function at(r,e="utf8"){let t=Ie[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ie(cr.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var k=F("node:net");function Se(r){return!!(0,k.isIP)(r)}var ar=k.isIPv4,so=k.isIPv6,dt=function(r){let e=0;if(r=r.toString().trim(),ar(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(so(r)){let t=r.split(":",8),n;for(n=0;n0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},dr=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s{let e=ao(...r);lt[e.code]=e,ae[e.name]=e});function ao(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function m(r){if(typeof r=="number"){if(lt[r]!=null)return lt[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ae[r]!=null)return ae[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var pc=m("ip4"),fc=m("ip6"),hc=m("ipcidr");function ht(r,e){switch(m(r).code){case 4:case 41:return uo(e);case 42:return ft(e);case 6:case 273:case 33:case 132:return pr(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ft(e);case 421:return mo(e);case 444:return ur(e);case 445:return ur(e);case 466:return ho(e);case 481:return globalThis.encodeURIComponent(ft(e));default:return P(e,"base16")}}function mt(r,e){switch(m(r).code){case 4:return lr(e);case 41:return lr(e);case 42:return pt(e);case 6:case 273:case 33:case 132:return xt(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return pt(e);case 421:return po(e);case 444:return xo(e);case 445:return go(e);case 466:return fo(e);case 481:return pt(globalThis.decodeURIComponent(e));default:return at(e,"base16")}}var ut=Object.values(me).map(r=>r.decoder),lo=function(){let r=ut[0].or(ut[1]);return ut.slice(2).forEach(e=>r=r.or(e)),r}();function lr(r){if(!Se(r))throw new Error("invalid ip address");return dt(r)}function uo(r){let e=dr(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Se(e))throw new Error("invalid ip address");return e}function xt(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function pr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function pt(r){let e=at(r),t=Uint8Array.from(ce(e.length));return _([t,e],t.length+e.length)}function ft(r){let e=Q(r);if(r=r.slice(V(e)),r.length!==e)throw new Error("inconsistent lengths");return P(r)}function po(r){let e;r[0]==="Q"||r[0]==="1"?e=Ee(T.decode(`z${r}`)).bytes:e=G.parse(r).multihash.bytes;let t=Uint8Array.from(ce(e.length));return _([t,e],t.length+e.length)}function fo(r){let e=lo.decode(r),t=Uint8Array.from(ce(e.length));return _([t,e],t.length+e.length)}function ho(r){let e=Q(r),t=r.slice(V(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+P(t,"base64url")}function mo(r){let e=Q(r),t=r.slice(V(e));if(t.length!==e)throw new Error("inconsistent lengths");return P(t,"base58btc")}function xo(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=R.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=xt(n);return _([t,o],t.length+o.length)}function go(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=R.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=xt(n);return _([t,o],t.length+o.length)}function ur(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=P(e,"base32"),o=pr(t);return`${n}:${o}`}function fr(r){r=gt(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s=o.length)throw mr("invalid address: "+r);if(a.path===!0){n=gt(o.slice(s).join("/")),e.push([a.code,mt(a.code,n)]),t.push([a.code,n]);break}let p=mt(a.code,o[s]);e.push([a.code,p]),t.push([a.code,ht(a.code,p)])}return{string:hr(t),bytes:bt(e),tuples:e,stringTuples:t,path:n}}function wt(r){let e=[],t=[],n=null,o=0;for(;or.length)throw mr("Invalid address Uint8Array: "+P(r,"base16"));e.push([s,w]);let u=ht(s,w);if(t.push([s,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:hr(t),tuples:e,stringTuples:t,path:n}}function hr(r){let e=[];return r.map(t=>{let n=m(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),gt(e.join("/"))}function bt(r){return _(r.map(e=>{let t=m(e[0]),n=Uint8Array.from(ce(t.code));return e.length>1&&e[1]!=null&&(n=_([n,e[1]])),n}))}function wo(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Q(e instanceof Uint8Array?e:Uint8Array.from(e));return t+V(t)}}function gt(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function mr(r){return new Error("Error parsing address: "+r)}var bo=Symbol.for("nodejs.util.inspect.custom"),vt=Symbol.for("@multiformats/js-multiaddr/multiaddr"),yo=[m("dns").code,m("dns4").code,m("dns6").code,m("dnsaddr").code],yt=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Te=class r{bytes;#e;#t;#r;#n;[vt]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=wt(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=fr(e)}else if(gr(e))t=wt(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=m("tcp"),a=m("udp"),p=m("ip4"),w=m("ip6"),u=m("dns6"),E=m("ip6zone");for(let[f,d]of this.stringTuples())f===E.code&&(s=`%${d??""}`),yo.includes(f)&&(t=i.name,o=443,n=`${d??""}${s}`,e=f===u.code?6:4),(f===i.code||f===a.code)&&(t=m(f).name,o=parseInt(d??"")),(f===p.code||f===w.code)&&(t=m(f).name,n=`${d??""}${s}`,e=f===w.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},m(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>m(e).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(bt(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===ae.p2p.code&&e.push([n,o]),n===ae["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?P(T.decode(`z${n}`),"base58btc"):P(G.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Jt(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=xr.get(t.name);if(n==null)throw new yt(`no available resolver for ${t.name}`);return(await n(this,e)).map(s=>L(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[bo](){return`Multiaddr(${this.#e})`}};var xr=new Map;function gr(r){return!!r?.[vt]}function L(r){return new Te(r)}var vo=c("dns4"),Eo=c("dns6"),Ao=c("dnsaddr"),Z=y(c("dns"),Ao,vo,Eo),De=y(c("ip4"),c("ip6")),J=y(l(De,c("tcp")),l(Z,c("tcp"))),Me=l(De,c("udp")),Io=l(Me,c("utp")),Co=l(Me,c("quic")),So=l(Me,c("quic-v1")),Et=y(l(J,c("ws")),l(Z,c("ws"))),Pe=y(l(Et,c("p2p")),Et),At=y(l(J,c("wss")),l(Z,c("wss")),l(J,c("tls"),c("ws")),l(Z,c("tls"),c("ws"))),Ue=y(l(At,c("p2p")),At),It=y(l(J,c("http")),l(De,c("http")),l(Z,c("http"))),Ct=y(l(J,c("https")),l(De,c("https")),l(Z,c("https"))),wr=l(Me,c("webrtc-direct"),c("certhash")),vr=y(l(wr,c("p2p")),wr),br=l(So,c("webtransport"),c("certhash"),c("certhash")),Er=y(l(br,c("p2p")),br),Ar=y(l(Pe,c("p2p-webrtc-star"),c("p2p")),l(Ue,c("p2p-webrtc-star"),c("p2p")),l(Pe,c("p2p-webrtc-star")),l(Ue,c("p2p-webrtc-star"))),Vc=y(l(Pe,c("p2p-websocket-star"),c("p2p")),l(Ue,c("p2p-websocket-star"),c("p2p")),l(Pe,c("p2p-websocket-star")),l(Ue,c("p2p-websocket-star"))),Ir=y(l(It,c("p2p-webrtc-direct"),c("p2p")),l(Ct,c("p2p-webrtc-direct"),c("p2p")),l(It,c("p2p-webrtc-direct")),l(Ct,c("p2p-webrtc-direct"))),Y=y(Et,At,It,Ct,Ar,Ir,J,Io,Co,Z,vr,Er),Bc=y(l(Y,c("p2p-stardust"),c("p2p")),l(Y,c("p2p-stardust"))),H=y(l(Y,c("p2p")),Ar,Ir,vr,Er,c("p2p")),yr=y(l(H,c("p2p-circuit"),H),l(H,c("p2p-circuit")),l(c("p2p-circuit"),H),l(Y,c("p2p-circuit")),l(c("p2p-circuit"),Y),c("p2p-circuit")),Cr=()=>y(l(yr,Cr),yr),K=Cr(),Rc=y(l(K,H,K),l(H,K),l(K,H),K,H);var _c=y(l(K,c("webrtc"),c("p2p")),l(K,c("webrtc")),l(Y,c("webrtc"),c("p2p")),l(Y,c("webrtc")),c("webrtc"));function Sr(r){function e(t){let n;try{n=L(t)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function l(...r){function e(t){if(t.length(n=typeof o=="function"?o().partialMatch(t):o.partialMatch(t),Array.isArray(n)&&(t=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Sr(e),partialMatch:e}}function y(...r){function e(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Sr(e),partialMatch:e}}function c(r){let e=r;function t(o){let s;try{s=L(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:t,partialMatch:n}}var ke=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var Mr=le(F("net"),1);function Tr(r,e){if(typeof r!="string")throw new z(`invalid ip provided: ${r}`);if(typeof e=="string"&&(e=parseInt(e)),isNaN(e))throw new z(`invalid port provided: ${e}`);if((0,k.isIPv4)(r))return L(`/ip4/${r}/tcp/${e}`);if((0,k.isIPv6)(r))return L(`/ip6/${r}/tcp/${e}`);throw new z(`invalid ip:port for creating a multiaddr: ${r}:${e}`)}function Pr(r){if(Uo(r))return async function*(){let e=r.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)return;yield n}}finally{e.releaseLock()}}();if(Po(r))return r;throw new Error("unknown stream")}function Po(r){return r[Symbol.asyncIterator]!=null}function Uo(r){return typeof r?.getReader=="function"}function Ur(r){return async e=>{let t=async()=>{Do(e)&&await e.return(void 0)},n,o,s=g=>{n=g,t().catch(v=>{v=new AggregateError([n,v],"The Writable emitted an error, additionally an error occurred while ending the Source")}).finally(()=>{o?.(g)})},i,a=!1,p=()=>{a=!0,i?.()},w,u=!1,E=()=>{u=!0,w?.()},I,f=()=>{I?.()},d=async()=>new Promise((g,v)=>{i=I=g,o=v,r.once("drain",f)}),x=async()=>(await t(),new Promise((g,v)=>{if(a||u||n!=null){g();return}w=i=g,o=v})),S=()=>{r.removeListener("error",s),r.removeListener("close",p),r.removeListener("finish",E),r.removeListener("drain",f)};r.once("error",s),r.once("close",p),r.once("finish",E);try{for await(let g of e){if(!r.writable||r.destroyed||n!=null)break;r.write(g)||await d()}}catch(g){n==null&&r.destroy(g),n=g}try{if(r.writable&&r.end(),await x(),n!=null)throw n}finally{S()}}}function Do(r){return r.return!=null}function St(r){return{sink:Ur(r),source:Pr(r)}}var Tt=le(F("os"),1),Dr=le(F("path"),1);var Mo={ip4:"IPv4",ip6:"IPv6"};function de(r,e={}){let t=r.getPath();return t!=null?Tt.default.platform()==="win32"?{path:Dr.default.join("\\\\.\\pipe\\",t)}:{path:t}:{...e,...r.toOptions()}}function Pt(r,e,t){let n=o=>L(`/${r}/${o}/tcp/${t}`);return(ko(e)?Fo(Mo[r]):[e]).map(n)}function ko(r){return["0.0.0.0","::"].includes(r)}var No=Tt.default.networkInterfaces();function Fo(r){let e=[];for(let[,t]of Object.entries(No))if(t!=null)for(let n of t)n.family===r&&e.push(n.address);return e}var Ne=(r,e)=>{let t=null,n=e.logger.forComponent("libp2p:tcp:socket"),o=e.metrics,s=e.metricPrefix??"",i=e.socketInactivityTimeout??12e4,a=e.socketCloseTimeout??500;e.listeningAddr?.getPath()!=null&&(e.remoteAddr=e.listeningAddr),e.remoteAddr?.getPath()!=null&&(e.localAddr=e.remoteAddr);let p;if(e.remoteAddr!=null)p=e.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null){let d=new z("Could not determine remote address or port");throw r.destroy(d),d}p=Tr(r.remoteAddress,r.remotePort)}let w=de(p),u=w.path??`${w.host??""}:${w.port??""}`,{sink:E,source:I}=St(r);r.setTimeout(i,()=>{n("%s socket read timeout",u),o?.increment({[`${s}timeout`]:!0});let d;r.readable&&(d=new ee("Socket read timeout")),r.destroy(d)}),r.on("error",d=>{n.error("socket error %e",d),o?.increment({[`${s}error`]:!0}),r.destroyed||r.destroy()}),r.once("close",()=>{n("%s socket close",u),o?.increment({[`${s}close`]:!0}),f.timeline.close==null&&(f.timeline.close=Date.now()),r.destroyed||r.destroy()}),r.once("end",()=>{n("%s socket end",u),o?.increment({[`${s}end`]:!0})});let f={async sink(d){try{await E(async function*(){for await(let x of d)x instanceof Uint8Array?yield x:yield x.subarray()}())}catch(x){x.type!=="aborted"&&n.error("%s error in sink",u,x)}r.end()},source:I,remoteAddr:p,timeline:{open:Date.now()},async close(d={}){if(r.closed){n("The %s socket is already closed",u);return}if(r.destroyed){n("The %s socket is already destroyed",u);return}let x=()=>{r.destroy(new q("Destroying socket after timeout"))};try{if(t!=null){n("The %s socket is already closing",u),await t;return}if(d.signal==null){let S=AbortSignal.timeout(a);d={...d,signal:S}}d.signal?.addEventListener("abort",x),n("%s closing socket",u),t=new Promise((S,g)=>{r.once("close",()=>{n("%s socket closed",u),S()}),r.once("error",v=>{n("%s socket error",u,v),r.destroyed||g(v)}),r.setTimeout(a),r.end(),r.writableLength>0?r.once("drain",()=>{n("%s socket drained",u),r.destroy()}):r.destroy()}),await t}catch(S){this.abort(S)}finally{d.signal?.removeEventListener("abort",x)}},abort:d=>{n("%s socket abort due to error %e",u,d),r.destroyed||r.destroy(d),f.timeline.close==null&&(f.timeline.close=Date.now())},log:n};return f};var A;(function(r){r[r.INACTIVE=0]="INACTIVE",r[r.ACTIVE=1]="ACTIVE",r[r.PAUSED=2]="PAUSED"})(A||(A={}));var Fe=class extends ye{context;server;connections=new Set;status={code:A.INACTIVE};metrics;addr;log;constructor(e){if(super(),this.context=e,e.keepAlive=e.keepAlive??!0,e.noDelay=e.noDelay??!0,this.log=e.logger.forComponent("libp2p:tcp:listener"),this.addr="unknown",this.server=Mr.default.createServer(e,this.onSocket.bind(this)),e.maxConnections!==void 0&&(this.server.maxConnections=e.maxConnections),e.closeServerOnMaxConnections!=null&&e.closeServerOnMaxConnections.closeAbove= listenBelow");this.server.on("listening",()=>{if(e.metrics!=null){let t=this.server.address();t==null?this.addr="unknown":typeof t=="string"?this.addr=t:this.addr=`${t.address}:${t.port}`,e.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:e.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:e.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:e.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:A.ACTIVE})}this.safeDispatchEvent("listening")}).on("error",t=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.safeDispatchEvent("error",{detail:t})}).on("close",()=>{this.metrics?.status.update({[this.addr]:this.status.code}),this.status.code!==A.PAUSED&&this.safeDispatchEvent("close")}).on("drop",()=>{this.metrics?.events.increment({[`${this.addr} drop`]:!0})})}onSocket(e){if(this.metrics?.events.increment({[`${this.addr} connection`]:!0}),this.status.code!==A.ACTIVE)throw e.destroy(),new we("Server is not listening yet");let t;try{t=Ne(e,{listeningAddr:this.status.listeningAddr,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `,logger:this.context.logger})}catch(n){this.log.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}this.log("new inbound connection %s",t.remoteAddr),this.context.upgrader.upgradeInbound(t).then(n=>{this.log("inbound connection upgraded %s",t.remoteAddr),this.connections.add(t),e.once("close",()=>{this.connections.delete(t),this.context.closeServerOnMaxConnections!=null&&this.connections.size{this.log.error("error attempting to listen server once connection count under limit",o),this.context.closeServerOnMaxConnections?.onListenError?.(o)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.pause(!1).catch(o=>{this.log.error("error attempting to close server once connection count over limit",o)}),this.safeDispatchEvent("connection",{detail:n})}).catch(async n=>{this.log.error("inbound connection upgrade failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),t.abort(n)})}getAddrs(){if(this.status.code===A.INACTIVE)return[];let e=[],t=this.server.address(),{listeningAddr:n,peerId:o}=this.status;if(t==null)return[];if(typeof t=="string")e=[n];else try{n.toString().startsWith("/ip4")?e=e.concat(Pt("ip4",t.address,t.port)):t.family==="IPv6"&&(e=e.concat(Pt("ip6",t.address,t.port)))}catch(s){this.log.error("could not turn %s:%s into multiaddr",t.address,t.port,s)}return e.map(s=>o!=null?s.encapsulate(`/p2p/${o}`):s)}async listen(e){if(this.status.code===A.ACTIVE||this.status.code===A.PAUSED)throw new be("server is already listening");let t=e.getPeerId(),n=t==null?e.decapsulateCode(421):e,{backlog:o}=this.context;try{this.status={code:A.ACTIVE,listeningAddr:n,peerId:t,netConfig:de(n,{backlog:o})},await this.resume()}catch(s){throw this.status={code:A.INACTIVE},s}}async close(){let e=new q("Listener is closing");this.connections.forEach(t=>{t.abort(e)}),await this.pause(!0)}async resume(){if(this.server.listening||this.status.code===A.INACTIVE)return;let e=this.status.netConfig;await new Promise((t,n)=>{this.server.once("error",n),this.server.listen(e,t)}),this.status={...this.status,code:A.ACTIVE},this.log("listening on %s",this.server.address())}async pause(e){if(!this.server.listening&&this.status.code===A.PAUSED&&e){this.status={code:A.INACTIVE};return}!this.server.listening||this.status.code!==A.ACTIVE||(this.log("closing server on %s",this.server.address()),this.status=e?{code:A.INACTIVE}:{...this.status,code:A.PAUSED},await new Promise((t,n)=>{this.server.close(o=>{if(o!=null){n(o);return}t()})}))}};var Le=class{opts;metrics;components;log;constructor(e,t={}){this.log=e.logger.forComponent("libp2p:tcp"),this.opts=t,this.components=e,e.metrics!=null&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[Mt]=!0;[Symbol.toStringTag]="@libp2p/tcp";[Ft]=["@libp2p/transport"];async dial(e,t){t.keepAlive=t.keepAlive??!0,t.noDelay=t.noDelay??!0;let n=await this._connect(e,t),o=Ne(n,{remoteAddr:e,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents,logger:this.components.logger});try{return this.log("new outbound connection %s",o.remoteAddr),await t.upgrader.upgradeOutbound(o,t)}catch(s){throw this.log.error("error upgrading outbound connection",s),o.abort(s),s}}async _connect(e,t){return t.signal?.throwIfAborted(),t.onProgress?.(new ke("tcp:open-connection")),new Promise((n,o)=>{let s=Date.now(),i=de(e,{...this.opts.dialOpts??{},...t});this.log("dialing %a",e);let a=kr.default.connect(i),p=f=>{let d=i.path??`${i.host??""}:${i.port}`;f.message=`connection error ${d}: ${f.message}`,this.metrics?.dialerEvents.increment({error:!0}),I(f)},w=()=>{this.log("connection timeout %a",e),this.metrics?.dialerEvents.increment({timeout:!0});let f=new ee(`connection timeout after ${Date.now()-s}ms`);a.emit("error",f)},u=()=>{this.log("connection opened %a",e),this.metrics?.dialerEvents.increment({connect:!0}),I()},E=()=>{this.log("connection aborted %a",e),this.metrics?.dialerEvents.increment({abort:!0}),a.destroy(),I(new q)},I=f=>{if(a.removeListener("error",p),a.removeListener("timeout",w),a.removeListener("connect",u),t.signal!=null&&t.signal.removeEventListener("abort",E),f!=null){o(f);return}n(a)};a.on("error",p),a.on("timeout",w),a.on("connect",u),t.signal!=null&&t.signal.addEventListener("abort",E)})}createListener(e){return new Fe({...this.opts.listenOpts??{},...e,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics,logger:this.components.logger})}listenFilter(e){return e=Array.isArray(e)?e:[e],e.filter(t=>t.protoCodes().includes(290)?!1:t.protoCodes().includes(400)?!0:J.matches(t.decapsulateCode(421)))}dialFilter(e){return this.listenFilter(e)}};function $o(r={}){return e=>new Le(e,r)}return zr(Oo);})(); ++"use strict";var Libp2PTcp=(()=>{var Nr=Object.create;var ge=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Lr=Object.getOwnPropertyNames;var $r=Object.getPrototypeOf,Or=Object.prototype.hasOwnProperty;var F=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var U=(r,e)=>{for(var t in e)ge(r,t,{get:e[t],enumerable:!0})},Ut=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Lr(e))!Or.call(r,o)&&o!==t&&ge(r,o,{get:()=>e[o],enumerable:!(n=Fr(e,o))||n.enumerable});return r};var le=(r,e,t)=>(t=r!=null?Nr($r(r)):{},Ut(e||!r||!r.__esModule?ge(t,"default",{value:r,enumerable:!0}):t,r)),zr=r=>Ut(ge({},"__esModule",{value:!0}),r);var Oo={};U(Oo,{tcp:()=>$o});var kr=le(F("net"),1);var Mt=Symbol.for("@libp2p/transport");var Dt;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Dt||(Dt={}));var q=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var z=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}};var ee=class extends Error{static name="TimeoutError";constructor(e="Timed out"){super(e),this.name="TimeoutError"}},we=class extends Error{static name="NotStartedError";constructor(e="Not started"){super(e),this.name="NotStartedError"}},be=class extends Error{static name="AlreadyStartedError";constructor(e="Already started"){super(e),this.name="AlreadyStartedError"}};var kt=F("events"),Nt=(r,...e)=>{try{(0,kt.setMaxListeners)(r,...e)}catch{}};var ye=class extends EventTarget{#e=new Map;constructor(){super(),Nt(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var Ft=Symbol.for("@libp2p/service-capabilities"),qo=Symbol.for("@libp2p/service-dependencies");var Be={};U(Be,{base58btc:()=>T,base58flickr:()=>qr});var hs=new Uint8Array(0);function Lt(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n>>0,D=new Uint8Array($);g!==v;){for(var O=d[g],j=0,N=$-1;(O!==0||j>>0,D[N]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");S=j,g++}for(var B=$-S;B!==$&&D[B]===0;)B++;for(var xe=p.repeat(x);B<$;++B)xe+=r.charAt(D[B]);return xe}function I(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var x=0;if(d[x]!==" "){for(var S=0,g=0;d[x]===p;)S++,x++;for(var v=(d.length-x)*w+1>>>0,$=new Uint8Array(v);d[x];){var D=t[d.charCodeAt(x)];if(D===255)return;for(var O=0,j=v-1;(D!==0||O>>0,$[j]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");g=O,x++}if(d[x]!==" "){for(var N=v-g;N!==v&&$[N]===0;)N++;for(var B=new Uint8Array(S+(v-N)),xe=S;N!==v;)B[xe++]=$[N++];return B}}}function f(d){var x=I(d);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:E,decodeUnsafe:I,decode:f}}var Br=Vr,Rr=Br,Vt=Rr;var $e=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Oe=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Bt(this,e)}},ze=class{decoders;constructor(e){this.decoders=e}or(e){return Bt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Bt(r,e){return new ze({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ve=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new $e(e,t,n),this.decoder=new Oe(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function te({name:r,prefix:e,encode:t,decode:n}){return new Ve(r,e,t,n)}function W({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Vt(t,r);return te({prefix:e,name:r,encode:n,decode:s=>M(o(s))})}function _r(r,e,t,n){let o={};for(let u=0;u=8&&(a-=8,i[w++]=255&p>>a)}if(a>=t||255&p<<8-a)throw new SyntaxError("Unexpected end of data");return i}function jr(r,e,t){let n=e[e.length-1]==="=",o=(1<t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<R,base32hex:()=>Jr,base32hexpad:()=>Qr,base32hexpadupper:()=>Kr,base32hexupper:()=>Xr,base32pad:()=>Gr,base32padupper:()=>Hr,base32upper:()=>Wr,base32z:()=>Zr});var R=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wr=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Gr=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hr=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jr=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xr=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qr=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Kr=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zr=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _e={};U(_e,{base36:()=>ue,base36upper:()=>Yr});var ue=W({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yr=W({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var en=jt,Rt=128,tn=127,rn=~tn,nn=Math.pow(2,31);function jt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=nn;)e[t++]=r&255|Rt,r/=128;for(;r&rn;)e[t++]=r&255|Rt,r>>>=7;return e[t]=r|0,jt.bytes=t-n+1,e}var on=je,sn=128,_t=127;function je(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw je.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&_t)<=sn);return je.bytes=s-n,t}var cn=Math.pow(2,7),an=Math.pow(2,14),dn=Math.pow(2,21),ln=Math.pow(2,28),un=Math.pow(2,35),pn=Math.pow(2,42),fn=Math.pow(2,49),hn=Math.pow(2,56),mn=Math.pow(2,63),xn=function(r){return r{let[E,I]=fe(e.subarray(t));return t+=I,E},o=n(),s=he;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),p=n(),w=t+p,u=w-i;return{version:o,codec:s,multihashCode:a,digestSize:p,multihashSize:u,size:w}}static parse(e,t){let[n,o]=bn(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qe(s).set(n,e),s}};function bn(r,e){switch(r[0]){case"Q":{let t=e??T;return[T.prefix,t.decode(`${T.prefix}${r}`)]}case T.prefix:{let t=e??T;return[T.prefix,t.decode(r)]}case R.prefix:{let t=e??R;return[R.prefix,t.decode(r)]}case ue.prefix:{let t=e??ue;return[ue.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function yn(r,e,t){let{prefix:n}=t;if(n!==T.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function vn(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var he=112,En=18;function Ht(r,e,t){let n=ne(r),o=n+ne(e),s=new Uint8Array(o+t.byteLength);return re(r,s,0),re(e,s,n),s.set(t,o),s}var An=Symbol.for("@ipld/js-cid/CID");function Jt(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;tIn});var In=W({prefix:"9",name:"base10",alphabet:"0123456789"});var Ge={};U(Ge,{base16:()=>Cn,base16upper:()=>Sn});var Cn=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sn=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var He={};U(He,{base2:()=>Tn});var Tn=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Je={};U(Je,{base256emoji:()=>kn});var Xt=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}"),Pn=Xt.reduce((r,e,t)=>(r[t]=e,r),[]),Un=Xt.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function Dn(r){return r.reduce((e,t)=>(e+=Pn[t],e),"")}function Mn(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=Un[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var kn=te({prefix:"\u{1F680}",name:"base256emoji",encode:Dn,decode:Mn});var Xe={};U(Xe,{base64:()=>Nn,base64pad:()=>Fn,base64url:()=>Ln,base64urlpad:()=>$n});var Nn=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fn=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ln=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$n=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Qe={};U(Qe,{base8:()=>On});var On=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ke={};U(Ke,{identity:()=>zn});var zn=te({prefix:"\0",name:"identity",encode:r=>Ot(r),decode:r=>$t(r)});var Bs=new TextEncoder,Rs=new TextDecoder;var Ze={};U(Ze,{identity:()=>jn});var Qt=0,Rn="identity",Kt=M;function _n(r){return X(Qt,Kt(r))}var jn={code:Qt,name:Rn,encode:Kt,digest:_n};var rt={};U(rt,{sha256:()=>qn,sha512:()=>Wn});var tt=le(F("crypto"),1);function et({name:r,code:e,encode:t}){return new Ye(r,e,t)}var Ye=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?X(this.code,t):t.then(n=>X(this.code,n))}else throw Error("Unknown type, must be binary type")}};var qn=et({name:"sha2-256",code:18,encode:r=>M(tt.default.createHash("sha256").update(r).digest())}),Wn=et({name:"sha2-512",code:19,encode:r=>M(tt.default.createHash("sha512").update(r).digest())});var me={...Ke,...He,...Qe,...We,...Ge,...Re,..._e,...Be,...Xe,...Je},ti={...rt,...Ze};var Yt=F("node:buffer");function ie(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Ae(r=0){return ie(Yt.Buffer.allocUnsafe(r))}function tr(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var er=tr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),nt=tr("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=Ae(r.length);for(let t=0;tNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Qn(r,e,t=0){switch(V(r)){case 8:e[t++]=r&255|h,r/=128;case 7:e[t++]=r&255|h,r/=128;case 6:e[t++]=r&255|h,r/=128;case 5:e[t++]=r&255|h,r/=128;case 4:e[t++]=r&255|h,r>>>=7;case 3:e[t++]=r&255|h,r>>>=7;case 2:e[t++]=r&255|h,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Kn(r,e,t=0){switch(V(r)){case 8:e.set(t++,r&255|h),r/=128;case 7:e.set(t++,r&255|h),r/=128;case 6:e.set(t++,r&255|h),r/=128;case 5:e.set(t++,r&255|h),r/=128;case 4:e.set(t++,r&255|h),r>>>=7;case 3:e.set(t++,r&255|h),r>>>=7;case 2:e.set(t++,r&255|h),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Zn(r,e){let t=r[e],n=0;if(n+=t&C,t=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let p=a==="0",w=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let E=this.readChar();if(E===void 0)return;let I=Number.parseInt(E,e);if(!Number.isNaN(I))return I});if(u===void 0)break;if(s*=e,s+=u,s>w||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&p&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;tthis.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;nthis.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var xi=new Ce;var Ii=parseInt("0xFFFF",16),Ci=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var cr=F("node:buffer");function at(r,e="utf8"){let t=Ie[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ie(cr.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var k=F("node:net");function Se(r){return!!(0,k.isIP)(r)}var ar=k.isIPv4,so=k.isIPv6,dt=function(r){let e=0;if(r=r.toString().trim(),ar(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(so(r)){let t=r.split(":",8),n;for(n=0;n0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},dr=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let s=0;s{let e=ao(...r);lt[e.code]=e,ae[e.name]=e});function ao(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function m(r){if(typeof r=="number"){if(lt[r]!=null)return lt[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ae[r]!=null)return ae[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var pc=m("ip4"),fc=m("ip6"),hc=m("ipcidr");function ht(r,e){switch(m(r).code){case 4:case 41:return uo(e);case 42:return ft(e);case 6:case 273:case 33:case 132:return pr(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ft(e);case 421:return mo(e);case 444:return ur(e);case 445:return ur(e);case 466:return ho(e);case 481:return globalThis.encodeURIComponent(ft(e));default:return P(e,"base16")}}function mt(r,e){switch(m(r).code){case 4:return lr(e);case 41:return lr(e);case 42:return pt(e);case 6:case 273:case 33:case 132:return xt(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return pt(e);case 421:return po(e);case 444:return xo(e);case 445:return go(e);case 466:return fo(e);case 481:return pt(globalThis.decodeURIComponent(e));default:return at(e,"base16")}}var ut=Object.values(me).map(r=>r.decoder),lo=function(){let r=ut[0].or(ut[1]);return ut.slice(2).forEach(e=>r=r.or(e)),r}();function lr(r){if(!Se(r))throw new Error("invalid ip address");return dt(r)}function uo(r){let e=dr(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Se(e))throw new Error("invalid ip address");return e}function xt(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function pr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function pt(r){let e=at(r),t=Uint8Array.from(ce(e.length));return _([t,e],t.length+e.length)}function ft(r){let e=Q(r);if(r=r.slice(V(e)),r.length!==e)throw new Error("inconsistent lengths");return P(r)}function po(r){let e;r[0]==="Q"||r[0]==="1"?e=Ee(T.decode(`z${r}`)).bytes:e=G.parse(r).multihash.bytes;let t=Uint8Array.from(ce(e.length));return _([t,e],t.length+e.length)}function fo(r){let e=lo.decode(r),t=Uint8Array.from(ce(e.length));return _([t,e],t.length+e.length)}function ho(r){let e=Q(r),t=r.slice(V(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+P(t,"base64url")}function mo(r){let e=Q(r),t=r.slice(V(e));if(t.length!==e)throw new Error("inconsistent lengths");return P(t,"base58btc")}function xo(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=R.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=xt(n);return _([t,o],t.length+o.length)}function go(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=R.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=xt(n);return _([t,o],t.length+o.length)}function ur(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=P(e,"base32"),o=pr(t);return`${n}:${o}`}function fr(r){r=gt(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s=o.length)throw mr("invalid address: "+r);if(a.path===!0){n=gt(o.slice(s).join("/")),e.push([a.code,mt(a.code,n)]),t.push([a.code,n]);break}let p=mt(a.code,o[s]);e.push([a.code,p]),t.push([a.code,ht(a.code,p)])}return{string:hr(t),bytes:bt(e),tuples:e,stringTuples:t,path:n}}function wt(r){let e=[],t=[],n=null,o=0;for(;or.length)throw mr("Invalid address Uint8Array: "+P(r,"base16"));e.push([s,w]);let u=ht(s,w);if(t.push([s,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:hr(t),tuples:e,stringTuples:t,path:n}}function hr(r){let e=[];return r.map(t=>{let n=m(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),gt(e.join("/"))}function bt(r){return _(r.map(e=>{let t=m(e[0]),n=Uint8Array.from(ce(t.code));return e.length>1&&e[1]!=null&&(n=_([n,e[1]])),n}))}function wo(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Q(e instanceof Uint8Array?e:Uint8Array.from(e));return t+V(t)}}function gt(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function mr(r){return new Error("Error parsing address: "+r)}var bo=Symbol.for("nodejs.util.inspect.custom"),vt=Symbol.for("@multiformats/js-multiaddr/multiaddr"),yo=[m("dns").code,m("dns4").code,m("dns6").code,m("dnsaddr").code],yt=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Te=class r{bytes;#e;#t;#r;#n;[vt]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=wt(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=fr(e)}else if(gr(e))t=wt(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=m("tcp"),a=m("udp"),p=m("ip4"),w=m("ip6"),u=m("dns6"),E=m("ip6zone");for(let[f,d]of this.stringTuples())f===E.code&&(s=`%${d??""}`),yo.includes(f)&&(t=i.name,o=443,n=`${d??""}${s}`,e=f===u.code?6:4),(f===i.code||f===a.code)&&(t=m(f).name,o=parseInt(d??"")),(f===p.code||f===w.code)&&(t=m(f).name,n=`${d??""}${s}`,e=f===w.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},m(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>m(e).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(bt(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===ae.p2p.code&&e.push([n,o]),n===ae["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?P(T.decode(`z${n}`),"base58btc"):P(G.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Jt(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=xr.get(t.name);if(n==null)throw new yt(`no available resolver for ${t.name}`);return(await n(this,e)).map(s=>L(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[bo](){return`Multiaddr(${this.#e})`}};var xr=new Map;function gr(r){return!!r?.[vt]}function L(r){return new Te(r)}var vo=c("dns4"),Eo=c("dns6"),Ao=c("dnsaddr"),Z=y(c("dns"),Ao,vo,Eo),De=y(c("ip4"),c("ip6")),J=y(l(De,c("tcp")),l(Z,c("tcp"))),Me=l(De,c("udp")),Io=l(Me,c("utp")),Co=l(Me,c("quic")),So=l(Me,c("quic-v1")),Et=y(l(J,c("ws")),l(Z,c("ws"))),Pe=y(l(Et,c("p2p")),Et),At=y(l(J,c("wss")),l(Z,c("wss")),l(J,c("tls"),c("ws")),l(Z,c("tls"),c("ws"))),Ue=y(l(At,c("p2p")),At),It=y(l(J,c("http")),l(De,c("http")),l(Z,c("http"))),Ct=y(l(J,c("https")),l(De,c("https")),l(Z,c("https"))),wr=l(Me,c("webrtc-direct"),c("certhash")),vr=y(l(wr,c("p2p")),wr),br=l(So,c("webtransport"),c("certhash"),c("certhash")),Er=y(l(br,c("p2p")),br),Ar=y(l(Pe,c("p2p-webrtc-star"),c("p2p")),l(Ue,c("p2p-webrtc-star"),c("p2p")),l(Pe,c("p2p-webrtc-star")),l(Ue,c("p2p-webrtc-star"))),Vc=y(l(Pe,c("p2p-websocket-star"),c("p2p")),l(Ue,c("p2p-websocket-star"),c("p2p")),l(Pe,c("p2p-websocket-star")),l(Ue,c("p2p-websocket-star"))),Ir=y(l(It,c("p2p-webrtc-direct"),c("p2p")),l(Ct,c("p2p-webrtc-direct"),c("p2p")),l(It,c("p2p-webrtc-direct")),l(Ct,c("p2p-webrtc-direct"))),Y=y(Et,At,It,Ct,Ar,Ir,J,Io,Co,Z,vr,Er),Bc=y(l(Y,c("p2p-stardust"),c("p2p")),l(Y,c("p2p-stardust"))),H=y(l(Y,c("p2p")),Ar,Ir,vr,Er,c("p2p")),yr=y(l(H,c("p2p-circuit"),H),l(H,c("p2p-circuit")),l(c("p2p-circuit"),H),l(Y,c("p2p-circuit")),l(c("p2p-circuit"),Y),c("p2p-circuit")),Cr=()=>y(l(yr,Cr),yr),K=Cr(),Rc=y(l(K,H,K),l(H,K),l(K,H),K,H);var _c=y(l(K,c("webrtc"),c("p2p")),l(K,c("webrtc")),l(Y,c("webrtc"),c("p2p")),l(Y,c("webrtc")),c("webrtc"));function Sr(r){function e(t){let n;try{n=L(t)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function l(...r){function e(t){if(t.length(n=typeof o=="function"?o().partialMatch(t):o.partialMatch(t),Array.isArray(n)&&(t=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Sr(e),partialMatch:e}}function y(...r){function e(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:Sr(e),partialMatch:e}}function c(r){let e=r;function t(o){let s;try{s=L(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:t,partialMatch:n}}var ke=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var Mr=le(F("net"),1);function Tr(r,e){if(typeof r!="string")throw new z(`invalid ip provided: ${r}`);if(typeof e=="string"&&(e=parseInt(e)),isNaN(e))throw new z(`invalid port provided: ${e}`);if((0,k.isIPv4)(r))return L(`/ip4/${r}/tcp/${e}`);if((0,k.isIPv6)(r))return L(`/ip6/${r}/tcp/${e}`);throw new z(`invalid ip:port for creating a multiaddr: ${r}:${e}`)}function Pr(r){if(Uo(r))return async function*(){let e=r.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)return;yield n}}finally{e.releaseLock()}}();if(Po(r))return r;throw new Error("unknown stream")}function Po(r){return r[Symbol.asyncIterator]!=null}function Uo(r){return typeof r?.getReader=="function"}function Ur(r){return async e=>{let t=async()=>{Do(e)&&await e.return(void 0)},n,o,s=g=>{n=g,t().catch(v=>{v=new AggregateError([n,v],"The Writable emitted an error, additionally an error occurred while ending the Source")}).finally(()=>{o?.(g)})},i,a=!1,p=()=>{a=!0,i?.()},w,u=!1,E=()=>{u=!0,w?.()},I,f=()=>{I?.()},d=async()=>new Promise((g,v)=>{i=I=g,o=v,r.once("drain",f)}),x=async()=>(await t(),new Promise((g,v)=>{if(a||u||n!=null){g();return}w=i=g,o=v})),S=()=>{r.removeListener("error",s),r.removeListener("close",p),r.removeListener("finish",E),r.removeListener("drain",f)};r.once("error",s),r.once("close",p),r.once("finish",E);try{for await(let g of e){if(!r.writable||r.destroyed||n!=null)break;r.write(g)||await d()}}catch(g){n==null&&r.destroy(g),n=g}try{if(r.writable&&r.end(),await x(),n!=null)throw n}finally{S()}}}function Do(r){return r.return!=null}function St(r){return{sink:Ur(r),source:Pr(r)}}var Tt=le(F("os"),1),Dr=le(F("path"),1);var Mo={ip4:"IPv4",ip6:"IPv6"};function de(r,e={}){let t=r.getPath();return t!=null?Tt.default.platform()==="win32"?{path:Dr.default.join("\\\\.\\pipe\\",t)}:{path:t}:{...e,...r.toOptions()}}function Pt(r,e,t){let n=o=>L(`/${r}/${o}/tcp/${t}`);return(ko(e)?Fo(Mo[r]):[e]).map(n)}function ko(r){return["0.0.0.0","::"].includes(r)}var No=Tt.default.networkInterfaces();function Fo(r){let e=[];for(let[,t]of Object.entries(No))if(t!=null)for(let n of t)n.family===r&&e.push(n.address);return e}var Ne=(r,e)=>{let t=null,n=e.logger.forComponent("libp2p:tcp:socket"),o=e.metrics,s=e.metricPrefix??"",i=e.socketInactivityTimeout??12e4,a=e.socketCloseTimeout??500;e.listeningAddr?.getPath()!=null&&(e.remoteAddr=e.listeningAddr),e.remoteAddr?.getPath()!=null&&(e.localAddr=e.remoteAddr);let p;if(e.remoteAddr!=null)p=e.remoteAddr;else{if(r.remoteAddress==null||r.remotePort==null){let d=new z("Could not determine remote address or port");throw r.destroy(d),d}p=Tr(r.remoteAddress,r.remotePort)}let w=de(p),u=w.path??`${w.host??""}:${w.port??""}`,{sink:E,source:I}=St(r);r.setTimeout(i,()=>{n("%s socket read timeout",u),o?.increment({[`${s}timeout`]:!0});let d;r.readable&&(d=new ee("Socket read timeout")),r.destroy(d)}),r.on("error",d=>{n.error("socket error %e",d),o?.increment({[`${s}error`]:!0}),r.destroyed||r.destroy()}),r.once("close",()=>{n("%s socket close",u),o?.increment({[`${s}close`]:!0}),f.timeline.close==null&&(f.timeline.close=Date.now()),r.destroyed||r.destroy()}),r.once("end",()=>{n("%s socket end",u),o?.increment({[`${s}end`]:!0})});let f={async sink(d){try{await E(async function*(){for await(let x of d)x instanceof Uint8Array?yield x:yield x.subarray()}())}catch(x){x.type!=="aborted"&&n.error("%s error in sink",u,x)}r.end()},source:I,remoteAddr:p,timeline:{open:Date.now()},async close(d={}){if(r.closed){n("The %s socket is already closed",u);return}if(r.destroyed){n("The %s socket is already destroyed",u);return}let x=()=>{r.destroy(new q("Destroying socket after timeout"))};try{if(t!=null){n("The %s socket is already closing",u),await t;return}if(d.signal==null){let S=AbortSignal.timeout(a);d={...d,signal:S}}d.signal?.addEventListener("abort",x),n("%s closing socket",u),t=new Promise((S,g)=>{r.once("close",()=>{n("%s socket closed",u),S()}),r.once("error",v=>{n("%s socket error",u,v),r.destroyed||g(v)}),r.setTimeout(a),r.end(),r.writableLength>0?r.once("drain",()=>{n("%s socket drained",u),r.destroy()}):r.destroy()}),await t}catch(S){this.abort(S)}finally{d.signal?.removeEventListener("abort",x)}},abort:d=>{n("%s socket abort due to error %e",u,d),r.destroyed||r.destroy(d),f.timeline.close==null&&(f.timeline.close=Date.now())},log:n};return f};var A;(function(r){r[r.INACTIVE=0]="INACTIVE",r[r.ACTIVE=1]="ACTIVE",r[r.PAUSED=2]="PAUSED"})(A||(A={}));var Fe=class extends ye{context;server;connections=new Set;status={code:A.INACTIVE};metrics;addr;log;constructor(e){if(super(),this.context=e,e.keepAlive=e.keepAlive??!0,e.noDelay=e.noDelay??!0,this.log=e.logger.forComponent("libp2p:tcp:listener"),this.addr="unknown",this.server=Mr.default.createServer(e,this.onSocket.bind(this)),e.maxConnections!==void 0&&(this.server.maxConnections=e.maxConnections),e.closeServerOnMaxConnections!=null&&e.closeServerOnMaxConnections.closeAbove= listenBelow");this.server.on("listening",()=>{if(e.metrics!=null){let t=this.server.address();t==null?this.addr="unknown":typeof t=="string"?this.addr=t:this.addr=`${t.address}:${t.port}`,e.metrics?.registerMetricGroup("libp2p_tcp_inbound_connections_total",{label:"address",help:"Current active connections in TCP listener",calculate:()=>({[this.addr]:this.connections.size})}),this.metrics={status:e.metrics.registerMetricGroup("libp2p_tcp_listener_status_info",{label:"address",help:"Current status of the TCP listener socket"}),errors:e.metrics.registerMetricGroup("libp2p_tcp_listener_errors_total",{label:"address",help:"Total count of TCP listener errors by type"}),events:e.metrics.registerMetricGroup("libp2p_tcp_listener_events_total",{label:"address",help:"Total count of TCP listener events by type"})},this.metrics?.status.update({[this.addr]:A.ACTIVE})}this.safeDispatchEvent("listening")}).on("error",t=>{this.metrics?.errors.increment({[`${this.addr} listen_error`]:!0}),this.safeDispatchEvent("error",{detail:t})}).on("close",()=>{this.metrics?.status.update({[this.addr]:this.status.code}),this.status.code!==A.PAUSED&&this.safeDispatchEvent("close")}).on("drop",()=>{this.metrics?.events.increment({[`${this.addr} drop`]:!0})})}onSocket(e){if(this.metrics?.events.increment({[`${this.addr} connection`]:!0}),this.status.code!==A.ACTIVE)throw e.destroy(),new we("Server is not listening yet");let t;try{t=Ne(e,{listeningAddr:this.status.listeningAddr,socketInactivityTimeout:this.context.socketInactivityTimeout,socketCloseTimeout:this.context.socketCloseTimeout,metrics:this.metrics?.events,metricPrefix:`${this.addr} `,logger:this.context.logger})}catch(n){this.log.error("inbound connection failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_to_connection`]:!0});return}this.log("new inbound connection %s",t.remoteAddr),this.context.upgrader.upgradeInbound(t).then(n=>{this.log("inbound connection upgraded %s",t.remoteAddr),this.connections.add(t),e.once("close",()=>{this.connections.delete(t),this.context.closeServerOnMaxConnections!=null&&this.connections.size{this.log.error("error attempting to listen server once connection count under limit",o),this.context.closeServerOnMaxConnections?.onListenError?.(o)})}),this.context.handler!=null&&this.context.handler(n),this.context.closeServerOnMaxConnections!=null&&this.connections.size>=this.context.closeServerOnMaxConnections.closeAbove&&this.pause(!1).catch(o=>{this.log.error("error attempting to close server once connection count over limit",o)}),this.safeDispatchEvent("connection",{detail:n})}).catch(async n=>{this.log.error("inbound connection upgrade failed",n),this.metrics?.errors.increment({[`${this.addr} inbound_upgrade`]:!0}),t.abort(n)})}getAddrs(){if(this.status.code===A.INACTIVE)return[];let e=[],t=this.server.address(),{listeningAddr:n,peerId:o}=this.status;if(t==null)return[];if(typeof t=="string")e=[n];else try{n.toString().startsWith("/ip4")?e=e.concat(Pt("ip4",t.address,t.port)):t.family==="IPv6"&&(e=e.concat(Pt("ip6",t.address,t.port)))}catch(s){this.log.error("could not turn %s:%s into multiaddr",t.address,t.port,s)}return e.map(s=>o!=null?s.encapsulate(`/p2p/${o}`):s)}async listen(e){if(this.status.code===A.ACTIVE||this.status.code===A.PAUSED)throw new be("server is already listening");let t=e.getPeerId(),n=t==null?e.decapsulateCode(421):e,{backlog:o}=this.context;try{this.status={code:A.ACTIVE,listeningAddr:n,peerId:t,netConfig:de(n,{backlog:o})},await this.resume()}catch(s){throw this.status={code:A.INACTIVE},s}}async close(){let e=new q("Listener is closing");this.connections.forEach(t=>{t.abort(e)}),await this.pause(!0)}async resume(){if(this.server.listening||this.status.code===A.INACTIVE)return;let e=this.status.netConfig;await new Promise((t,n)=>{this.server.once("error",n),this.server.listen(e,t)}),this.status={...this.status,code:A.ACTIVE},this.log("listening on %s",this.server.address())}async pause(e){if(!this.server.listening&&this.status.code===A.PAUSED&&e){this.status={code:A.INACTIVE};return}!this.server.listening||this.status.code!==A.ACTIVE||(this.log("closing server on %s",this.server.address()),this.status=e?{code:A.INACTIVE}:{...this.status,code:A.PAUSED},await new Promise((t,n)=>{this.server.close(o=>{if(o!=null){n(o);return}t()})}))}};var Le=class{opts;metrics;components;log;constructor(e,t={}){this.log=e.logger.forComponent("libp2p:tcp"),this.opts=t,this.components=e,e.metrics!=null&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_tcp_dialer_events_total",{label:"event",help:"Total count of TCP dialer events by type"})})}[Mt]=!0;[Symbol.toStringTag]="@libp2p/tcp";[Ft]=["@libp2p/transport"];async dial(e,t){t.keepAlive=t.keepAlive??!0,t.noDelay=t.noDelay??!0;let n=await this._connect(e,t),o=Ne(n,{remoteAddr:e,socketInactivityTimeout:this.opts.outboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.metrics?.dialerEvents,logger:this.components.logger});try{return this.log("new outbound connection %s",o.remoteAddr),await t.upgrader.upgradeOutbound(o,t)}catch(s){throw this.log.error("error upgrading outbound connection",s),o.abort(s),s}}async _connect(e,t){return t.signal?.throwIfAborted(),t.onProgress?.(new ke("tcp:open-connection")),new Promise((n,o)=>{let s=Date.now(),i=de(e,{...this.opts.dialOpts??{},...t});this.log("dialing %a",e);let a=kr.default.connect(i),p=f=>{this.log.error("dial to %a errored - %e",e,f);let d=i.path??`${i.host??""}:${i.port}`;f.message=`connection error ${d}: ${f.message}`,this.metrics?.dialerEvents.increment({error:!0}),a.destroy(),I(f)},w=()=>{this.log("connection timeout %a",e),this.metrics?.dialerEvents.increment({timeout:!0});let f=new ee(`connection timeout after ${Date.now()-s}ms`);a.emit("error",f)},u=()=>{this.log("connection opened %a",e),this.metrics?.dialerEvents.increment({connect:!0}),I()},E=()=>{this.log("connection aborted %a",e),this.metrics?.dialerEvents.increment({abort:!0}),a.destroy(),I(new q)},I=f=>{if(a.removeListener("error",p),a.removeListener("timeout",w),a.removeListener("connect",u),t.signal!=null&&t.signal.removeEventListener("abort",E),f!=null){o(f);return}n(a)};a.on("error",p),a.on("timeout",w),a.on("connect",u),t.signal!=null&&t.signal.addEventListener("abort",E)})}createListener(e){return new Fe({...this.opts.listenOpts??{},...e,maxConnections:this.opts.maxConnections,backlog:this.opts.backlog,closeServerOnMaxConnections:this.opts.closeServerOnMaxConnections,socketInactivityTimeout:this.opts.inboundSocketInactivityTimeout,socketCloseTimeout:this.opts.socketCloseTimeout,metrics:this.components.metrics,logger:this.components.logger})}listenFilter(e){return e=Array.isArray(e)?e:[e],e.filter(t=>t.protoCodes().includes(290)?!1:t.protoCodes().includes(400)?!0:J.matches(t.decapsulateCode(421)))}dialFilter(e){return this.listenFilter(e)}};function $o(r={}){return e=>new Le(e,r)}return zr(Oo);})(); return Libp2PTcp})); diff --git a/node_modules/@libp2p/tcp/dist/src/constants.js b/node_modules/@libp2p/tcp/dist/src/constants.js index 271d393..6b5bfd9 100644 @@ -132,16 +132,16 @@ index b999be8..38a0b5d 100644 +{"version":3,"file":"socket-to-conn.js","sourceRoot":"","sources":["../../src/socket-to-conn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACpF,OAAO,EAAE,iBAAiB,IAAI,WAAW,EAAE,MAAM,oCAAoC,CAAA;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAgBjD;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,OAA4B,EAAuB,EAAE;IACzG,IAAI,YAAY,GAAyB,IAAI,CAAA;IAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAA;IAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;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AC,QAAQ,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;gBAClC,MAAM,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YACpC,CAAC;QACH,CAAC;QAED,GAAG;KACJ,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"} \ No newline at end of file diff --git a/node_modules/@libp2p/tcp/dist/src/tcp.d.ts.map b/node_modules/@libp2p/tcp/dist/src/tcp.d.ts.map -index b7cc596..49b8846 100644 +index b7cc596..4453df7 100644 --- a/node_modules/@libp2p/tcp/dist/src/tcp.d.ts.map +++ b/node_modules/@libp2p/tcp/dist/src/tcp.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"tcp.d.ts","sourceRoot":"","sources":["../../src/tcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;AAGH,OAAO,EAA4B,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAOlG,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB,EAAE,aAAa,EAAE,cAAc,EAAc,UAAU,EAAE,MAAM,YAAY,CAAA;AAChI,OAAO,KAAK,EAAU,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAA8C,MAAM,KAAK,CAAA;AAE7E,qBAAa,GAAI,YAAW,SAAS,CAAC,aAAa,CAAC;IAClD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAY;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAC1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;gBAEf,UAAU,EAAE,aAAa,EAAE,OAAO,GAAE,UAAe;IAehE,QAAQ,CAAC,CAAC,eAAe,CAA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IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAY;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAC1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;gBAEf,UAAU,EAAE,aAAa,EAAE,OAAO,GAAE,UAAe;IAehE,QAAQ,CAAC,CAAC,eAAe,CAAC,QAAO;IAEjC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,iBAAgB;IAE7C,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAEvC;IAEK,IAAI,CAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IAyBlE,QAAQ,CAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAuExE;;;;OAIG;IACH,cAAc,CAAE,OAAO,EAAE,wBAAwB,GAAG,QAAQ;IAc5D;;OAEG;IACH,YAAY,CAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE;IAgBnD;;OAEG;IACH,UAAU,CAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE;CAGlD"} \ No newline at end of file diff --git a/node_modules/@libp2p/tcp/dist/src/tcp.js b/node_modules/@libp2p/tcp/dist/src/tcp.js -index cb4fe13..a712548 100644 +index cb4fe13..3a89aa0 100644 --- a/node_modules/@libp2p/tcp/dist/src/tcp.js +++ b/node_modules/@libp2p/tcp/dist/src/tcp.js @@ -62,10 +62,6 @@ export class TCP { @@ -155,14 +155,26 @@ index cb4fe13..a712548 100644 const maConn = toMultiaddrConnection(socket, { remoteAddr: ma, socketInactivityTimeout: this.opts.outboundSocketInactivityTimeout, +@@ -95,9 +91,11 @@ export class TCP { + this.log('dialing %a', ma); + const rawSocket = net.connect(cOpts); + const onError = (err) => { ++ this.log.error('dial to %a errored - %e', ma, err); + const cOptsStr = cOpts.path ?? `${cOpts.host ?? ''}:${cOpts.port}`; + err.message = `connection error ${cOptsStr}: ${err.message}`; + this.metrics?.dialerEvents.increment({ error: true }); ++ rawSocket.destroy(); + done(err); + }; + const onTimeout = () => { diff --git a/node_modules/@libp2p/tcp/dist/src/tcp.js.map b/node_modules/@libp2p/tcp/dist/src/tcp.js.map -index 60bf8f3..cd27d97 100644 +index 60bf8f3..e51e5ce 100644 --- a/node_modules/@libp2p/tcp/dist/src/tcp.js.map +++ b/node_modules/@libp2p/tcp/dist/src/tcp.js.map @@ -1 +1 @@ -{"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../src/tcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAClG,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAMjD,MAAM,OAAO,GAAG;IACG,IAAI,CAAY;IAChB,OAAO,CAAa;IACpB,UAAU,CAAe;IACzB,GAAG,CAAQ;IAE5B,YAAa,UAAyB,EAAE,UAAsB,EAAE;QAC9D,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;QACvD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAA;QACnB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAE5B,IAAI,UAAU,CAAC,OA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,CAAC;YAC/B,GAAG,OAAO;YACV,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc;YACxC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO;YAC1B,2BAA2B,EAAE,IAAI,CAAC,IAAI,CAAC,2BAA2B;YAClE,uBAAuB,EAAE,IAAI,CAAC,IAAI,CAAC,8BAA8B;YACjE,kBAAkB,EAAE,IAAI,CAAC,IAAI,CAAC,kBAAkB;YAChD,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO;YAChC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;SAC/B,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,YAAY,CAAE,UAAuB;QACnC,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;QAElE,OAAO,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;YAC5B,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC3C,OAAO,KAAK,CAAA;YACd,CAAC;YAED,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBACxC,OAAO,IAAI,CAAA;YACb,CAAC;YAED,OAAO,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAA;QACxD,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,UAAU,CAAE,UAAuB;QACjC,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;IACtC,CAAC;CACF"} \ No newline at end of file diff --git a/node_modules/@libp2p/tcp/dist/typedoc-urls.json b/node_modules/@libp2p/tcp/dist/typedoc-urls.json deleted file mode 100644 @@ -283,7 +295,7 @@ index 09dea95..e076974 100644 // the abortSignalListener may already destroyed the socket with an error if (!socket.destroyed) { diff --git a/node_modules/@libp2p/tcp/src/tcp.ts b/node_modules/@libp2p/tcp/src/tcp.ts -index 9b03998..e0ee76f 100644 +index 9b03998..416f4e9 100644 --- a/node_modules/@libp2p/tcp/src/tcp.ts +++ b/node_modules/@libp2p/tcp/src/tcp.ts @@ -76,11 +76,6 @@ export class TCP implements Transport { @@ -298,3 +310,16 @@ index 9b03998..e0ee76f 100644 const maConn = toMultiaddrConnection(socket, { remoteAddr: ma, socketInactivityTimeout: this.opts.outboundSocketInactivityTimeout, +@@ -114,10 +109,11 @@ export class TCP implements Transport { + const rawSocket = net.connect(cOpts) + + const onError = (err: Error): void => { ++ this.log.error('dial to %a errored - %e', ma, err) + const cOptsStr = cOpts.path ?? `${cOpts.host ?? ''}:${cOpts.port}` + err.message = `connection error ${cOptsStr}: ${err.message}` + this.metrics?.dialerEvents.increment({ error: true }) +- ++ rawSocket.destroy() + done(err) + } +