@libp2p/peer-collections 4.0.3 → 4.0.4-5a6a4379
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/dist/index.min.js +1 -1
- package/package.json +5 -4
- package/dist/typedoc-urls.json +0 -5
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 Ge=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var u=(r,e)=>{for(var t in e)ee(r,t,{get:e[t],enumerable:!0})},Ye=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of He(e))!Qe.call(r,o)&&o!==t&&ee(r,o,{get:()=>e[o],enumerable:!(n=Ge(e,o))||n.enumerable});return r};var _e=r=>Ye(ee({},"__esModule",{value:!0}),r);var ir={};u(ir,{PeerList:()=>Z,PeerMap:()=>_,PeerSet:()=>W});var Ee=Symbol.for("@libp2p/peer-id");var se={};u(se,{base58btc:()=>l,base58flickr:()=>nt});function We(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 c=r.length,p=r.charAt(0),z=Math.log(c)/Math.log(256),m=Math.log(256)/Math.log(c);function N(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,U=0,x=0,y=a.length;x!==y&&a[x]===0;)x++,f++;for(var w=(y-x)*m+1>>>0,b=new Uint8Array(w);x!==y;){for(var v=a[x],I=0,g=w-1;(v!==0||I<U)&&g!==-1;g--,I++)v+=256*b[g]>>>0,b[g]=v%c>>>0,v=v/c>>>0;if(v!==0)throw new Error("Non-zero carry");U=I,x++}for(var S=w-U;S!==w&&b[S]===0;)S++;for(var G=p.repeat(f);S<w;++S)G+=r.charAt(b[S]);return G}function X(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 U=0,x=0;a[f]===p;)U++,f++;for(var y=(a.length-f)*z+1>>>0,w=new Uint8Array(y);a[f];){var b=t[a.charCodeAt(f)];if(b===255)return;for(var v=0,I=y-1;(b!==0||v<x)&&I!==-1;I--,v++)b+=c*w[I]>>>0,w[I]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");x=v,f++}if(a[f]!==" "){for(var g=y-x;g!==y&&w[g]===0;)g++;for(var S=new Uint8Array(U+(y-g)),G=U;g!==y;)S[G++]=w[g++];return S}}}function Xe(a){var f=X(a);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:N,decodeUnsafe:X,decode:Xe}}var Ze=We,et=Ze,Ae=et;var pr=new Uint8Array(0);var Ie=(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 Ce=r=>new TextEncoder().encode(r),De=r=>new TextDecoder().decode(r);var te=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")}},re=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 Re(this,e)}},ne=class{constructor(e){this.decoders=e}or(e){return Re(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`)}},Re=(r,e)=>new ne({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),oe=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new te(e,t,n),this.decoder=new re(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},L=({name:r,prefix:e,encode:t,decode:n})=>new oe(r,e,t,n),C=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Ae(t,e);return L({prefix:r,name:e,encode:n,decode:s=>E(o(s))})},tt=(r,e,t,n)=>{let o={};for(let m=0;m<e.length;++m)o[e[m]]=m;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,p=0,z=0;for(let m=0;m<s;++m){let N=o[r[m]];if(N===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<t|N,c+=t,c>=8&&(c-=8,i[z++]=255&p>>c)}if(c>=t||255&p<<8-c)throw new SyntaxError("Unexpected end of data");return i},rt=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let p=0;p<r.length;++p)for(c=c<<8|r[p],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},h=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>L({prefix:e,name:r,encode(o){return rt(o,n,t)},decode(o){return tt(o,n,t,r)}});var l=C({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nt=C({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ie={};u(ie,{identity:()=>ot});var ot=L({prefix:"\0",name:"identity",encode:r=>De(r),decode:r=>Ce(r)});var ae={};u(ae,{base2:()=>st});var st=h({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ce={};u(ce,{base8:()=>it});var it=h({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var he={};u(he,{base10:()=>at});var at=C({prefix:"9",name:"base10",alphabet:"0123456789"});var de={};u(de,{base16:()=>ct,base16upper:()=>ht});var ct=h({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ht=h({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pe={};u(pe,{base32:()=>P,base32hex:()=>ut,base32hexpad:()=>mt,base32hexpadupper:()=>bt,base32hexupper:()=>lt,base32pad:()=>pt,base32padupper:()=>ft,base32upper:()=>dt,base32z:()=>xt});var P=h({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),dt=h({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),pt=h({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ft=h({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ut=h({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),lt=h({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mt=h({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),bt=h({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xt=h({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fe={};u(fe,{base36:()=>gt,base36upper:()=>yt});var gt=C({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),yt=C({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ue={};u(ue,{base64:()=>wt,base64pad:()=>vt,base64url:()=>St,base64urlpad:()=>Et});var wt=h({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),vt=h({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),St=h({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Et=h({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var le={};u(le,{base256emoji:()=>Ut});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}"),At=ze.reduce((r,e,t)=>(r[t]=e,r),[]),It=ze.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Ct(r){return r.reduce((e,t)=>(e+=At[t],e),"")}function Dt(r){let e=[];for(let t of r){let n=It[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Ut=L({prefix:"\u{1F680}",name:"base256emoji",encode:Ct,decode:Dt});var ge={};u(ge,{sha256:()=>Q,sha512:()=>Gt});var Rt=Pe,Ne=128,zt=127,Nt=~zt,Lt=Math.pow(2,31);function Pe(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Lt;)e[t++]=r&255|Ne,r/=128;for(;r&Nt;)e[t++]=r&255|Ne,r>>>=7;return e[t]=r|0,Pe.bytes=t-n+1,e}var Pt=me,Ot=128,Le=127;function me(r,n){var t=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw me.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Le)<<o:(i&Le)*Math.pow(2,o),o+=7}while(i>=Ot);return me.bytes=s-n,t}var Tt=Math.pow(2,7),Mt=Math.pow(2,14),Bt=Math.pow(2,21),Vt=Math.pow(2,28),Ft=Math.pow(2,35),kt=Math.pow(2,42),qt=Math.pow(2,49),jt=Math.pow(2,56),$t=Math.pow(2,63),Kt=function(r){return r<Tt?1:r<Mt?2:r<Bt?3:r<Vt?4:r<Ft?5:r<kt?6:r<qt?7:r<jt?8:r<$t?9:10},Jt={encode:Rt,decode:Pt,encodingLength:Kt},Xt=Jt,V=Xt;var F=(r,e=0)=>[V.decode(r,e),V.decode.bytes],O=(r,e,t=0)=>(V.encode(r,e,t),e),T=r=>V.encodingLength(r);var D=(r,e)=>{let t=e.byteLength,n=T(r),o=n+T(t),s=new Uint8Array(o+t);return O(r,s,0),O(t,s,n),s.set(e,o),new M(r,t,e,s)},k=r=>{let e=E(r),[t,n]=F(e),[o,s]=F(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new M(t,o,i,e)},Oe=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ie(r.bytes,t.bytes)}},M=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var xe=({name:r,code:e,encode:t})=>new be(r,e,t),be=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 Me=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Q=xe({name:"sha2-256",code:18,encode:Me("SHA-256")}),Gt=xe({name:"sha2-512",code:19,encode:Me("SHA-512")});var ye={};u(ye,{identity:()=>Y});var Be=0,Ht="identity",Ve=E,Qt=r=>D(Be,Ve(r)),Y={code:Be,name:Ht,encode:Ve,digest:Qt};var Lr=new TextEncoder,Pr=new TextDecoder;var Fe=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Zt(t,we(r),e||l.encoder);default:return er(t,we(r),e||P.encoder)}};var ke=new WeakMap,we=r=>{let e=ke.get(r);if(e==null){let t=new Map;return ke.set(r,t),t}return e},R=class r{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!==q)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==tr)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,n=D(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Oe(e.multihash,n.multihash)}toString(e){return Fe(this,e)}toJSON(){return{"/":Fe(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:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i||qe(n,o,s.bytes))}else if(t[rr]===!0){let{version:n,multihash:o,code:s}=t,i=k(o);return r.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!==q)throw new Error(`Version 0 CID must use dag-pb (code: ${q}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=qe(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,q,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=E(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 M(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[N,X]=F(e.subarray(t));return t+=X,N},o=n(),s=q;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,c=n(),p=n(),z=t+p,m=z-i;return{version:o,codec:s,multihashCode:c,digestSize:p,multihashSize:m,size:z}}static parse(e,t){let[n,o]=Wt(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return we(s).set(n,e),s}},Wt=(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 P.prefix:{let t=e||P;return[P.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)]}}},Zt=(r,e,t)=>{let{prefix:n}=t;if(n!==l.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},er=(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},q=112,tr=18,qe=(r,e,t)=>{let n=T(r),o=n+T(e),s=new Uint8Array(o+t.byteLength);return O(r,s,0),O(e,s,n),s.set(t,o),s},rr=Symbol.for("@ipld/js-cid/CID");var ve={...ie,...ae,...ce,...he,...de,...pe,...fe,...se,...ue,...le},$r={...ge,...ye};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 nr=Symbol.for("nodejs.util.inspect.custom"),je=Object.values(ve).map(r=>r.decoder).reduce((r,e)=>r.or(e),ve.identity.decoder),$e=114,Ke=36,Je=37,j=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()})`}[Ee]=!0;toString(){return this.string==null&&(this.string=l.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return R.createV1($e,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 d(e).equals(this);if(e?.multihash?.bytes!=null)return Se(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[nr](){return`PeerId(${this.toString()})`}},$=class extends j{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},K=class extends j{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},J=class extends j{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function d(r,e){if(e=e??je,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=k(l.decode(`z${r}`));return r.startsWith("12D")?new K({multihash:t}):r.startsWith("16U")?new J({multihash:t}):new $({multihash:t})}return or(je.decode(r))}function or(r){try{let e=k(r);if(e.code===Y.code){if(e.digest.length===Ke)return new K({multihash:e});if(e.digest.length===Je)return new J({multihash:e})}if(e.code===Q.code)return new $({multihash:e})}catch{return sr(R.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function sr(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==$e)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Q.code)return new $({multihash:r.multihash});if(e.code===Y.code){if(e.digest.length===Ke)return new K({multihash:r.multihash});if(e.digest.length===Je)return new J({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}function A(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 _=class{map;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 A(this.map.entries(),e=>[d(e[0]),e[1]])}forEach(e){this.map.forEach((t,n)=>{e(t,d(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 A(this.map.keys(),e=>d(e))}values(){return this.map.values()}get size(){return this.map.size}};var W=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=d(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{let n=d(t);e(n,n,this)})}has(e){return this.set.has(e.toString())}values(){return A(this.set.values(),e=>d(e))}intersection(e){let t=new r;for(let n of e)this.has(n)&&t.add(n);return t}difference(e){let t=new r;for(let n of this)e.has(n)||t.add(n);return t}union(e){let t=new r;for(let n of e)t.add(n);for(let n of this)t.add(n);return t}};var Z=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=>d(e[1]))}concat(e){let t=new r(this);for(let n of e)t.push(n);return t}entries(){return A(this.list.entries(),e=>[e[0],d(e[1])])}every(e){return this.list.every((t,n)=>e(d(t),n,this))}filter(e){let t=new r;return this.list.forEach((n,o)=>{let s=d(n);e(s,o,this)&&t.push(s)}),t}find(e){let t=this.list.find((n,o)=>e(d(n),o,this));if(t!=null)return d(t)}findIndex(e){return this.list.findIndex((t,n)=>e(d(t),n,this))}forEach(e){this.list.forEach((t,n)=>{e(d(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 d(e)}push(...e){for(let t of e)this.list.push(t.toString())}shift(){let e=this.list.shift();if(e!=null)return d(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 _e(ir);})();
|
|
2
|
+
"use strict";var Libp2PPeerCollections=(()=>{var ee=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var u=(r,e)=>{for(var t in e)ee(r,t,{get:e[t],enumerable:!0})},Ye=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of He(e))!Qe.call(r,o)&&o!==t&&ee(r,o,{get:()=>e[o],enumerable:!(n=Ge(e,o))||n.enumerable});return r};var _e=r=>Ye(ee({},"__esModule",{value:!0}),r);var ir={};u(ir,{PeerList:()=>Z,PeerMap:()=>_,PeerSet:()=>W});var Ee=Symbol.for("@libp2p/peer-id");var se={};u(se,{base58btc:()=>l,base58flickr:()=>nt});function We(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 c=r.length,p=r.charAt(0),z=Math.log(c)/Math.log(256),m=Math.log(256)/Math.log(c);function N(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,U=0,x=0,y=a.length;x!==y&&a[x]===0;)x++,f++;for(var w=(y-x)*m+1>>>0,b=new Uint8Array(w);x!==y;){for(var v=a[x],I=0,g=w-1;(v!==0||I<U)&&g!==-1;g--,I++)v+=256*b[g]>>>0,b[g]=v%c>>>0,v=v/c>>>0;if(v!==0)throw new Error("Non-zero carry");U=I,x++}for(var S=w-U;S!==w&&b[S]===0;)S++;for(var G=p.repeat(f);S<w;++S)G+=r.charAt(b[S]);return G}function X(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 U=0,x=0;a[f]===p;)U++,f++;for(var y=(a.length-f)*z+1>>>0,w=new Uint8Array(y);a[f];){var b=t[a.charCodeAt(f)];if(b===255)return;for(var v=0,I=y-1;(b!==0||v<x)&&I!==-1;I--,v++)b+=c*w[I]>>>0,w[I]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");x=v,f++}if(a[f]!==" "){for(var g=y-x;g!==y&&w[g]===0;)g++;for(var S=new Uint8Array(U+(y-g)),G=U;g!==y;)S[G++]=w[g++];return S}}}function Xe(a){var f=X(a);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:N,decodeUnsafe:X,decode:Xe}}var Ze=We,et=Ze,Ae=et;var pr=new Uint8Array(0);var Ie=(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 Ce=r=>new TextEncoder().encode(r),De=r=>new TextDecoder().decode(r);var te=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")}},re=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 Re(this,e)}},ne=class{constructor(e){this.decoders=e}or(e){return Re(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`)}},Re=(r,e)=>new ne({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),oe=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new te(e,t,n),this.decoder=new re(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},L=({name:r,prefix:e,encode:t,decode:n})=>new oe(r,e,t,n),C=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Ae(t,e);return L({prefix:r,name:e,encode:n,decode:s=>E(o(s))})},tt=(r,e,t,n)=>{let o={};for(let m=0;m<e.length;++m)o[e[m]]=m;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,p=0,z=0;for(let m=0;m<s;++m){let N=o[r[m]];if(N===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<t|N,c+=t,c>=8&&(c-=8,i[z++]=255&p>>c)}if(c>=t||255&p<<8-c)throw new SyntaxError("Unexpected end of data");return i},rt=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let p=0;p<r.length;++p)for(c=c<<8|r[p],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},h=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>L({prefix:e,name:r,encode(o){return rt(o,n,t)},decode(o){return tt(o,n,t,r)}});var l=C({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nt=C({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ie={};u(ie,{base10:()=>ot});var ot=C({prefix:"9",name:"base10",alphabet:"0123456789"});var ae={};u(ae,{base16:()=>st,base16upper:()=>it});var st=h({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),it=h({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ce={};u(ce,{base2:()=>at});var at=h({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var he={};u(he,{base256emoji:()=>ft});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}"),ct=ze.reduce((r,e,t)=>(r[t]=e,r),[]),ht=ze.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function dt(r){return r.reduce((e,t)=>(e+=ct[t],e),"")}function pt(r){let e=[];for(let t of r){let n=ht[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var ft=L({prefix:"\u{1F680}",name:"base256emoji",encode:dt,decode:pt});var de={};u(de,{base32:()=>P,base32hex:()=>bt,base32hexpad:()=>gt,base32hexpadupper:()=>yt,base32hexupper:()=>xt,base32pad:()=>lt,base32padupper:()=>mt,base32upper:()=>ut,base32z:()=>wt});var P=h({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ut=h({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),lt=h({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),mt=h({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bt=h({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xt=h({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gt=h({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),yt=h({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),wt=h({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var pe={};u(pe,{base36:()=>vt,base36upper:()=>St});var vt=C({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),St=C({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var fe={};u(fe,{base64:()=>Et,base64pad:()=>At,base64url:()=>It,base64urlpad:()=>Ct});var Et=h({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),At=h({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),It=h({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ct=h({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ue={};u(ue,{base8:()=>Dt});var Dt=h({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var le={};u(le,{identity:()=>Ut});var Ut=L({prefix:"\0",name:"identity",encode:r=>De(r),decode:r=>Ce(r)});var Cr=new TextEncoder,Dr=new TextDecoder;var be={};u(be,{identity:()=>Q});var Nt=Pe,Ne=128,Lt=127,Pt=~Lt,Ot=Math.pow(2,31);function Pe(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Ot;)e[t++]=r&255|Ne,r/=128;for(;r&Pt;)e[t++]=r&255|Ne,r>>>=7;return e[t]=r|0,Pe.bytes=t-n+1,e}var Tt=me,Mt=128,Le=127;function me(r,n){var t=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw me.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Le)<<o:(i&Le)*Math.pow(2,o),o+=7}while(i>=Mt);return me.bytes=s-n,t}var Bt=Math.pow(2,7),Vt=Math.pow(2,14),Ft=Math.pow(2,21),kt=Math.pow(2,28),qt=Math.pow(2,35),jt=Math.pow(2,42),$t=Math.pow(2,49),Kt=Math.pow(2,56),Jt=Math.pow(2,63),Xt=function(r){return r<Bt?1:r<Vt?2:r<Ft?3:r<kt?4:r<qt?5:r<jt?6:r<$t?7:r<Kt?8:r<Jt?9:10},Gt={encode:Nt,decode:Tt,encodingLength:Xt},Ht=Gt,V=Ht;var F=(r,e=0)=>[V.decode(r,e),V.decode.bytes],O=(r,e,t=0)=>(V.encode(r,e,t),e),T=r=>V.encodingLength(r);var D=(r,e)=>{let t=e.byteLength,n=T(r),o=n+T(t),s=new Uint8Array(o+t);return O(r,s,0),O(t,s,n),s.set(e,o),new M(r,t,e,s)},k=r=>{let e=E(r),[t,n]=F(e),[o,s]=F(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new M(t,o,i,e)},Oe=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ie(r.bytes,t.bytes)}},M=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Te=0,Qt="identity",Me=E,Yt=r=>D(Te,Me(r)),Q={code:Te,name:Qt,encode:Me,digest:Yt};var ye={};u(ye,{sha256:()=>Y,sha512:()=>_t});var ge=({name:r,code:e,encode:t})=>new xe(r,e,t),xe=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 Ve=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Y=ge({name:"sha2-256",code:18,encode:Ve("SHA-256")}),_t=ge({name:"sha2-512",code:19,encode:Ve("SHA-512")});var Fe=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Zt(t,we(r),e||l.encoder);default:return er(t,we(r),e||P.encoder)}};var ke=new WeakMap,we=r=>{let e=ke.get(r);if(e==null){let t=new Map;return ke.set(r,t),t}return e},R=class r{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!==q)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==tr)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,n=D(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Oe(e.multihash,n.multihash)}toString(e){return Fe(this,e)}toJSON(){return{"/":Fe(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:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i||qe(n,o,s.bytes))}else if(t[rr]===!0){let{version:n,multihash:o,code:s}=t,i=k(o);return r.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!==q)throw new Error(`Version 0 CID must use dag-pb (code: ${q}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=qe(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,q,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=E(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 M(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[N,X]=F(e.subarray(t));return t+=X,N},o=n(),s=q;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,c=n(),p=n(),z=t+p,m=z-i;return{version:o,codec:s,multihashCode:c,digestSize:p,multihashSize:m,size:z}}static parse(e,t){let[n,o]=Wt(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return we(s).set(n,e),s}},Wt=(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 P.prefix:{let t=e||P;return[P.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)]}}},Zt=(r,e,t)=>{let{prefix:n}=t;if(n!==l.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},er=(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},q=112,tr=18,qe=(r,e,t)=>{let n=T(r),o=n+T(e),s=new Uint8Array(o+t.byteLength);return O(r,s,0),O(e,s,n),s.set(t,o),s},rr=Symbol.for("@ipld/js-cid/CID");var ve={...le,...ce,...ue,...ie,...ae,...de,...pe,...se,...fe,...he},$r={...ye,...be};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 nr=Symbol.for("nodejs.util.inspect.custom"),je=Object.values(ve).map(r=>r.decoder).reduce((r,e)=>r.or(e),ve.identity.decoder),$e=114,Ke=36,Je=37,j=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()})`}[Ee]=!0;toString(){return this.string==null&&(this.string=l.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return R.createV1($e,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 d(e).equals(this);if(e?.multihash?.bytes!=null)return Se(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[nr](){return`PeerId(${this.toString()})`}},$=class extends j{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},K=class extends j{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},J=class extends j{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function d(r,e){if(e=e??je,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=k(l.decode(`z${r}`));return r.startsWith("12D")?new K({multihash:t}):r.startsWith("16U")?new J({multihash:t}):new $({multihash:t})}return or(je.decode(r))}function or(r){try{let e=k(r);if(e.code===Q.code){if(e.digest.length===Ke)return new K({multihash:e});if(e.digest.length===Je)return new J({multihash:e})}if(e.code===Y.code)return new $({multihash:e})}catch{return sr(R.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function sr(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==$e)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Y.code)return new $({multihash:r.multihash});if(e.code===Q.code){if(e.digest.length===Ke)return new K({multihash:r.multihash});if(e.digest.length===Je)return new J({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}function A(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 _=class{map;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 A(this.map.entries(),e=>[d(e[0]),e[1]])}forEach(e){this.map.forEach((t,n)=>{e(t,d(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 A(this.map.keys(),e=>d(e))}values(){return this.map.values()}get size(){return this.map.size}};var W=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=d(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{let n=d(t);e(n,n,this)})}has(e){return this.set.has(e.toString())}values(){return A(this.set.values(),e=>d(e))}intersection(e){let t=new r;for(let n of e)this.has(n)&&t.add(n);return t}difference(e){let t=new r;for(let n of this)e.has(n)||t.add(n);return t}union(e){let t=new r;for(let n of e)t.add(n);for(let n of this)t.add(n);return t}};var Z=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=>d(e[1]))}concat(e){let t=new r(this);for(let n of e)t.push(n);return t}entries(){return A(this.list.entries(),e=>[e[0],d(e[1])])}every(e){return this.list.every((t,n)=>e(d(t),n,this))}filter(e){let t=new r;return this.list.forEach((n,o)=>{let s=d(n);e(s,o,this)&&t.push(s)}),t}find(e){let t=this.list.find((n,o)=>e(d(n),o,this));if(t!=null)return d(t)}findIndex(e){return this.list.findIndex((t,n)=>e(d(t),n,this))}forEach(e){this.list.forEach((t,n)=>{e(d(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 d(e)}push(...e){for(let t of e)this.list.push(t.toString())}shift(){let e=this.list.shift();if(e!=null)return d(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 _e(ir);})();
|
|
3
3
|
return Libp2PPeerCollections}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/peer-collections",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4-5a6a4379",
|
|
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/master/packages/peer-collections#readme",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"eslintConfig": {
|
|
32
32
|
"extends": "ipfs",
|
|
33
33
|
"parserOptions": {
|
|
34
|
+
"project": true,
|
|
34
35
|
"sourceType": "module"
|
|
35
36
|
}
|
|
36
37
|
},
|
|
@@ -48,11 +49,11 @@
|
|
|
48
49
|
"test:electron-main": "aegir test -t electron-main"
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
|
-
"@libp2p/interface": "
|
|
52
|
-
"@libp2p/peer-id": "
|
|
52
|
+
"@libp2p/interface": "0.1.2-5a6a4379",
|
|
53
|
+
"@libp2p/peer-id": "3.0.2-5a6a4379"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@libp2p/peer-id-factory": "
|
|
56
|
+
"@libp2p/peer-id-factory": "3.0.4-5a6a4379",
|
|
56
57
|
"aegir": "^40.0.8"
|
|
57
58
|
}
|
|
58
59
|
}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"PeerMap": "https://libp2p.github.io/js-libp2p/classes/_libp2p_interface_compliance_tests.transport.unknown.PeerMap.html",
|
|
3
|
-
"PeerList": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerList.html",
|
|
4
|
-
"PeerSet": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerSet.html"
|
|
5
|
-
}
|