@libp2p/peer-collections 5.1.0-6d11e8268 → 5.1.1

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 CHANGED
@@ -11,6 +11,81 @@ We can't use PeerIds as collection keys because collection keys are compared usi
11
11
 
12
12
  PeerIds cache stringified versions of themselves so this should be a cheap operation.
13
13
 
14
+ Tracked versions are also available which report their current size to the libp2p Metrics collector.
15
+
16
+ ## Example - Peer lists
17
+
18
+ ```JavaScript
19
+ import { peerList } from '@libp2p/peer-collections'
20
+
21
+ const list = peerList()
22
+ list.push(peerId)
23
+ ```
24
+
25
+ ## Example - Tracked peer lists
26
+
27
+ - ```Typescript
28
+ ```
29
+
30
+ import { trackedPeerList } from '@libp2p/peer-collections'
31
+ import { createLibp2p } from 'libp2p'
32
+
33
+ const libp2p = await createLibp2p()
34
+
35
+ const list = trackedPeerList({ name: 'my\_metric\_name', metrics: libp2p.metrics })
36
+ list.push(peerId)
37
+
38
+ ````
39
+
40
+ ## Example - Peer maps
41
+
42
+ ```JavaScript
43
+ import { peerMap } from '@libp2p/peer-collections'
44
+
45
+ const map = peerMap<string>()
46
+ map.set(peerId, 'value')
47
+ ````
48
+
49
+ ## Example - Tracked peer maps
50
+
51
+ - ```Typescript
52
+ ```
53
+
54
+ import { trackedPeerMap } from '@libp2p/peer-collections'
55
+ import { createLibp2p } from 'libp2p'
56
+
57
+ const libp2p = await createLibp2p()
58
+
59
+ const list = trackedPeerMap({ name: 'my\_metric\_name', metrics: libp2p.metrics })
60
+ map.set(peerId, 'value')
61
+
62
+ ````
63
+
64
+ ## Example - Peer sets
65
+
66
+ ```JavaScript
67
+ import { peerSet } from '@libp2p/peer-collections'
68
+
69
+ const set = peerSet()
70
+ set.add(peerId)
71
+ ````
72
+
73
+ ## Example - Tracked peer sets
74
+
75
+ - ```Typescript
76
+ ```
77
+
78
+ import { trackedPeerSet } from '@libp2p/peer-collections'
79
+ import { createLibp2p } from 'libp2p'
80
+
81
+ const libp2p = await createLibp2p()
82
+
83
+ const list = trackedPeerSet({ name: 'my\_metric\_name', metrics: libp2p.metrics })
84
+ map.add(peerId)
85
+
86
+ ```
87
+ ```
88
+
14
89
  # Install
15
90
 
16
91
  ```console
package/dist/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerCollections = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PPeerCollections=(()=>{var ee=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var d=(r,e)=>{for(var t in e)ee(r,t,{get:e[t],enumerable:!0})},ct=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of it(e))!at.call(r,n)&&n!==t&&ee(r,n,{get:()=>e[n],enumerable:!(o=st(e,n))||o.enumerable});return r};var pt=r=>ct(ee({},"__esModule",{value:!0}),r);var gr={};d(gr,{PeerList:()=>L,PeerMap:()=>M,PeerSet:()=>R,peerList:()=>et,peerMap:()=>We,peerSet:()=>Ze,trackedPeerList:()=>ot,trackedPeerMap:()=>tt,trackedPeerSet:()=>rt});var wr=Symbol.for("@libp2p/connection");var vr=Symbol.for("@libp2p/content-routing");var Ir=Symbol.for("@libp2p/peer-discovery");var De=Symbol.for("@libp2p/peer-id");var Mr=Symbol.for("@libp2p/peer-routing");var Me;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Me||(Me={}));var Pr=Symbol.for("@libp2p/transport");var Re;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Re||(Re={}));var te=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},kr=globalThis.CustomEvent??te;var ie={};d(ie,{base58btc:()=>l,base58flickr:()=>mt});function ht(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),o=0;o<t.length;o++)t[o]=255;for(var n=0;n<r.length;n++){var s=r.charAt(n),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=n}var c=r.length,u=r.charAt(0),U=Math.log(c)/Math.log(256),m=Math.log(256)/Math.log(c);function O(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var f=0,N=0,b=0,y=a.length;b!==y&&a[b]===0;)b++,f++;for(var w=(y-b)*m+1>>>0,x=new Uint8Array(w);b!==y;){for(var S=a[b],I=0,g=w-1;(S!==0||I<N)&&g!==-1;g--,I++)S+=256*x[g]>>>0,x[g]=S%c>>>0,S=S/c>>>0;if(S!==0)throw new Error("Non-zero carry");N=I,b++}for(var v=w-N;v!==w&&x[v]===0;)v++;for(var Q=u.repeat(f);v<w;++v)Q+=r.charAt(x[v]);return Q}function H(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var f=0;if(a[f]!==" "){for(var N=0,b=0;a[f]===u;)N++,f++;for(var y=(a.length-f)*U+1>>>0,w=new Uint8Array(y);a[f];){var x=t[a.charCodeAt(f)];if(x===255)return;for(var S=0,I=y-1;(x!==0||S<b)&&I!==-1;I--,S++)x+=c*w[I]>>>0,w[I]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");b=S,f++}if(a[f]!==" "){for(var g=y-b;g!==y&&w[g]===0;)g++;for(var v=new Uint8Array(N+(y-g)),Q=N;g!==y;)v[Q++]=w[g++];return v}}}function nt(a){var f=H(a);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:O,decodeUnsafe:H,decode:nt}}var ut=ht,ft=ut,Le=ft;var ho=new Uint8Array(0);var Ne=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},E=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")};var Pe=r=>new TextEncoder().encode(r),Ue=r=>new TextDecoder().decode(r);var re=class{constructor(e,t,o){this.name=e,this.prefix=t,this.baseEncode=o}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},oe=class{constructor(e,t,o){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=o}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 Te(this,e)}},ne=class{constructor(e){this.decoders=e}or(e){return Te(this,e)}decode(e){let t=e[0],o=this.decoders[t];if(o)return o.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Te=(r,e)=>new ne({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),se=class{constructor(e,t,o,n){this.name=e,this.prefix=t,this.baseEncode=o,this.baseDecode=n,this.encoder=new re(e,t,o),this.decoder=new oe(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},T=({name:r,prefix:e,encode:t,decode:o})=>new se(r,e,t,o),C=({prefix:r,name:e,alphabet:t})=>{let{encode:o,decode:n}=Le(t,e);return T({prefix:r,name:e,encode:o,decode:s=>E(n(s))})},dt=(r,e,t,o)=>{let n={};for(let m=0;m<e.length;++m)n[e[m]]=m;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,u=0,U=0;for(let m=0;m<s;++m){let O=n[r[m]];if(O===void 0)throw new SyntaxError(`Non-${o} character`);u=u<<t|O,c+=t,c>=8&&(c-=8,i[U++]=255&u>>c)}if(c>=t||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return i},lt=(r,e,t)=>{let o=e[e.length-1]==="=",n=(1<<t)-1,s="",i=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],i+=8;i>t;)i-=t,s+=e[n&c>>i];if(i&&(s+=e[n&c<<t-i]),o)for(;s.length*t&7;)s+="=";return s},p=({name:r,prefix:e,bitsPerChar:t,alphabet:o})=>T({prefix:e,name:r,encode(n){return lt(n,o,t)},decode(n){return dt(n,o,t,r)}});var l=C({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),mt=C({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ae={};d(ae,{base10:()=>xt});var xt=C({prefix:"9",name:"base10",alphabet:"0123456789"});var ce={};d(ce,{base16:()=>bt,base16upper:()=>gt});var bt=p({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gt=p({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pe={};d(pe,{base2:()=>yt});var yt=p({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var he={};d(he,{base256emoji:()=>At});var ze=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}"),wt=ze.reduce((r,e,t)=>(r[t]=e,r),[]),St=ze.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function vt(r){return r.reduce((e,t)=>(e+=wt[t],e),"")}function Et(r){let e=[];for(let t of r){let o=St[t.codePointAt(0)];if(o===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var At=T({prefix:"\u{1F680}",name:"base256emoji",encode:vt,decode:Et});var ue={};d(ue,{base32:()=>z,base32hex:()=>Mt,base32hexpad:()=>Lt,base32hexpadupper:()=>Nt,base32hexupper:()=>Rt,base32pad:()=>Ct,base32padupper:()=>Dt,base32upper:()=>It,base32z:()=>Pt});var z=p({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),It=p({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ct=p({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Dt=p({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Mt=p({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Rt=p({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lt=p({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nt=p({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pt=p({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fe={};d(fe,{base36:()=>Ut,base36upper:()=>Ot});var Ut=C({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ot=C({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var de={};d(de,{base64:()=>Tt,base64pad:()=>zt,base64url:()=>Bt,base64urlpad:()=>kt});var Tt=p({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zt=p({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Bt=p({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kt=p({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var le={};d(le,{base8:()=>Vt});var Vt=p({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var me={};d(me,{identity:()=>Ft});var Ft=T({prefix:"\0",name:"identity",encode:r=>Ue(r),decode:r=>Pe(r)});var Co=new TextEncoder,Do=new TextDecoder;var be={};d(be,{identity:()=>W});var qt=Ve,Be=128,$t=127,Kt=~$t,Jt=Math.pow(2,31);function Ve(r,e,t){e=e||[],t=t||0;for(var o=t;r>=Jt;)e[t++]=r&255|Be,r/=128;for(;r&Kt;)e[t++]=r&255|Be,r>>>=7;return e[t]=r|0,Ve.bytes=t-o+1,e}var Gt=xe,Xt=128,ke=127;function xe(r,o){var t=0,o=o||0,n=0,s=o,i,c=r.length;do{if(s>=c)throw xe.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=n<28?(i&ke)<<n:(i&ke)*Math.pow(2,n),n+=7}while(i>=Xt);return xe.bytes=s-o,t}var Ht=Math.pow(2,7),Qt=Math.pow(2,14),Yt=Math.pow(2,21),Wt=Math.pow(2,28),Zt=Math.pow(2,35),er=Math.pow(2,42),tr=Math.pow(2,49),rr=Math.pow(2,56),or=Math.pow(2,63),nr=function(r){return r<Ht?1:r<Qt?2:r<Yt?3:r<Wt?4:r<Zt?5:r<er?6:r<tr?7:r<rr?8:r<or?9:10},sr={encode:qt,decode:Gt,encodingLength:nr},ir=sr,_=ir;var j=(r,e=0)=>[_.decode(r,e),_.decode.bytes],B=(r,e,t=0)=>(_.encode(r,e,t),e),k=r=>_.encodingLength(r);var D=(r,e)=>{let t=e.byteLength,o=k(r),n=o+k(t),s=new Uint8Array(n+t);return B(r,s,0),B(t,s,o),s.set(e,n),new V(r,t,e,s)},q=r=>{let e=E(r),[t,o]=j(e),[n,s]=j(e.subarray(o)),i=e.subarray(o+s);if(i.byteLength!==n)throw new Error("Incorrect length");return new V(t,n,i,e)},Fe=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ne(r.bytes,t.bytes)}},V=class{constructor(e,t,o,n){this.code=e,this.size=t,this.digest=o,this.bytes=n}};var _e=0,ar="identity",je=E,cr=r=>D(_e,je(r)),W={code:_e,name:ar,encode:je,digest:cr};var we={};d(we,{sha256:()=>Z,sha512:()=>pr});var ye=({name:r,code:e,encode:t})=>new ge(r,e,t),ge=class{constructor(e,t,o){this.name=e,this.code=t,this.encode=o}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?D(this.code,t):t.then(o=>D(this.code,o))}else throw Error("Unknown type, must be binary type")}};var $e=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Z=ye({name:"sha2-256",code:18,encode:$e("SHA-256")}),pr=ye({name:"sha2-512",code:19,encode:$e("SHA-512")});var Ke=(r,e)=>{let{bytes:t,version:o}=r;switch(o){case 0:return ur(t,Se(r),e||l.encoder);default:return fr(t,Se(r),e||z.encoder)}};var Je=new WeakMap,Se=r=>{let e=Je.get(r);if(e==null){let t=new Map;return Je.set(r,t),t}return e},P=class r{constructor(e,t,o,n){this.code=t,this.version=e,this.multihash=o,this.bytes=n,this["/"]=n}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:t}=this;if(e!==$)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==dr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:t}=this.multihash,o=D(e,t);return r.createV1(this.code,o)}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 r.equals(this,e)}static equals(e,t){let o=t;return o&&e.code===o.code&&e.version===o.version&&Fe(e.multihash,o.multihash)}toString(e){return Ke(this,e)}toJSON(){return{"/":Ke(this)}}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 t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:o,code:n,multihash:s,bytes:i}=t;return new r(o,n,s,i||Ge(o,n,s.bytes))}else if(t[lr]===!0){let{version:o,multihash:n,code:s}=t,i=q(n);return r.create(o,s,i)}else return null}static create(e,t,o){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(o.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==$)throw new Error(`Version 0 CID must use dag-pb (code: ${$}) block encoding`);return new r(e,t,o,o.bytes)}case 1:{let n=Ge(e,t,o.bytes);return new r(e,t,o,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,$,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,o]=r.decodeFirst(e);if(o.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),o=t.size-t.multihashSize,n=E(e.subarray(o,o+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),i=new V(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,o=()=>{let[O,H]=j(e.subarray(t));return t+=H,O},n=o(),s=$;if(n===18?(n=0,t=0):s=o(),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let i=t,c=o(),u=o(),U=t+u,m=U-i;return{version:n,codec:s,multihashCode:c,digestSize:u,multihashSize:m,size:U}}static parse(e,t){let[o,n]=hr(e,t),s=r.decode(n);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Se(s).set(o,e),s}},hr=(r,e)=>{switch(r[0]){case"Q":{let t=e||l;return[l.prefix,t.decode(`${l.prefix}${r}`)]}case l.prefix:{let t=e||l;return[l.prefix,t.decode(r)]}case z.prefix:{let t=e||z;return[z.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},ur=(r,e,t)=>{let{prefix:o}=t;if(o!==l.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(o);if(n==null){let s=t.encode(r).slice(1);return e.set(o,s),s}else return n},fr=(r,e,t)=>{let{prefix:o}=t,n=e.get(o);if(n==null){let s=t.encode(r);return e.set(o,s),s}else return n},$=112,dr=18,Ge=(r,e,t)=>{let o=k(r),n=o+k(e),s=new Uint8Array(n+t.byteLength);return B(r,s,0),B(e,s,o),s.set(t,n),s},lr=Symbol.for("@ipld/js-cid/CID");var ve={...me,...pe,...le,...ae,...ce,...ue,...fe,...ie,...de,...he},qo={...we,...be};function Ee(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var mr=Symbol.for("nodejs.util.inspect.custom"),Xe=Object.values(ve).map(r=>r.decoder).reduce((r,e)=>r.or(e),ve.identity.decoder),He=114,Qe=36,Ye=37,K=class{type;multihash;privateKey;publicKey;string;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()})`}[De]=!0;toString(){return this.string==null&&(this.string=l.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return P.createV1(He,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return Ee(this.multihash.bytes,e);if(typeof e=="string")return h(e).equals(this);if(e?.multihash?.bytes!=null)return Ee(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[mr](){return`PeerId(${this.toString()})`}},J=class extends K{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},G=class extends K{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},X=class extends K{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function h(r,e){if(e=e??Xe,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=q(l.decode(`z${r}`));return r.startsWith("12D")?new G({multihash:t}):r.startsWith("16U")?new X({multihash:t}):new J({multihash:t})}return xr(Xe.decode(r))}function xr(r){try{let e=q(r);if(e.code===W.code){if(e.digest.length===Qe)return new G({multihash:e});if(e.digest.length===Ye)return new X({multihash:e})}if(e.code===Z.code)return new J({multihash:e})}catch{return br(P.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function br(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==He)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Z.code)return new J({multihash:r.multihash});if(e.code===W.code){if(e.digest.length===Qe)return new G({multihash:r.multihash});if(e.digest.length===Ye)return new X({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}function A(r,e){let t={[Symbol.iterator]:()=>t,next:()=>{let o=r.next(),n=o.value;return o.done===!0||n==null?{done:!0,value:void 0}:{done:!1,value:e(n)}}};return t}var M=class{map;constructor(e){if(this.map=new Map,e!=null)for(let[t,o]of e.entries())this.map.set(t.toString(),o)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){return this.map.delete(e.toString())}entries(){return A(this.map.entries(),e=>[h(e[0]),e[1]])}forEach(e){this.map.forEach((t,o)=>{e(t,h(o),this)})}get(e){return this.map.get(e.toString())}has(e){return this.map.has(e.toString())}set(e,t){this.map.set(e.toString(),t)}keys(){return A(this.map.keys(),e=>h(e))}values(){return this.map.values()}get size(){return this.map.size}};function We(){return new M}var R=class r{set;constructor(e){if(this.set=new Set,e!=null)for(let t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return A(this.set.entries(),e=>{let t=h(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{let o=h(t);e(o,o,this)})}has(e){return this.set.has(e.toString())}values(){return A(this.set.values(),e=>h(e))}intersection(e){let t=new r;for(let o of e)this.has(o)&&t.add(o);return t}difference(e){let t=new r;for(let o of this)e.has(o)||t.add(o);return t}union(e){let t=new r;for(let o of e)t.add(o);for(let o of this)t.add(o);return t}};function Ze(){return new R}var L=class r{list;constructor(e){if(this.list=[],e!=null)for(let t of e)this.list.push(t.toString())}[Symbol.iterator](){return A(this.list.entries(),e=>h(e[1]))}concat(e){let t=new r(this);for(let o of e)t.push(o);return t}entries(){return A(this.list.entries(),e=>[e[0],h(e[1])])}every(e){return this.list.every((t,o)=>e(h(t),o,this))}filter(e){let t=new r;return this.list.forEach((o,n)=>{let s=h(o);e(s,n,this)&&t.push(s)}),t}find(e){let t=this.list.find((o,n)=>e(h(o),n,this));if(t!=null)return h(t)}findIndex(e){return this.list.findIndex((t,o)=>e(h(t),o,this))}forEach(e){this.list.forEach((t,o)=>{e(h(t),o,this)})}includes(e){return this.list.includes(e.toString())}indexOf(e){return this.list.indexOf(e.toString())}pop(){let e=this.list.pop();if(e!=null)return h(e)}push(...e){for(let t of e)this.list.push(t.toString())}shift(){let e=this.list.shift();if(e!=null)return h(e)}unshift(...e){let t=this.list.length;for(let o=e.length-1;o>-1;o--)t=this.list.unshift(e[o].toString());return t}clear(){this.list=[]}get length(){return this.list.length}};function et(){return new L}var Ae=class extends M{metric;constructor(e){super();let{name:t,metrics:o}=e;this.metric=o.registerMetric(t),this.updateComponentMetric()}set(e,t){return super.set(e,t),this.updateComponentMetric(),this}delete(e){let t=super.delete(e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function tt(r){let{name:e,metrics:t}=r,o;return t!=null?o=new Ae({name:e,metrics:t}):o=new M,o}var Ie=class extends R{metric;constructor(e){super();let{name:t,metrics:o}=e;this.metric=o.registerMetric(t),this.updateComponentMetric()}add(e){super.add(e),this.updateComponentMetric()}delete(e){super.delete(e),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function rt(r){let{name:e,metrics:t}=r,o;return t!=null?o=new Ie({name:e,metrics:t}):o=new R,o}var Ce=class extends L{metric;constructor(e){super();let{name:t,metrics:o}=e;this.metric=o.registerMetric(t),this.updateComponentMetric()}pop(){let e=super.pop();return this.updateComponentMetric(),e}push(...e){super.push(...e),this.updateComponentMetric()}shift(){let e=super.shift();return this.updateComponentMetric(),e}unshift(...e){let t=super.unshift(...e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function ot(r){let{name:e,metrics:t}=r,o;return t!=null?o=new Ce({name:e,metrics:t}):o=new L,o}return pt(gr);})();
2
+ "use strict";var Libp2PPeerCollections=(()=>{var ee=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var d=(r,e)=>{for(var t in e)ee(r,t,{get:e[t],enumerable:!0})},ct=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of it(e))!at.call(r,n)&&n!==t&&ee(r,n,{get:()=>e[n],enumerable:!(o=st(e,n))||o.enumerable});return r};var pt=r=>ct(ee({},"__esModule",{value:!0}),r);var gr={};d(gr,{PeerList:()=>L,PeerMap:()=>M,PeerSet:()=>R,peerList:()=>et,peerMap:()=>We,peerSet:()=>Ze,trackedPeerList:()=>ot,trackedPeerMap:()=>tt,trackedPeerSet:()=>rt});var wr=Symbol.for("@libp2p/connection");var vr=Symbol.for("@libp2p/content-routing");var Ir=Symbol.for("@libp2p/peer-discovery");var De=Symbol.for("@libp2p/peer-id");var Mr=Symbol.for("@libp2p/peer-routing");var Me;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Me||(Me={}));var Pr=Symbol.for("@libp2p/transport");var Re;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Re||(Re={}));var te=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},Tr=globalThis.CustomEvent??te;var ie={};d(ie,{base58btc:()=>l,base58flickr:()=>mt});function ht(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),o=0;o<t.length;o++)t[o]=255;for(var n=0;n<r.length;n++){var s=r.charAt(n),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=n}var c=r.length,u=r.charAt(0),U=Math.log(c)/Math.log(256),m=Math.log(256)/Math.log(c);function O(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var f=0,N=0,b=0,y=a.length;b!==y&&a[b]===0;)b++,f++;for(var w=(y-b)*m+1>>>0,x=new Uint8Array(w);b!==y;){for(var S=a[b],I=0,g=w-1;(S!==0||I<N)&&g!==-1;g--,I++)S+=256*x[g]>>>0,x[g]=S%c>>>0,S=S/c>>>0;if(S!==0)throw new Error("Non-zero carry");N=I,b++}for(var v=w-N;v!==w&&x[v]===0;)v++;for(var Q=u.repeat(f);v<w;++v)Q+=r.charAt(x[v]);return Q}function H(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var f=0;if(a[f]!==" "){for(var N=0,b=0;a[f]===u;)N++,f++;for(var y=(a.length-f)*U+1>>>0,w=new Uint8Array(y);a[f];){var x=t[a.charCodeAt(f)];if(x===255)return;for(var S=0,I=y-1;(x!==0||S<b)&&I!==-1;I--,S++)x+=c*w[I]>>>0,w[I]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");b=S,f++}if(a[f]!==" "){for(var g=y-b;g!==y&&w[g]===0;)g++;for(var v=new Uint8Array(N+(y-g)),Q=N;g!==y;)v[Q++]=w[g++];return v}}}function nt(a){var f=H(a);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:O,decodeUnsafe:H,decode:nt}}var ut=ht,ft=ut,Le=ft;var fo=new Uint8Array(0);var Ne=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},E=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")};var Pe=r=>new TextEncoder().encode(r),Ue=r=>new TextDecoder().decode(r);var re=class{constructor(e,t,o){this.name=e,this.prefix=t,this.baseEncode=o}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},oe=class{constructor(e,t,o){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=o}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 Te(this,e)}},ne=class{constructor(e){this.decoders=e}or(e){return Te(this,e)}decode(e){let t=e[0],o=this.decoders[t];if(o)return o.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Te=(r,e)=>new ne({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),se=class{constructor(e,t,o,n){this.name=e,this.prefix=t,this.baseEncode=o,this.baseDecode=n,this.encoder=new re(e,t,o),this.decoder=new oe(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},T=({name:r,prefix:e,encode:t,decode:o})=>new se(r,e,t,o),C=({prefix:r,name:e,alphabet:t})=>{let{encode:o,decode:n}=Le(t,e);return T({prefix:r,name:e,encode:o,decode:s=>E(n(s))})},dt=(r,e,t,o)=>{let n={};for(let m=0;m<e.length;++m)n[e[m]]=m;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,u=0,U=0;for(let m=0;m<s;++m){let O=n[r[m]];if(O===void 0)throw new SyntaxError(`Non-${o} character`);u=u<<t|O,c+=t,c>=8&&(c-=8,i[U++]=255&u>>c)}if(c>=t||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return i},lt=(r,e,t)=>{let o=e[e.length-1]==="=",n=(1<<t)-1,s="",i=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],i+=8;i>t;)i-=t,s+=e[n&c>>i];if(i&&(s+=e[n&c<<t-i]),o)for(;s.length*t&7;)s+="=";return s},p=({name:r,prefix:e,bitsPerChar:t,alphabet:o})=>T({prefix:e,name:r,encode(n){return lt(n,o,t)},decode(n){return dt(n,o,t,r)}});var l=C({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),mt=C({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ae={};d(ae,{base10:()=>xt});var xt=C({prefix:"9",name:"base10",alphabet:"0123456789"});var ce={};d(ce,{base16:()=>bt,base16upper:()=>gt});var bt=p({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gt=p({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pe={};d(pe,{base2:()=>yt});var yt=p({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var he={};d(he,{base256emoji:()=>At});var ze=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}"),wt=ze.reduce((r,e,t)=>(r[t]=e,r),[]),St=ze.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function vt(r){return r.reduce((e,t)=>(e+=wt[t],e),"")}function Et(r){let e=[];for(let t of r){let o=St[t.codePointAt(0)];if(o===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var At=T({prefix:"\u{1F680}",name:"base256emoji",encode:vt,decode:Et});var ue={};d(ue,{base32:()=>z,base32hex:()=>Mt,base32hexpad:()=>Lt,base32hexpadupper:()=>Nt,base32hexupper:()=>Rt,base32pad:()=>Ct,base32padupper:()=>Dt,base32upper:()=>It,base32z:()=>Pt});var z=p({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),It=p({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ct=p({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Dt=p({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Mt=p({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Rt=p({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lt=p({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nt=p({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pt=p({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fe={};d(fe,{base36:()=>Ut,base36upper:()=>Ot});var Ut=C({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ot=C({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var de={};d(de,{base64:()=>Tt,base64pad:()=>zt,base64url:()=>Bt,base64urlpad:()=>kt});var Tt=p({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zt=p({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Bt=p({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kt=p({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var le={};d(le,{base8:()=>Vt});var Vt=p({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var me={};d(me,{identity:()=>Ft});var Ft=T({prefix:"\0",name:"identity",encode:r=>Ue(r),decode:r=>Pe(r)});var Mo=new TextEncoder,Ro=new TextDecoder;var be={};d(be,{identity:()=>W});var qt=Ve,Be=128,$t=127,Kt=~$t,Jt=Math.pow(2,31);function Ve(r,e,t){e=e||[],t=t||0;for(var o=t;r>=Jt;)e[t++]=r&255|Be,r/=128;for(;r&Kt;)e[t++]=r&255|Be,r>>>=7;return e[t]=r|0,Ve.bytes=t-o+1,e}var Gt=xe,Xt=128,ke=127;function xe(r,o){var t=0,o=o||0,n=0,s=o,i,c=r.length;do{if(s>=c)throw xe.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=n<28?(i&ke)<<n:(i&ke)*Math.pow(2,n),n+=7}while(i>=Xt);return xe.bytes=s-o,t}var Ht=Math.pow(2,7),Qt=Math.pow(2,14),Yt=Math.pow(2,21),Wt=Math.pow(2,28),Zt=Math.pow(2,35),er=Math.pow(2,42),tr=Math.pow(2,49),rr=Math.pow(2,56),or=Math.pow(2,63),nr=function(r){return r<Ht?1:r<Qt?2:r<Yt?3:r<Wt?4:r<Zt?5:r<er?6:r<tr?7:r<rr?8:r<or?9:10},sr={encode:qt,decode:Gt,encodingLength:nr},ir=sr,_=ir;var j=(r,e=0)=>[_.decode(r,e),_.decode.bytes],B=(r,e,t=0)=>(_.encode(r,e,t),e),k=r=>_.encodingLength(r);var D=(r,e)=>{let t=e.byteLength,o=k(r),n=o+k(t),s=new Uint8Array(n+t);return B(r,s,0),B(t,s,o),s.set(e,n),new V(r,t,e,s)},q=r=>{let e=E(r),[t,o]=j(e),[n,s]=j(e.subarray(o)),i=e.subarray(o+s);if(i.byteLength!==n)throw new Error("Incorrect length");return new V(t,n,i,e)},Fe=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ne(r.bytes,t.bytes)}},V=class{constructor(e,t,o,n){this.code=e,this.size=t,this.digest=o,this.bytes=n}};var _e=0,ar="identity",je=E,cr=r=>D(_e,je(r)),W={code:_e,name:ar,encode:je,digest:cr};var we={};d(we,{sha256:()=>Z,sha512:()=>pr});var ye=({name:r,code:e,encode:t})=>new ge(r,e,t),ge=class{constructor(e,t,o){this.name=e,this.code=t,this.encode=o}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?D(this.code,t):t.then(o=>D(this.code,o))}else throw Error("Unknown type, must be binary type")}};var $e=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Z=ye({name:"sha2-256",code:18,encode:$e("SHA-256")}),pr=ye({name:"sha2-512",code:19,encode:$e("SHA-512")});var Ke=(r,e)=>{let{bytes:t,version:o}=r;switch(o){case 0:return ur(t,Se(r),e||l.encoder);default:return fr(t,Se(r),e||z.encoder)}};var Je=new WeakMap,Se=r=>{let e=Je.get(r);if(e==null){let t=new Map;return Je.set(r,t),t}return e},P=class r{constructor(e,t,o,n){this.code=t,this.version=e,this.multihash=o,this.bytes=n,this["/"]=n}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:t}=this;if(e!==$)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==dr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:t}=this.multihash,o=D(e,t);return r.createV1(this.code,o)}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 r.equals(this,e)}static equals(e,t){let o=t;return o&&e.code===o.code&&e.version===o.version&&Fe(e.multihash,o.multihash)}toString(e){return Ke(this,e)}toJSON(){return{"/":Ke(this)}}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 t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:o,code:n,multihash:s,bytes:i}=t;return new r(o,n,s,i||Ge(o,n,s.bytes))}else if(t[lr]===!0){let{version:o,multihash:n,code:s}=t,i=q(n);return r.create(o,s,i)}else return null}static create(e,t,o){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(o.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==$)throw new Error(`Version 0 CID must use dag-pb (code: ${$}) block encoding`);return new r(e,t,o,o.bytes)}case 1:{let n=Ge(e,t,o.bytes);return new r(e,t,o,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,$,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,o]=r.decodeFirst(e);if(o.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),o=t.size-t.multihashSize,n=E(e.subarray(o,o+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),i=new V(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,o=()=>{let[O,H]=j(e.subarray(t));return t+=H,O},n=o(),s=$;if(n===18?(n=0,t=0):s=o(),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let i=t,c=o(),u=o(),U=t+u,m=U-i;return{version:n,codec:s,multihashCode:c,digestSize:u,multihashSize:m,size:U}}static parse(e,t){let[o,n]=hr(e,t),s=r.decode(n);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Se(s).set(o,e),s}},hr=(r,e)=>{switch(r[0]){case"Q":{let t=e||l;return[l.prefix,t.decode(`${l.prefix}${r}`)]}case l.prefix:{let t=e||l;return[l.prefix,t.decode(r)]}case z.prefix:{let t=e||z;return[z.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},ur=(r,e,t)=>{let{prefix:o}=t;if(o!==l.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(o);if(n==null){let s=t.encode(r).slice(1);return e.set(o,s),s}else return n},fr=(r,e,t)=>{let{prefix:o}=t,n=e.get(o);if(n==null){let s=t.encode(r);return e.set(o,s),s}else return n},$=112,dr=18,Ge=(r,e,t)=>{let o=k(r),n=o+k(e),s=new Uint8Array(n+t.byteLength);return B(r,s,0),B(e,s,o),s.set(t,n),s},lr=Symbol.for("@ipld/js-cid/CID");var ve={...me,...pe,...le,...ae,...ce,...ue,...fe,...ie,...de,...he},Ko={...we,...be};function Ee(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var mr=Symbol.for("nodejs.util.inspect.custom"),Xe=Object.values(ve).map(r=>r.decoder).reduce((r,e)=>r.or(e),ve.identity.decoder),He=114,Qe=36,Ye=37,K=class{type;multihash;privateKey;publicKey;string;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()})`}[De]=!0;toString(){return this.string==null&&(this.string=l.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return P.createV1(He,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return Ee(this.multihash.bytes,e);if(typeof e=="string")return h(e).equals(this);if(e?.multihash?.bytes!=null)return Ee(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[mr](){return`PeerId(${this.toString()})`}},J=class extends K{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},G=class extends K{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},X=class extends K{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function h(r,e){if(e=e??Xe,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=q(l.decode(`z${r}`));return r.startsWith("12D")?new G({multihash:t}):r.startsWith("16U")?new X({multihash:t}):new J({multihash:t})}return xr(Xe.decode(r))}function xr(r){try{let e=q(r);if(e.code===W.code){if(e.digest.length===Qe)return new G({multihash:e});if(e.digest.length===Ye)return new X({multihash:e})}if(e.code===Z.code)return new J({multihash:e})}catch{return br(P.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function br(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==He)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Z.code)return new J({multihash:r.multihash});if(e.code===W.code){if(e.digest.length===Qe)return new G({multihash:r.multihash});if(e.digest.length===Ye)return new X({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}function A(r,e){let t={[Symbol.iterator]:()=>t,next:()=>{let o=r.next(),n=o.value;return o.done===!0||n==null?{done:!0,value:void 0}:{done:!1,value:e(n)}}};return t}var M=class{map;constructor(e){if(this.map=new Map,e!=null)for(let[t,o]of e.entries())this.map.set(t.toString(),o)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){return this.map.delete(e.toString())}entries(){return A(this.map.entries(),e=>[h(e[0]),e[1]])}forEach(e){this.map.forEach((t,o)=>{e(t,h(o),this)})}get(e){return this.map.get(e.toString())}has(e){return this.map.has(e.toString())}set(e,t){this.map.set(e.toString(),t)}keys(){return A(this.map.keys(),e=>h(e))}values(){return this.map.values()}get size(){return this.map.size}};function We(){return new M}var R=class r{set;constructor(e){if(this.set=new Set,e!=null)for(let t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return A(this.set.entries(),e=>{let t=h(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{let o=h(t);e(o,o,this)})}has(e){return this.set.has(e.toString())}values(){return A(this.set.values(),e=>h(e))}intersection(e){let t=new r;for(let o of e)this.has(o)&&t.add(o);return t}difference(e){let t=new r;for(let o of this)e.has(o)||t.add(o);return t}union(e){let t=new r;for(let o of e)t.add(o);for(let o of this)t.add(o);return t}};function Ze(){return new R}var L=class r{list;constructor(e){if(this.list=[],e!=null)for(let t of e)this.list.push(t.toString())}[Symbol.iterator](){return A(this.list.entries(),e=>h(e[1]))}concat(e){let t=new r(this);for(let o of e)t.push(o);return t}entries(){return A(this.list.entries(),e=>[e[0],h(e[1])])}every(e){return this.list.every((t,o)=>e(h(t),o,this))}filter(e){let t=new r;return this.list.forEach((o,n)=>{let s=h(o);e(s,n,this)&&t.push(s)}),t}find(e){let t=this.list.find((o,n)=>e(h(o),n,this));if(t!=null)return h(t)}findIndex(e){return this.list.findIndex((t,o)=>e(h(t),o,this))}forEach(e){this.list.forEach((t,o)=>{e(h(t),o,this)})}includes(e){return this.list.includes(e.toString())}indexOf(e){return this.list.indexOf(e.toString())}pop(){let e=this.list.pop();if(e!=null)return h(e)}push(...e){for(let t of e)this.list.push(t.toString())}shift(){let e=this.list.shift();if(e!=null)return h(e)}unshift(...e){let t=this.list.length;for(let o=e.length-1;o>-1;o--)t=this.list.unshift(e[o].toString());return t}clear(){this.list=[]}get length(){return this.list.length}};function et(){return new L}var Ae=class extends M{metric;constructor(e){super();let{name:t,metrics:o}=e;this.metric=o.registerMetric(t),this.updateComponentMetric()}set(e,t){return super.set(e,t),this.updateComponentMetric(),this}delete(e){let t=super.delete(e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function tt(r){let{name:e,metrics:t}=r,o;return t!=null?o=new Ae({name:e,metrics:t}):o=new M,o}var Ie=class extends R{metric;constructor(e){super();let{name:t,metrics:o}=e;this.metric=o.registerMetric(t),this.updateComponentMetric()}add(e){super.add(e),this.updateComponentMetric()}delete(e){super.delete(e),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function rt(r){let{name:e,metrics:t}=r,o;return t!=null?o=new Ie({name:e,metrics:t}):o=new R,o}var Ce=class extends L{metric;constructor(e){super();let{name:t,metrics:o}=e;this.metric=o.registerMetric(t),this.updateComponentMetric()}pop(){let e=super.pop();return this.updateComponentMetric(),e}push(...e){super.push(...e),this.updateComponentMetric()}shift(){let e=super.shift();return this.updateComponentMetric(),e}unshift(...e){let t=super.unshift(...e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function ot(r){let{name:e,metrics:t}=r,o;return t!=null?o=new Ce({name:e,metrics:t}):o=new L,o}return pt(gr);})();
3
3
  return Libp2PPeerCollections}));
@@ -0,0 +1,11 @@
1
+ {
2
+ "PeerList": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerList.html",
3
+ "PeerMap": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerMap.html",
4
+ "PeerSet": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerSet.html",
5
+ "peerList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerList-1.html",
6
+ "peerMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerMap-1.html",
7
+ "peerSet": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerSet-1.html",
8
+ "trackedPeerList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerList.html",
9
+ "trackedPeerMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerMap.html",
10
+ "trackedPeerSet": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerSet.html"
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/peer-collections",
3
- "version": "5.1.0-6d11e8268",
3
+ "version": "5.1.1",
4
4
  "description": "Stores values against a peer id",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-collections#readme",
@@ -53,11 +53,11 @@
53
53
  "test:electron-main": "aegir test -t electron-main"
54
54
  },
55
55
  "dependencies": {
56
- "@libp2p/interface": "1.0.1-6d11e8268",
57
- "@libp2p/peer-id": "4.0.1-6d11e8268"
56
+ "@libp2p/interface": "^1.0.2",
57
+ "@libp2p/peer-id": "^4.0.2"
58
58
  },
59
59
  "devDependencies": {
60
- "@libp2p/peer-id-factory": "4.0.0-6d11e8268",
60
+ "@libp2p/peer-id-factory": "^4.0.1",
61
61
  "@types/sinon": "^17.0.2",
62
62
  "aegir": "^41.0.2",
63
63
  "sinon": "^17.0.1",