@libp2p/dcutr 1.1.5 → 2.0.0-18dd3cb26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.min.js +1 -1
- package/dist/src/dcutr.d.ts.map +1 -1
- package/dist/src/dcutr.js +14 -13
- package/dist/src/dcutr.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +2 -2
- package/dist/src/pb/message.d.ts +2 -2
- package/dist/src/pb/message.d.ts.map +1 -1
- package/dist/src/pb/message.js +13 -7
- package/dist/src/pb/message.js.map +1 -1
- package/package.json +5 -5
- package/src/dcutr.ts +14 -13
- package/src/index.ts +2 -2
- package/src/pb/message.ts +14 -8
- package/dist/typedoc-urls.json +0 -10
package/README.md
CHANGED
|
@@ -59,11 +59,11 @@ const ma = multiaddr('/ip4/.../p2p/QmRelay/p2p-circuit/p2p/QmTarget')
|
|
|
59
59
|
await node.dial(ma)
|
|
60
60
|
|
|
61
61
|
// after a while the connection should automatically get upgraded to a
|
|
62
|
-
// direct connection (e.g. non-
|
|
62
|
+
// direct connection (e.g. non-limited)
|
|
63
63
|
while (true) {
|
|
64
64
|
const connections = node.getConnections()
|
|
65
65
|
|
|
66
|
-
if (connections.find(conn => conn.
|
|
66
|
+
if (connections.find(conn => conn.limits == null)) {
|
|
67
67
|
console.info('have direct connection')
|
|
68
68
|
break
|
|
69
69
|
} else {
|
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDcutr = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PDcutr=(()=>{var Tn=Object.create;var Ut=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var Rn=Object.getOwnPropertyNames;var Pn=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty;var kn=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),U=(r,t)=>{for(var e in t)Ut(r,e,{get:t[e],enumerable:!0})},wr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rn(t))!Mn.call(r,o)&&o!==e&&Ut(r,o,{get:()=>t[o],enumerable:!(n=Cn(t,o))||n.enumerable});return r};var Bn=(r,t,e)=>(e=r!=null?Tn(Pn(r)):{},wr(t||!r||!r.__esModule?Ut(e,"default",{value:r,enumerable:!0}):e,r)),_n=r=>wr(Ut({},"__esModule",{value:!0}),r);var mn=kn(Nt=>{(function(){var r,t,e,n,o,i,s,a;a=function(c){var h,f,u,l;return h=(c&255<<24)>>>24,f=(c&255<<16)>>>16,u=(c&65280)>>>8,l=c&255,[h,f,u,l].join(".")},s=function(c){var h,f,u,l,w,d;for(h=[],u=l=0;l<=3&&c.length!==0;u=++l){if(u>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}d=t(c),w=d[0],f=d[1],c=c.substring(f),h.push(w)}if(c.length!==0)throw new Error("Invalid IP");switch(h.length){case 1:if(h[0]>4294967295)throw new Error("Invalid IP");return h[0]>>>0;case 2:if(h[0]>255||h[1]>16777215)throw new Error("Invalid IP");return(h[0]<<24|h[1])>>>0;case 3:if(h[0]>255||h[1]>255||h[2]>65535)throw new Error("Invalid IP");return(h[0]<<24|h[1]<<16|h[2])>>>0;case 4:if(h[0]>255||h[1]>255||h[2]>255||h[3]>255)throw new Error("Invalid IP");return(h[0]<<24|h[1]<<16|h[2]<<8|h[3])>>>0;default:throw new Error("Invalid IP")}},e=function(c){return c.charCodeAt(0)},n=e("0"),i=e("a"),o=e("A"),t=function(c){var h,f,u,l,w;for(l=0,h=10,f="9",u=0,c.length>1&&c[u]==="0"&&(c[u+1]==="x"||c[u+1]==="X"?(u+=2,h=16):"0"<=c[u+1]&&c[u+1]<="9"&&(u++,h=8,f="7")),w=u;u<c.length;){if("0"<=c[u]&&c[u]<=f)l=l*h+(e(c[u])-n)>>>0;else if(h===16)if("a"<=c[u]&&c[u]<="f")l=l*h+(10+e(c[u])-i)>>>0;else if("A"<=c[u]&&c[u]<="F")l=l*h+(10+e(c[u])-o)>>>0;else break;else break;if(l>4294967295)throw new Error("too large");u++}if(u===w)throw new Error("empty octet");return[l,u]},r=function(){function c(h,f){var u,l,w,d;if(typeof h!="string")throw new Error("Missing `net' parameter");if(f||(d=h.split("/",2),h=d[0],f=d[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=s(f)}catch(E){throw u=E,new Error("Invalid mask: "+f)}for(l=w=32;w>=0;l=--w)if(this.maskLong===4294967295<<32-l>>>0){this.bitmask=l;break}}else if(f||f===0)this.bitmask=parseInt(f,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(s(h)&this.maskLong)>>>0}catch(E){throw u=E,new Error("Invalid net address: "+h)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(h){return typeof h=="string"&&(h.indexOf("/")>0||h.split(".").length!==4)&&(h=new c(h)),h instanceof c?this.contains(h.base)&&this.contains(h.broadcast||h.last):(s(h)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(h){return h==null&&(h=1),new c(a(this.netLong+this.size*h),this.mask)},c.prototype.forEach=function(h){var f,u,l;for(l=s(this.first),u=s(this.last),f=0;l<=u;)h(a(l),l,f),f++,l++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),Nt.ip2long=s,Nt.long2ip=a,Nt.Netmask=r}).call(Nt)});var Gi={};U(Gi,{dcutr:()=>$i,multicodec:()=>wt});var B=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var rt="ERR_INVALID_MESSAGE";var qi=Symbol.for("@libp2p/service-capabilities"),br=Symbol.for("@libp2p/service-dependencies");var ie={};U(ie,{base58btc:()=>S,base58flickr:()=>jn});var gs=new Uint8Array(0);function xr(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function W(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function yr(r){return new TextEncoder().encode(r)}function Ir(r){return new TextDecoder().decode(r)}function Vn(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var a=r.length,c=r.charAt(0),h=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function u(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var E=0,et=0,M=0,O=d.length;M!==O&&d[M]===0;)M++,E++;for(var z=(O-M)*f+1>>>0,C=new Uint8Array(z);M!==O;){for(var $=d[M],H=0,k=z-1;($!==0||H<et)&&k!==-1;k--,H++)$+=256*C[k]>>>0,C[k]=$%a>>>0,$=$/a>>>0;if($!==0)throw new Error("Non-zero carry");et=H,M++}for(var j=z-et;j!==z&&C[j]===0;)j++;for(var Dt=c.repeat(E);j<z;++j)Dt+=r.charAt(C[j]);return Dt}function l(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var E=0;if(d[E]!==" "){for(var et=0,M=0;d[E]===c;)et++,E++;for(var O=(d.length-E)*h+1>>>0,z=new Uint8Array(O);d[E];){var C=e[d.charCodeAt(E)];if(C===255)return;for(var $=0,H=O-1;(C!==0||$<M)&&H!==-1;H--,$++)C+=a*z[H]>>>0,z[H]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");M=$,E++}if(d[E]!==" "){for(var k=O-M;k!==O&&z[k]===0;)k++;for(var j=new Uint8Array(et+(O-k)),Dt=et;k!==O;)j[Dt++]=z[k++];return j}}}function w(d){var E=l(d);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:l,decode:w}}var On=Vn,zn=On,Ar=zn;var ee=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},re=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Sr(this,t)}},ne=class{decoders;constructor(t){this.decoders=t}or(t){return Sr(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Sr(r,t){return new ne({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var oe=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new ee(t,e,n),this.decoder=new re(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function st({name:r,prefix:t,encode:e,decode:n}){return new oe(r,t,e,n)}function Z({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ar(e,r);return st({prefix:t,name:r,encode:n,decode:i=>W(o(i))})}function $n(r,t,e,n){let o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),a=0,c=0,h=0;for(let f=0;f<i;++f){let u=o[r[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,a+=e,a>=8&&(a-=8,s[h++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Gn(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>e;)s-=e,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<e-s]),n)for(;i.length*e&7;)i+="=";return i}function x({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return st({prefix:t,name:r,encode(o){return Gn(o,n,e)},decode(o){return $n(o,n,e,r)}})}var S=Z({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),jn=Z({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var se={};U(se,{base32:()=>q,base32hex:()=>Qn,base32hexpad:()=>Hn,base32hexpadupper:()=>Zn,base32hexupper:()=>Jn,base32pad:()=>qn,base32padupper:()=>Xn,base32upper:()=>Wn,base32z:()=>Kn});var q=x({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wn=x({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qn=x({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Xn=x({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qn=x({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jn=x({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Hn=x({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zn=x({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Kn=x({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Yn=Fr,vr=128,to=127,eo=~to,ro=Math.pow(2,31);function Fr(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ro;)t[e++]=r&255|vr,r/=128;for(;r&eo;)t[e++]=r&255|vr,r>>>=7;return t[e]=r|0,Fr.bytes=e-n+1,t}var no=ae,oo=128,Nr=127;function ae(r,n){var e=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw ae.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&Nr)<<o:(s&Nr)*Math.pow(2,o),o+=7}while(s>=oo);return ae.bytes=i-n,e}var io=Math.pow(2,7),so=Math.pow(2,14),ao=Math.pow(2,21),co=Math.pow(2,28),ho=Math.pow(2,35),uo=Math.pow(2,42),fo=Math.pow(2,49),lo=Math.pow(2,56),po=Math.pow(2,63),mo=function(r){return r<io?1:r<so?2:r<ao?3:r<co?4:r<ho?5:r<uo?6:r<fo?7:r<lo?8:r<po?9:10},go={encode:Yn,decode:no,encodingLength:mo},wo=go,bt=wo;function xt(r,t=0){return[bt.decode(r,t),bt.decode.bytes]}function at(r,t,e=0){return bt.encode(r,t,e),t}function ct(r){return bt.encodingLength(r)}function nt(r,t){let e=t.byteLength,n=ct(r),o=n+ct(e),i=new Uint8Array(o+e);return at(r,i,0),at(e,i,n),i.set(t,o),new ht(r,e,t,i)}function Ct(r){let t=W(r),[e,n]=xt(t),[o,i]=xt(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ht(e,o,s,t)}function Lr(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&xr(r.bytes,e.bytes)}}var ht=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Dr(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return xo(e,ce(r),t??S.encoder);default:return yo(e,ce(r),t??q.encoder)}}var Ur=new WeakMap;function ce(r){let t=Ur.get(r);if(t==null){let e=new Map;return Ur.set(r,e),e}return t}var K=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==yt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Io)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=nt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Lr(t.multihash,n.multihash)}toString(t){return Dr(this,t)}toJSON(){return{"/":Dr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s??Tr(n,o,i.bytes))}else if(e[Eo]===!0){let{version:n,multihash:o,code:i}=e,s=Ct(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==yt)throw new Error(`Version 0 CID must use dag-pb (code: ${yt}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Tr(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,yt,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=W(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new ht(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[u,l]=xt(t.subarray(e));return e+=l,u},o=n(),i=yt;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,a=n(),c=n(),h=e+c,f=h-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:h}}static parse(t,e){let[n,o]=bo(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ce(i).set(n,t),i}};function bo(r,t){switch(r[0]){case"Q":{let e=t??S;return[S.prefix,e.decode(`${S.prefix}${r}`)]}case S.prefix:{let e=t??S;return[S.prefix,e.decode(r)]}case q.prefix:{let e=t??q;return[q.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function xo(r,t,e){let{prefix:n}=e;if(n!==S.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function yo(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o}var yt=112,Io=18;function Tr(r,t,e){let n=ct(r),o=n+ct(t),i=new Uint8Array(o+e.byteLength);return at(r,i,0),at(t,i,n),i.set(e,o),i}var Eo=Symbol.for("@ipld/js-cid/CID");function Rt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var he={};U(he,{base10:()=>Ao});var Ao=Z({prefix:"9",name:"base10",alphabet:"0123456789"});var ue={};U(ue,{base16:()=>So,base16upper:()=>vo});var So=x({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),vo=x({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var fe={};U(fe,{base2:()=>No});var No=x({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var le={};U(le,{base256emoji:()=>To});var Cr=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}"),Fo=Cr.reduce((r,t,e)=>(r[e]=t,r),[]),Lo=Cr.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Do(r){return r.reduce((t,e)=>(t+=Fo[e],t),"")}function Uo(r){let t=[];for(let e of r){let n=Lo[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var To=st({prefix:"\u{1F680}",name:"base256emoji",encode:Do,decode:Uo});var de={};U(de,{base36:()=>Co,base36upper:()=>Ro});var Co=Z({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ro=Z({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var me={};U(me,{base64:()=>Po,base64pad:()=>Mo,base64url:()=>pe,base64urlpad:()=>ko});var Po=x({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Mo=x({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),pe=x({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ko=x({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ge={};U(ge,{base8:()=>Bo});var Bo=x({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var we={};U(we,{identity:()=>_o});var _o=st({prefix:"\0",name:"identity",encode:r=>Ir(r),decode:r=>yr(r)});var zs=new TextEncoder,$s=new TextDecoder;var be={};U(be,{identity:()=>Go});var Rr=0,zo="identity",Pr=W;function $o(r){return nt(Rr,Pr(r))}var Go={code:Rr,name:zo,encode:Pr,digest:$o};var Ie={};U(Ie,{sha256:()=>jo,sha512:()=>Wo});function ye({name:r,code:t,encode:e}){return new xe(r,t,e)}var xe=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?nt(this.code,e):e.then(n=>nt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function kr(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var jo=ye({name:"sha2-256",code:18,encode:kr("SHA-256")}),Wo=ye({name:"sha2-512",code:19,encode:kr("SHA-512")});var It={...we,...fe,...ge,...he,...ue,...se,...de,...ie,...me,...le},ea={...Ie,...be};function X(r=0){return new Uint8Array(r)}function L(r=0){return new Uint8Array(r)}function _r(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Br=_r("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ee=_r("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=L(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),qo={utf8:Br,"utf-8":Br,hex:It.base16,latin1:Ee,ascii:Ee,binary:Ee,...It},Pt=qo;function D(r,t="utf8"){let e=Pt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Xo=Math.pow(2,7),Qo=Math.pow(2,14),Jo=Math.pow(2,21),Ae=Math.pow(2,28),Se=Math.pow(2,35),ve=Math.pow(2,42),Ne=Math.pow(2,49),m=128,v=127;function N(r){if(r<Xo)return 1;if(r<Qo)return 2;if(r<Jo)return 3;if(r<Ae)return 4;if(r<Se)return 5;if(r<ve)return 6;if(r<Ne)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Fe(r,t,e=0){switch(N(r)){case 8:t[e++]=r&255|m,r/=128;case 7:t[e++]=r&255|m,r/=128;case 6:t[e++]=r&255|m,r/=128;case 5:t[e++]=r&255|m,r/=128;case 4:t[e++]=r&255|m,r>>>=7;case 3:t[e++]=r&255|m,r>>>=7;case 2:t[e++]=r&255|m,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Ho(r,t,e=0){switch(N(r)){case 8:t.set(e++,r&255|m),r/=128;case 7:t.set(e++,r&255|m),r/=128;case 6:t.set(e++,r&255|m),r/=128;case 5:t.set(e++,r&255|m),r/=128;case 4:t.set(e++,r&255|m),r>>>=7;case 3:t.set(e++,r&255|m),r>>>=7;case 2:t.set(e++,r&255|m),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Le(r,t){let e=r[t],n=0;if(n+=e&v,e<m||(e=r[t+1],n+=(e&v)<<7,e<m)||(e=r[t+2],n+=(e&v)<<14,e<m)||(e=r[t+3],n+=(e&v)<<21,e<m)||(e=r[t+4],n+=(e&v)*Ae,e<m)||(e=r[t+5],n+=(e&v)*Se,e<m)||(e=r[t+6],n+=(e&v)*ve,e<m)||(e=r[t+7],n+=(e&v)*Ne,e<m))return n;throw new RangeError("Could not decode varint")}function Zo(r,t){let e=r.get(t),n=0;if(n+=e&v,e<m||(e=r.get(t+1),n+=(e&v)<<7,e<m)||(e=r.get(t+2),n+=(e&v)<<14,e<m)||(e=r.get(t+3),n+=(e&v)<<21,e<m)||(e=r.get(t+4),n+=(e&v)*Ae,e<m)||(e=r.get(t+5),n+=(e&v)*Se,e<m)||(e=r.get(t+6),n+=(e&v)*ve,e<m)||(e=r.get(t+7),n+=(e&v)*Ne,e<m))return n;throw new RangeError("Could not decode varint")}function Y(r,t,e=0){return t==null&&(t=L(N(r))),t instanceof Uint8Array?Fe(r,t,e):Ho(r,t,e)}function Q(r,t=0){return r instanceof Uint8Array?Le(r,t):Zo(r,t)}function R(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=L(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Mt=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",h=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let l=Number.parseInt(u,t);if(!Number.isNaN(l))return l});if(f===void 0)break;if(i*=t,i+=f,i>h||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2],e[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];e[o]=i>>8,e[o+1]=i&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return e.set(i.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Vr=45,Ko=15,ft=new Mt;function Ue(r){if(!(r.length>Ko))return ft.new(r).parseWith(()=>ft.readIPv4Addr())}function Te(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Vr))return ft.new(r).parseWith(()=>ft.readIPv6Addr())}function kt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Vr))return ft.new(r).parseWith(()=>ft.readIPAddr())}var Sa=parseInt("0xFFFF",16),va=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Et(r,t="utf8"){let e=Pt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function lt(r){return!!Ue(r)}function dt(r){return!!Te(r)}function Bt(r){return!!kt(r)}var $r=lt,ni=dt,Ce=function(r){let t=0;if(r=r.toString().trim(),$r(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(ni(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=$r(e[n]),s;i&&(s=Ce(e[n]),e[n]=D(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,D(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Gr=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var pt={},Re={},ii=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];ii.forEach(r=>{let t=si(...r);Re[t.code]=t,pt[t.name]=t});function si(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function b(r){if(typeof r=="number"){if(Re[r]!=null)return Re[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(pt[r]!=null)return pt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var uc=b("ip4"),fc=b("ip6"),lc=b("ipcidr");function Be(r,t){switch(b(r).code){case 4:case 41:return ci(t);case 42:return ke(t);case 6:case 273:case 33:case 132:return qr(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ke(t);case 421:return li(t);case 444:return Wr(t);case 445:return Wr(t);case 466:return fi(t);case 481:return globalThis.encodeURIComponent(ke(t));default:return D(t,"base16")}}function _e(r,t){switch(b(r).code){case 4:return jr(t);case 41:return jr(t);case 42:return Me(t);case 6:case 273:case 33:case 132:return Ve(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Me(t);case 421:return hi(t);case 444:return di(t);case 445:return pi(t);case 466:return ui(t);case 481:return Me(globalThis.decodeURIComponent(t));default:return Et(t,"base16")}}var Pe=Object.values(It).map(r=>r.decoder),ai=function(){let r=Pe[0].or(Pe[1]);return Pe.slice(2).forEach(t=>r=r.or(t)),r}();function jr(r){if(!Bt(r))throw new Error("invalid ip address");return Ce(r)}function ci(r){let t=Gr(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Bt(t))throw new Error("invalid ip address");return t}function Ve(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function qr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Me(r){let t=Et(r),e=Uint8Array.from(Y(t.length));return R([e,t],e.length+t.length)}function ke(r){let t=Q(r);if(r=r.slice(N(t)),r.length!==t)throw new Error("inconsistent lengths");return D(r)}function hi(r){let t;r[0]==="Q"||r[0]==="1"?t=Ct(S.decode(`z${r}`)).bytes:t=K.parse(r).multihash.bytes;let e=Uint8Array.from(Y(t.length));return R([e,t],e.length+t.length)}function ui(r){let t=ai.decode(r),e=Uint8Array.from(Y(t.length));return R([e,t],e.length+t.length)}function fi(r){let t=Q(r),e=r.slice(N(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+D(e,"base64url")}function li(r){let t=Q(r),e=r.slice(N(t));if(e.length!==t)throw new Error("inconsistent lengths");return D(e,"base58btc")}function di(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=q.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ve(n);return R([e,o],e.length+o.length)}function pi(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=q.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ve(n);return R([e,o],e.length+o.length)}function Wr(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=D(t,"base32"),o=qr(e);return`${n}:${o}`}function Xr(r){r=Oe(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=b(s);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(i++,i>=o.length)throw Jr("invalid address: "+r);if(a.path===!0){n=Oe(o.slice(i).join("/")),t.push([a.code,_e(a.code,n)]),e.push([a.code,n]);break}let c=_e(a.code,o[i]);t.push([a.code,c]),e.push([a.code,Be(a.code,c)])}return{string:Qr(e),bytes:$e(t),tuples:t,stringTuples:e,path:n}}function ze(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=Q(r,o),s=N(i),a=b(i),c=mi(a,r.slice(o+s));if(c===0){t.push([i]),e.push([i]),o+=s;continue}let h=r.slice(o+s,o+s+c);if(o+=c+s,o>r.length)throw Jr("Invalid address Uint8Array: "+D(r,"base16"));t.push([i,h]);let f=Be(i,h);if(e.push([i,f]),a.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:Qr(e),tuples:t,stringTuples:e,path:n}}function Qr(r){let t=[];return r.map(e=>{let n=b(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Oe(t.join("/"))}function $e(r){return R(r.map(t=>{let e=b(t[0]),n=Uint8Array.from(Y(e.code));return t.length>1&&t[1]!=null&&(n=R([n,t[1]])),n}))}function mi(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=Q(t instanceof Uint8Array?t:Uint8Array.from(t));return e+N(e)}}function Oe(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Jr(r){return new Error("Error parsing address: "+r)}var gi=Symbol.for("nodejs.util.inspect.custom"),Ge=Symbol.for("@multiformats/js-multiaddr/multiaddr"),wi=[b("dns").code,b("dns4").code,b("dns6").code,b("dnsaddr").code],_t=class r{bytes;#e;#t;#r;#n;[Ge]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=ze(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Xr(t)}else if(Zr(t))e=ze(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",s=b("tcp"),a=b("udp"),c=b("ip4"),h=b("ip6"),f=b("dns6"),u=b("ip6zone");for(let[w,d]of this.stringTuples())w===u.code&&(i=`%${d??""}`),wi.includes(w)&&(e=s.name,o=443,n=`${d??""}${i}`,t=w===f.code?6:4),(w===s.code||w===a.code)&&(e=b(w).name,o=parseInt(d??"")),(w===c.code||w===h.code)&&(e=b(w).name,n=`${d??""}${i}`,t=w===h.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},b(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>b(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r($e(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===pt.p2p.code&&t.push([n,o]),n===pt["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?D(S.decode(`z${n}`),"base58btc"):D(K.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Rt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=Hr.get(e.name);if(n==null)throw new B(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(i=>At(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[gi](){return`Multiaddr(${this.#e})`}};var Hr=new Map;function Zr(r){return!!r?.[Ge]}function At(r){return new _t(r)}var Kr=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},bi=new WeakMap;function xi({clearTimeout:r,setTimeout:t}={}){return(e,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(Kr());let i,s,a,c=r??clearTimeout,h=()=>{c(i),a(Kr())},f=()=>{o&&o.removeEventListener("abort",h)},u=new Promise((l,w)=>{s=()=>{f(),l(n)},a=w,i=(t??setTimeout)(s,e)});return o&&o.addEventListener("abort",h,{once:!0}),bi.set(u,()=>{c(i),i=null,s()}),u}}var yi=xi(),Yr=yi;function mt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Vt=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function tn(r,t,e){if(t==null)return r;if(t.aborted)return Promise.reject(new Vt(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Vt(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((i,s)=>{n=()=>{s(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var je=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=mt(),this.haveNext=mt()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=mt(),t}async throw(t){return this.ended=!0,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return await this._push(void 0),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=mt(),await tn(this.readNext.promise,e?.signal,e)}};function en(){return new je}var nn=Symbol.for("@achingbrain/uint8arraylist");function rn(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function Ot(r){return!!r?.[nn]}var J=class r{bufs;length;[nn]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Ot(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Ot(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=rn(this.bufs,t);return e.buf[e.index]}set(t,e){let n=rn(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Ot(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return R(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:R(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=[...n],i}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let h=t>=a&&t<c,f=e>a&&e<=c;if(h&&f){if(t===a&&e===c){n.push(s);break}let u=t-a;n.push(s.subarray(u,u+(e-t)));break}if(h){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(f){if(e===c){n.push(s);break}n.push(s.subarray(0,e-a));break}n.push(s)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Ot(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let u=0;u<i;u++)s[u]=-1;for(let u=0;u<o;u++)s[n[u]]=u;let a=s,c=this.byteLength-n.byteLength,h=n.byteLength-1,f;for(let u=e;u<=c;u+=f){f=0;for(let l=h;l>=0;l--){let w=this.get(u+l);if(n[l]!==w){f=Math.max(1,l-a[w]);break}}if(f===0)return u}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=L(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=X(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=X(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=X(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=L(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=X(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=X(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=X(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=X(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=X(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!Rt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,i)=>o+i.byteLength,0)),n.length=e,n}};var zt=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var We=class extends Error{code;constructor(t,e){super(t),this.code=e}},qe=class extends We{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function on(r,t){let e=en();r.sink(e).catch(async s=>{await e.end(s)}),r.sink=async s=>{for await(let a of s)await e.push(a);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new J;return{read:async(s,a)=>{a?.signal?.throwIfAborted();let c,h=new Promise((f,u)=>{c=()=>{u(new qe("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(s==null){let{done:u,value:l}=await Promise.race([n.next(),h]);return u===!0?new J:l}for(;o.byteLength<s;){let{value:u,done:l}=await Promise.race([n.next(),h]);if(l===!0)throw new zt("unexpected end of input");o.append(u)}let f=o.sublist(0,s);return o.consume(s),f}finally{c!=null&&a?.signal?.removeEventListener("abort",c)}},write:async(s,a)=>{a?.signal?.throwIfAborted(),s instanceof Uint8Array?await e.push(s,a):await e.push(s.subarray(),a)},unwrap:()=>{if(o.byteLength>0){let s=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*s}()}return r}}}var $t=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Gt=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},jt=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function sn(r,t={}){let e=on(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=N(t.maxDataLength));let n=t?.lengthDecoder??Q,o=t?.lengthEncoder??Y;return{read:async s=>{let a=-1,c=new J;for(;;){c.append(await e.read(1,s));try{a=n(c)}catch(h){if(h instanceof RangeError)continue;throw h}if(a<0)throw new $t("Invalid message length");if(t?.maxLengthLength!=null&&c.byteLength>t.maxLengthLength)throw new jt("message length length too long");if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new Gt("message length too long");return e.read(a,s)},write:async(s,a)=>{await e.write(new J(o(s.byteLength),s),a)},writeV:async(s,a)=>{let c=new J(...s.flatMap(h=>[o(h.byteLength),h]));await e.write(c,a)},unwrap:()=>e.unwrap()}}function Xe(r,t){let e=sn(r,t),n={read:async(o,i)=>{let s=await e.read(i);return o.decode(s)},write:async(o,i,s)=>{await e.write(i.encode(o),s)},writeV:async(o,i,s)=>{await e.writeV(o.map(a=>i.encode(a)),s)},pb:o=>({read:async i=>n.read(o,i),write:async(i,s)=>n.write(i,o,s),writeV:async(i,s)=>n.writeV(i,o,s),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var Qe=new Float32Array([-0]),tt=new Uint8Array(Qe.buffer);function an(r,t,e){Qe[0]=r,t[e]=tt[0],t[e+1]=tt[1],t[e+2]=tt[2],t[e+3]=tt[3]}function cn(r,t){return tt[0]=r[t],tt[1]=r[t+1],tt[2]=r[t+2],tt[3]=r[t+3],Qe[0]}var Je=new Float64Array([-0]),F=new Uint8Array(Je.buffer);function hn(r,t,e){Je[0]=r,t[e]=F[0],t[e+1]=F[1],t[e+2]=F[2],t[e+3]=F[3],t[e+4]=F[4],t[e+5]=F[5],t[e+6]=F[6],t[e+7]=F[7]}function un(r,t){return F[0]=r[t],F[1]=r[t+1],F[2]=r[t+2],F[3]=r[t+3],F[4]=r[t+4],F[5]=r[t+5],F[6]=r[t+6],F[7]=r[t+7],Je[0]}var Ii=BigInt(Number.MAX_SAFE_INTEGER),Ei=BigInt(Number.MIN_SAFE_INTEGER),T=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ot;if(t<Ii&&t>Ei)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>fn&&(o=0n,++n>fn&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ot;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ot}},ot=new T(0,0);ot.toBigInt=function(){return 0n};ot.zzEncode=ot.zzDecode=function(){return this};ot.length=function(){return 1};var fn=4294967296n;function ln(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function dn(r,t,e){if(e-t<1)return"";let o,i=[],s=0,a;for(;t<e;)a=r[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function He(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function _(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Wt(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Ze=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,_(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw _(this,4);return Wt(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw _(this,4);return Wt(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw _(this,4);let t=cn(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw _(this,4);let t=un(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw _(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return dn(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw _(this,t);this.pos+=t}else do if(this.pos>=this.len)throw _(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new T(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw _(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw _(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw _(this,8);let t=Wt(this.buf,this.pos+=4),e=Wt(this.buf,this.pos+=4);return new T(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Le(this.buf,this.pos);return this.pos+=N(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Ke(r){return new Ze(r instanceof Uint8Array?r:r.subarray())}function Ye(r,t,e){let n=Ke(r);return t.decode(n,void 0,e)}function tr(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return L(s);o+s>t&&(n=L(t),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var it=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function er(){}var nr=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Ai=tr();function Si(r){return globalThis.Buffer!=null?L(r):Ai(r)}var vt=class{len;head;tail;states;constructor(){this.len=0,this.head=new it(er,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new it(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new or((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(qt,10,T.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=T.fromBigInt(t);return this._push(qt,e.length(),e)}uint64Number(t){return this._push(Fe,N(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=T.fromBigInt(t).zzEncode();return this._push(qt,e.length(),e)}sint64Number(t){let e=T.fromNumber(t).zzEncode();return this._push(qt,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(rr,1,t?1:0)}fixed32(t){return this._push(St,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=T.fromBigInt(t);return this._push(St,4,e.lo)._push(St,4,e.hi)}fixed64Number(t){let e=T.fromNumber(t);return this._push(St,4,e.lo)._push(St,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(an,4,t)}double(t){return this._push(hn,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(rr,1,0):this.uint32(e)._push(Ni,e,t)}string(t){let e=ln(t);return e!==0?this.uint32(e)._push(He,e,t):this._push(rr,1,0)}fork(){return this.states=new nr(this),this.head=this.tail=new it(er,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new it(er,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Si(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function rr(r,t,e){t[e]=r&255}function vi(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var or=class extends it{next;constructor(t,e){super(vi,t,e),this.next=void 0}};function qt(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function St(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Ni(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(vt.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Fi,t,r),this},vt.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Li,t,r),this});function Fi(r,t,e){t.set(r,e)}function Li(r,t,e){r.length<40?He(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Et(r),e)}function ir(){return new vt}function sr(r,t){let e=ir();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var gt;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(gt||(gt={}));function Xt(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function ar(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return Xt("enum",gt.VARINT,e,n)}function cr(r,t){return Xt("message",gt.LENGTH_DELIMITED,r,t)}var V;(function(r){let t;(function(o){o.UNUSED="UNUSED",o.CONNECT="CONNECT",o.SYNC="SYNC"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.UNUSED=0]="UNUSED",o[o.CONNECT=100]="CONNECT",o[o.SYNC=300]="SYNC"})(e||(e={})),function(o){o.codec=()=>ar(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=cr((o,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.observedAddresses!=null)for(let a of o.observedAddresses)i.uint32(18),i.bytes(a);s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={observedAddresses:[]},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let c=o.uint32();switch(c>>>3){case 1:s.type=r.Type.codec().decode(o);break;case 2:s.observedAddresses.push(o.bytes());break;default:o.skipType(c&7);break}}return s})),n),r.encode=o=>sr(o,r.codec()),r.decode=o=>Ye(o,r.codec())})(V||(V={}));var gn=Bn(mn(),1),Di=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],Ui=Di.map(r=>new gn.Netmask(r));function hr(r){for(let t of Ui)if(t.contains(r))return!0;return!1}function Ti(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function Ci(r){let t=r.split(":");if(t.length<2)return!1;let e=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(e.substring(0,2),16)}.${parseInt(e.substring(2),16)}`;return hr(o)}function Ri(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function Pi(r){let t=r.split(":"),e=t[t.length-1];return hr(e)}function Mi(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function wn(r){return lt(r)?hr(r):Ti(r)?Ci(r):Ri(r)?Pi(r):dt(r)?Mi(r):void 0}var ki=r=>r.toString().split("/").slice(1),Ft=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),p=r=>({match:t=>Ft(e=>e===r).match(t),pattern:r}),Ht=()=>({match:r=>Ft(t=>typeof t=="string").match(r),pattern:"{string}"}),Zt=()=>({match:r=>Ft(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),A=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{S.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),Qt=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{pe.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),I=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),P=(...r)=>({match:t=>{let e;for(let n of r){let o=n.match(t);o!==!1&&(e==null||o.length<e.length)&&(e=o)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),g=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function y(...r){function t(o){let i=ki(o);for(let s of r){let a=s.match(i);if(a===!1)return!1;i=a}return i}function e(o){return t(o)!==!1}function n(o){let i=t(o);return i===!1?!1:i.length===0}return{matches:e,exactMatch:n}}var fr=g(p("dns4"),Ht()),lr=g(p("dns6"),Ht()),dr=g(p("dnsaddr"),Ht()),bn=g(p("dns"),Ht()),Wh=y(fr),qh=y(lr),Xh=y(dr),xn=y(P(bn,dr,fr,lr)),yn=g(p("ip4"),Ft(lt)),In=g(p("ip6"),Ft(dt)),En=P(yn,In),G=P(En,bn,fr,lr,dr),Qh=y(G),Jh=y(yn),Hh=y(In),An=y(En),pr=g(G,p("tcp"),Zt()),Lt=g(G,p("udp"),Zt()),Zh=y(pr),Kh=y(Lt),mr=g(Lt,p("quic")),Kt=g(Lt,p("quic-v1")),Bi=P(mr,Kt),Yh=y(mr),tu=y(Kt),ur=P(G,pr,Lt,mr,Kt),Sn=P(g(ur,p("ws"),I(A()))),eu=y(Sn),vn=P(g(ur,p("wss"),I(A())),g(ur,p("tls"),p("ws"),I(A()))),ru=y(vn),Nn=g(Lt,p("webrtc-direct"),I(Qt()),I(Qt()),I(A())),nu=y(Nn),Fn=g(Kt,p("webtransport"),I(Qt()),I(Qt()),I(A())),ou=y(Fn),Jt=P(Sn,vn,g(pr,I(A())),g(Bi,I(A())),g(G,I(A())),Nn,Fn,A()),iu=y(Jt),_i=g(Jt,p("p2p-circuit"),A()),Ln=y(_i),Vi=P(g(Jt,p("p2p-circuit"),p("webrtc"),I(A())),g(Jt,p("webrtc"),I(A())),p("webrtc")),su=y(Vi),Oi=P(g(G,p("tcp"),Zt(),p("http"),I(A())),g(G,p("http"),I(A()))),au=y(Oi),zi=P(g(G,p("tcp"),P(g(p("443"),p("http")),g(Zt(),p("https"))),I(A())),g(G,p("tls"),p("http"),I(A())),g(G,p("https"),I(A()))),cu=y(zi);function gr(r,t){return Ln.matches(r)||t.dialTransportForMultiaddr(r)==null?!1:xn.matches(r)?!0:An.matches(r)?wn(r.toOptions().host)===!1:!1}var Dn=1024*4,Un=100,Yt={timeout:5e3,retries:3,maxInboundStreams:1,maxOutboundStreams:1},te=class{started;timeout;retries;maxInboundStreams;maxOutboundStreams;peerStore;registrar;connectionManager;addressManager;transportManager;topologyId;log;constructor(t,e){this.log=t.logger.forComponent("libp2p:dcutr"),this.started=!1,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.connectionManager=t.connectionManager,this.transportManager=t.transportManager,this.timeout=e.timeout??Yt.timeout,this.retries=e.retries??Yt.retries,this.maxInboundStreams=e.maxInboundStreams??Yt.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??Yt.maxOutboundStreams}[Symbol.toStringTag]="@libp2p/dcutr";[br]=["@libp2p/identify"];isStarted(){return this.started}async start(){this.started||(this.topologyId=await this.registrar.register(wt,{notifyOnTransient:!0,onConnect:(t,e)=>{e.transient&&e.direction==="inbound"&&this.upgradeInbound(e).catch(n=>{this.log.error("error during outgoing DCUtR attempt",n)})}}),await this.registrar.handle(wt,t=>{this.handleIncomingUpgrade(t.stream,t.connection).catch(e=>{this.log.error("error during incoming DCUtR attempt",e),t.stream.abort(e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:!0}),this.started=!0)}async stop(){await this.registrar.unhandle(wt),this.topologyId!=null&&this.registrar.unregister(this.topologyId),this.started=!1}async upgradeInbound(t){if(await this.attemptUnilateralConnectionUpgrade(t))return;let e;for(let n=0;n<this.retries;n++){let o={signal:AbortSignal.timeout(this.timeout)};try{e=await t.newStream([wt],{signal:o.signal,runOnTransientConnection:!0});let i=Xe(e,{maxDataLength:Dn}).pb(V);this.log("B sending connect to %p",t.remotePeer);let s=Date.now();await i.write({type:V.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(u=>u.bytes)},o),this.log("B receiving connect from %p",t.remotePeer);let a=await i.read(o);if(a.type!==V.Type.CONNECT)throw this.log("A sent wrong message type"),new B("DCUtR message type was incorrect",rt);let c=this.getDialableMultiaddrs(a.observedAddresses);if(c.length===0)throw this.log("A did not have any dialable multiaddrs"),new B("DCUtR connect message had no multiaddrs",rt);let h=Date.now()-s;this.log("A sending sync, rtt %dms",h),await i.write({type:V.Type.SYNC,observedAddresses:[]},o),this.log("A waiting for half RTT"),await Yr(h/2),this.log("B dialing",c);let f=await this.connectionManager.openConnection(c,{signal:o.signal,priority:Un});this.log("DCUtR to %p succeeded to address %a, closing relayed connection",t.remotePeer,f.remoteAddr),await t.close(o);break}catch(i){if(this.log.error("error while attempting DCUtR on attempt %d of %d",n+1,this.retries,i),e?.abort(i),n===this.retries)throw i}finally{e!=null&&await e.close(o)}}}async attemptUnilateralConnectionUpgrade(t){let n=(await this.peerStore.get(t.remotePeer)).addresses.map(o=>{let i=o.multiaddr;return i.getPeerId()==null?i.encapsulate(`/p2p/${t.remotePeer}`):i}).filter(o=>gr(o,this.transportManager));if(n.length>0){let o=AbortSignal.timeout(this.timeout);try{this.log("attempting unilateral connection upgrade to %a",n);let i=await this.connectionManager.openConnection(n,{signal:o,force:!0});if(i.transient)throw new Error("Could not open a new, non-transient, connection");return this.log("unilateral connection upgrade to %p succeeded via %a, closing relayed connection",t.remotePeer,i.remoteAddr),await t.close({signal:o}),!0}catch(i){this.log.error("unilateral connection upgrade to %p on addresses %a failed",t.remotePeer,n,i)}}else this.log("peer %p has no public addresses, not attempting unilateral connection upgrade",t.remotePeer);return!1}async handleIncomingUpgrade(t,e){let n={signal:AbortSignal.timeout(this.timeout)};try{let o=Xe(t,{maxDataLength:Dn}).pb(V);this.log("A receiving connect");let i=await o.read(n);if(i.type!==V.Type.CONNECT)throw this.log("B sent wrong message type"),new B("DCUtR message type was incorrect",rt);if(i.observedAddresses.length===0)throw this.log("B sent no multiaddrs"),new B("DCUtR connect message had no multiaddrs",rt);let s=this.getDialableMultiaddrs(i.observedAddresses);if(s.length===0)throw this.log("B had no dialable multiaddrs"),new B("DCUtR connect message had no dialable multiaddrs",rt);if(this.log("A sending connect"),await o.write({type:V.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(h=>h.bytes)}),this.log("A receiving sync"),(await o.read(n)).type!==V.Type.SYNC)throw new B("DCUtR message type was incorrect",rt);this.log("A dialing",s);let c=await this.connectionManager.openConnection(s,{signal:n.signal,priority:Un,force:!0});this.log("DCUtR to %p succeeded via %a, closing relayed connection",e.remotePeer,c.remoteAddr),await e.close(n)}catch(o){this.log.error("incoming DCUtR from %p failed",e.remotePeer,o),t.abort(o)}finally{await t.close(n)}}getDialableMultiaddrs(t){let e=[];for(let n of t)if(!(n==null||n.length===0))try{let o=At(n);if(!gr(o,this.transportManager))continue;e.push(o)}catch{}return e}};var wt="/libp2p/dcutr";function $i(r={}){return t=>new te(t,r)}return _n(Gi);})();
|
|
2
|
+
"use strict";var Libp2PDcutr=(()=>{var Tn=Object.create;var Dt=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var Mn=Object.getOwnPropertyNames;var kn=Object.getPrototypeOf,Rn=Object.prototype.hasOwnProperty;var Bn=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),D=(r,t)=>{for(var e in t)Dt(r,e,{get:t[e],enumerable:!0})},xr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Mn(t))!Rn.call(r,o)&&o!==e&&Dt(r,o,{get:()=>t[o],enumerable:!(n=Pn(t,o))||n.enumerable});return r};var Vn=(r,t,e)=>(e=r!=null?Tn(kn(r)):{},xr(t||!r||!r.__esModule?Dt(e,"default",{value:r,enumerable:!0}):e,r)),On=r=>xr(Dt({},"__esModule",{value:!0}),r);var Nn=Bn(Lt=>{(function(){var r,t,e,n,o,s,i,a;a=function(c){var h,l,u,f;return h=(c&255<<24)>>>24,l=(c&255<<16)>>>16,u=(c&65280)>>>8,f=c&255,[h,l,u,f].join(".")},i=function(c){var h,l,u,f,w,d;for(h=[],u=f=0;f<=3&&c.length!==0;u=++f){if(u>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}d=t(c),w=d[0],l=d[1],c=c.substring(l),h.push(w)}if(c.length!==0)throw new Error("Invalid IP");switch(h.length){case 1:if(h[0]>4294967295)throw new Error("Invalid IP");return h[0]>>>0;case 2:if(h[0]>255||h[1]>16777215)throw new Error("Invalid IP");return(h[0]<<24|h[1])>>>0;case 3:if(h[0]>255||h[1]>255||h[2]>65535)throw new Error("Invalid IP");return(h[0]<<24|h[1]<<16|h[2])>>>0;case 4:if(h[0]>255||h[1]>255||h[2]>255||h[3]>255)throw new Error("Invalid IP");return(h[0]<<24|h[1]<<16|h[2]<<8|h[3])>>>0;default:throw new Error("Invalid IP")}},e=function(c){return c.charCodeAt(0)},n=e("0"),s=e("a"),o=e("A"),t=function(c){var h,l,u,f,w;for(f=0,h=10,l="9",u=0,c.length>1&&c[u]==="0"&&(c[u+1]==="x"||c[u+1]==="X"?(u+=2,h=16):"0"<=c[u+1]&&c[u+1]<="9"&&(u++,h=8,l="7")),w=u;u<c.length;){if("0"<=c[u]&&c[u]<=l)f=f*h+(e(c[u])-n)>>>0;else if(h===16)if("a"<=c[u]&&c[u]<="f")f=f*h+(10+e(c[u])-s)>>>0;else if("A"<=c[u]&&c[u]<="F")f=f*h+(10+e(c[u])-o)>>>0;else break;else break;if(f>4294967295)throw new Error("too large");u++}if(u===w)throw new Error("empty octet");return[f,u]},r=function(){function c(h,l){var u,f,w,d;if(typeof h!="string")throw new Error("Missing `net' parameter");if(l||(d=h.split("/",2),h=d[0],l=d[1]),l||(l=32),typeof l=="string"&&l.indexOf(".")>-1){try{this.maskLong=i(l)}catch(I){throw u=I,new Error("Invalid mask: "+l)}for(f=w=32;w>=0;f=--w)if(this.maskLong===4294967295<<32-f>>>0){this.bitmask=f;break}}else if(l||l===0)this.bitmask=parseInt(l,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(i(h)&this.maskLong)>>>0}catch(I){throw u=I,new Error("Invalid net address: "+h)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+l);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(h){return typeof h=="string"&&(h.indexOf("/")>0||h.split(".").length!==4)&&(h=new c(h)),h instanceof c?this.contains(h.base)&&this.contains(h.broadcast||h.last):(i(h)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(h){return h==null&&(h=1),new c(a(this.netLong+this.size*h),this.mask)},c.prototype.forEach=function(h){var l,u,f;for(f=i(this.first),u=i(this.last),l=0;f<=u;)h(a(f),f,l),l++,f++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),Lt.ip2long=i,Lt.long2ip=a,Lt.Netmask=r}).call(Lt)});var Gs={};D(Gs,{dcutr:()=>js,multicodec:()=>gt});var G=class extends Error{static name="InvalidMessageError";constructor(t="Invalid message"){super(t),this.name="InvalidMessageError"}};var Xs=Symbol.for("@libp2p/service-capabilities"),yr=Symbol.for("@libp2p/service-dependencies");var ie={};D(ie,{base58btc:()=>v,base58flickr:()=>Wn});var wi=new Uint8Array(0);function Er(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function W(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Ir(r){return new TextEncoder().encode(r)}function Ar(r){return new TextDecoder().decode(r)}function _n(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function u(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var I=0,et=0,k=0,O=d.length;k!==O&&d[k]===0;)k++,I++;for(var _=(O-k)*l+1>>>0,T=new Uint8Array(_);k!==O;){for(var z=d[k],H=0,R=_-1;(z!==0||H<et)&&R!==-1;R--,H++)z+=256*T[R]>>>0,T[R]=z%a>>>0,z=z/a>>>0;if(z!==0)throw new Error("Non-zero carry");et=H,k++}for(var j=_-et;j!==_&&T[j]===0;)j++;for(var Ut=c.repeat(I);j<_;++j)Ut+=r.charAt(T[j]);return Ut}function f(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var I=0;if(d[I]!==" "){for(var et=0,k=0;d[I]===c;)et++,I++;for(var O=(d.length-I)*h+1>>>0,_=new Uint8Array(O);d[I];){var T=e[d.charCodeAt(I)];if(T===255)return;for(var z=0,H=O-1;(T!==0||z<k)&&H!==-1;H--,z++)T+=a*_[H]>>>0,_[H]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");k=z,I++}if(d[I]!==" "){for(var R=O-k;R!==O&&_[R]===0;)R++;for(var j=new Uint8Array(et+(O-R)),Ut=et;R!==O;)j[Ut++]=_[R++];return j}}}function w(d){var I=f(d);if(I)return I;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:f,decode:w}}var zn=_n,$n=zn,Sr=$n;var re=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ne=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Fr(this,t)}},oe=class{decoders;constructor(t){this.decoders=t}or(t){return Fr(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Fr(r,t){return new oe({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var se=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new re(t,e,n),this.decoder=new ne(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function st({name:r,prefix:t,encode:e,decode:n}){return new se(r,t,e,n)}function K({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Sr(e,r);return st({prefix:t,name:r,encode:n,decode:s=>W(o(s))})}function jn(r,t,e,n){let o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),a=0,c=0,h=0;for(let l=0;l<s;++l){let u=o[r[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,a+=e,a>=8&&(a-=8,i[h++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function Gn(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;s.length*e&7;)s+="=";return s}function x({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return st({prefix:t,name:r,encode(o){return Gn(o,n,e)},decode(o){return jn(o,n,e,r)}})}var v=K({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wn=K({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ae={};D(ae,{base32:()=>q,base32hex:()=>Jn,base32hexpad:()=>Kn,base32hexpadupper:()=>Zn,base32hexupper:()=>Hn,base32pad:()=>Xn,base32padupper:()=>Qn,base32upper:()=>qn,base32z:()=>Yn});var q=x({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qn=x({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Xn=x({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qn=x({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jn=x({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Hn=x({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Kn=x({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zn=x({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yn=x({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var to=Ur,Nr=128,eo=127,ro=~eo,no=Math.pow(2,31);function Ur(r,t,e){t=t||[],e=e||0;for(var n=e;r>=no;)t[e++]=r&255|Nr,r/=128;for(;r&ro;)t[e++]=r&255|Nr,r>>>=7;return t[e]=r|0,Ur.bytes=e-n+1,t}var oo=ce,so=128,Lr=127;function ce(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw ce.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Lr)<<o:(i&Lr)*Math.pow(2,o),o+=7}while(i>=so);return ce.bytes=s-n,e}var io=Math.pow(2,7),ao=Math.pow(2,14),co=Math.pow(2,21),ho=Math.pow(2,28),uo=Math.pow(2,35),lo=Math.pow(2,42),fo=Math.pow(2,49),po=Math.pow(2,56),mo=Math.pow(2,63),go=function(r){return r<io?1:r<ao?2:r<co?3:r<ho?4:r<uo?5:r<lo?6:r<fo?7:r<po?8:r<mo?9:10},wo={encode:to,decode:oo,encodingLength:go},bo=wo,wt=bo;function bt(r,t=0){return[wt.decode(r,t),wt.decode.bytes]}function it(r,t,e=0){return wt.encode(r,t,e),t}function at(r){return wt.encodingLength(r)}function rt(r,t){let e=t.byteLength,n=at(r),o=n+at(e),s=new Uint8Array(o+e);return it(r,s,0),it(e,s,n),s.set(t,o),new ct(r,e,t,s)}function Tt(r){let t=W(r),[e,n]=bt(t),[o,s]=bt(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ct(e,o,i,t)}function Dr(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Er(r.bytes,e.bytes)}}var ct=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Cr(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return yo(e,he(r),t??v.encoder);default:return Eo(e,he(r),t??q.encoder)}}var Tr=new WeakMap;function he(r){let t=Tr.get(r);if(t==null){let e=new Map;return Tr.set(r,e),e}return t}var Z=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==xt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Io)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=rt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Dr(t.multihash,n.multihash)}toString(t){return Cr(this,t)}toJSON(){return{"/":Cr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Pr(n,o,s.bytes))}else if(e[Ao]===!0){let{version:n,multihash:o,code:s}=e,i=Tt(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==xt)throw new Error(`Version 0 CID must use dag-pb (code: ${xt}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Pr(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,xt,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=W(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new ct(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[u,f]=bt(t.subarray(e));return e+=f,u},o=n(),s=xt;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),h=e+c,l=h-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:l,size:h}}static parse(t,e){let[n,o]=xo(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return he(s).set(n,t),s}};function xo(r,t){switch(r[0]){case"Q":{let e=t??v;return[v.prefix,e.decode(`${v.prefix}${r}`)]}case v.prefix:{let e=t??v;return[v.prefix,e.decode(r)]}case q.prefix:{let e=t??q;return[q.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function yo(r,t,e){let{prefix:n}=e;if(n!==v.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Eo(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var xt=112,Io=18;function Pr(r,t,e){let n=at(r),o=n+at(t),s=new Uint8Array(o+e.byteLength);return it(r,s,0),it(t,s,n),s.set(e,o),s}var Ao=Symbol.for("@ipld/js-cid/CID");function Pt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var ue={};D(ue,{base10:()=>vo});var vo=K({prefix:"9",name:"base10",alphabet:"0123456789"});var le={};D(le,{base16:()=>So,base16upper:()=>Fo});var So=x({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fo=x({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var fe={};D(fe,{base2:()=>No});var No=x({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var de={};D(de,{base256emoji:()=>To});var Mr=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}"),Lo=Mr.reduce((r,t,e)=>(r[e]=t,r),[]),Uo=Mr.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Do(r){return r.reduce((t,e)=>(t+=Lo[e],t),"")}function Co(r){let t=[];for(let e of r){let n=Uo[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var To=st({prefix:"\u{1F680}",name:"base256emoji",encode:Do,decode:Co});var pe={};D(pe,{base36:()=>Po,base36upper:()=>Mo});var Po=K({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Mo=K({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ge={};D(ge,{base64:()=>ko,base64pad:()=>Ro,base64url:()=>me,base64urlpad:()=>Bo});var ko=x({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ro=x({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),me=x({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Bo=x({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var we={};D(we,{base8:()=>Vo});var Vo=x({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var be={};D(be,{identity:()=>Oo});var Oo=st({prefix:"\0",name:"identity",encode:r=>Ar(r),decode:r=>Ir(r)});var $i=new TextEncoder,ji=new TextDecoder;var xe={};D(xe,{identity:()=>Go});var kr=0,$o="identity",Rr=W;function jo(r){return rt(kr,Rr(r))}var Go={code:kr,name:$o,encode:Rr,digest:jo};var Ie={};D(Ie,{sha256:()=>Wo,sha512:()=>qo});function Ee({name:r,code:t,encode:e}){return new ye(r,t,e)}var ye=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?rt(this.code,e):e.then(n=>rt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Vr(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Wo=Ee({name:"sha2-256",code:18,encode:Vr("SHA-256")}),qo=Ee({name:"sha2-512",code:19,encode:Vr("SHA-512")});var yt={...be,...fe,...we,...ue,...le,...ae,...pe,...ie,...ge,...de},ra={...Ie,...xe};function X(r=0){return new Uint8Array(r)}function L(r=0){return new Uint8Array(r)}function _r(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Or=_r("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ae=_r("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=L(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Xo={utf8:Or,"utf-8":Or,hex:yt.base16,latin1:Ae,ascii:Ae,binary:Ae,...yt},Mt=Xo;function U(r,t="utf8"){let e=Mt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Qo=Math.pow(2,7),Jo=Math.pow(2,14),Ho=Math.pow(2,21),ve=Math.pow(2,28),Se=Math.pow(2,35),Fe=Math.pow(2,42),Ne=Math.pow(2,49),m=128,S=127;function F(r){if(r<Qo)return 1;if(r<Jo)return 2;if(r<Ho)return 3;if(r<ve)return 4;if(r<Se)return 5;if(r<Fe)return 6;if(r<Ne)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Le(r,t,e=0){switch(F(r)){case 8:t[e++]=r&255|m,r/=128;case 7:t[e++]=r&255|m,r/=128;case 6:t[e++]=r&255|m,r/=128;case 5:t[e++]=r&255|m,r/=128;case 4:t[e++]=r&255|m,r>>>=7;case 3:t[e++]=r&255|m,r>>>=7;case 2:t[e++]=r&255|m,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Ko(r,t,e=0){switch(F(r)){case 8:t.set(e++,r&255|m),r/=128;case 7:t.set(e++,r&255|m),r/=128;case 6:t.set(e++,r&255|m),r/=128;case 5:t.set(e++,r&255|m),r/=128;case 4:t.set(e++,r&255|m),r>>>=7;case 3:t.set(e++,r&255|m),r>>>=7;case 2:t.set(e++,r&255|m),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Ue(r,t){let e=r[t],n=0;if(n+=e&S,e<m||(e=r[t+1],n+=(e&S)<<7,e<m)||(e=r[t+2],n+=(e&S)<<14,e<m)||(e=r[t+3],n+=(e&S)<<21,e<m)||(e=r[t+4],n+=(e&S)*ve,e<m)||(e=r[t+5],n+=(e&S)*Se,e<m)||(e=r[t+6],n+=(e&S)*Fe,e<m)||(e=r[t+7],n+=(e&S)*Ne,e<m))return n;throw new RangeError("Could not decode varint")}function Zo(r,t){let e=r.get(t),n=0;if(n+=e&S,e<m||(e=r.get(t+1),n+=(e&S)<<7,e<m)||(e=r.get(t+2),n+=(e&S)<<14,e<m)||(e=r.get(t+3),n+=(e&S)<<21,e<m)||(e=r.get(t+4),n+=(e&S)*ve,e<m)||(e=r.get(t+5),n+=(e&S)*Se,e<m)||(e=r.get(t+6),n+=(e&S)*Fe,e<m)||(e=r.get(t+7),n+=(e&S)*Ne,e<m))return n;throw new RangeError("Could not decode varint")}function Y(r,t,e=0){return t==null&&(t=L(F(r))),t instanceof Uint8Array?Le(r,t,e):Ko(r,t,e)}function Q(r,t=0){return r instanceof Uint8Array?Ue(r,t):Zo(r,t)}function P(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=L(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var kt=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",h=2**(8*o)-1;for(;;){let l=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let f=Number.parseInt(u,t);if(!Number.isNaN(f))return f});if(l===void 0)break;if(s*=t,s+=l,s>h||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[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];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var zr=45,Yo=15,ut=new kt;function Ce(r){if(!(r.length>Yo))return ut.new(r).parseWith(()=>ut.readIPv4Addr())}function Te(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>zr))return ut.new(r).parseWith(()=>ut.readIPv6Addr())}function Rt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>zr))return ut.new(r).parseWith(()=>ut.readIPAddr())}var Sa=parseInt("0xFFFF",16),Fa=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Et(r,t="utf8"){let e=Mt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function lt(r){return!!Ce(r)}function ft(r){return!!Te(r)}function Bt(r){return!!Rt(r)}var Gr=lt,os=ft,Pe=function(r){let t=0;if(r=r.toString().trim(),Gr(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(os(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Gr(e[n]),i;s&&(i=Pe(e[n]),e[n]=U(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,U(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},Wr=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var dt={},Me={},is=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];is.forEach(r=>{let t=as(...r);Me[t.code]=t,dt[t.name]=t});function as(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function b(r){if(typeof r=="number"){if(Me[r]!=null)return Me[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(dt[r]!=null)return dt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var lc=b("ip4"),fc=b("ip6"),dc=b("ipcidr");function Ve(r,t){switch(b(r).code){case 4:case 41:return hs(t);case 42:return Be(t);case 6:case 273:case 33:case 132:return Qr(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Be(t);case 421:return ds(t);case 444:return Xr(t);case 445:return Xr(t);case 466:return fs(t);case 481:return globalThis.encodeURIComponent(Be(t));default:return U(t,"base16")}}function Oe(r,t){switch(b(r).code){case 4:return qr(t);case 41:return qr(t);case 42:return Re(t);case 6:case 273:case 33:case 132:return _e(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Re(t);case 421:return us(t);case 444:return ps(t);case 445:return ms(t);case 466:return ls(t);case 481:return Re(globalThis.decodeURIComponent(t));default:return Et(t,"base16")}}var ke=Object.values(yt).map(r=>r.decoder),cs=function(){let r=ke[0].or(ke[1]);return ke.slice(2).forEach(t=>r=r.or(t)),r}();function qr(r){if(!Bt(r))throw new Error("invalid ip address");return Pe(r)}function hs(r){let t=Wr(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Bt(t))throw new Error("invalid ip address");return t}function _e(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Qr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Re(r){let t=Et(r),e=Uint8Array.from(Y(t.length));return P([e,t],e.length+t.length)}function Be(r){let t=Q(r);if(r=r.slice(F(t)),r.length!==t)throw new Error("inconsistent lengths");return U(r)}function us(r){let t;r[0]==="Q"||r[0]==="1"?t=Tt(v.decode(`z${r}`)).bytes:t=Z.parse(r).multihash.bytes;let e=Uint8Array.from(Y(t.length));return P([e,t],e.length+t.length)}function ls(r){let t=cs.decode(r),e=Uint8Array.from(Y(t.length));return P([e,t],e.length+t.length)}function fs(r){let t=Q(r),e=r.slice(F(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+U(e,"base64url")}function ds(r){let t=Q(r),e=r.slice(F(t));if(e.length!==t)throw new Error("inconsistent lengths");return U(e,"base58btc")}function ps(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=q.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=_e(n);return P([e,o],e.length+o.length)}function ms(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=q.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=_e(n);return P([e,o],e.length+o.length)}function Xr(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=U(t,"base32"),o=Qr(e);return`${n}:${o}`}function Jr(r){r=ze(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=b(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(s++,s>=o.length)throw Kr("invalid address: "+r);if(a.path===!0){n=ze(o.slice(s).join("/")),t.push([a.code,Oe(a.code,n)]),e.push([a.code,n]);break}let c=Oe(a.code,o[s]);t.push([a.code,c]),e.push([a.code,Ve(a.code,c)])}return{string:Hr(e),bytes:je(t),tuples:t,stringTuples:e,path:n}}function $e(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=Q(r,o),i=F(s),a=b(s),c=gs(a,r.slice(o+i));if(c===0){t.push([s]),e.push([s]),o+=i;continue}let h=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw Kr("Invalid address Uint8Array: "+U(r,"base16"));t.push([s,h]);let l=Ve(s,h);if(e.push([s,l]),a.path===!0){n=l;break}}return{bytes:Uint8Array.from(r),string:Hr(e),tuples:t,stringTuples:e,path:n}}function Hr(r){let t=[];return r.map(e=>{let n=b(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ze(t.join("/"))}function je(r){return P(r.map(t=>{let e=b(t[0]),n=Uint8Array.from(Y(e.code));return t.length>1&&t[1]!=null&&(n=P([n,t[1]])),n}))}function gs(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=Q(t instanceof Uint8Array?t:Uint8Array.from(t));return e+F(e)}}function ze(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Kr(r){return new Error("Error parsing address: "+r)}var ws=Symbol.for("nodejs.util.inspect.custom"),We=Symbol.for("@multiformats/js-multiaddr/multiaddr"),bs=[b("dns").code,b("dns4").code,b("dns6").code,b("dnsaddr").code],Ge=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Vt=class r{bytes;#e;#t;#r;#n;[We]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=$e(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Jr(t)}else if(Yr(t))e=$e(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=b("tcp"),a=b("udp"),c=b("ip4"),h=b("ip6"),l=b("dns6"),u=b("ip6zone");for(let[w,d]of this.stringTuples())w===u.code&&(s=`%${d??""}`),bs.includes(w)&&(e=i.name,o=443,n=`${d??""}${s}`,t=w===l.code?6:4),(w===i.code||w===a.code)&&(e=b(w).name,o=parseInt(d??"")),(w===c.code||w===h.code)&&(e=b(w).name,n=`${d??""}${s}`,t=w===h.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},b(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>b(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(je(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===dt.p2p.code&&t.push([n,o]),n===dt["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?U(v.decode(`z${n}`),"base58btc"):U(Z.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Pt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Zr.get(e.name);if(n==null)throw new Ge(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>It(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[ws](){return`Multiaddr(${this.#e})`}};var Zr=new Map;function Yr(r){return!!r?.[We]}function It(r){return new Vt(r)}var xs=r=>r.toString().split("/").slice(1),At=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),p=r=>({match:t=>At(e=>e===r).match(t),pattern:r}),zt=()=>({match:r=>At(t=>typeof t=="string").match(r),pattern:"{string}"}),$t=()=>({match:r=>At(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),A=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{v.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),Ot=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{me.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),E=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),M=(...r)=>({match:t=>{let e;for(let n of r){let o=n.match(t);o!==!1&&(e==null||o.length<e.length)&&(e=o)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),g=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function y(...r){function t(o){let s=xs(o);for(let i of r){let a=i.match(s);if(a===!1)return!1;s=a}return s}function e(o){return t(o)!==!1}function n(o){let s=t(o);return s===!1?!1:s.length===0}return{matches:e,exactMatch:n}}var Xe=g(p("dns4"),zt()),Qe=g(p("dns6"),zt()),Je=g(p("dnsaddr"),zt()),tn=g(p("dns"),zt()),zc=y(Xe),$c=y(Qe),jc=y(Je),en=y(M(tn,Je,Xe,Qe)),rn=g(p("ip4"),At(lt)),nn=g(p("ip6"),At(ft)),on=M(rn,nn),$=M(on,tn,Xe,Qe,Je),Gc=y($),Wc=y(rn),qc=y(nn),sn=y(on),He=g($,p("tcp"),$t()),vt=g($,p("udp"),$t()),Xc=y(He),Qc=y(vt),Ke=g(vt,p("quic")),jt=g(vt,p("quic-v1")),ys=M(Ke,jt),Jc=y(Ke),Hc=y(jt),qe=M($,He,vt,Ke,jt),an=M(g(qe,p("ws"),E(A()))),Kc=y(an),cn=M(g(qe,p("wss"),E(A())),g(qe,p("tls"),p("ws"),E(A()))),Zc=y(cn),hn=g(vt,p("webrtc-direct"),E(Ot()),E(Ot()),E(A())),Yc=y(hn),un=g(jt,p("webtransport"),E(Ot()),E(Ot()),E(A())),th=y(un),_t=M(an,cn,g(He,E(A())),g(ys,E(A())),g($,E(A())),hn,un,A()),eh=y(_t),Es=g(_t,p("p2p-circuit"),A()),St=y(Es),Is=M(g(_t,p("p2p-circuit"),p("webrtc"),E(A())),g(_t,p("webrtc"),E(A())),p("webrtc")),rh=y(Is),As=M(g($,p("tcp"),$t(),p("http"),E(A())),g($,p("http"),E(A()))),nh=y(As),vs=M(g($,p("tcp"),M(g(p("443"),p("http")),g($t(),p("https"))),E(A())),g($,p("tls"),p("http"),E(A())),g($,p("https"),E(A()))),oh=y(vs);var ln=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},Ss=new WeakMap;function Fs({clearTimeout:r,setTimeout:t}={}){return(e,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(ln());let s,i,a,c=r??clearTimeout,h=()=>{c(s),a(ln())},l=()=>{o&&o.removeEventListener("abort",h)},u=new Promise((f,w)=>{i=()=>{l(),f(n)},a=w,s=(t??setTimeout)(i,e)});return o&&o.addEventListener("abort",h,{once:!0}),Ss.set(u,()=>{c(s),s=null,i()}),u}}var Ns=Fs(),fn=Ns;function pt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Gt=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function dn(r,t,e){if(t==null)return r;if(t.aborted)return Promise.reject(new Gt(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Gt(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var Ze=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=pt(),this.haveNext=pt()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=pt(),t}async throw(t){return this.ended=!0,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return await this._push(void 0),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=pt(),await dn(this.readNext.promise,e?.signal,e)}};function pn(){return new Ze}var gn=Symbol.for("@achingbrain/uint8arraylist");function mn(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function Wt(r){return!!r?.[gn]}var J=class r{bufs;length;[gn]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Wt(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Wt(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=mn(this.bufs,t);return e.buf[e.index]}set(t,e){let n=mn(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Wt(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return P(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:P(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let h=t>=a&&t<c,l=e>a&&e<=c;if(h&&l){if(t===a&&e===c){n.push(i);break}let u=t-a;n.push(i.subarray(u,u+(e-t)));break}if(h){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(l){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Wt(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let u=0;u<s;u++)i[u]=-1;for(let u=0;u<o;u++)i[n[u]]=u;let a=i,c=this.byteLength-n.byteLength,h=n.byteLength-1,l;for(let u=e;u<=c;u+=l){l=0;for(let f=h;f>=0;f--){let w=this.get(u+f);if(n[f]!==w){l=Math.max(1,f-a[w]);break}}if(l===0)return u}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=L(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=X(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=X(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=X(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=L(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=X(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=X(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=X(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=X(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=X(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!Pt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var qt=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var Ye=class extends Error{code;constructor(t,e){super(t),this.code=e}},tr=class extends Ye{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function wn(r,t){let e=pn();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let a of i)await e.push(a);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new J;return{read:async(i,a)=>{a?.signal?.throwIfAborted();let c,h=new Promise((l,u)=>{c=()=>{u(new tr("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(i==null){let{done:u,value:f}=await Promise.race([n.next(),h]);return u===!0?new J:f}for(;o.byteLength<i;){let{value:u,done:f}=await Promise.race([n.next(),h]);if(f===!0)throw new qt("unexpected end of input");o.append(u)}let l=o.sublist(0,i);return o.consume(i),l}finally{c!=null&&a?.signal?.removeEventListener("abort",c)}},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,a):await e.push(i.subarray(),a)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i}()}return r}}}var Xt=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Qt=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Jt=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function bn(r,t={}){let e=wn(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=F(t.maxDataLength));let n=t?.lengthDecoder??Q,o=t?.lengthEncoder??Y;return{read:async i=>{let a=-1,c=new J;for(;;){c.append(await e.read(1,i));try{a=n(c)}catch(h){if(h instanceof RangeError)continue;throw h}if(a<0)throw new Xt("Invalid message length");if(t?.maxLengthLength!=null&&c.byteLength>t.maxLengthLength)throw new Jt("message length length too long");if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new Qt("message length too long");return e.read(a,i)},write:async(i,a)=>{await e.write(new J(o(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new J(...i.flatMap(h=>[o(h.byteLength),h]));await e.write(c,a)},unwrap:()=>e.unwrap()}}function er(r,t){let e=bn(r,t),n={read:async(o,s)=>{let i=await e.read(s);return o.decode(i)},write:async(o,s,i)=>{await e.write(s.encode(o),i)},writeV:async(o,s,i)=>{await e.writeV(o.map(a=>s.encode(a)),i)},pb:o=>({read:async s=>n.read(o,s),write:async(s,i)=>n.write(s,o,i),writeV:async(s,i)=>n.writeV(s,o,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var rr=new Float32Array([-0]),tt=new Uint8Array(rr.buffer);function xn(r,t,e){rr[0]=r,t[e]=tt[0],t[e+1]=tt[1],t[e+2]=tt[2],t[e+3]=tt[3]}function yn(r,t){return tt[0]=r[t],tt[1]=r[t+1],tt[2]=r[t+2],tt[3]=r[t+3],rr[0]}var nr=new Float64Array([-0]),N=new Uint8Array(nr.buffer);function En(r,t,e){nr[0]=r,t[e]=N[0],t[e+1]=N[1],t[e+2]=N[2],t[e+3]=N[3],t[e+4]=N[4],t[e+5]=N[5],t[e+6]=N[6],t[e+7]=N[7]}function In(r,t){return N[0]=r[t],N[1]=r[t+1],N[2]=r[t+2],N[3]=r[t+3],N[4]=r[t+4],N[5]=r[t+5],N[6]=r[t+6],N[7]=r[t+7],nr[0]}var Ls=BigInt(Number.MAX_SAFE_INTEGER),Us=BigInt(Number.MIN_SAFE_INTEGER),C=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return nt;if(t<Ls&&t>Us)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>An&&(o=0n,++n>An&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return nt;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):nt}},nt=new C(0,0);nt.toBigInt=function(){return 0n};nt.zzEncode=nt.zzDecode=function(){return this};nt.length=function(){return 1};var An=4294967296n;function vn(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Sn(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function or(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function B(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Ht(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var sr=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,B(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw B(this,4);return Ht(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw B(this,4);return Ht(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw B(this,4);let t=yn(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw B(this,4);let t=In(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw B(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Sn(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw B(this,t);this.pos+=t}else do if(this.pos>=this.len)throw B(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new C(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw B(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw B(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw B(this,8);let t=Ht(this.buf,this.pos+=4),e=Ht(this.buf,this.pos+=4);return new C(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Ue(this.buf,this.pos);return this.pos+=F(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ir(r){return new sr(r instanceof Uint8Array?r:r.subarray())}function ar(r,t,e){let n=ir(r);return t.decode(n,void 0,e)}function cr(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return L(i);o+i>t&&(n=L(t),o=0);let a=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),a}}var ot=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function hr(){}var lr=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Ds=cr();function Cs(r){return globalThis.Buffer!=null?L(r):Ds(r)}var Nt=class{len;head;tail;states;constructor(){this.len=0,this.head=new ot(hr,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ot(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new fr((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Kt,10,C.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=C.fromBigInt(t);return this._push(Kt,e.length(),e)}uint64Number(t){return this._push(Le,F(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=C.fromBigInt(t).zzEncode();return this._push(Kt,e.length(),e)}sint64Number(t){let e=C.fromNumber(t).zzEncode();return this._push(Kt,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ur,1,t?1:0)}fixed32(t){return this._push(Ft,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=C.fromBigInt(t);return this._push(Ft,4,e.lo)._push(Ft,4,e.hi)}fixed64Number(t){let e=C.fromNumber(t);return this._push(Ft,4,e.lo)._push(Ft,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(xn,4,t)}double(t){return this._push(En,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(ur,1,0):this.uint32(e)._push(Ps,e,t)}string(t){let e=vn(t);return e!==0?this.uint32(e)._push(or,e,t):this._push(ur,1,0)}fork(){return this.states=new lr(this),this.head=this.tail=new ot(hr,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new ot(hr,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Cs(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function ur(r,t,e){t[e]=r&255}function Ts(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var fr=class extends ot{next;constructor(t,e){super(Ts,t,e),this.next=void 0}};function Kt(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Ft(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Ps(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Nt.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Ms,t,r),this},Nt.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ks,t,r),this});function Ms(r,t,e){t.set(r,e)}function ks(r,t,e){r.length<40?or(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Et(r),e)}function dr(){return new Nt}function pr(r,t){let e=dr();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var mt;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(mt||(mt={}));function Zt(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function mr(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return Zt("enum",mt.VARINT,e,n)}function gr(r,t){return Zt("message",mt.LENGTH_DELIMITED,r,t)}var Yt=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var V;(function(r){let t;(function(o){o.UNUSED="UNUSED",o.CONNECT="CONNECT",o.SYNC="SYNC"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.UNUSED=0]="UNUSED",o[o.CONNECT=100]="CONNECT",o[o.SYNC=300]="SYNC"})(e||(e={})),function(o){o.codec=()=>mr(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=gr((o,s,i={})=>{if(i.lengthDelimited!==!1&&s.fork(),o.type!=null&&(s.uint32(8),r.Type.codec().encode(o.type,s)),o.observedAddresses!=null)for(let a of o.observedAddresses)s.uint32(18),s.bytes(a);i.lengthDelimited!==!1&&s.ldelim()},(o,s,i={})=>{let a={observedAddresses:[]},c=s==null?o.len:o.pos+s;for(;o.pos<c;){let h=o.uint32();switch(h>>>3){case 1:{a.type=r.Type.codec().decode(o);break}case 2:{if(i.limits?.observedAddresses!=null&&a.observedAddresses.length===i.limits.observedAddresses)throw new Yt('Decode error - map field "observedAddresses" had too many elements');a.observedAddresses.push(o.bytes());break}default:{o.skipType(h&7);break}}}return a})),n),r.encode=o=>pr(o,r.codec()),r.decode=(o,s)=>ar(o,r.codec(),s)})(V||(V={}));var Ln=Vn(Nn(),1),Rs=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],Bs=Rs.map(r=>new Ln.Netmask(r));function wr(r){for(let t of Bs)if(t.contains(r))return!0;return!1}function Vs(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function Os(r){let t=r.split(":");if(t.length<2)return!1;let e=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(e.substring(0,2),16)}.${parseInt(e.substring(2),16)}`;return wr(o)}function _s(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function zs(r){let t=r.split(":"),e=t[t.length-1];return wr(e)}function $s(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function Un(r){return lt(r)?wr(r):Vs(r)?Os(r):_s(r)?zs(r):ft(r)?$s(r):void 0}function br(r,t){return St.matches(r)||t.dialTransportForMultiaddr(r)==null?!1:en.matches(r)?!0:sn.matches(r)?Un(r.toOptions().host)===!1:!1}var Dn=1024*4,Cn=100,te={timeout:5e3,retries:3,maxInboundStreams:1,maxOutboundStreams:1},ee=class{started;timeout;retries;maxInboundStreams;maxOutboundStreams;peerStore;registrar;connectionManager;addressManager;transportManager;topologyId;log;constructor(t,e){this.log=t.logger.forComponent("libp2p:dcutr"),this.started=!1,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.connectionManager=t.connectionManager,this.transportManager=t.transportManager,this.timeout=e.timeout??te.timeout,this.retries=e.retries??te.retries,this.maxInboundStreams=e.maxInboundStreams??te.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??te.maxOutboundStreams}[Symbol.toStringTag]="@libp2p/dcutr";[yr]=["@libp2p/identify"];isStarted(){return this.started}async start(){this.started||(this.topologyId=await this.registrar.register(gt,{notifyOnLimitedConnection:!0,onConnect:(t,e)=>{St.exactMatch(e.remoteAddr)&&e.direction==="inbound"&&this.upgradeInbound(e).catch(n=>{this.log.error("error during outgoing DCUtR attempt",n)})}}),await this.registrar.handle(gt,t=>{this.handleIncomingUpgrade(t.stream,t.connection).catch(e=>{this.log.error("error during incoming DCUtR attempt",e),t.stream.abort(e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:!0}),this.started=!0)}async stop(){await this.registrar.unhandle(gt),this.topologyId!=null&&this.registrar.unregister(this.topologyId),this.started=!1}async upgradeInbound(t){if(await this.attemptUnilateralConnectionUpgrade(t))return;let e;for(let n=0;n<this.retries;n++){let o={signal:AbortSignal.timeout(this.timeout)};try{e=await t.newStream([gt],{signal:o.signal,runOnLimitedConnection:!0});let s=er(e,{maxDataLength:Dn}).pb(V);this.log("B sending connect to %p",t.remotePeer);let i=Date.now();await s.write({type:V.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(u=>u.bytes)},o),this.log("B receiving connect from %p",t.remotePeer);let a=await s.read(o);if(a.type!==V.Type.CONNECT)throw this.log("A sent wrong message type"),new G("DCUtR message type was incorrect");let c=this.getDialableMultiaddrs(a.observedAddresses);if(c.length===0)throw this.log("A did not have any dialable multiaddrs"),new G("DCUtR connect message had no multiaddrs");let h=Date.now()-i;this.log("A sending sync, rtt %dms",h),await s.write({type:V.Type.SYNC,observedAddresses:[]},o),this.log("A waiting for half RTT"),await fn(h/2),this.log("B dialing",c);let l=await this.connectionManager.openConnection(c,{signal:o.signal,priority:Cn});this.log("DCUtR to %p succeeded to address %a, closing relayed connection",t.remotePeer,l.remoteAddr),await t.close(o);break}catch(s){if(this.log.error("error while attempting DCUtR on attempt %d of %d",n+1,this.retries,s),e?.abort(s),n===this.retries)throw s}finally{e!=null&&await e.close(o)}}}async attemptUnilateralConnectionUpgrade(t){let n=(await this.peerStore.get(t.remotePeer)).addresses.map(o=>{let s=o.multiaddr;return s.getPeerId()==null?s.encapsulate(`/p2p/${t.remotePeer}`):s}).filter(o=>br(o,this.transportManager));if(n.length>0){let o=AbortSignal.timeout(this.timeout);try{this.log("attempting unilateral connection upgrade to %a",n);let s=await this.connectionManager.openConnection(n,{signal:o,force:!0});if(St.exactMatch(s.remoteAddr))throw new Error("Could not open a new, non-limited, connection");return this.log("unilateral connection upgrade to %p succeeded via %a, closing relayed connection",t.remotePeer,s.remoteAddr),await t.close({signal:o}),!0}catch(s){this.log.error("unilateral connection upgrade to %p on addresses %a failed",t.remotePeer,n,s)}}else this.log("peer %p has no public addresses, not attempting unilateral connection upgrade",t.remotePeer);return!1}async handleIncomingUpgrade(t,e){let n={signal:AbortSignal.timeout(this.timeout)};try{let o=er(t,{maxDataLength:Dn}).pb(V);this.log("A receiving connect");let s=await o.read(n);if(s.type!==V.Type.CONNECT)throw this.log("B sent wrong message type"),new G("DCUtR message type was incorrect");if(s.observedAddresses.length===0)throw this.log("B sent no multiaddrs"),new G("DCUtR connect message had no multiaddrs");let i=this.getDialableMultiaddrs(s.observedAddresses);if(i.length===0)throw this.log("B had no dialable multiaddrs"),new G("DCUtR connect message had no dialable multiaddrs");if(this.log("A sending connect"),await o.write({type:V.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(h=>h.bytes)}),this.log("A receiving sync"),(await o.read(n)).type!==V.Type.SYNC)throw new G("DCUtR message type was incorrect");this.log("A dialing",i);let c=await this.connectionManager.openConnection(i,{signal:n.signal,priority:Cn,force:!0});this.log("DCUtR to %p succeeded via %a, closing relayed connection",e.remotePeer,c.remoteAddr),await e.close(n)}catch(o){this.log.error("incoming DCUtR from %p failed",e.remotePeer,o),t.abort(o)}finally{await t.close(n)}}getDialableMultiaddrs(t){let e=[];for(let n of t)if(!(n==null||n.length===0))try{let o=It(n);if(!br(o,this.transportManager))continue;e.push(o)}catch{}return e}};var gt="/libp2p/dcutr";function js(r={}){return t=>new ee(t,r)}return On(Gs);})();
|
|
3
3
|
return Libp2PDcutr}));
|
package/dist/src/dcutr.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dcutr.d.ts","sourceRoot":"","sources":["../../src/dcutr.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"dcutr.d.ts","sourceRoot":"","sources":["../../src/dcutr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,yBAAyB,CAAA;AAOnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC1E,OAAO,KAAK,EAAU,UAAU,EAAE,MAAM,EAAa,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAiBzF,qBAAa,mBAAoB,YAAW,SAAS;IACnD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAmB;IACrD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAC/C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkB;IACnD,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;gBAEf,UAAU,EAAE,sBAAsB,EAAE,IAAI,EAAE,gBAAgB;IAevE,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAkB;IAE/C,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAEvC;IAED,SAAS,IAAK,OAAO;IAIf,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAyCvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IAU5B;;;;OAIG;IACG,cAAc,CAAE,iBAAiB,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAkGnE;;;OAGG;IACG,kCAAkC,CAAE,iBAAiB,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IA0D1F;;;;OAIG;IACG,qBAAqB,CAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAmE1F;;OAEG;IACH,qBAAqB,CAAE,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,SAAS,EAAE;CAqB1F"}
|
package/dist/src/dcutr.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InvalidMessageError, serviceDependencies } from '@libp2p/interface';
|
|
2
2
|
import { multiaddr } from '@multiformats/multiaddr';
|
|
3
|
+
import { Circuit } from '@multiformats/multiaddr-matcher';
|
|
3
4
|
import delay from 'delay';
|
|
4
5
|
import { pbStream } from 'it-protobuf-stream';
|
|
5
6
|
import { HolePunch } from './pb/message.js';
|
|
@@ -57,9 +58,9 @@ export class DefaultDCUtRService {
|
|
|
57
58
|
// register for notifications of when peers that support DCUtR connect
|
|
58
59
|
// nb. requires the identify service to be enabled
|
|
59
60
|
this.topologyId = await this.registrar.register(multicodec, {
|
|
60
|
-
|
|
61
|
+
notifyOnLimitedConnection: true,
|
|
61
62
|
onConnect: (peerId, connection) => {
|
|
62
|
-
if (!connection.
|
|
63
|
+
if (!Circuit.exactMatch(connection.remoteAddr)) {
|
|
63
64
|
// the connection is already direct, no upgrade is required
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
@@ -81,7 +82,7 @@ export class DefaultDCUtRService {
|
|
|
81
82
|
}, {
|
|
82
83
|
maxInboundStreams: this.maxInboundStreams,
|
|
83
84
|
maxOutboundStreams: this.maxOutboundStreams,
|
|
84
|
-
|
|
85
|
+
runOnLimitedConnection: true
|
|
85
86
|
});
|
|
86
87
|
this.started = true;
|
|
87
88
|
}
|
|
@@ -116,7 +117,7 @@ export class DefaultDCUtRService {
|
|
|
116
117
|
// 1. B opens a stream to A using the /libp2p/dcutr protocol.
|
|
117
118
|
stream = await relayedConnection.newStream([multicodec], {
|
|
118
119
|
signal: options.signal,
|
|
119
|
-
|
|
120
|
+
runOnLimitedConnection: true
|
|
120
121
|
});
|
|
121
122
|
const pb = pbStream(stream, {
|
|
122
123
|
maxDataLength: MAX_DCUTR_MESSAGE_SIZE
|
|
@@ -135,12 +136,12 @@ export class DefaultDCUtRService {
|
|
|
135
136
|
const connect = await pb.read(options);
|
|
136
137
|
if (connect.type !== HolePunch.Type.CONNECT) {
|
|
137
138
|
this.log('A sent wrong message type');
|
|
138
|
-
throw new
|
|
139
|
+
throw new InvalidMessageError('DCUtR message type was incorrect');
|
|
139
140
|
}
|
|
140
141
|
const multiaddrs = this.getDialableMultiaddrs(connect.observedAddresses);
|
|
141
142
|
if (multiaddrs.length === 0) {
|
|
142
143
|
this.log('A did not have any dialable multiaddrs');
|
|
143
|
-
throw new
|
|
144
|
+
throw new InvalidMessageError('DCUtR connect message had no multiaddrs');
|
|
144
145
|
}
|
|
145
146
|
const rtt = Date.now() - connectTimer;
|
|
146
147
|
this.log('A sending sync, rtt %dms', rtt);
|
|
@@ -212,8 +213,8 @@ export class DefaultDCUtRService {
|
|
|
212
213
|
signal,
|
|
213
214
|
force: true
|
|
214
215
|
});
|
|
215
|
-
if (connection.
|
|
216
|
-
throw new Error('Could not open a new, non-
|
|
216
|
+
if (Circuit.exactMatch(connection.remoteAddr)) {
|
|
217
|
+
throw new Error('Could not open a new, non-limited, connection');
|
|
217
218
|
}
|
|
218
219
|
this.log('unilateral connection upgrade to %p succeeded via %a, closing relayed connection', relayedConnection.remotePeer, connection.remoteAddr);
|
|
219
220
|
await relayedConnection.close({
|
|
@@ -250,16 +251,16 @@ export class DefaultDCUtRService {
|
|
|
250
251
|
const connect = await pb.read(options);
|
|
251
252
|
if (connect.type !== HolePunch.Type.CONNECT) {
|
|
252
253
|
this.log('B sent wrong message type');
|
|
253
|
-
throw new
|
|
254
|
+
throw new InvalidMessageError('DCUtR message type was incorrect');
|
|
254
255
|
}
|
|
255
256
|
if (connect.observedAddresses.length === 0) {
|
|
256
257
|
this.log('B sent no multiaddrs');
|
|
257
|
-
throw new
|
|
258
|
+
throw new InvalidMessageError('DCUtR connect message had no multiaddrs');
|
|
258
259
|
}
|
|
259
260
|
const multiaddrs = this.getDialableMultiaddrs(connect.observedAddresses);
|
|
260
261
|
if (multiaddrs.length === 0) {
|
|
261
262
|
this.log('B had no dialable multiaddrs');
|
|
262
|
-
throw new
|
|
263
|
+
throw new InvalidMessageError('DCUtR connect message had no dialable multiaddrs');
|
|
263
264
|
}
|
|
264
265
|
this.log('A sending connect');
|
|
265
266
|
await pb.write({
|
|
@@ -269,7 +270,7 @@ export class DefaultDCUtRService {
|
|
|
269
270
|
this.log('A receiving sync');
|
|
270
271
|
const sync = await pb.read(options);
|
|
271
272
|
if (sync.type !== HolePunch.Type.SYNC) {
|
|
272
|
-
throw new
|
|
273
|
+
throw new InvalidMessageError('DCUtR message type was incorrect');
|
|
273
274
|
}
|
|
274
275
|
// TODO: when we have a QUIC transport, the dial step is different - for
|
|
275
276
|
// now we only have tcp support
|
package/dist/src/dcutr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dcutr.js","sourceRoot":"","sources":["../../src/dcutr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"dcutr.js","sourceRoot":"","sources":["../../src/dcutr.ts"],"names":[],"mappings":"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"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
* await node.dial(ma)
|
|
37
37
|
*
|
|
38
38
|
* // after a while the connection should automatically get upgraded to a
|
|
39
|
-
* // direct connection (e.g. non-
|
|
39
|
+
* // direct connection (e.g. non-limited)
|
|
40
40
|
* while (true) {
|
|
41
41
|
* const connections = node.getConnections()
|
|
42
42
|
*
|
|
43
|
-
* if (connections.find(conn => conn.
|
|
43
|
+
* if (connections.find(conn => conn.limits == null)) {
|
|
44
44
|
* console.info('have direct connection')
|
|
45
45
|
* break
|
|
46
46
|
* } else {
|
package/dist/src/index.js
CHANGED
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
* await node.dial(ma)
|
|
37
37
|
*
|
|
38
38
|
* // after a while the connection should automatically get upgraded to a
|
|
39
|
-
* // direct connection (e.g. non-
|
|
39
|
+
* // direct connection (e.g. non-limited)
|
|
40
40
|
* while (true) {
|
|
41
41
|
* const connections = node.getConnections()
|
|
42
42
|
*
|
|
43
|
-
* if (connections.find(conn => conn.
|
|
43
|
+
* if (connections.find(conn => conn.limits == null)) {
|
|
44
44
|
* console.info('have direct connection')
|
|
45
45
|
* break
|
|
46
46
|
* } else {
|
package/dist/src/pb/message.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Codec, type DecodeOptions } from 'protons-runtime';
|
|
2
2
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
3
3
|
export interface HolePunch {
|
|
4
4
|
type?: HolePunch.Type;
|
|
@@ -15,6 +15,6 @@ export declare namespace HolePunch {
|
|
|
15
15
|
}
|
|
16
16
|
const codec: () => Codec<HolePunch>;
|
|
17
17
|
const encode: (obj: Partial<HolePunch>) => Uint8Array;
|
|
18
|
-
const decode: (buf: Uint8Array | Uint8ArrayList) => HolePunch;
|
|
18
|
+
const decode: (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<HolePunch>) => HolePunch;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAiB,KAAK,aAAa,EAAuD,MAAM,iBAAiB,CAAA;AACpI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,SAAS,CAAC,IAAI,CAAA;IACrB,iBAAiB,EAAE,UAAU,EAAE,CAAA;CAChC;AAED,yBAAiB,SAAS,CAAC;IACzB,KAAY,IAAI;QACd,MAAM,WAAW;QACjB,OAAO,YAAY;QACnB,IAAI,SAAS;KACd;IAQD,UAAiB,IAAI,CAAC;QACb,MAAM,KAAK,QAAO,MAAM,IAAI,CAElC,CAAA;KACF;IAIM,MAAM,KAAK,QAAO,MAAM,SAAS,CAyDvC,CAAA;IAEM,MAAM,MAAM,QAAS,QAAQ,SAAS,CAAC,KAAG,UAEhD,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,GAAG,cAAc,SAAS,cAAc,SAAS,CAAC,KAAG,SAE1F,CAAA;CACF"}
|
package/dist/src/pb/message.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
6
|
-
import {
|
|
6
|
+
import { decodeMessage, encodeMessage, enumeration, MaxLengthError, message } from 'protons-runtime';
|
|
7
7
|
export var HolePunch;
|
|
8
8
|
(function (HolePunch) {
|
|
9
9
|
let Type;
|
|
@@ -43,7 +43,7 @@ export var HolePunch;
|
|
|
43
43
|
if (opts.lengthDelimited !== false) {
|
|
44
44
|
w.ldelim();
|
|
45
45
|
}
|
|
46
|
-
}, (reader, length) => {
|
|
46
|
+
}, (reader, length, opts = {}) => {
|
|
47
47
|
const obj = {
|
|
48
48
|
observedAddresses: []
|
|
49
49
|
};
|
|
@@ -51,15 +51,21 @@ export var HolePunch;
|
|
|
51
51
|
while (reader.pos < end) {
|
|
52
52
|
const tag = reader.uint32();
|
|
53
53
|
switch (tag >>> 3) {
|
|
54
|
-
case 1:
|
|
54
|
+
case 1: {
|
|
55
55
|
obj.type = HolePunch.Type.codec().decode(reader);
|
|
56
56
|
break;
|
|
57
|
-
|
|
57
|
+
}
|
|
58
|
+
case 2: {
|
|
59
|
+
if (opts.limits?.observedAddresses != null && obj.observedAddresses.length === opts.limits.observedAddresses) {
|
|
60
|
+
throw new MaxLengthError('Decode error - map field "observedAddresses" had too many elements');
|
|
61
|
+
}
|
|
58
62
|
obj.observedAddresses.push(reader.bytes());
|
|
59
63
|
break;
|
|
60
|
-
|
|
64
|
+
}
|
|
65
|
+
default: {
|
|
61
66
|
reader.skipType(tag & 7);
|
|
62
67
|
break;
|
|
68
|
+
}
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
return obj;
|
|
@@ -70,8 +76,8 @@ export var HolePunch;
|
|
|
70
76
|
HolePunch.encode = (obj) => {
|
|
71
77
|
return encodeMessage(obj, HolePunch.codec());
|
|
72
78
|
};
|
|
73
|
-
HolePunch.decode = (buf) => {
|
|
74
|
-
return decodeMessage(buf, HolePunch.codec());
|
|
79
|
+
HolePunch.decode = (buf, opts) => {
|
|
80
|
+
return decodeMessage(buf, HolePunch.codec(), opts);
|
|
75
81
|
};
|
|
76
82
|
})(HolePunch || (HolePunch = {}));
|
|
77
83
|
//# sourceMappingURL=message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+BAA+B;AAC/B,oDAAoD;AACpD,8EAA8E;AAC9E,0DAA0D;AAE1D,OAAO,
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+BAA+B;AAC/B,oDAAoD;AACpD,8EAA8E;AAC9E,0DAA0D;AAE1D,OAAO,EAAc,aAAa,EAAsB,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAQpI,MAAM,KAAW,SAAS,CAuFzB;AAvFD,WAAiB,SAAS;IACxB,IAAY,IAIX;IAJD,WAAY,IAAI;QACd,yBAAiB,CAAA;QACjB,2BAAmB,CAAA;QACnB,qBAAa,CAAA;IACf,CAAC,EAJW,IAAI,GAAJ,cAAI,KAAJ,cAAI,QAIf;IAED,IAAK,YAIJ;IAJD,WAAK,YAAY;QACf,mDAAU,CAAA;QACV,uDAAa,CAAA;QACb,iDAAU,CAAA;IACZ,CAAC,EAJI,YAAY,KAAZ,YAAY,QAIhB;IAED,WAAiB,IAAI;QACN,UAAK,GAAG,GAAgB,EAAE;YACrC,OAAO,WAAW,CAAO,YAAY,CAAC,CAAA;QACxC,CAAC,CAAA;IACH,CAAC,EAJgB,IAAI,GAAJ,cAAI,KAAJ,cAAI,QAIpB;IAED,IAAI,MAAwB,CAAA;IAEf,eAAK,GAAG,GAAqB,EAAE;QAC1C,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,MAAM,GAAG,OAAO,CAAY,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;gBAChD,IAAI,IAAI,CAAC,eAAe,KAAK,KAAK,EAAE,CAAC;oBACnC,CAAC,CAAC,IAAI,EAAE,CAAA;gBACV,CAAC;gBAED,IAAI,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;oBACrB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;oBACX,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;gBAC5C,CAAC;gBAED,IAAI,GAAG,CAAC,iBAAiB,IAAI,IAAI,EAAE,CAAC;oBAClC,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,iBAAiB,EAAE,CAAC;wBAC1C,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;wBACZ,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;oBAChB,CAAC;gBACH,CAAC;gBAED,IAAI,IAAI,CAAC,eAAe,KAAK,KAAK,EAAE,CAAC;oBACnC,CAAC,CAAC,MAAM,EAAE,CAAA;gBACZ,CAAC;YACH,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;gBAC/B,MAAM,GAAG,GAAQ;oBACf,iBAAiB,EAAE,EAAE;iBACtB,CAAA;gBAED,MAAM,GAAG,GAAG,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAA;gBAE7D,OAAO,MAAM,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;oBACxB,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,CAAA;oBAE3B,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC;wBAClB,KAAK,CAAC,CAAC,CAAC,CAAC;4BACP,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;4BAChD,MAAK;wBACP,CAAC;wBACD,KAAK,CAAC,CAAC,CAAC,CAAC;4BACP,IAAI,IAAI,CAAC,MAAM,EAAE,iBAAiB,IAAI,IAAI,IAAI,GAAG,CAAC,iBAAiB,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;gCAC7G,MAAM,IAAI,cAAc,CAAC,oEAAoE,CAAC,CAAA;4BAChG,CAAC;4BAED,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;4BAC1C,MAAK;wBACP,CAAC;wBACD,OAAO,CAAC,CAAC,CAAC;4BACR,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;4BACxB,MAAK;wBACP,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,OAAO,GAAG,CAAA;YACZ,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAEY,gBAAM,GAAG,CAAC,GAAuB,EAAc,EAAE;QAC5D,OAAO,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAA;IAC9C,CAAC,CAAA;IAEY,gBAAM,GAAG,CAAC,GAAgC,EAAE,IAA+B,EAAa,EAAE;QACrG,OAAO,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,CAAA;IACpD,CAAC,CAAA;AACH,CAAC,EAvFgB,SAAS,KAAT,SAAS,QAuFzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/dcutr",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-18dd3cb26",
|
|
4
4
|
"description": "Implementation of the DCUtR Protocol",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-dcutr#readme",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"build": "aegir build",
|
|
42
42
|
"test": "aegir test",
|
|
43
43
|
"clean": "aegir clean",
|
|
44
|
-
"generate": "protons ./src/pb/
|
|
44
|
+
"generate": "protons ./src/pb/message.proto",
|
|
45
45
|
"lint": "aegir lint",
|
|
46
46
|
"test:chrome": "aegir test -t browser --cov",
|
|
47
47
|
"test:chrome-webworker": "aegir test -t webworker",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"doc-check": "aegir doc-check"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@libp2p/interface": "
|
|
56
|
-
"@libp2p/interface-internal": "
|
|
57
|
-
"@libp2p/utils": "
|
|
55
|
+
"@libp2p/interface": "2.0.0-18dd3cb26",
|
|
56
|
+
"@libp2p/interface-internal": "2.0.0-18dd3cb26",
|
|
57
|
+
"@libp2p/utils": "6.0.0-18dd3cb26",
|
|
58
58
|
"@multiformats/multiaddr": "^12.2.3",
|
|
59
59
|
"@multiformats/multiaddr-matcher": "^1.2.1",
|
|
60
60
|
"delay": "^6.0.0",
|
package/src/dcutr.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InvalidMessageError, serviceDependencies } from '@libp2p/interface'
|
|
2
2
|
import { type Multiaddr, multiaddr } from '@multiformats/multiaddr'
|
|
3
|
+
import { Circuit } from '@multiformats/multiaddr-matcher'
|
|
3
4
|
import delay from 'delay'
|
|
4
5
|
import { pbStream } from 'it-protobuf-stream'
|
|
5
6
|
import { HolePunch } from './pb/message.js'
|
|
@@ -70,9 +71,9 @@ export class DefaultDCUtRService implements Startable {
|
|
|
70
71
|
// register for notifications of when peers that support DCUtR connect
|
|
71
72
|
// nb. requires the identify service to be enabled
|
|
72
73
|
this.topologyId = await this.registrar.register(multicodec, {
|
|
73
|
-
|
|
74
|
+
notifyOnLimitedConnection: true,
|
|
74
75
|
onConnect: (peerId, connection) => {
|
|
75
|
-
if (!connection.
|
|
76
|
+
if (!Circuit.exactMatch(connection.remoteAddr)) {
|
|
76
77
|
// the connection is already direct, no upgrade is required
|
|
77
78
|
return
|
|
78
79
|
}
|
|
@@ -97,7 +98,7 @@ export class DefaultDCUtRService implements Startable {
|
|
|
97
98
|
}, {
|
|
98
99
|
maxInboundStreams: this.maxInboundStreams,
|
|
99
100
|
maxOutboundStreams: this.maxOutboundStreams,
|
|
100
|
-
|
|
101
|
+
runOnLimitedConnection: true
|
|
101
102
|
})
|
|
102
103
|
|
|
103
104
|
this.started = true
|
|
@@ -140,7 +141,7 @@ export class DefaultDCUtRService implements Startable {
|
|
|
140
141
|
// 1. B opens a stream to A using the /libp2p/dcutr protocol.
|
|
141
142
|
stream = await relayedConnection.newStream([multicodec], {
|
|
142
143
|
signal: options.signal,
|
|
143
|
-
|
|
144
|
+
runOnLimitedConnection: true
|
|
144
145
|
})
|
|
145
146
|
|
|
146
147
|
const pb = pbStream(stream, {
|
|
@@ -163,14 +164,14 @@ export class DefaultDCUtRService implements Startable {
|
|
|
163
164
|
|
|
164
165
|
if (connect.type !== HolePunch.Type.CONNECT) {
|
|
165
166
|
this.log('A sent wrong message type')
|
|
166
|
-
throw new
|
|
167
|
+
throw new InvalidMessageError('DCUtR message type was incorrect')
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
const multiaddrs = this.getDialableMultiaddrs(connect.observedAddresses)
|
|
170
171
|
|
|
171
172
|
if (multiaddrs.length === 0) {
|
|
172
173
|
this.log('A did not have any dialable multiaddrs')
|
|
173
|
-
throw new
|
|
174
|
+
throw new InvalidMessageError('DCUtR connect message had no multiaddrs')
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
const rtt = Date.now() - connectTimer
|
|
@@ -256,8 +257,8 @@ export class DefaultDCUtRService implements Startable {
|
|
|
256
257
|
force: true
|
|
257
258
|
})
|
|
258
259
|
|
|
259
|
-
if (connection.
|
|
260
|
-
throw new Error('Could not open a new, non-
|
|
260
|
+
if (Circuit.exactMatch(connection.remoteAddr)) {
|
|
261
|
+
throw new Error('Could not open a new, non-limited, connection')
|
|
261
262
|
}
|
|
262
263
|
|
|
263
264
|
this.log('unilateral connection upgrade to %p succeeded via %a, closing relayed connection', relayedConnection.remotePeer, connection.remoteAddr)
|
|
@@ -300,19 +301,19 @@ export class DefaultDCUtRService implements Startable {
|
|
|
300
301
|
|
|
301
302
|
if (connect.type !== HolePunch.Type.CONNECT) {
|
|
302
303
|
this.log('B sent wrong message type')
|
|
303
|
-
throw new
|
|
304
|
+
throw new InvalidMessageError('DCUtR message type was incorrect')
|
|
304
305
|
}
|
|
305
306
|
|
|
306
307
|
if (connect.observedAddresses.length === 0) {
|
|
307
308
|
this.log('B sent no multiaddrs')
|
|
308
|
-
throw new
|
|
309
|
+
throw new InvalidMessageError('DCUtR connect message had no multiaddrs')
|
|
309
310
|
}
|
|
310
311
|
|
|
311
312
|
const multiaddrs = this.getDialableMultiaddrs(connect.observedAddresses)
|
|
312
313
|
|
|
313
314
|
if (multiaddrs.length === 0) {
|
|
314
315
|
this.log('B had no dialable multiaddrs')
|
|
315
|
-
throw new
|
|
316
|
+
throw new InvalidMessageError('DCUtR connect message had no dialable multiaddrs')
|
|
316
317
|
}
|
|
317
318
|
|
|
318
319
|
this.log('A sending connect')
|
|
@@ -325,7 +326,7 @@ export class DefaultDCUtRService implements Startable {
|
|
|
325
326
|
const sync = await pb.read(options)
|
|
326
327
|
|
|
327
328
|
if (sync.type !== HolePunch.Type.SYNC) {
|
|
328
|
-
throw new
|
|
329
|
+
throw new InvalidMessageError('DCUtR message type was incorrect')
|
|
329
330
|
}
|
|
330
331
|
|
|
331
332
|
// TODO: when we have a QUIC transport, the dial step is different - for
|
package/src/index.ts
CHANGED
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
* await node.dial(ma)
|
|
37
37
|
*
|
|
38
38
|
* // after a while the connection should automatically get upgraded to a
|
|
39
|
-
* // direct connection (e.g. non-
|
|
39
|
+
* // direct connection (e.g. non-limited)
|
|
40
40
|
* while (true) {
|
|
41
41
|
* const connections = node.getConnections()
|
|
42
42
|
*
|
|
43
|
-
* if (connections.find(conn => conn.
|
|
43
|
+
* if (connections.find(conn => conn.limits == null)) {
|
|
44
44
|
* console.info('have direct connection')
|
|
45
45
|
* break
|
|
46
46
|
* } else {
|
package/src/pb/message.ts
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import type { Codec } from 'protons-runtime'
|
|
7
|
+
import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, enumeration, MaxLengthError, message } from 'protons-runtime'
|
|
9
8
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
10
9
|
|
|
11
10
|
export interface HolePunch {
|
|
@@ -56,7 +55,7 @@ export namespace HolePunch {
|
|
|
56
55
|
if (opts.lengthDelimited !== false) {
|
|
57
56
|
w.ldelim()
|
|
58
57
|
}
|
|
59
|
-
}, (reader, length) => {
|
|
58
|
+
}, (reader, length, opts = {}) => {
|
|
60
59
|
const obj: any = {
|
|
61
60
|
observedAddresses: []
|
|
62
61
|
}
|
|
@@ -67,15 +66,22 @@ export namespace HolePunch {
|
|
|
67
66
|
const tag = reader.uint32()
|
|
68
67
|
|
|
69
68
|
switch (tag >>> 3) {
|
|
70
|
-
case 1:
|
|
69
|
+
case 1: {
|
|
71
70
|
obj.type = HolePunch.Type.codec().decode(reader)
|
|
72
71
|
break
|
|
73
|
-
|
|
72
|
+
}
|
|
73
|
+
case 2: {
|
|
74
|
+
if (opts.limits?.observedAddresses != null && obj.observedAddresses.length === opts.limits.observedAddresses) {
|
|
75
|
+
throw new MaxLengthError('Decode error - map field "observedAddresses" had too many elements')
|
|
76
|
+
}
|
|
77
|
+
|
|
74
78
|
obj.observedAddresses.push(reader.bytes())
|
|
75
79
|
break
|
|
76
|
-
|
|
80
|
+
}
|
|
81
|
+
default: {
|
|
77
82
|
reader.skipType(tag & 7)
|
|
78
83
|
break
|
|
84
|
+
}
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
|
|
@@ -90,7 +96,7 @@ export namespace HolePunch {
|
|
|
90
96
|
return encodeMessage(obj, HolePunch.codec())
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): HolePunch => {
|
|
94
|
-
return decodeMessage(buf, HolePunch.codec())
|
|
99
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<HolePunch>): HolePunch => {
|
|
100
|
+
return decodeMessage(buf, HolePunch.codec(), opts)
|
|
95
101
|
}
|
|
96
102
|
}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"DCUtRServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_dcutr.DCUtRServiceComponents.html",
|
|
3
|
-
".:DCUtRServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_dcutr.DCUtRServiceComponents.html",
|
|
4
|
-
"DCUtRServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_dcutr.DCUtRServiceInit.html",
|
|
5
|
-
".:DCUtRServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_dcutr.DCUtRServiceInit.html",
|
|
6
|
-
"multicodec": "https://libp2p.github.io/js-libp2p/variables/_libp2p_dcutr.multicodec.html",
|
|
7
|
-
".:multicodec": "https://libp2p.github.io/js-libp2p/variables/_libp2p_dcutr.multicodec.html",
|
|
8
|
-
"dcutr": "https://libp2p.github.io/js-libp2p/functions/_libp2p_dcutr.dcutr.html",
|
|
9
|
-
".:dcutr": "https://libp2p.github.io/js-libp2p/functions/_libp2p_dcutr.dcutr.html"
|
|
10
|
-
}
|