Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@libp2p/peer-collections

Package Overview
Dependencies
Maintainers
6
Versions
562
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/peer-collections - npm Package Compare versions

Comparing version 2.2.2 to 3.0.0

2

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerCollections = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var Libp2PPeerCollections=(()=>{var We=Object.create;var W=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var _e=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var tt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),l=(r,e)=>{for(var t in e)W(r,t,{get:e[t],enumerable:!0})},Ee=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ze(e))!et.call(r,o)&&o!==t&&W(r,o,{get:()=>e[o],enumerable:!(n=Ye(e,o))||n.enumerable});return r};var rt=(r,e,t)=>(t=r!=null?We(_e(r)):{},Ee(e||!r||!r.__esModule?W(t,"default",{value:r,enumerable:!0}):t,r)),nt=r=>Ee(W({},"__esModule",{value:!0}),r);var $e=tt((_r,qe)=>{"use strict";function je(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function fr(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return je(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),je(new o,t)}}qe.exports=fr});var mr={};l(mr,{PeerList:()=>L,PeerMap:()=>ee,PeerSet:()=>z});var ot=Ce,Ae=128,st=127,it=~st,at=Math.pow(2,31);function Ce(r,e,t){e=e||[],t=t||0;for(var n=t;r>=at;)e[t++]=r&255|Ae,r/=128;for(;r&it;)e[t++]=r&255|Ae,r>>>=7;return e[t]=r|0,Ce.bytes=t-n+1,e}var ct=te,ht=128,Ie=127;function te(r,n){var t=0,n=n||0,o=0,s=n,i,h=r.length;do{if(s>=h)throw te.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Ie)<<o:(i&Ie)*Math.pow(2,o),o+=7}while(i>=ht);return te.bytes=s-n,t}var ft=Math.pow(2,7),ut=Math.pow(2,14),dt=Math.pow(2,21),pt=Math.pow(2,28),lt=Math.pow(2,35),mt=Math.pow(2,42),bt=Math.pow(2,49),gt=Math.pow(2,56),yt=Math.pow(2,63),wt=function(r){return r<ft?1:r<ut?2:r<dt?3:r<pt?4:r<lt?5:r<mt?6:r<bt?7:r<gt?8:r<yt?9:10},xt={encode:ot,decode:ct,encodingLength:wt},vt=xt,V=vt;var j=(r,e=0)=>[V.decode(r,e),V.decode.bytes],N=(r,e,t=0)=>(V.encode(r,e,t),e),P=r=>V.encodingLength(r);var wr=new Uint8Array(0);var De=(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},A=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 Ue=r=>new TextEncoder().encode(r),ze=r=>new TextDecoder().decode(r);var D=(r,e)=>{let t=e.byteLength,n=P(r),o=n+P(t),s=new Uint8Array(o+t);return N(r,s,0),N(t,s,n),s.set(e,o),new B(r,t,e,s)},q=r=>{let e=A(r),[t,n]=j(e),[o,s]=j(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new B(t,o,i,e)},Le=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&De(r.bytes,t.bytes)}},B=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var ie={};l(ie,{base58btc:()=>m,base58flickr:()=>Dt});function St(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var h=r.length,d=r.charAt(0),M=Math.log(h)/Math.log(256),b=Math.log(256)/Math.log(h);function T(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 p=0,O=0,y=0,x=a.length;y!==x&&a[y]===0;)y++,p++;for(var v=(x-y)*b+1>>>0,g=new Uint8Array(v);y!==x;){for(var S=a[y],C=0,w=v-1;(S!==0||C<O)&&w!==-1;w--,C++)S+=256*g[w]>>>0,g[w]=S%h>>>0,S=S/h>>>0;if(S!==0)throw new Error("Non-zero carry");O=C,y++}for(var E=v-O;E!==v&&g[E]===0;)E++;for(var Q=d.repeat(p);E<v;++E)Q+=r.charAt(g[E]);return Q}function X(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var p=0;if(a[p]!==" "){for(var O=0,y=0;a[p]===d;)O++,p++;for(var x=(a.length-p)*M+1>>>0,v=new Uint8Array(x);a[p];){var g=t[a.charCodeAt(p)];if(g===255)return;for(var S=0,C=x-1;(g!==0||S<y)&&C!==-1;C--,S++)g+=h*v[C]>>>0,v[C]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");y=S,p++}if(a[p]!==" "){for(var w=x-y;w!==x&&v[w]===0;)w++;for(var E=new Uint8Array(O+(x-w)),Q=O;w!==x;)E[Q++]=v[w++];return E}}}function Qe(a){var p=X(a);if(p)return p;throw new Error(`Non-${e} character`)}return{encode:T,decodeUnsafe:X,decode:Qe}}var Et=St,At=Et,Me=At;var re=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ne=class{constructor(e,t,n){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=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 Te(this,e)}},oe=class{constructor(e){this.decoders=e}or(e){return Te(this,e)}decode(e){let t=e[0],n=this.decoders[t];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`)}},Te=(r,e)=>new oe({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),se=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new re(e,t,n),this.decoder=new ne(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},R=({name:r,prefix:e,encode:t,decode:n})=>new se(r,e,t,n),U=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Me(t,e);return R({prefix:r,name:e,encode:n,decode:s=>A(o(s))})},It=(r,e,t,n)=>{let o={};for(let b=0;b<e.length;++b)o[e[b]]=b;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),h=0,d=0,M=0;for(let b=0;b<s;++b){let T=o[r[b]];if(T===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<t|T,h+=t,h>=8&&(h-=8,i[M++]=255&d>>h)}if(h>=t||255&d<<8-h)throw new SyntaxError("Unexpected end of data");return i},Ct=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,h=0;for(let d=0;d<r.length;++d)for(h=h<<8|r[d],i+=8;i>t;)i-=t,s+=e[o&h>>i];if(i&&(s+=e[o&h<<t-i]),n)for(;s.length*t&7;)s+="=";return s},f=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>R({prefix:e,name:r,encode(o){return Ct(o,n,t)},decode(o){return It(o,n,t,r)}});var m=U({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Dt=U({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ae={};l(ae,{base32:()=>F,base32hex:()=>Lt,base32hexpad:()=>Tt,base32hexpadupper:()=>Nt,base32hexupper:()=>Mt,base32pad:()=>zt,base32padupper:()=>Ot,base32upper:()=>Ut,base32z:()=>Pt});var F=f({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ut=f({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zt=f({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ot=f({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Lt=f({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Mt=f({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Tt=f({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nt=f({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pt=f({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bt=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Rt(t,ce(r),e||m.encoder);default:return Ft(t,ce(r),e||F.encoder)}},Ne=new WeakMap,ce=r=>{let e=Ne.get(r);if(e==null){let t=new Map;return Ne.set(r,t),t}return e},c=class{constructor(e,t,n,o){this.code=t,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:t}=this;if(e!==$)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Vt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return c.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,n=D(e,t);return c.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 c.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Le(e.multihash,n.multihash)}toString(e){return Bt(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 t=e;if(t instanceof c)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new c(n,o,s,i||Pe(n,o,s.bytes))}else if(t[jt]===!0){let{version:n,multihash:o,code:s}=t,i=q(o);return c.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="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(t!==$)throw new Error(`Version 0 CID must use dag-pb (code: ${$}) block encoding`);return new c(e,t,n,n.bytes)}case 1:{let o=Pe(e,t,n.bytes);return new c(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return c.create(0,$,e)}static createV1(e,t){return c.create(1,e,t)}static decode(e){let[t,n]=c.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=c.inspectBytes(e),n=t.size-t.multihashSize,o=A(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new B(t.multihashCode,t.digestSize,s,o);return[t.version===0?c.createV0(i):c.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[T,X]=j(e.subarray(t));return t+=X,T},o=n(),s=$;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,h=n(),d=n(),M=t+d,b=M-i;return{version:o,codec:s,multihashCode:h,digestSize:d,multihashSize:b,size:M}}static parse(e,t){let[n,o]=kt(e,t),s=c.decode(o);return ce(s).set(n,e),s}},kt=(r,e)=>{switch(r[0]){case"Q":{let t=e||m;return[m.prefix,t.decode(`${m.prefix}${r}`)]}case m.prefix:{let t=e||m;return[m.prefix,t.decode(r)]}case F.prefix:{let t=e||F;return[F.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)]}}},Rt=(r,e,t)=>{let{prefix:n}=t;if(n!==m.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Ft=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},$=112,Vt=18,Pe=(r,e,t)=>{let n=P(r),o=n+P(e),s=new Uint8Array(o+t.byteLength);return N(r,s,0),N(e,s,n),s.set(t,o),s},jt=Symbol.for("@ipld/js-cid/CID");var he={};l(he,{identity:()=>qt});var qt=R({prefix:"\0",name:"identity",encode:r=>ze(r),decode:r=>Ue(r)});var fe={};l(fe,{base2:()=>$t});var $t=f({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ue={};l(ue,{base8:()=>Jt});var Jt=f({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var de={};l(de,{base10:()=>Kt});var Kt=U({prefix:"9",name:"base10",alphabet:"0123456789"});var pe={};l(pe,{base16:()=>Gt,base16upper:()=>Ht});var Gt=f({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ht=f({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var le={};l(le,{base36:()=>Xt,base36upper:()=>Qt});var Xt=U({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Qt=U({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var me={};l(me,{base64:()=>Wt,base64pad:()=>Yt,base64url:()=>Zt,base64urlpad:()=>_t});var Wt=f({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yt=f({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zt=f({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_t=f({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var be={};l(be,{base256emoji:()=>or});var Be=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}"),er=Be.reduce((r,e,t)=>(r[t]=e,r),[]),tr=Be.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function rr(r){return r.reduce((e,t)=>(e+=er[t],e),"")}function nr(r){let e=[];for(let t of r){let n=tr[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var or=R({prefix:"\u{1F680}",name:"base256emoji",encode:rr,decode:nr});var we={};l(we,{sha256:()=>Z,sha512:()=>sr});var ye=({name:r,code:e,encode:t})=>new ge(r,e,t),ge=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?D(this.code,t):t.then(n=>D(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Re=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Z=ye({name:"sha2-256",code:18,encode:Re("SHA-256")}),sr=ye({name:"sha2-512",code:19,encode:Re("SHA-512")});var xe={};l(xe,{identity:()=>_});var Fe=0,ir="identity",Ve=A,ar=r=>D(Fe,Ve(r)),_={code:Fe,name:ir,encode:Ve,digest:ar};var Jr=new TextEncoder,Kr=new TextDecoder;var ve={...he,...fe,...ue,...de,...pe,...ae,...le,...ie,...me,...be},Wr={...we,...xe};function Se(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 ur=rt($e(),1);var Je=Symbol.for("@libp2p/peer-id");var dr=Symbol.for("nodejs.util.inspect.custom"),Ke=Object.values(ve).map(r=>r.decoder).reduce((r,e)=>r.or(e),ve.identity.decoder),Ge=114,He=36,Xe=37,J=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[Je](){return!0}toString(){return this.string==null&&(this.string=m.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return c.createV1(Ge,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return Se(this.multihash.bytes,e);if(typeof e=="string")return u(e).equals(this);if(e?.multihash?.bytes!=null)return Se(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[dr](){return`PeerId(${this.toString()})`}},K=class extends J{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}},G=class extends J{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}},H=class extends J{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}};function u(r,e){if(e=e??Ke,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=q(m.decode(`z${r}`));return r.startsWith("12D")?new G({multihash:t}):r.startsWith("16U")?new H({multihash:t}):new K({multihash:t})}return pr(Ke.decode(r))}function pr(r){try{let e=q(r);if(e.code===_.code){if(e.digest.length===He)return new G({multihash:e});if(e.digest.length===Xe)return new H({multihash:e})}if(e.code===Z.code)return new K({multihash:e})}catch{return lr(c.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function lr(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Ge)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Z.code)return new K({multihash:r.multihash});if(e.code===_.code){if(e.digest.length===He)return new G({multihash:r.multihash});if(e.digest.length===Xe)return new H({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}function I(r,e){let t={[Symbol.iterator]:()=>t,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:e(o)}}};return t}var ee=class{constructor(e){if(this.map=new Map,e!=null)for(let[t,n]of e.entries())this.map.set(t.toString(),n)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){this.map.delete(e.toString())}entries(){return I(this.map.entries(),e=>[u(e[0]),e[1]])}forEach(e){this.map.forEach((t,n)=>{e(t,u(n),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 I(this.map.keys(),e=>u(e))}values(){return this.map.values()}get size(){return this.map.size}};var z=class{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 I(this.set.entries(),e=>{let t=u(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{let n=u(t);e(n,n,this)})}has(e){return this.set.has(e.toString())}values(){return I(this.set.values(),e=>u(e))}intersection(e){let t=new z;for(let n of e)this.has(n)&&t.add(n);return t}difference(e){let t=new z;for(let n of this)e.has(n)||t.add(n);return t}union(e){let t=new z;for(let n of e)t.add(n);for(let n of this)t.add(n);return t}};var L=class{constructor(e){if(this.list=[],e!=null)for(let t of e)this.list.push(t.toString())}[Symbol.iterator](){return I(this.list.entries(),e=>u(e[1]))}concat(e){let t=new L(this);for(let n of e)t.push(n);return t}entries(){return I(this.list.entries(),e=>[e[0],u(e[1])])}every(e){return this.list.every((t,n)=>e(u(t),n,this))}filter(e){let t=new L;return this.list.forEach((n,o)=>{let s=u(n);e(s,o,this)&&t.push(s)}),t}find(e){let t=this.list.find((n,o)=>e(u(n),o,this));if(t!=null)return u(t)}findIndex(e){return this.list.findIndex((t,n)=>e(u(t),n,this))}forEach(e){this.list.forEach((t,n)=>{e(u(t),n,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 u(e)}push(...e){for(let t of e)this.list.push(t.toString())}shift(){let e=this.list.shift();if(e!=null)return u(e)}unshift(...e){let t=this.list.length;for(let n=e.length-1;n>-1;n--)t=this.list.unshift(e[n].toString());return t}get length(){return this.list.length}};return nt(mr);})();
"use strict";var Libp2PPeerCollections=(()=>{var Ye=Object.create;var W=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var et=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var rt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),l=(r,e)=>{for(var t in e)W(r,t,{get:e[t],enumerable:!0})},Ee=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _e(e))!tt.call(r,o)&&o!==t&&W(r,o,{get:()=>e[o],enumerable:!(n=Ze(e,o))||n.enumerable});return r};var nt=(r,e,t)=>(t=r!=null?Ye(et(r)):{},Ee(e||!r||!r.__esModule?W(t,"default",{value:r,enumerable:!0}):t,r)),ot=r=>Ee(W({},"__esModule",{value:!0}),r);var Je=rt((_r,$e)=>{"use strict";function qe(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function fr(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return qe(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),qe(new o,t)}}$e.exports=fr});var mr={};l(mr,{PeerList:()=>L,PeerMap:()=>ee,PeerSet:()=>z});var st=Ce,Ae=128,it=127,at=~it,ct=Math.pow(2,31);function Ce(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ct;)e[t++]=r&255|Ae,r/=128;for(;r&at;)e[t++]=r&255|Ae,r>>>=7;return e[t]=r|0,Ce.bytes=t-n+1,e}var ht=te,ft=128,Ie=127;function te(r,n){var t=0,n=n||0,o=0,s=n,i,h=r.length;do{if(s>=h)throw te.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Ie)<<o:(i&Ie)*Math.pow(2,o),o+=7}while(i>=ft);return te.bytes=s-n,t}var ut=Math.pow(2,7),dt=Math.pow(2,14),pt=Math.pow(2,21),lt=Math.pow(2,28),mt=Math.pow(2,35),bt=Math.pow(2,42),gt=Math.pow(2,49),yt=Math.pow(2,56),wt=Math.pow(2,63),xt=function(r){return r<ut?1:r<dt?2:r<pt?3:r<lt?4:r<mt?5:r<bt?6:r<gt?7:r<yt?8:r<wt?9:10},vt={encode:st,decode:ht,encodingLength:xt},St=vt,V=St;var j=(r,e=0)=>[V.decode(r,e),V.decode.bytes],T=(r,e,t=0)=>(V.encode(r,e,t),e),P=r=>V.encodingLength(r);var wr=new Uint8Array(0);var De=(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},A=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 Ue=r=>new TextEncoder().encode(r),ze=r=>new TextDecoder().decode(r);var D=(r,e)=>{let t=e.byteLength,n=P(r),o=n+P(t),s=new Uint8Array(o+t);return T(r,s,0),T(t,s,n),s.set(e,o),new B(r,t,e,s)},q=r=>{let e=A(r),[t,n]=j(e),[o,s]=j(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new B(t,o,i,e)},Le=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&De(r.bytes,t.bytes)}},B=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var ie={};l(ie,{base58btc:()=>m,base58flickr:()=>Ut});function Et(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var h=r.length,d=r.charAt(0),N=Math.log(h)/Math.log(256),b=Math.log(256)/Math.log(h);function M(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 p=0,O=0,y=0,x=a.length;y!==x&&a[y]===0;)y++,p++;for(var v=(x-y)*b+1>>>0,g=new Uint8Array(v);y!==x;){for(var S=a[y],C=0,w=v-1;(S!==0||C<O)&&w!==-1;w--,C++)S+=256*g[w]>>>0,g[w]=S%h>>>0,S=S/h>>>0;if(S!==0)throw new Error("Non-zero carry");O=C,y++}for(var E=v-O;E!==v&&g[E]===0;)E++;for(var Q=d.repeat(p);E<v;++E)Q+=r.charAt(g[E]);return Q}function X(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var p=0;if(a[p]!==" "){for(var O=0,y=0;a[p]===d;)O++,p++;for(var x=(a.length-p)*N+1>>>0,v=new Uint8Array(x);a[p];){var g=t[a.charCodeAt(p)];if(g===255)return;for(var S=0,C=x-1;(g!==0||S<y)&&C!==-1;C--,S++)g+=h*v[C]>>>0,v[C]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");y=S,p++}if(a[p]!==" "){for(var w=x-y;w!==x&&v[w]===0;)w++;for(var E=new Uint8Array(O+(x-w)),Q=O;w!==x;)E[Q++]=v[w++];return E}}}function We(a){var p=X(a);if(p)return p;throw new Error(`Non-${e} character`)}return{encode:M,decodeUnsafe:X,decode:We}}var At=Et,It=At,Ne=It;var re=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ne=class{constructor(e,t,n){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=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 Me(this,e)}},oe=class{constructor(e){this.decoders=e}or(e){return Me(this,e)}decode(e){let t=e[0],n=this.decoders[t];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`)}},Me=(r,e)=>new oe({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),se=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new re(e,t,n),this.decoder=new ne(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},R=({name:r,prefix:e,encode:t,decode:n})=>new se(r,e,t,n),U=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Ne(t,e);return R({prefix:r,name:e,encode:n,decode:s=>A(o(s))})},Ct=(r,e,t,n)=>{let o={};for(let b=0;b<e.length;++b)o[e[b]]=b;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),h=0,d=0,N=0;for(let b=0;b<s;++b){let M=o[r[b]];if(M===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<t|M,h+=t,h>=8&&(h-=8,i[N++]=255&d>>h)}if(h>=t||255&d<<8-h)throw new SyntaxError("Unexpected end of data");return i},Dt=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,h=0;for(let d=0;d<r.length;++d)for(h=h<<8|r[d],i+=8;i>t;)i-=t,s+=e[o&h>>i];if(i&&(s+=e[o&h<<t-i]),n)for(;s.length*t&7;)s+="=";return s},f=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>R({prefix:e,name:r,encode(o){return Dt(o,n,t)},decode(o){return Ct(o,n,t,r)}});var m=U({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ut=U({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ae={};l(ae,{base32:()=>F,base32hex:()=>Nt,base32hexpad:()=>Tt,base32hexpadupper:()=>Pt,base32hexupper:()=>Mt,base32pad:()=>Ot,base32padupper:()=>Lt,base32upper:()=>zt,base32z:()=>Bt});var F=f({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zt=f({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ot=f({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Lt=f({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Nt=f({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Mt=f({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Tt=f({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pt=f({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bt=f({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Te=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Rt(t,ce(r),e||m.encoder);default:return Ft(t,ce(r),e||F.encoder)}};var Pe=new WeakMap,ce=r=>{let e=Pe.get(r);if(e==null){let t=new Map;return Pe.set(r,t),t}return e},c=class{constructor(e,t,n,o){this.code=t,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:t}=this;if(e!==$)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Vt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return c.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,n=D(e,t);return c.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 c.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Le(e.multihash,n.multihash)}toString(e){return Te(this,e)}toJSON(){return{"/":Te(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 c)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new c(n,o,s,i||Be(n,o,s.bytes))}else if(t[jt]===!0){let{version:n,multihash:o,code:s}=t,i=q(o);return c.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="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(t!==$)throw new Error(`Version 0 CID must use dag-pb (code: ${$}) block encoding`);return new c(e,t,n,n.bytes)}case 1:{let o=Be(e,t,n.bytes);return new c(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return c.create(0,$,e)}static createV1(e,t){return c.create(1,e,t)}static decode(e){let[t,n]=c.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=c.inspectBytes(e),n=t.size-t.multihashSize,o=A(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new B(t.multihashCode,t.digestSize,s,o);return[t.version===0?c.createV0(i):c.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[M,X]=j(e.subarray(t));return t+=X,M},o=n(),s=$;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,h=n(),d=n(),N=t+d,b=N-i;return{version:o,codec:s,multihashCode:h,digestSize:d,multihashSize:b,size:N}}static parse(e,t){let[n,o]=kt(e,t),s=c.decode(o);return ce(s).set(n,e),s}},kt=(r,e)=>{switch(r[0]){case"Q":{let t=e||m;return[m.prefix,t.decode(`${m.prefix}${r}`)]}case m.prefix:{let t=e||m;return[m.prefix,t.decode(r)]}case F.prefix:{let t=e||F;return[F.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)]}}},Rt=(r,e,t)=>{let{prefix:n}=t;if(n!==m.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Ft=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},$=112,Vt=18,Be=(r,e,t)=>{let n=P(r),o=n+P(e),s=new Uint8Array(o+t.byteLength);return T(r,s,0),T(e,s,n),s.set(t,o),s},jt=Symbol.for("@ipld/js-cid/CID");var he={};l(he,{identity:()=>qt});var qt=R({prefix:"\0",name:"identity",encode:r=>ze(r),decode:r=>Ue(r)});var fe={};l(fe,{base2:()=>$t});var $t=f({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ue={};l(ue,{base8:()=>Jt});var Jt=f({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var de={};l(de,{base10:()=>Kt});var Kt=U({prefix:"9",name:"base10",alphabet:"0123456789"});var pe={};l(pe,{base16:()=>Gt,base16upper:()=>Ht});var Gt=f({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ht=f({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var le={};l(le,{base36:()=>Xt,base36upper:()=>Qt});var Xt=U({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Qt=U({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var me={};l(me,{base64:()=>Wt,base64pad:()=>Yt,base64url:()=>Zt,base64urlpad:()=>_t});var Wt=f({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yt=f({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zt=f({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_t=f({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var be={};l(be,{base256emoji:()=>or});var ke=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}"),er=ke.reduce((r,e,t)=>(r[t]=e,r),[]),tr=ke.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function rr(r){return r.reduce((e,t)=>(e+=er[t],e),"")}function nr(r){let e=[];for(let t of r){let n=tr[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var or=R({prefix:"\u{1F680}",name:"base256emoji",encode:rr,decode:nr});var we={};l(we,{sha256:()=>Z,sha512:()=>sr});var ye=({name:r,code:e,encode:t})=>new ge(r,e,t),ge=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?D(this.code,t):t.then(n=>D(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Fe=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Z=ye({name:"sha2-256",code:18,encode:Fe("SHA-256")}),sr=ye({name:"sha2-512",code:19,encode:Fe("SHA-512")});var xe={};l(xe,{identity:()=>_});var Ve=0,ir="identity",je=A,ar=r=>D(Ve,je(r)),_={code:Ve,name:ir,encode:je,digest:ar};var Jr=new TextEncoder,Kr=new TextDecoder;var ve={...he,...fe,...ue,...de,...pe,...ae,...le,...ie,...me,...be},Wr={...we,...xe};function Se(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 ur=nt(Je(),1);var Ke=Symbol.for("@libp2p/peer-id");var dr=Symbol.for("nodejs.util.inspect.custom"),Ge=Object.values(ve).map(r=>r.decoder).reduce((r,e)=>r.or(e),ve.identity.decoder),He=114,Xe=36,Qe=37,J=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[Ke](){return!0}toString(){return this.string==null&&(this.string=m.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return c.createV1(He,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return Se(this.multihash.bytes,e);if(typeof e=="string")return u(e).equals(this);if(e?.multihash?.bytes!=null)return Se(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[dr](){return`PeerId(${this.toString()})`}},K=class extends J{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}},G=class extends J{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}},H=class extends J{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}};function u(r,e){if(e=e??Ge,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=q(m.decode(`z${r}`));return r.startsWith("12D")?new G({multihash:t}):r.startsWith("16U")?new H({multihash:t}):new K({multihash:t})}return pr(Ge.decode(r))}function pr(r){try{let e=q(r);if(e.code===_.code){if(e.digest.length===Xe)return new G({multihash:e});if(e.digest.length===Qe)return new H({multihash:e})}if(e.code===Z.code)return new K({multihash:e})}catch{return lr(c.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function lr(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 K({multihash:r.multihash});if(e.code===_.code){if(e.digest.length===Xe)return new G({multihash:r.multihash});if(e.digest.length===Qe)return new H({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}function I(r,e){let t={[Symbol.iterator]:()=>t,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:e(o)}}};return t}var ee=class{constructor(e){if(this.map=new Map,e!=null)for(let[t,n]of e.entries())this.map.set(t.toString(),n)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){this.map.delete(e.toString())}entries(){return I(this.map.entries(),e=>[u(e[0]),e[1]])}forEach(e){this.map.forEach((t,n)=>{e(t,u(n),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 I(this.map.keys(),e=>u(e))}values(){return this.map.values()}get size(){return this.map.size}};var z=class{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 I(this.set.entries(),e=>{let t=u(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{let n=u(t);e(n,n,this)})}has(e){return this.set.has(e.toString())}values(){return I(this.set.values(),e=>u(e))}intersection(e){let t=new z;for(let n of e)this.has(n)&&t.add(n);return t}difference(e){let t=new z;for(let n of this)e.has(n)||t.add(n);return t}union(e){let t=new z;for(let n of e)t.add(n);for(let n of this)t.add(n);return t}};var L=class{constructor(e){if(this.list=[],e!=null)for(let t of e)this.list.push(t.toString())}[Symbol.iterator](){return I(this.list.entries(),e=>u(e[1]))}concat(e){let t=new L(this);for(let n of e)t.push(n);return t}entries(){return I(this.list.entries(),e=>[e[0],u(e[1])])}every(e){return this.list.every((t,n)=>e(u(t),n,this))}filter(e){let t=new L;return this.list.forEach((n,o)=>{let s=u(n);e(s,o,this)&&t.push(s)}),t}find(e){let t=this.list.find((n,o)=>e(u(n),o,this));if(t!=null)return u(t)}findIndex(e){return this.list.findIndex((t,n)=>e(u(t),n,this))}forEach(e){this.list.forEach((t,n)=>{e(u(t),n,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 u(e)}push(...e){for(let t of e)this.list.push(t.toString())}shift(){let e=this.list.shift();if(e!=null)return u(e)}unshift(...e){let t=this.list.length;for(let n=e.length-1;n>-1;n--)t=this.list.unshift(e[n].toString());return t}get length(){return this.list.length}};return ot(mr);})();
return Libp2PPeerCollections}));
{
"name": "@libp2p/peer-collections",
"version": "2.2.2",
"version": "3.0.0",
"description": "Stores values against a peer id",

@@ -142,9 +142,9 @@ "license": "Apache-2.0 OR MIT",

"dependencies": {
"@libp2p/interface-peer-id": "^1.0.4",
"@libp2p/peer-id": "^1.1.0"
"@libp2p/interface-peer-id": "^2.0.0",
"@libp2p/peer-id": "^2.0.0"
},
"devDependencies": {
"@libp2p/peer-id-factory": "^1.0.0",
"aegir": "^37.0.7"
"@libp2p/peer-id-factory": "^2.0.0",
"aegir": "^37.9.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc