@libp2p/bootstrap 5.0.1 → 5.0.2
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 +15 -2
- package/dist/index.min.js +3 -0
- package/dist/typedoc-urls.json +5 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
# @libp2p/bootstrap <!-- omit in toc -->
|
|
2
2
|
|
|
3
3
|
[](http://libp2p.io/)
|
|
4
|
-
[](http://webchat.freenode.net/?channels=%23libp2p)
|
|
5
4
|
[](https://discuss.libp2p.io)
|
|
6
5
|
[](https://codecov.io/gh/libp2p/js-libp2p-bootstrap)
|
|
7
|
-
[](https://github.com/libp2p/js-libp2p-bootstrap/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
|
|
8
7
|
|
|
9
8
|
> Node.js IPFS Implementation of the railing process of a Node through a bootstrap peer list
|
|
10
9
|
|
|
11
10
|
## Table of contents <!-- omit in toc -->
|
|
12
11
|
|
|
13
12
|
- [Install](#install)
|
|
13
|
+
- [Browser `<script>` tag](#browser-script-tag)
|
|
14
14
|
- [Usage](#usage)
|
|
15
15
|
- [Contribute](#contribute)
|
|
16
|
+
- [API Docs](#api-docs)
|
|
16
17
|
- [License](#license)
|
|
17
18
|
- [Contribute](#contribute-1)
|
|
18
19
|
|
|
@@ -22,6 +23,14 @@
|
|
|
22
23
|
$ npm i @libp2p/bootstrap
|
|
23
24
|
```
|
|
24
25
|
|
|
26
|
+
### Browser `<script>` tag
|
|
27
|
+
|
|
28
|
+
Loading this module through a script tag will make it's exports available as `Libp2pBootstrap` in the global namespace.
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<script src="https://unpkg.com/@libp2p/bootstrap/dist/index.min.js"></script>
|
|
32
|
+
```
|
|
33
|
+
|
|
25
34
|
## Usage
|
|
26
35
|
|
|
27
36
|
The configured bootstrap peers will be discovered after the configured timeout. This will ensure
|
|
@@ -86,6 +95,10 @@ The libp2p implementation in JavaScript is a work in progress. As such, there ar
|
|
|
86
95
|
- Go through the modules and **check out existing issues**. This is especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
|
|
87
96
|
- **Perform code reviews**. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
|
|
88
97
|
|
|
98
|
+
## API Docs
|
|
99
|
+
|
|
100
|
+
- <https://libp2p.github.io/js-libp2p-bootstrap>
|
|
101
|
+
|
|
89
102
|
## License
|
|
90
103
|
|
|
91
104
|
Licensed under either of
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PBootstrap = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
+
"use strict";var Libp2PBootstrap=(()=>{var Kr=Object.create;var Ie=Object.defineProperty;var Qr=Object.getOwnPropertyDescriptor;var Yr=Object.getOwnPropertyNames;var Zr=Object.getPrototypeOf,en=Object.prototype.hasOwnProperty;var R=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),F=(t,e)=>{for(var r in e)Ie(t,r,{get:e[r],enumerable:!0})},Nt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Yr(e))!en.call(t,o)&&o!==r&&Ie(t,o,{get:()=>e[o],enumerable:!(n=Qr(e,o))||n.enumerable});return t};var Y=(t,e,r)=>(r=t!=null?Kr(Zr(t)):{},Nt(e||!t||!t.__esModule?Ie(r,"default",{value:t,enumerable:!0}):r,t)),tn=t=>Nt(Ie({},"__esModule",{value:!0}),t);var lr=R((vi,ur)=>{ur.exports=gt;var cr=128,mo=127,bo=~mo,go=Math.pow(2,31);function gt(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw gt.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=go;)e[r++]=t&255|cr,t/=128;for(;t&bo;)e[r++]=t&255|cr,t>>>=7;return e[r]=t|0,gt.bytes=r-n+1,e}});var pr=R((Ci,fr)=>{fr.exports=wt;var wo=128,dr=127;function wt(t,n){var r=0,n=n||0,o=0,s=n,i,d=t.length;do{if(s>=d||o>49)throw wt.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&dr)<<o:(i&dr)*Math.pow(2,o),o+=7}while(i>=wo);return wt.bytes=s-n,r}});var mr=R((Si,hr)=>{var yo=Math.pow(2,7),xo=Math.pow(2,14),vo=Math.pow(2,21),Co=Math.pow(2,28),So=Math.pow(2,35),Eo=Math.pow(2,42),Ao=Math.pow(2,49),To=Math.pow(2,56),Fo=Math.pow(2,63);hr.exports=function(t){return t<yo?1:t<xo?2:t<vo?3:t<Co?4:t<So?5:t<Eo?6:t<Ao?7:t<To?8:t<Fo?9:10}});var _e=R((Ei,br)=>{br.exports={encode:lr(),decode:pr(),encodingLength:mr()}});var Ft=R((qi,Ar)=>{"use strict";function Er(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function qo(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return Er(t,r)}catch{r.message=t.message,r.stack=t.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(t)),Er(new o,r)}}Ar.exports=qo});var Vr=R((na,zr)=>{var ce=1e3,ue=ce*60,le=ue*60,X=le*24,es=X*7,ts=X*365.25;zr.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return rs(t);if(r==="number"&&isFinite(t))return e.long?os(t):ns(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function rs(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*ts;case"weeks":case"week":case"w":return r*es;case"days":case"day":case"d":return r*X;case"hours":case"hour":case"hrs":case"hr":case"h":return r*le;case"minutes":case"minute":case"mins":case"min":case"m":return r*ue;case"seconds":case"second":case"secs":case"sec":case"s":return r*ce;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function ns(t){var e=Math.abs(t);return e>=X?Math.round(t/X)+"d":e>=le?Math.round(t/le)+"h":e>=ue?Math.round(t/ue)+"m":e>=ce?Math.round(t/ce)+"s":t+"ms"}function os(t){var e=Math.abs(t);return e>=X?je(t,e,X,"day"):e>=le?je(t,e,le,"hour"):e>=ue?je(t,e,ue,"minute"):e>=ce?je(t,e,ce,"second"):t+" ms"}function je(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var Rr=R((oa,kr)=>{function ss(t){r.debug=r,r.default=r,r.coerce=v,r.disable=s,r.enable=o,r.enabled=i,r.humanize=Vr(),r.destroy=N,Object.keys(t).forEach(a=>{r[a]=t[a]}),r.names=[],r.skips=[],r.formatters={};function e(a){let u=0;for(let p=0;p<a.length;p++)u=(u<<5)-u+a.charCodeAt(p),u|=0;return r.colors[Math.abs(u)%r.colors.length]}r.selectColor=e;function r(a){let u,p=null,K,f;function m(...g){if(!m.enabled)return;let y=m,E=Number(new Date),I=E-(u||E);y.diff=I,y.prev=u,y.curr=E,u=E,g[0]=r.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let C=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(U,T)=>{if(U==="%%")return"%";C++;let B=r.formatters[T];if(typeof B=="function"){let Q=g[C];U=B.call(y,Q),g.splice(C,1),C--}return U}),r.formatArgs.call(y,g),(y.log||r.log).apply(y,g)}return m.namespace=a,m.useColors=r.useColors(),m.color=r.selectColor(a),m.extend=n,m.destroy=r.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(K!==r.namespaces&&(K=r.namespaces,f=r.enabled(a)),f),set:g=>{p=g}}),typeof r.init=="function"&&r.init(m),m}function n(a,u){let p=r(this.namespace+(typeof u>"u"?":":u)+a);return p.log=this.log,p}function o(a){r.save(a),r.namespaces=a,r.names=[],r.skips=[];let u,p=(typeof a=="string"?a:"").split(/[\s,]+/),K=p.length;for(u=0;u<K;u++)p[u]&&(a=p[u].replace(/\*/g,".*?"),a[0]==="-"?r.skips.push(new RegExp("^"+a.slice(1)+"$")):r.names.push(new RegExp("^"+a+"$")))}function s(){let a=[...r.names.map(d),...r.skips.map(d).map(u=>"-"+u)].join(",");return r.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let u,p;for(u=0,p=r.skips.length;u<p;u++)if(r.skips[u].test(a))return!1;for(u=0,p=r.names.length;u<p;u++)if(r.names[u].test(a))return!0;return!1}function d(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function v(a){return a instanceof Error?a.stack||a.message:a}function N(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}kr.exports=ss});var $r=R((P,qe)=>{P.formatArgs=as;P.save=cs;P.load=us;P.useColors=is;P.storage=ls();P.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();P.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function is(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function as(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+qe.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}P.log=console.debug||console.log||(()=>{});function cs(t){try{t?P.storage.setItem("debug",t):P.storage.removeItem("debug")}catch{}}function us(){let t;try{t=P.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function ls(){try{return localStorage}catch{}}qe.exports=Rr()(P);var{formatters:ds}=qe.exports;ds.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var vs={};F(vs,{bootstrap:()=>xs});var Ue=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let s=0,i=0,d=this.peekChar();if(d===void 0)return;let v=d==="0",N=2**(8*o)-1;for(;;){let a=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let p=Number.parseInt(u,e);if(!Number.isNaN(p))return p});if(a===void 0)break;if(s*=e,s+=a,s>N||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&v&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[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];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=e(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[d]=e(s.subarray(0,i));return r.set(s.subarray(0,d),16-d),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ot=45,rn=15,Z=new Ue;function Lt(t){if(!(t.length>rn))return Z.new(t).parseWith(()=>Z.readIPv4Addr())}function _t(t){if(!(t.length>Ot))return Z.new(t).parseWith(()=>Z.readIPv6Addr())}function zt(t){if(!(t.length>Ot))return Z.new(t).parseWith(()=>Z.readIPAddr())}function Vt(t){return Boolean(Lt(t))}function kt(t){return Boolean(_t(t))}function Be(t){return Boolean(zt(t))}var Qe={};F(Qe,{identity:()=>un});function nn(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var d=t.length,v=t.charAt(0),N=Math.log(d)/Math.log(256),a=Math.log(256)/Math.log(d);function u(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var m=0,g=0,y=0,E=f.length;y!==E&&f[y]===0;)y++,m++;for(var I=(E-y)*a+1>>>0,C=new Uint8Array(I);y!==E;){for(var M=f[y],U=0,T=I-1;(M!==0||U<g)&&T!==-1;T--,U++)M+=256*C[T]>>>0,C[T]=M%d>>>0,M=M/d>>>0;if(M!==0)throw new Error("Non-zero carry");g=U,y++}for(var B=I-g;B!==I&&C[B]===0;)B++;for(var Q=v.repeat(m);B<I;++B)Q+=t.charAt(C[B]);return Q}function p(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var m=0;if(f[m]!==" "){for(var g=0,y=0;f[m]===v;)g++,m++;for(var E=(f.length-m)*N+1>>>0,I=new Uint8Array(E);f[m];){var C=r[f.charCodeAt(m)];if(C===255)return;for(var M=0,U=E-1;(C!==0||M<y)&&U!==-1;U--,M++)C+=d*I[U]>>>0,I[U]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");y=M,m++}if(f[m]!==" "){for(var T=E-y;T!==E&&I[T]===0;)T++;for(var B=new Uint8Array(g+(E-T)),Q=g;T!==E;)B[Q++]=I[T++];return B}}}function K(f){var m=p(f);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:p,decode:K}}var on=nn,sn=on,Rt=sn;var Is=new Uint8Array(0);var $t=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},_=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var jt=t=>new TextEncoder().encode(t),qt=t=>new TextDecoder().decode(t);var Je=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},He=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Wt(this,e)}},Xe=class{constructor(e){this.decoders=e}or(e){return Wt(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Wt=(t,e)=>new Xe({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Ke=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Je(e,r,n),this.decoder=new He(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ee=({name:t,prefix:e,encode:r,decode:n})=>new Ke(t,e,r,n),$=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=Rt(r,e);return ee({prefix:t,name:e,encode:n,decode:s=>_(o(s))})},an=(t,e,r,n)=>{let o={};for(let a=0;a<e.length;++a)o[e[a]]=a;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),d=0,v=0,N=0;for(let a=0;a<s;++a){let u=o[t[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);v=v<<r|u,d+=r,d>=8&&(d-=8,i[N++]=255&v>>d)}if(d>=r||255&v<<8-d)throw new SyntaxError("Unexpected end of data");return i},cn=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,d=0;for(let v=0;v<t.length;++v)for(d=d<<8|t[v],i+=8;i>r;)i-=r,s+=e[o&d>>i];if(i&&(s+=e[o&d<<r-i]),n)for(;s.length*r&7;)s+="=";return s},b=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>ee({prefix:e,name:t,encode(o){return cn(o,n,r)},decode(o){return an(o,n,r,t)}});var un=ee({prefix:"\0",name:"identity",encode:t=>qt(t),decode:t=>jt(t)});var Ye={};F(Ye,{base2:()=>ln});var ln=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ze={};F(Ze,{base8:()=>dn});var dn=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var et={};F(et,{base10:()=>fn});var fn=$({prefix:"9",name:"base10",alphabet:"0123456789"});var tt={};F(tt,{base16:()=>pn,base16upper:()=>hn});var pn=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hn=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var rt={};F(rt,{base32:()=>D,base32hex:()=>wn,base32hexpad:()=>xn,base32hexpadupper:()=>vn,base32hexupper:()=>yn,base32pad:()=>bn,base32padupper:()=>gn,base32upper:()=>mn,base32z:()=>Cn});var D=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mn=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bn=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gn=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wn=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yn=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xn=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vn=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cn=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var nt={};F(nt,{base36:()=>Sn,base36upper:()=>En});var Sn=$({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),En=$({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ot={};F(ot,{base58btc:()=>x,base58flickr:()=>An});var x=$({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),An=$({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var it={};F(it,{base64:()=>st,base64pad:()=>Tn,base64url:()=>Fn,base64urlpad:()=>Pn});var st=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Tn=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fn=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pn=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var at={};F(at,{base256emoji:()=>Dn});var Jt=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}"),In=Jt.reduce((t,e,r)=>(t[r]=e,t),[]),Un=Jt.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Bn(t){return t.reduce((e,r)=>(e+=In[r],e),"")}function Mn(t){let e=[];for(let r of t){let n=Un[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Dn=ee({prefix:"\u{1F680}",name:"base256emoji",encode:Bn,decode:Mn});var dt={};F(dt,{sha256:()=>De,sha512:()=>Yn});var Nn=Kt,Ht=128,On=127,Ln=~On,_n=Math.pow(2,31);function Kt(t,e,r){e=e||[],r=r||0;for(var n=r;t>=_n;)e[r++]=t&255|Ht,t/=128;for(;t&Ln;)e[r++]=t&255|Ht,t>>>=7;return e[r]=t|0,Kt.bytes=r-n+1,e}var zn=ct,Vn=128,Xt=127;function ct(t,n){var r=0,n=n||0,o=0,s=n,i,d=t.length;do{if(s>=d)throw ct.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Xt)<<o:(i&Xt)*Math.pow(2,o),o+=7}while(i>=Vn);return ct.bytes=s-n,r}var kn=Math.pow(2,7),Rn=Math.pow(2,14),$n=Math.pow(2,21),jn=Math.pow(2,28),qn=Math.pow(2,35),Gn=Math.pow(2,42),Wn=Math.pow(2,49),Jn=Math.pow(2,56),Hn=Math.pow(2,63),Xn=function(t){return t<kn?1:t<Rn?2:t<$n?3:t<jn?4:t<qn?5:t<Gn?6:t<Wn?7:t<Jn?8:t<Hn?9:10},Kn={encode:Nn,decode:zn,encodingLength:Xn},Qn=Kn,de=Qn;var fe=(t,e=0)=>[de.decode(t,e),de.decode.bytes],te=(t,e,r=0)=>(de.encode(t,e,r),e),re=t=>de.encodingLength(t);var j=(t,e)=>{let r=e.byteLength,n=re(t),o=n+re(r),s=new Uint8Array(o+r);return te(t,s,0),te(r,s,n),s.set(e,o),new ne(t,r,e,s)},W=t=>{let e=_(t),[r,n]=fe(e),[o,s]=fe(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ne(r,o,i,e)},Qt=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&$t(t.bytes,r.bytes)}},ne=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var lt=({name:t,code:e,encode:r})=>new ut(t,e,r),ut=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?j(this.code,r):r.then(n=>j(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Zt=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),De=lt({name:"sha2-256",code:18,encode:Zt("SHA-256")}),Yn=lt({name:"sha2-512",code:19,encode:Zt("SHA-512")});var ft={};F(ft,{identity:()=>Ne});var er=0,Zn="identity",tr=_,eo=t=>j(er,tr(t)),Ne={code:er,name:Zn,encode:tr,digest:eo};var Ks=new TextEncoder,Qs=new TextDecoder;var no=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return so(r,pt(t),e||x.encoder);default:return io(r,pt(t),e||D.encoder)}},rr=new WeakMap,pt=t=>{let e=rr.get(t);if(e==null){let r=new Map;return rr.set(t,r),r}return e},h=class{constructor(e,r,n,o){this.code=r,this.version=e,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:e,multihash:r}=this;if(e!==pe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ao)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return h.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=j(e,r);return h.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(e){return h.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Qt(e.multihash,n.multihash)}toString(e){return no(this,e)}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof h)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new h(n,o,s,i||nr(n,o,s.bytes))}else if(r[co]===!0){let{version:n,multihash:o,code:s}=r,i=W(o);return h.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==pe)throw new Error(`Version 0 CID must use dag-pb (code: ${pe}) block encoding`);return new h(e,r,n,n.bytes)}case 1:{let o=nr(e,r,n.bytes);return new h(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return h.create(0,pe,e)}static createV1(e,r){return h.create(1,e,r)}static decode(e){let[r,n]=h.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=h.inspectBytes(e),n=r.size-r.multihashSize,o=_(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new ne(r.multihashCode,r.digestSize,s,o);return[r.version===0?h.createV0(i):h.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[u,p]=fe(e.subarray(r));return r+=p,u},o=n(),s=pe;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,d=n(),v=n(),N=r+v,a=N-i;return{version:o,codec:s,multihashCode:d,digestSize:v,multihashSize:a,size:N}}static parse(e,r){let[n,o]=oo(e,r),s=h.decode(o);return pt(s).set(n,e),s}},oo=(t,e)=>{switch(t[0]){case"Q":{let r=e||x;return[x.prefix,r.decode(`${x.prefix}${t}`)]}case x.prefix:{let r=e||x;return[x.prefix,r.decode(t)]}case D.prefix:{let r=e||D;return[D.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},so=(t,e,r)=>{let{prefix:n}=r;if(n!==x.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},io=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},pe=112,ao=18,nr=(t,e,r)=>{let n=re(t),o=n+re(e),s=new Uint8Array(o+r.byteLength);return te(t,s,0),te(e,s,n),s.set(r,o),s},co=Symbol.for("@ipld/js-cid/CID");var q={...Qe,...Ye,...Ze,...et,...tt,...rt,...nt,...ot,...it,...at},ai={...dt,...ft};function oe(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Oe(t=0){return globalThis.Buffer?.allocUnsafe!=null?oe(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function sr(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var or=sr("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ht=sr("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Oe(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),uo={utf8:or,"utf-8":or,hex:q.base16,latin1:ht,ascii:ht,binary:ht,...q},Le=uo;function A(t,e="utf8"){let r=Le[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var ir=Vt,lo=kt,mt=function(t){let e=0;if(t=t.toString().trim(),ir(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(lo(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=ir(r[n]),i;s&&(i=mt(r[n]),r[n]=A(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,A(i.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},ar=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(t[e+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var he={},bt={},po=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[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"],[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"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];po.forEach(t=>{let e=ho(...t);bt[e.code]=e,he[e.name]=e});function ho(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:Boolean(n),path:Boolean(o)}}function w(t){if(typeof t=="number"){if(bt[t]!=null)return bt[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(he[t]!=null)return he[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var O=Y(_e(),1);function yt(t,e="utf8"){let r=Le[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?oe(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function z(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=Oe(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return oe(r)}function yr(t,e){switch(w(t).code){case 4:case 41:return Io(e);case 6:case 273:case 33:case 132:return vr(e).toString();case 53:case 54:case 55:case 56:case 400:case 777:return Bo(e);case 421:return Oo(e);case 444:return wr(e);case 445:return wr(e);case 466:return No(e);default:return A(e,"base16")}}function xr(t,e){switch(w(t).code){case 4:return gr(e);case 41:return gr(e);case 6:case 273:case 33:case 132:return vt(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return Uo(e);case 421:return Mo(e);case 444:return Lo(e);case 445:return _o(e);case 466:return Do(e);default:return yt(e,"base16")}}var xt=Object.values(q).map(t=>t.decoder),Po=function(){let t=xt[0].or(xt[1]);return xt.slice(2).forEach(e=>t=t.or(e)),t}();function gr(t){if(!Be(t))throw new Error("invalid ip address");return mt(t)}function Io(t){let e=ar(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!Be(e))throw new Error("invalid ip address");return e}function vt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function vr(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function Uo(t){let e=yt(t),r=Uint8Array.from(O.default.encode(e.length));return z([r,e],r.length+e.length)}function Bo(t){let e=O.default.decode(t);if(t=t.slice(O.default.decode.bytes),t.length!==e)throw new Error("inconsistent lengths");return A(t)}function Mo(t){let e;t[0]==="Q"||t[0]==="1"?e=W(x.decode(`z${t}`)).bytes:e=h.parse(t).multihash.bytes;let r=Uint8Array.from(O.default.encode(e.length));return z([r,e],r.length+e.length)}function Do(t){let e=Po.decode(t),r=Uint8Array.from(O.default.encode(e.length));return z([r,e],r.length+e.length)}function No(t){let e=O.default.decode(t),r=t.slice(O.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return"u"+A(r,"base64url")}function Oo(t){let e=O.default.decode(t),r=t.slice(O.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return A(r,"base58btc")}function Lo(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=D.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=vt(n);return z([r,o],r.length+o.length)}function _o(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=D.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=vt(n);return z([r,o],r.length+o.length)}function wr(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=A(e,"base32"),o=vr(r);return`${n}:${o}`}var se=Y(_e(),1);function zo(t){let e=[],r=t.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let o=r[n],s=w(o);if(s.size===0){e.push([o]);continue}if(n++,n>=r.length)throw Sr("invalid address: "+t);if(s.path===!0){e.push([o,Tt(r.slice(n).join("/"))]);break}e.push([o,r[n]])}return e}function Vo(t){let e=[];return t.map(r=>{let n=ke(r);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),Tt(e.join("/"))}function ko(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=ke(e);return e.length>1?[r.code,xr(r.code,e[1])]:[r.code]})}function Ct(t){return t.map(e=>{let r=ke(e);return e[1]!=null?[r.code,yr(r.code,e[1])]:[r.code]})}function St(t){return Ve(z(t.map(e=>{let r=ke(e),n=Uint8Array.from(se.default.encode(r.code));return e.length>1&&e[1]!=null&&(n=z([n,e[1]])),n})))}function Et(t,e){return t.size>0?t.size/8:t.size===0?0:se.default.decode(e)+(se.default.decode.bytes??0)}function ze(t){let e=[],r=0;for(;r<t.length;){let n=se.default.decode(t,r),o=se.default.decode.bytes??0,s=w(n),i=Et(s,t.slice(r+o));if(i===0){e.push([n]),r+=o;continue}let d=t.slice(r+o,r+o+i);if(r+=i+o,r>t.length)throw Sr("Invalid address Uint8Array: "+A(t,"base16"));e.push([n,d])}return e}function At(t){let e=ze(t),r=Ct(e);return Vo(r)}function Ro(t){t=Tt(t);let e=zo(t),r=ko(e);return St(r)}function Cr(t){return Ro(t)}function Ve(t){let e=$o(t);if(e!=null)throw e;return Uint8Array.from(t)}function $o(t){try{ze(t)}catch(e){return e}}function Tt(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Sr(t){return new Error("Error parsing address: "+t)}function ke(t){return w(t[0])}var It=Y(_e(),1);var Pr=Y(Ft(),1);function me(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var ie=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Pt=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},be,ge,we,Tr,Go=Symbol.for("nodejs.util.inspect.custom"),Fr=[w("dns").code,w("dns4").code,w("dns6").code,w("dnsaddr").code],Wo=[w("p2p").code,w("ipfs").code],Jo=new Map,Ir=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Ho(t){return Boolean(t?.[Ir])}var V=class{constructor(e){if(be.set(this,void 0),ge.set(this,void 0),we.set(this,void 0),this[Tr]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=Ve(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Cr(e)}else if(Ho(e))this.bytes=Ve(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return ie(this,be,"f")==null&&Pt(this,be,At(this.bytes),"f"),ie(this,be,"f")}toJSON(){return this.toString()}toOptions(){let e=this.protoCodes(),r=this.toString().split("/").slice(1),n,o;if(r.length>2)Fr.includes(e[0])&&Wo.includes(e[1])?(n=w("tcp").name,o=443):(n=w(r[2]).name,o=parseInt(r[3]));else if(Fr.includes(e[0]))n=w("tcp").name,o=443;else throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e[0]===41||e[0]===55?6:4,host:r[1],transport:n,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},w(e)))}protoCodes(){let e=[],r=this.bytes,n=0;for(;n<r.length;){let o=It.default.decode(r,n),s=It.default.decode.bytes??0,i=w(o),d=Et(i,r.slice(n+s));n+=d+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return ie(this,ge,"f")==null&&Pt(this,ge,ze(this.bytes),"f"),ie(this,ge,"f")}stringTuples(){return ie(this,we,"f")==null&&Pt(this,we,Ct(this.tuples()),"f"),ie(this,we,"f")}encapsulate(e){return e=new V(e),new V(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new V(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new V(St(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===he.ipfs.code).pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?A(x.decode(`z${n}`),"base58btc"):A(h.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(r=>w(r[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return me(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=Jo.get(r.name);if(n==null)throw(0,Pr.default)(new Error(`no available resolver for ${r.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new V(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[(be=new WeakMap,ge=new WeakMap,we=new WeakMap,Tr=Ir,Go)](){return`Multiaddr(${At(this.bytes)})`}};function ye(t){return new V(t)}var Xo=c("dns4"),Ko=c("dns6"),Qo=c("dnsaddr"),ae=S(c("dns"),Qo,Xo,Ko),Re=S(c("ip4"),c("ip6")),Ee=S(l(Re,c("tcp")),l(ae,c("tcp"))),Br=l(Re,c("udp")),Yo=l(Br,c("utp")),Zo=l(Br,c("quic")),ve=S(l(Ee,c("ws")),l(ae,c("ws"))),Ce=S(l(Ee,c("wss")),l(ae,c("wss"))),Ut=S(l(Ee,c("http")),l(Re,c("http")),l(ae,c("http"))),Bt=S(l(Ee,c("https")),l(Re,c("https")),l(ae,c("https"))),Mr=S(l(ve,c("p2p-webrtc-star"),c("p2p")),l(Ce,c("p2p-webrtc-star"),c("p2p")),l(ve,c("p2p-webrtc-star")),l(Ce,c("p2p-webrtc-star"))),Zi=S(l(ve,c("p2p-websocket-star"),c("p2p")),l(Ce,c("p2p-websocket-star"),c("p2p")),l(ve,c("p2p-websocket-star")),l(Ce,c("p2p-websocket-star"))),Dr=S(l(Ut,c("p2p-webrtc-direct"),c("p2p")),l(Bt,c("p2p-webrtc-direct"),c("p2p")),l(Ut,c("p2p-webrtc-direct")),l(Bt,c("p2p-webrtc-direct"))),Se=S(ve,Ce,Ut,Bt,Mr,Dr,Ee,Yo,Zo,ae),ea=S(l(Se,c("p2p-stardust"),c("p2p")),l(Se,c("p2p-stardust"))),G=S(l(Se,c("p2p")),Mr,Dr,c("p2p")),Ur=S(l(G,c("p2p-circuit"),G),l(G,c("p2p-circuit")),l(c("p2p-circuit"),G),l(Se,c("p2p-circuit")),l(c("p2p-circuit"),Se),c("p2p-circuit")),Nr=()=>S(l(Ur,Nr),Ur),xe=Nr(),Or=S(l(xe,G,xe),l(G,xe),l(xe,G),xe,G);function Lr(t){function e(r){let n;try{n=ye(r)}catch{return!1}let o=t(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function l(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Lr(e),partialMatch:e}}function S(...t){function e(n){let o=null;return t.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Lr(e),partialMatch:e}}function c(t){let e=t;function r(o){let s;try{s=ye(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}var H=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},k,$e=class extends EventTarget{constructor(){super(...arguments),k.set(this,new Map)}listenerCount(e){let r=H(this,k,"f").get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let o=H(this,k,"f").get(e);o==null&&(o=[],H(this,k,"f").set(e,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=H(this,k,"f").get(e);o!=null&&(o=o.filter(({callback:s})=>s!==r),H(this,k,"f").set(e,o))}dispatchEvent(e){let r=super.dispatchEvent(e),n=H(this,k,"f").get(e.type);return n==null||(n=n.filter(({once:o})=>!o),H(this,k,"f").set(e.type,n)),r}};k=new WeakMap;var Mt=class extends Event{constructor(e,r){super(e,r),this.detail=r?.detail}},_r=globalThis.CustomEvent??Mt;var L=Y($r(),1);L.default.formatters.b=t=>t==null?"undefined":x.baseEncode(t);L.default.formatters.t=t=>t==null?"undefined":D.baseEncode(t);L.default.formatters.m=t=>t==null?"undefined":st.baseEncode(t);L.default.formatters.p=t=>t==null?"undefined":t.toString();L.default.formatters.c=t=>t==null?"undefined":t.toString();L.default.formatters.k=t=>t==null?"undefined":t.toString();function jr(t){return Object.assign((0,L.default)(t),{error:(0,L.default)(`${t}:error`),trace:(0,L.default)(`${t}:trace`)})}var fs=Y(Ft(),1);var qr=Symbol.for("@libp2p/peer-id");var ps=Symbol.for("nodejs.util.inspect.custom"),Gr=Object.values(q).map(t=>t.decoder).reduce((t,e)=>t.or(e),q.identity.decoder),Wr=114,Jr=36,Hr=37,Ae=class{constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[qr](){return!0}toString(){return this.string==null&&(this.string=x.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return h.createV1(Wr,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return me(this.multihash.bytes,e);if(typeof e=="string")return Dt(e).equals(this);if(e?.multihash?.bytes!=null)return me(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[ps](){return`PeerId(${this.toString()})`}},Te=class extends Ae{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}},Fe=class extends Ae{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}},Pe=class extends Ae{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}};function Dt(t,e){if(e=e??Gr,t.charAt(0)==="1"||t.charAt(0)==="Q"){let r=W(x.decode(`z${t}`));return t.startsWith("12D")?new Fe({multihash:r}):t.startsWith("16U")?new Pe({multihash:r}):new Te({multihash:r})}return hs(Gr.decode(t))}function hs(t){try{let e=W(t);if(e.code===Ne.code){if(e.digest.length===Jr)return new Fe({multihash:e});if(e.digest.length===Hr)return new Pe({multihash:e})}if(e.code===De.code)return new Te({multihash:e})}catch{return ms(h.decode(t))}throw new Error("Supplied PeerID CID is invalid")}function ms(t){if(t==null||t.multihash==null||t.version==null||t.version===1&&t.code!==Wr)throw new Error("Supplied PeerID CID is invalid");let e=t.multihash;if(e.code===De.code)return new Te({multihash:t.multihash});if(e.code===Ne.code){if(e.digest.length===Jr)return new Fe({multihash:t.multihash});if(e.digest.length===Hr)return new Pe({multihash:t.multihash})}throw new Error("Supplied PeerID CID is invalid")}var Xr=Symbol.for("@libp2p/peer-discovery");var Ge=jr("libp2p:bootstrap"),bs="bootstrap",gs=50,ws=12e4,ys=1e3,We=class extends $e{constructor(e,r={list:[]}){if(r.list==null||r.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=e,this.timeout=r.timeout??ys,this.list=[];for(let n of r.list){if(!Or.matches(n)){Ge.error("Invalid multiaddr");continue}let o=ye(n),s=o.getPeerId();if(s==null){Ge.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:Dt(s),multiaddrs:[o],protocols:[]};this.list.push(i)}this._init=r}get[Xr](){return!0}get[Symbol.toStringTag](){return"@libp2p/bootstrap"}isStarted(){return Boolean(this.timer)}start(){this.isStarted()||(Ge("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(e=>{Ge.error(e)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let e of this.list){if(await this.components.peerStore.tagPeer(e.id,this._init.tagName??bs,{value:this._init.tagValue??gs,ttl:this._init.tagTTL??ws}),this.timer==null)return;this.dispatchEvent(new _r("peer",{detail:e}))}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};We.tag="bootstrap";function xs(t){return e=>new We(e,t)}return tn(vs);})();
|
|
3
|
+
return Libp2PBootstrap}));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"BootstrapComponents": "https://libp2p.github.io/js-libp2p-bootstrap/interfaces/BootstrapComponents.html",
|
|
3
|
+
"BootstrapInit": "https://libp2p.github.io/js-libp2p-bootstrap/interfaces/BootstrapInit.html",
|
|
4
|
+
"bootstrap": "https://libp2p.github.io/js-libp2p-bootstrap/functions/bootstrap.html"
|
|
5
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/bootstrap",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Node.js IPFS Implementation of the railing process of a Node through a bootstrap peer list",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p-bootstrap#readme",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"types": "./dist/src/index.d.ts",
|
|
23
23
|
"files": [
|
|
24
24
|
"src",
|
|
25
|
-
"dist
|
|
25
|
+
"dist",
|
|
26
26
|
"!dist/test",
|
|
27
27
|
"!**/*.tsbuildinfo"
|
|
28
28
|
],
|
|
@@ -135,7 +135,8 @@
|
|
|
135
135
|
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
|
|
136
136
|
"test:node": "aegir test -t node --cov",
|
|
137
137
|
"test:electron-main": "aegir test -t electron-main",
|
|
138
|
-
"release": "aegir release"
|
|
138
|
+
"release": "aegir release",
|
|
139
|
+
"docs": "aegir docs"
|
|
139
140
|
},
|
|
140
141
|
"dependencies": {
|
|
141
142
|
"@libp2p/interface-peer-discovery": "^1.0.1",
|
|
@@ -152,7 +153,7 @@
|
|
|
152
153
|
"@libp2p/interface-peer-id": "^1.0.4",
|
|
153
154
|
"@libp2p/peer-id-factory": "^1.0.18",
|
|
154
155
|
"@libp2p/peer-store": "^5.0.0",
|
|
155
|
-
"aegir": "^37.5
|
|
156
|
+
"aegir": "^37.7.5",
|
|
156
157
|
"datastore-core": "^8.0.1",
|
|
157
158
|
"delay": "^5.0.0"
|
|
158
159
|
}
|