@libp2p/memory 1.1.0-a4f0db1e9 → 1.1.0-e7e01f58f
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 +4 -4
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMemory = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PMemory=(()=>{var _t=Object.defineProperty;var Nr=Object.getOwnPropertyDescriptor;var Mr=Object.getOwnPropertyNames;var kr=Object.prototype.hasOwnProperty;var k=(r,t)=>{for(var e in t)_t(r,e,{get:t[e],enumerable:!0})},Fr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Mr(t))!kr.call(r,o)&&o!==e&&_t(r,o,{get:()=>t[o],enumerable:!(n=Nr(t,o))||n.enumerable});return r};var Lr=r=>Fr(_t({},"__esModule",{value:!0}),r);var Mo={};k(Mo,{memory:()=>No});var Ve=Symbol.for("@libp2p/transport");var $e;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})($e||($e={}));var H=class extends Error{static name="ConnectionFailedError";constructor(t="Connection failed"){super(t),this.name="ConnectionFailedError"}};var gt=class extends Error{static name="ListenError";constructor(t="Listen error"){super(t),this.name="ListenError"}};var wt=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var Be=Symbol.for("@libp2p/service-capabilities"),$o=Symbol.for("@libp2p/service-dependencies");var bt=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",v=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let I=this.readChar();if(I===void 0)return;let N=Number.parseInt(I,t);if(!Number.isNaN(N))return N});if(g===void 0)break;if(s*=t,s+=g,s>v||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Oe=45,zr=15,X=new bt;function jt(r){if(!(r.length>zr))return X.new(r).parseWith(()=>X.readIPv4Addr())}function qt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Oe))return X.new(r).parseWith(()=>X.readIPv6Addr())}function yt(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Oe)return;let e=X.new(r).parseWith(()=>X.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}function vt(r){return!!jt(r)}function Et(r){return!!qt(r)}function It(r){return!!yt(r)}var Ht={};k(Ht,{base58btc:()=>P,base58flickr:()=>_r});var ps=new Uint8Array(0);function Re(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function V(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function _e(r){return new TextEncoder().encode(r)}function je(r){return new TextDecoder().decode(r)}function $r(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),v=Math.log(a)/Math.log(256),g=Math.log(256)/Math.log(a);function I(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var y=0,p=0,E=0,U=d.length;E!==U&&d[E]===0;)E++,y++;for(var A=(U-E)*g+1>>>0,M=new Uint8Array(A);E!==U;){for(var F=d[E],_=0,L=A-1;(F!==0||_<p)&&L!==-1;L--,_++)F+=256*M[L]>>>0,M[L]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");p=_,E++}for(var $=A-p;$!==A&&M[$]===0;)$++;for(var xt=c.repeat(y);$<A;++$)xt+=r.charAt(M[$]);return xt}function N(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var y=0;if(d[y]!==" "){for(var p=0,E=0;d[y]===c;)p++,y++;for(var U=(d.length-y)*v+1>>>0,A=new Uint8Array(U);d[y];){var M=e[d.charCodeAt(y)];if(M===255)return;for(var F=0,_=U-1;(M!==0||F<E)&&_!==-1;_--,F++)M+=a*A[_]>>>0,A[_]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");E=F,y++}if(d[y]!==" "){for(var L=U-E;L!==U&&A[L]===0;)L++;for(var $=new Uint8Array(p+(U-L)),xt=p;L!==U;)$[xt++]=A[L++];return $}}}function S(d){var y=N(d);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:I,decodeUnsafe:N,decode:S}}var Vr=$r,Br=Vr,We=Br;var Wt=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Gt=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Ge(this,t)}},Qt=class{decoders;constructor(t){this.decoders=t}or(t){return Ge(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ge(r,t){return new Qt({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Jt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Wt(t,e,n),this.decoder=new Gt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function K({name:r,prefix:t,encode:e,decode:n}){return new Jt(r,t,e,n)}function j({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=We(e,r);return K({prefix:t,name:r,encode:n,decode:s=>V(o(s))})}function Or(r,t,e,n){let o={};for(let g=0;g<t.length;++g)o[t[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),a=0,c=0,v=0;for(let g=0;g<s;++g){let I=o[r[g]];if(I===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|I,a+=e,a>=8&&(a-=8,i[v++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function Rr(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;s.length*e&7;)s+="=";return s}function b({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return K({prefix:t,name:r,encode(o){return Rr(o,n,e)},decode(o){return Or(o,n,e,r)}})}var P=j({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_r=j({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Kt={};k(Kt,{base64:()=>jr,base64pad:()=>qr,base64url:()=>Xt,base64urlpad:()=>Wr});var jr=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qr=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xt=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wr=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Gr=r=>r.toString().split("/").slice(1),Z=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),u=r=>({match:t=>Z(e=>e===r).match(t),pattern:r}),G=()=>({match:r=>Z(t=>typeof t=="string").match(r),pattern:"{string}"}),ct=()=>({match:r=>Z(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),m=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{P.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),ut=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Xt.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),f=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),C=(...r)=>({match:t=>{let e;for(let n of r){let o=n.match(t);o!==!1&&(e==null||o.length<e.length)&&(e=o)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),l=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function w(...r){function t(o){let s=Gr(o);for(let i of r){let a=i.match(s);if(a===!1)return!1;s=a}return s}function e(o){return t(o)!==!1}function n(o){let s=t(o);return s===!1?!1:s.length===0}return{matchers:r,matches:e,exactMatch:n}}var St=l(u("dns4"),G()),Pt=l(u("dns6"),G()),Ct=l(u("dnsaddr"),G()),Yt=l(u("dns"),G()),Is=w(St,f(m())),As=w(Pt,f(m())),Ss=w(Ct,f(m())),Ps=w(C(Yt,Ct,St,Pt),f(m())),Qe=l(u("ip4"),Z(vt)),Je=l(u("ip6"),Z(Et)),te=C(Qe,Je),B=C(te,Yt,St,Pt,Ct),Cs=w(C(te,l(C(Yt,Ct,St,Pt),f(m())))),Ts=w(Qe),Us=w(Je),Ds=w(te),ee=l(B,u("tcp"),ct()),lt=l(B,u("udp"),ct()),Ns=w(l(ee,f(m()))),Ms=w(lt),re=l(lt,u("quic"),f(m())),Tt=l(lt,u("quic-v1"),f(m())),Qr=C(re,Tt),ks=w(re),Fs=w(Tt),Zt=C(B,ee,lt,re,Tt),He=C(l(Zt,u("ws"),f(m()))),Ls=w(He),Xe=C(l(Zt,u("wss"),f(m())),l(Zt,u("tls"),f(l(u("sni"),G())),u("ws"),f(m()))),zs=w(Xe),Ke=l(lt,u("webrtc-direct"),f(ut()),f(ut()),f(m())),$s=w(Ke),Ze=l(Tt,u("webtransport"),f(ut()),f(ut()),f(m())),Vs=w(Ze),At=C(He,Xe,l(ee,f(m())),l(Qr,f(m())),l(B,f(m())),Ke,Ze,m()),Bs=w(At),Jr=l(At,u("p2p-circuit"),m()),Os=w(Jr),Hr=C(l(At,u("p2p-circuit"),u("webrtc"),f(m())),l(At,u("webrtc"),f(m())),l(u("webrtc"),f(m()))),Rs=w(Hr),Xr=C(l(B,u("tcp"),ct(),u("http"),f(m())),l(B,u("http"),f(m()))),_s=w(Xr),Kr=C(l(B,u("tcp"),C(l(u("443"),u("http")),l(ct(),u("https"))),f(m())),l(B,u("tls"),u("http"),f(m())),l(B,u("https"),f(m()))),js=w(Kr),Zr=C(l(u("memory"),G(),f(m()))),Ye=w(Zr);function Y(r=0){return new Uint8Array(r)}var Yr=Math.pow(2,7),tn=Math.pow(2,14),en=Math.pow(2,21),ne=Math.pow(2,28),oe=Math.pow(2,35),se=Math.pow(2,42),ie=Math.pow(2,49),h=128,T=127;function z(r){if(r<Yr)return 1;if(r<tn)return 2;if(r<en)return 3;if(r<ne)return 4;if(r<oe)return 5;if(r<se)return 6;if(r<ie)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function rn(r,t,e=0){switch(z(r)){case 8:t[e++]=r&255|h,r/=128;case 7:t[e++]=r&255|h,r/=128;case 6:t[e++]=r&255|h,r/=128;case 5:t[e++]=r&255|h,r/=128;case 4:t[e++]=r&255|h,r>>>=7;case 3:t[e++]=r&255|h,r>>>=7;case 2:t[e++]=r&255|h,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function nn(r,t,e=0){switch(z(r)){case 8:t.set(e++,r&255|h),r/=128;case 7:t.set(e++,r&255|h),r/=128;case 6:t.set(e++,r&255|h),r/=128;case 5:t.set(e++,r&255|h),r/=128;case 4:t.set(e++,r&255|h),r>>>=7;case 3:t.set(e++,r&255|h),r>>>=7;case 2:t.set(e++,r&255|h),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function on(r,t){let e=r[t],n=0;if(n+=e&T,e<h||(e=r[t+1],n+=(e&T)<<7,e<h)||(e=r[t+2],n+=(e&T)<<14,e<h)||(e=r[t+3],n+=(e&T)<<21,e<h)||(e=r[t+4],n+=(e&T)*ne,e<h)||(e=r[t+5],n+=(e&T)*oe,e<h)||(e=r[t+6],n+=(e&T)*se,e<h)||(e=r[t+7],n+=(e&T)*ie,e<h))return n;throw new RangeError("Could not decode varint")}function sn(r,t){let e=r.get(t),n=0;if(n+=e&T,e<h||(e=r.get(t+1),n+=(e&T)<<7,e<h)||(e=r.get(t+2),n+=(e&T)<<14,e<h)||(e=r.get(t+3),n+=(e&T)<<21,e<h)||(e=r.get(t+4),n+=(e&T)*ne,e<h)||(e=r.get(t+5),n+=(e&T)*oe,e<h)||(e=r.get(t+6),n+=(e&T)*se,e<h)||(e=r.get(t+7),n+=(e&T)*ie,e<h))return n;throw new RangeError("Could not decode varint")}function tt(r,t,e=0){return t==null&&(t=Y(z(r))),t instanceof Uint8Array?rn(r,t,e):nn(r,t,e)}function Q(r,t=0){return r instanceof Uint8Array?on(r,t):sn(r,t)}function O(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=Y(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ae={};k(ae,{base10:()=>an});var an=j({prefix:"9",name:"base10",alphabet:"0123456789"});var ce={};k(ce,{base16:()=>cn,base16upper:()=>un});var cn=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),un=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ue={};k(ue,{base2:()=>ln});var ln=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var le={};k(le,{base256emoji:()=>mn});var er=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}"),pn=er.reduce((r,t,e)=>(r[e]=t,r),[]),dn=er.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function fn(r){return r.reduce((t,e)=>(t+=pn[e],t),"")}function hn(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=dn[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var mn=K({prefix:"\u{1F680}",name:"base256emoji",encode:fn,decode:hn});var pe={};k(pe,{base32:()=>R,base32hex:()=>bn,base32hexpad:()=>vn,base32hexpadupper:()=>En,base32hexupper:()=>yn,base32pad:()=>gn,base32padupper:()=>wn,base32upper:()=>xn,base32z:()=>In});var R=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xn=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gn=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wn=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bn=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yn=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vn=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),En=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),In=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var de={};k(de,{base36:()=>pt,base36upper:()=>An});var pt=j({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),An=j({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var fe={};k(fe,{base8:()=>Sn});var Sn=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var he={};k(he,{identity:()=>Pn});var Pn=K({prefix:"\0",name:"identity",encode:r=>je(r),decode:r=>_e(r)});var ai=new TextEncoder,ci=new TextDecoder;var xe={};k(xe,{identity:()=>Hn});var Un=or,rr=128,Dn=127,Nn=~Dn,Mn=Math.pow(2,31);function or(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Mn;)t[e++]=r&255|rr,r/=128;for(;r&Nn;)t[e++]=r&255|rr,r>>>=7;return t[e]=r|0,or.bytes=e-n+1,t}var kn=me,Fn=128,nr=127;function me(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw me.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&nr)<<o:(i&nr)*Math.pow(2,o),o+=7}while(i>=Fn);return me.bytes=s-n,e}var Ln=Math.pow(2,7),zn=Math.pow(2,14),$n=Math.pow(2,21),Vn=Math.pow(2,28),Bn=Math.pow(2,35),On=Math.pow(2,42),Rn=Math.pow(2,49),_n=Math.pow(2,56),jn=Math.pow(2,63),qn=function(r){return r<Ln?1:r<zn?2:r<$n?3:r<Vn?4:r<Bn?5:r<On?6:r<Rn?7:r<_n?8:r<jn?9:10},Wn={encode:Un,decode:kn,encodingLength:qn},Gn=Wn,dt=Gn;function ft(r,t=0){return[dt.decode(r,t),dt.decode.bytes]}function et(r,t,e=0){return dt.encode(r,t,e),t}function rt(r){return dt.encodingLength(r)}function J(r,t){let e=t.byteLength,n=rt(r),o=n+rt(e),s=new Uint8Array(o+e);return et(r,s,0),et(e,s,n),s.set(t,o),new nt(r,e,t,s)}function Dt(r){let t=V(r),[e,n]=ft(t),[o,s]=ft(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new nt(e,o,i,t)}function sr(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Re(r.bytes,e.bytes)}}var nt=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var ir=0,Qn="identity",ar=V;function Jn(r){return J(ir,ar(r))}var Hn={code:ir,name:Qn,encode:ar,digest:Jn};var be={};k(be,{sha256:()=>Xn,sha512:()=>Kn});function we({name:r,code:t,encode:e}){return new ge(r,t,e)}var ge=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?J(this.code,e):e.then(n=>J(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ur(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Xn=we({name:"sha2-256",code:18,encode:ur("SHA-256")}),Kn=we({name:"sha2-512",code:19,encode:ur("SHA-512")});function lr(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Yn(e,ye(r),t??P.encoder);default:return to(e,ye(r),t??R.encoder)}}var pr=new WeakMap;function ye(r){let t=pr.get(r);if(t==null){let e=new Map;return pr.set(r,e),e}return t}var q=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==ht)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==eo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=J(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&sr(t.multihash,n.multihash)}toString(t){return lr(this,t)}toJSON(){return{"/":lr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??dr(n,o,s.bytes))}else if(e[ro]===!0){let{version:n,multihash:o,code:s}=e,i=Dt(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==ht)throw new Error(`Version 0 CID must use dag-pb (code: ${ht}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=dr(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ht,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=V(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new nt(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[I,N]=ft(t.subarray(e));return e+=N,I},o=n(),s=ht;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),v=e+c,g=v-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:g,size:v}}static parse(t,e){let[n,o]=Zn(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ye(s).set(n,t),s}};function Zn(r,t){switch(r[0]){case"Q":{let e=t??P;return[P.prefix,e.decode(`${P.prefix}${r}`)]}case P.prefix:{let e=t??P;return[P.prefix,e.decode(r)]}case R.prefix:{let e=t??R;return[R.prefix,e.decode(r)]}case pt.prefix:{let e=t??pt;return[pt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Yn(r,t,e){let{prefix:n}=e;if(n!==P.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function to(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var ht=112,eo=18;function dr(r,t,e){let n=rt(r),o=n+rt(t),s=new Uint8Array(o+e.byteLength);return et(r,s,0),et(t,s,n),s.set(e,o),s}var ro=Symbol.for("@ipld/js-cid/CID");var mt={...he,...ue,...fe,...ae,...ce,...pe,...de,...Ht,...Kt,...le},Di={...be,...xe};function hr(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var fr=hr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ve=hr("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Y(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),no={utf8:fr,"utf-8":fr,hex:mt.base16,latin1:ve,ascii:ve,binary:ve,...mt},Nt=no;function D(r,t="utf8"){let e=Nt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var ji=parseInt("0xFFFF",16),qi=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Mt(r,t="utf8"){let e=Nt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}var gr=vt,co=Et,Ee=function(r){let t=0;if(r=r.toString().trim(),gr(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(co(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=gr(e[n]),i;s&&(i=Ee(e[n]),e[n]=D(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,D(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},wr=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var st={},Ie={},lo=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];lo.forEach(r=>{let t=po(...r);Ie[t.code]=t,st[t.name]=t});function po(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function x(r){if(typeof r=="number"){if(Ie[r]!=null)return Ie[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(st[r]!=null)return st[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ca=x("ip4"),Ta=x("ip6"),Ua=x("ipcidr");function Ce(r,t){switch(x(r).code){case 4:case 41:return ho(t);case 42:return Pe(t);case 43:return D(t,"base10");case 6:case 273:case 33:case 132:return vr(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Pe(t);case 421:return wo(t);case 444:return yr(t);case 445:return yr(t);case 466:return go(t);case 481:return globalThis.encodeURIComponent(Pe(t));default:return D(t,"base16")}}function Te(r,t){switch(x(r).code){case 4:return br(t);case 41:return br(t);case 42:return Se(t);case 43:return Mt(t,"base10");case 6:case 273:case 33:case 132:return Ue(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Se(t);case 421:return mo(t);case 444:return bo(t);case 445:return yo(t);case 466:return xo(t);case 481:return Se(globalThis.decodeURIComponent(t));default:return Mt(t,"base16")}}var Ae=Object.values(mt).map(r=>r.decoder),fo=function(){let r=Ae[0].or(Ae[1]);return Ae.slice(2).forEach(t=>r=r.or(t)),r}();function br(r){if(!It(r))throw new Error("invalid ip address");return Ee(r)}function ho(r){let t=wr(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!It(t))throw new Error("invalid ip address");return t}function Ue(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function vr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Se(r){let t=Mt(r),e=Uint8Array.from(tt(t.length));return O([e,t],e.length+t.length)}function Pe(r){let t=Q(r);if(r=r.slice(z(t)),r.length!==t)throw new Error("inconsistent lengths");return D(r)}function mo(r){let t;r[0]==="Q"||r[0]==="1"?t=Dt(P.decode(`z${r}`)).bytes:t=q.parse(r).multihash.bytes;let e=Uint8Array.from(tt(t.length));return O([e,t],e.length+t.length)}function xo(r){let t=fo.decode(r),e=Uint8Array.from(tt(t.length));return O([e,t],e.length+t.length)}function go(r){let t=Q(r),e=r.slice(z(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+D(e,"base64url")}function wo(r){let t=Q(r),e=r.slice(z(t));if(e.length!==t)throw new Error("inconsistent lengths");return D(e,"base58btc")}function bo(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=R.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ue(n);return O([e,o],e.length+o.length)}function yo(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=R.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ue(n);return O([e,o],e.length+o.length)}function yr(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=D(t,"base32"),o=vr(e);return`${n}:${o}`}function Er(r){r=De(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=x(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(s++,s>=o.length)throw new kt("invalid address: "+r);if(a.path===!0){n=De(o.slice(s).join("/")),t.push([a.code,Te(a.code,n)]),e.push([a.code,n]);break}let c=Te(a.code,o[s]);t.push([a.code,c]),e.push([a.code,Ce(a.code,c)])}return{string:Ir(e),bytes:Ft(t),tuples:t,stringTuples:e,path:n}}function Ne(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=Q(r,o),i=z(s),a=x(s),c=vo(a,r.slice(o+i));if(c===0){t.push([s]),e.push([s]),o+=i;continue}let v=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw new kt("Invalid address Uint8Array: "+D(r,"base16"));t.push([s,v]);let g=Ce(s,v);if(e.push([s,g]),a.path===!0){n=g;break}}return{bytes:Uint8Array.from(r),string:Ir(e),tuples:t,stringTuples:e,path:n}}function Ir(r){let t=[];return r.map(e=>{let n=x(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),De(t.join("/"))}function Ft(r){return O(r.map(t=>{let e=x(t[0]),n=Uint8Array.from(tt(e.code));return t.length>1&&t[1]!=null&&(n=O([n,t[1]])),n}))}function vo(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=Q(t instanceof Uint8Array?t:Uint8Array.from(t));return e+z(e)}}function De(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var kt=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};function Ar(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Eo=Symbol.for("nodejs.util.inspect.custom"),ke=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Io=[x("dns").code,x("dns4").code,x("dns6").code,x("dnsaddr").code],Me=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Lt=class r{bytes;#t;#e;#r;#n;[ke]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Ne(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Er(t)}else if(Pr(t))e=Ne(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=x("tcp"),a=x("udp"),c=x("ip4"),v=x("ip6"),g=x("dns6"),I=x("ip6zone");for(let[S,d]of this.stringTuples())S===I.code&&(s=`%${d??""}`),Io.includes(S)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${d??""}${s}`,t=S===g.code?6:4),(S===i.code||S===a.code)&&(e=x(S).name==="tcp"?"tcp":"udp",o=parseInt(d??"")),(S===c.code||S===v.code)&&(e=x(S).name==="tcp"?"tcp":"udp",n=`${d??""}${s}`,t=S===v.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},x(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>x(t).name)}tuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Ft(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===st.p2p.code&&t.push([n,o]),n===st["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?D(P.decode(`z${n}`),"base58btc"):D(q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Ar(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Sr.get(e.name);if(n==null)throw new Me(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>W(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Eo](){return`Multiaddr(${this.#t})`}};var Sr=new Map;function Pr(r){return!!r?.[ke]}function W(r){return new Lt(r)}var Cr=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},Ao=new WeakMap;function So({clearTimeout:r,setTimeout:t}={}){return(e,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(Cr());let s,i,a,c=r??clearTimeout,v=()=>{c(s),a(Cr())},g=()=>{o&&o.removeEventListener("abort",v)},I=new Promise((N,S)=>{i=()=>{g(),N(n)},a=S,s=(t??setTimeout)(i,e)});return o&&o.addEventListener("abort",v,{once:!0}),Ao.set(I,()=>{c(s),s=null,i()}),I}}var Po=So(),zt=Po;function Co(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var Tr=Co;function To(r){return r[Symbol.asyncIterator]!=null}function Uo(r,t){let e=0;if(To(r))return async function*(){for await(let c of r)yield t(c,e++)}();let n=Tr(r),{value:o,done:s}=n.next();if(s===!0)return function*(){}();let i=t(o,e++);if(typeof i.then=="function")return async function*(){yield await i;for await(let c of n)yield t(c,e++)}();let a=t;return function*(){yield i;for(let c of n)yield a(c,e++)}()}var Fe=Uo;function $t(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Vt=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},it=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Vt(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Vt(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var Le=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function ze(r={}){return Do(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Do(r,t){t=t??{};let e=t.onEnd,n=new it,o,s,i,a=$t(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((p,E)=>{s=U=>{s=null,n.push(U);try{p(r(n))}catch(A){E(A)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=$t()})}},v=p=>s!=null?s(p):(n.push(p),o),g=p=>(n=new it,s!=null?s({error:p}):(n.push({error:p}),o)),I=p=>{if(i)return o;if(t?.objectMode!==!0&&p?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return v({done:!1,value:p})},N=p=>i?o:(i=!0,p!=null?g(p):v({done:!0})),S=()=>(n=new it,N(),{done:!0}),d=p=>(N(p),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:S,throw:d,push:I,end:N,get readableLength(){return n.size},onEmpty:async p=>{let E=p?.signal;if(E?.throwIfAborted(),n.isEmpty())return;let U,A;E!=null&&(U=new Promise((M,F)=>{A=()=>{F(new Le)},E.addEventListener("abort",A)}));try{await Promise.race([a.promise,U])}finally{A!=null&&E!=null&&E?.removeEventListener("abort",A)}}},e==null)return o;let y=o;return o={[Symbol.asyncIterator](){return this},next(){return y.next()},throw(p){return y.throw(p),e!=null&&(e(p),e=void 0),{done:!0}},return(){return y.return(),e!=null&&(e(),e=void 0),{done:!0}},push:I,end(p){return y.end(p),e!=null&&(e(p),e=void 0),o},get readableLength(){return y.readableLength},onEmpty:p=>y.onEmpty(p)},o}var at=new Map,Bt=class{components;init;connections;latency;constructor(t,e){this.components=t,this.init=e,this.connections=new Set,this.latency=e.latency??0}async dial(t){let e=ze(),n=ze(),o=this,s={source:async function*(){yield*Fe(n,async a=>(o.latency>0&&await zt(o.latency),a))}(),sink:async a=>{for await(let c of a)e.push(c)},close:async()=>{e.end(),this.connections.delete(s),s.timeline.close=Date.now(),n.end(),this.connections.delete(i),i.timeline.close=Date.now()},abort:a=>{e.end(a),this.connections.delete(s),s.timeline.close=Date.now(),n.end(a),this.connections.delete(i),i.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}/p2p/${this.components.peerId}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")},i={source:async function*(){yield*Fe(e,async a=>(o.latency>0&&await zt(o.latency),a))}(),sink:async a=>{for await(let c of a)n.push(c)},close:async()=>{n.end(),this.connections.delete(i),i.timeline.close=Date.now(),e.end(),this.connections.delete(s),s.timeline.close=Date.now()},abort:a=>{n.end(a),this.connections.delete(i),i.timeline.close=Date.now(),e.end(a),this.connections.delete(s),s.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}-outgoing/p2p/${t}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")};return this.connections.add(s),this.connections.add(i),await zt(this.latency),this.init.onConnection(i),s}close(){[...this.connections].forEach(t=>{t.abort(new H("Memory Connection closed"))})}};var Ur="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Dr=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Ur[e[r]&63];return t};var Ot=class extends wt{listenAddr;connection;components;init;constructor(t,e){super(),this.components=t,this.init=e}async listen(t){let[[,e]]=t.stringTuples(),n=`/memory/${e??Dr()}`;if(e!=null&&at.has(n))throw new gt(`Memory address ${n} already in use`);this.connection=new Bt(this.components,{...this.init,onConnection:this.onConnection.bind(this),address:n}),this.listenAddr=W(n),at.set(n,this.connection),queueMicrotask(()=>{this.safeDispatchEvent("listening")})}onConnection(t){let e;this.init.inboundUpgradeTimeout!=null&&(e=AbortSignal.timeout(this.init.inboundUpgradeTimeout)),this.init.upgrader.upgradeInbound(t,{...this.init.upgraderOptions,signal:e}).catch(n=>{t.abort(n)})}getAddrs(){return this.listenAddr==null?[]:[this.listenAddr]}updateAnnounceAddrs(){}async close(){this.connection?.close(),this.listenAddr!=null&&at.delete(this.listenAddr.toString()),queueMicrotask(()=>{this.safeDispatchEvent("close")})}};var Rt=class{components;init;constructor(t,e={}){this.components=t,this.init=e}[Ve]=!0;[Symbol.toStringTag]="@libp2p/memory";[Be]=["@libp2p/transport"];async dial(t,e){e.signal?.throwIfAborted();let n=at.get(`${t.getPeerId()==null?t:t.decapsulate("/p2p")}`);if(n==null)throw new H(`No memory listener found at ${t}`);let o=await n.dial(this.components.peerId);try{return e.signal?.throwIfAborted(),await e.upgrader.upgradeOutbound(o,{...e,...this.init.upgraderOptions})}catch(s){throw o.abort(s),s}}createListener(t){return new Ot(this.components,{...t,...this.init})}listenFilter(t){return t.filter(e=>Ye.exactMatch(e))}dialFilter(t){return this.listenFilter(t)}};function No(r){return t=>new Rt(t,r)}return Lr(Mo);})();
|
|
2
|
+
"use strict";var Libp2PMemory=(()=>{var _t=Object.defineProperty;var Nr=Object.getOwnPropertyDescriptor;var Mr=Object.getOwnPropertyNames;var kr=Object.prototype.hasOwnProperty;var k=(r,t)=>{for(var e in t)_t(r,e,{get:t[e],enumerable:!0})},Fr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Mr(t))!kr.call(r,o)&&o!==e&&_t(r,o,{get:()=>t[o],enumerable:!(n=Nr(t,o))||n.enumerable});return r};var Lr=r=>Fr(_t({},"__esModule",{value:!0}),r);var Mo={};k(Mo,{memory:()=>No});var Ve=Symbol.for("@libp2p/transport");var $e;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})($e||($e={}));var H=class extends Error{static name="ConnectionFailedError";constructor(t="Connection failed"){super(t),this.name="ConnectionFailedError"}};var gt=class extends Error{static name="ListenError";constructor(t="Listen error"){super(t),this.name="ListenError"}};var wt=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var Be=Symbol.for("@libp2p/service-capabilities"),$o=Symbol.for("@libp2p/service-dependencies");var bt=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",v=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let I=this.readChar();if(I===void 0)return;let N=Number.parseInt(I,t);if(!Number.isNaN(N))return N});if(g===void 0)break;if(s*=t,s+=g,s>v||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Oe=45,zr=15,X=new bt;function jt(r){if(!(r.length>zr))return X.new(r).parseWith(()=>X.readIPv4Addr())}function qt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Oe))return X.new(r).parseWith(()=>X.readIPv6Addr())}function yt(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Oe)return;let e=X.new(r).parseWith(()=>X.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}function vt(r){return!!jt(r)}function Et(r){return!!qt(r)}function It(r){return!!yt(r)}var Ht={};k(Ht,{base58btc:()=>P,base58flickr:()=>_r});var ps=new Uint8Array(0);function Re(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function V(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function _e(r){return new TextEncoder().encode(r)}function je(r){return new TextDecoder().decode(r)}function $r(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),v=Math.log(a)/Math.log(256),g=Math.log(256)/Math.log(a);function I(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var y=0,p=0,E=0,U=d.length;E!==U&&d[E]===0;)E++,y++;for(var A=(U-E)*g+1>>>0,M=new Uint8Array(A);E!==U;){for(var F=d[E],_=0,L=A-1;(F!==0||_<p)&&L!==-1;L--,_++)F+=256*M[L]>>>0,M[L]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");p=_,E++}for(var $=A-p;$!==A&&M[$]===0;)$++;for(var xt=c.repeat(y);$<A;++$)xt+=r.charAt(M[$]);return xt}function N(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var y=0;if(d[y]!==" "){for(var p=0,E=0;d[y]===c;)p++,y++;for(var U=(d.length-y)*v+1>>>0,A=new Uint8Array(U);d[y];){var M=e[d.charCodeAt(y)];if(M===255)return;for(var F=0,_=U-1;(M!==0||F<E)&&_!==-1;_--,F++)M+=a*A[_]>>>0,A[_]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");E=F,y++}if(d[y]!==" "){for(var L=U-E;L!==U&&A[L]===0;)L++;for(var $=new Uint8Array(p+(U-L)),xt=p;L!==U;)$[xt++]=A[L++];return $}}}function S(d){var y=N(d);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:I,decodeUnsafe:N,decode:S}}var Vr=$r,Br=Vr,We=Br;var Wt=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Gt=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Ge(this,t)}},Qt=class{decoders;constructor(t){this.decoders=t}or(t){return Ge(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ge(r,t){return new Qt({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Jt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Wt(t,e,n),this.decoder=new Gt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function K({name:r,prefix:t,encode:e,decode:n}){return new Jt(r,t,e,n)}function j({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=We(e,r);return K({prefix:t,name:r,encode:n,decode:s=>V(o(s))})}function Or(r,t,e,n){let o={};for(let g=0;g<t.length;++g)o[t[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),a=0,c=0,v=0;for(let g=0;g<s;++g){let I=o[r[g]];if(I===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|I,a+=e,a>=8&&(a-=8,i[v++]=255&c>>a)}if(a>=e||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return i}function Rr(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function b({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return K({prefix:t,name:r,encode(o){return Rr(o,n,e)},decode(o){return Or(o,n,e,r)}})}var P=j({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_r=j({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Kt={};k(Kt,{base64:()=>jr,base64pad:()=>qr,base64url:()=>Xt,base64urlpad:()=>Wr});var jr=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qr=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xt=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wr=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Gr=r=>r.toString().split("/").slice(1),Z=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),u=r=>({match:t=>Z(e=>e===r).match(t),pattern:r}),G=()=>({match:r=>Z(t=>typeof t=="string").match(r),pattern:"{string}"}),ct=()=>({match:r=>Z(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),m=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{P.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),ut=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Xt.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),f=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),C=(...r)=>({match:t=>{let e;for(let n of r){let o=n.match(t);o!==!1&&(e==null||o.length<e.length)&&(e=o)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),l=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function w(...r){function t(o){let s=Gr(o);for(let i of r){let a=i.match(s);if(a===!1)return!1;s=a}return s}function e(o){return t(o)!==!1}function n(o){let s=t(o);return s===!1?!1:s.length===0}return{matchers:r,matches:e,exactMatch:n}}var St=l(u("dns4"),G()),Pt=l(u("dns6"),G()),Ct=l(u("dnsaddr"),G()),Yt=l(u("dns"),G()),Is=w(St,f(m())),As=w(Pt,f(m())),Ss=w(Ct,f(m())),Ps=w(C(Yt,Ct,St,Pt),f(m())),Qe=l(u("ip4"),Z(vt)),Je=l(u("ip6"),Z(Et)),te=C(Qe,Je),B=C(te,Yt,St,Pt,Ct),Cs=w(C(te,l(C(Yt,Ct,St,Pt),f(m())))),Ts=w(Qe),Us=w(Je),Ds=w(te),ee=l(B,u("tcp"),ct()),lt=l(B,u("udp"),ct()),Ns=w(l(ee,f(m()))),Ms=w(lt),re=l(lt,u("quic"),f(m())),Tt=l(lt,u("quic-v1"),f(m())),Qr=C(re,Tt),ks=w(re),Fs=w(Tt),Zt=C(B,ee,lt,re,Tt),He=C(l(Zt,u("ws"),f(m()))),Ls=w(He),Xe=C(l(Zt,u("wss"),f(m())),l(Zt,u("tls"),f(l(u("sni"),G())),u("ws"),f(m()))),zs=w(Xe),Ke=l(lt,u("webrtc-direct"),f(ut()),f(ut()),f(m())),$s=w(Ke),Ze=l(Tt,u("webtransport"),f(ut()),f(ut()),f(m())),Vs=w(Ze),At=C(He,Xe,l(ee,f(m())),l(Qr,f(m())),l(B,f(m())),Ke,Ze,m()),Bs=w(At),Jr=l(At,u("p2p-circuit"),m()),Os=w(Jr),Hr=C(l(At,u("p2p-circuit"),u("webrtc"),f(m())),l(At,u("webrtc"),f(m())),l(u("webrtc"),f(m()))),Rs=w(Hr),Xr=C(l(B,u("tcp"),ct(),u("http"),f(m())),l(B,u("http"),f(m()))),_s=w(Xr),Kr=C(l(B,u("tcp"),C(l(u("443"),u("http")),l(ct(),u("https"))),f(m())),l(B,u("tls"),u("http"),f(m())),l(B,u("https"),f(m()))),js=w(Kr),Zr=C(l(u("memory"),G(),f(m()))),Ye=w(Zr);function Y(r=0){return new Uint8Array(r)}var Yr=Math.pow(2,7),tn=Math.pow(2,14),en=Math.pow(2,21),ne=Math.pow(2,28),oe=Math.pow(2,35),se=Math.pow(2,42),ie=Math.pow(2,49),h=128,T=127;function z(r){if(r<Yr)return 1;if(r<tn)return 2;if(r<en)return 3;if(r<ne)return 4;if(r<oe)return 5;if(r<se)return 6;if(r<ie)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function rn(r,t,e=0){switch(z(r)){case 8:t[e++]=r&255|h,r/=128;case 7:t[e++]=r&255|h,r/=128;case 6:t[e++]=r&255|h,r/=128;case 5:t[e++]=r&255|h,r/=128;case 4:t[e++]=r&255|h,r>>>=7;case 3:t[e++]=r&255|h,r>>>=7;case 2:t[e++]=r&255|h,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function nn(r,t,e=0){switch(z(r)){case 8:t.set(e++,r&255|h),r/=128;case 7:t.set(e++,r&255|h),r/=128;case 6:t.set(e++,r&255|h),r/=128;case 5:t.set(e++,r&255|h),r/=128;case 4:t.set(e++,r&255|h),r>>>=7;case 3:t.set(e++,r&255|h),r>>>=7;case 2:t.set(e++,r&255|h),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function on(r,t){let e=r[t],n=0;if(n+=e&T,e<h||(e=r[t+1],n+=(e&T)<<7,e<h)||(e=r[t+2],n+=(e&T)<<14,e<h)||(e=r[t+3],n+=(e&T)<<21,e<h)||(e=r[t+4],n+=(e&T)*ne,e<h)||(e=r[t+5],n+=(e&T)*oe,e<h)||(e=r[t+6],n+=(e&T)*se,e<h)||(e=r[t+7],n+=(e&T)*ie,e<h))return n;throw new RangeError("Could not decode varint")}function sn(r,t){let e=r.get(t),n=0;if(n+=e&T,e<h||(e=r.get(t+1),n+=(e&T)<<7,e<h)||(e=r.get(t+2),n+=(e&T)<<14,e<h)||(e=r.get(t+3),n+=(e&T)<<21,e<h)||(e=r.get(t+4),n+=(e&T)*ne,e<h)||(e=r.get(t+5),n+=(e&T)*oe,e<h)||(e=r.get(t+6),n+=(e&T)*se,e<h)||(e=r.get(t+7),n+=(e&T)*ie,e<h))return n;throw new RangeError("Could not decode varint")}function tt(r,t,e=0){return t==null&&(t=Y(z(r))),t instanceof Uint8Array?rn(r,t,e):nn(r,t,e)}function Q(r,t=0){return r instanceof Uint8Array?on(r,t):sn(r,t)}function O(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=Y(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ae={};k(ae,{base10:()=>an});var an=j({prefix:"9",name:"base10",alphabet:"0123456789"});var ce={};k(ce,{base16:()=>cn,base16upper:()=>un});var cn=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),un=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ue={};k(ue,{base2:()=>ln});var ln=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var le={};k(le,{base256emoji:()=>mn});var er=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}"),pn=er.reduce((r,t,e)=>(r[e]=t,r),[]),dn=er.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function fn(r){return r.reduce((t,e)=>(t+=pn[e],t),"")}function hn(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=dn[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var mn=K({prefix:"\u{1F680}",name:"base256emoji",encode:fn,decode:hn});var pe={};k(pe,{base32:()=>R,base32hex:()=>bn,base32hexpad:()=>vn,base32hexpadupper:()=>En,base32hexupper:()=>yn,base32pad:()=>gn,base32padupper:()=>wn,base32upper:()=>xn,base32z:()=>In});var R=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xn=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gn=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wn=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bn=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yn=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vn=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),En=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),In=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var de={};k(de,{base36:()=>pt,base36upper:()=>An});var pt=j({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),An=j({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var fe={};k(fe,{base8:()=>Sn});var Sn=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var he={};k(he,{identity:()=>Pn});var Pn=K({prefix:"\0",name:"identity",encode:r=>je(r),decode:r=>_e(r)});var ai=new TextEncoder,ci=new TextDecoder;var xe={};k(xe,{identity:()=>Hn});var Un=or,rr=128,Dn=127,Nn=~Dn,Mn=Math.pow(2,31);function or(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Mn;)t[e++]=r&255|rr,r/=128;for(;r&Nn;)t[e++]=r&255|rr,r>>>=7;return t[e]=r|0,or.bytes=e-n+1,t}var kn=me,Fn=128,nr=127;function me(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw me.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&nr)<<o:(i&nr)*Math.pow(2,o),o+=7}while(i>=Fn);return me.bytes=s-n,e}var Ln=Math.pow(2,7),zn=Math.pow(2,14),$n=Math.pow(2,21),Vn=Math.pow(2,28),Bn=Math.pow(2,35),On=Math.pow(2,42),Rn=Math.pow(2,49),_n=Math.pow(2,56),jn=Math.pow(2,63),qn=function(r){return r<Ln?1:r<zn?2:r<$n?3:r<Vn?4:r<Bn?5:r<On?6:r<Rn?7:r<_n?8:r<jn?9:10},Wn={encode:Un,decode:kn,encodingLength:qn},Gn=Wn,dt=Gn;function ft(r,t=0){return[dt.decode(r,t),dt.decode.bytes]}function et(r,t,e=0){return dt.encode(r,t,e),t}function rt(r){return dt.encodingLength(r)}function J(r,t){let e=t.byteLength,n=rt(r),o=n+rt(e),s=new Uint8Array(o+e);return et(r,s,0),et(e,s,n),s.set(t,o),new nt(r,e,t,s)}function Dt(r){let t=V(r),[e,n]=ft(t),[o,s]=ft(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new nt(e,o,i,t)}function sr(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Re(r.bytes,e.bytes)}}var nt=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var ir=0,Qn="identity",ar=V;function Jn(r){return J(ir,ar(r))}var Hn={code:ir,name:Qn,encode:ar,digest:Jn};var be={};k(be,{sha256:()=>Xn,sha512:()=>Kn});function we({name:r,code:t,encode:e}){return new ge(r,t,e)}var ge=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?J(this.code,e):e.then(n=>J(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ur(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Xn=we({name:"sha2-256",code:18,encode:ur("SHA-256")}),Kn=we({name:"sha2-512",code:19,encode:ur("SHA-512")});function lr(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Yn(e,ye(r),t??P.encoder);default:return to(e,ye(r),t??R.encoder)}}var pr=new WeakMap;function ye(r){let t=pr.get(r);if(t==null){let e=new Map;return pr.set(r,e),e}return t}var q=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==ht)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==eo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=J(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&sr(t.multihash,n.multihash)}toString(t){return lr(this,t)}toJSON(){return{"/":lr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??dr(n,o,s.bytes))}else if(e[ro]===!0){let{version:n,multihash:o,code:s}=e,i=Dt(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==ht)throw new Error(`Version 0 CID must use dag-pb (code: ${ht}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=dr(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ht,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=V(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new nt(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[I,N]=ft(t.subarray(e));return e+=N,I},o=n(),s=ht;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),v=e+c,g=v-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:g,size:v}}static parse(t,e){let[n,o]=Zn(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ye(s).set(n,t),s}};function Zn(r,t){switch(r[0]){case"Q":{let e=t??P;return[P.prefix,e.decode(`${P.prefix}${r}`)]}case P.prefix:{let e=t??P;return[P.prefix,e.decode(r)]}case R.prefix:{let e=t??R;return[R.prefix,e.decode(r)]}case pt.prefix:{let e=t??pt;return[pt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Yn(r,t,e){let{prefix:n}=e;if(n!==P.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function to(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var ht=112,eo=18;function dr(r,t,e){let n=rt(r),o=n+rt(t),s=new Uint8Array(o+e.byteLength);return et(r,s,0),et(t,s,n),s.set(e,o),s}var ro=Symbol.for("@ipld/js-cid/CID");var mt={...he,...ue,...fe,...ae,...ce,...pe,...de,...Ht,...Kt,...le},Di={...be,...xe};function hr(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var fr=hr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ve=hr("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Y(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),no={utf8:fr,"utf-8":fr,hex:mt.base16,latin1:ve,ascii:ve,binary:ve,...mt},Nt=no;function D(r,t="utf8"){let e=Nt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var ji=parseInt("0xFFFF",16),qi=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Mt(r,t="utf8"){let e=Nt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}var gr=vt,co=Et,Ee=function(r){let t=0;if(r=r.toString().trim(),gr(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(co(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=gr(e[n]),i;s&&(i=Ee(e[n]),e[n]=D(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,D(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},wr=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var st={},Ie={},lo=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];lo.forEach(r=>{let t=po(...r);Ie[t.code]=t,st[t.name]=t});function po(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function x(r){if(typeof r=="number"){if(Ie[r]!=null)return Ie[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(st[r]!=null)return st[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ca=x("ip4"),Ta=x("ip6"),Ua=x("ipcidr");function Ce(r,t){switch(x(r).code){case 4:case 41:return ho(t);case 42:return Pe(t);case 43:return D(t,"base10");case 6:case 273:case 33:case 132:return vr(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Pe(t);case 421:return wo(t);case 444:return yr(t);case 445:return yr(t);case 466:return go(t);case 481:return globalThis.encodeURIComponent(Pe(t));default:return D(t,"base16")}}function Te(r,t){switch(x(r).code){case 4:return br(t);case 41:return br(t);case 42:return Se(t);case 43:return Mt(t,"base10");case 6:case 273:case 33:case 132:return Ue(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Se(t);case 421:return mo(t);case 444:return bo(t);case 445:return yo(t);case 466:return xo(t);case 481:return Se(globalThis.decodeURIComponent(t));default:return Mt(t,"base16")}}var Ae=Object.values(mt).map(r=>r.decoder),fo=function(){let r=Ae[0].or(Ae[1]);return Ae.slice(2).forEach(t=>r=r.or(t)),r}();function br(r){if(!It(r))throw new Error("invalid ip address");return Ee(r)}function ho(r){let t=wr(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!It(t))throw new Error("invalid ip address");return t}function Ue(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function vr(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Se(r){let t=Mt(r),e=Uint8Array.from(tt(t.length));return O([e,t],e.length+t.length)}function Pe(r){let t=Q(r);if(r=r.slice(z(t)),r.length!==t)throw new Error("inconsistent lengths");return D(r)}function mo(r){let t;r[0]==="Q"||r[0]==="1"?t=Dt(P.decode(`z${r}`)).bytes:t=q.parse(r).multihash.bytes;let e=Uint8Array.from(tt(t.length));return O([e,t],e.length+t.length)}function xo(r){let t=fo.decode(r),e=Uint8Array.from(tt(t.length));return O([e,t],e.length+t.length)}function go(r){let t=Q(r),e=r.slice(z(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+D(e,"base64url")}function wo(r){let t=Q(r),e=r.slice(z(t));if(e.length!==t)throw new Error("inconsistent lengths");return D(e,"base58btc")}function bo(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=R.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ue(n);return O([e,o],e.length+o.length)}function yo(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=R.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ue(n);return O([e,o],e.length+o.length)}function yr(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=D(t,"base32"),o=vr(e);return`${n}:${o}`}function Er(r){r=De(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=x(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(s++,s>=o.length)throw new kt("invalid address: "+r);if(a.path===!0){n=De(o.slice(s).join("/")),t.push([a.code,Te(a.code,n)]),e.push([a.code,n]);break}let c=Te(a.code,o[s]);t.push([a.code,c]),e.push([a.code,Ce(a.code,c)])}return{string:Ir(e),bytes:Ft(t),tuples:t,stringTuples:e,path:n}}function Ne(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=Q(r,o),i=z(s),a=x(s),c=vo(a,r.slice(o+i));if(c===0){t.push([s]),e.push([s]),o+=i;continue}let v=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw new kt("Invalid address Uint8Array: "+D(r,"base16"));t.push([s,v]);let g=Ce(s,v);if(e.push([s,g]),a.path===!0){n=g;break}}return{bytes:Uint8Array.from(r),string:Ir(e),tuples:t,stringTuples:e,path:n}}function Ir(r){let t=[];return r.map(e=>{let n=x(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),De(t.join("/"))}function Ft(r){return O(r.map(t=>{let e=x(t[0]),n=Uint8Array.from(tt(e.code));return t.length>1&&t[1]!=null&&(n=O([n,t[1]])),n}))}function vo(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=Q(t instanceof Uint8Array?t:Uint8Array.from(t));return e+z(e)}}function De(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var kt=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};function Ar(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Eo=Symbol.for("nodejs.util.inspect.custom"),ke=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Io=[x("dns").code,x("dns4").code,x("dns6").code,x("dnsaddr").code],Me=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Lt=class r{bytes;#t;#e;#r;#n;[ke]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Ne(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Er(t)}else if(Pr(t))e=Ne(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#e=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=x("tcp"),a=x("udp"),c=x("ip4"),v=x("ip6"),g=x("dns6"),I=x("ip6zone");for(let[S,d]of this.stringTuples())S===I.code&&(s=`%${d??""}`),Io.includes(S)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${d??""}${s}`,t=S===g.code?6:4),(S===i.code||S===a.code)&&(e=x(S).name==="tcp"?"tcp":"udp",o=parseInt(d??"")),(S===c.code||S===v.code)&&(e=x(S).name==="tcp"?"tcp":"udp",n=`${d??""}${s}`,t=S===v.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#e.map(([t])=>Object.assign({},x(t)))}protoCodes(){return this.#e.map(([t])=>t)}protoNames(){return this.#e.map(([t])=>x(t).name)}tuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Ft(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===st.p2p.code&&t.push([n,o]),n===st["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?D(P.decode(`z${n}`),"base58btc"):D(q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Ar(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Sr.get(e.name);if(n==null)throw new Me(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>W(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Eo](){return`Multiaddr(${this.#t})`}};var Sr=new Map;function Pr(r){return!!r?.[ke]}function W(r){return new Lt(r)}var Cr=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},Ao=new WeakMap;function So({clearTimeout:r,setTimeout:t}={}){return(e,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(Cr());let s,i,a,c=r??clearTimeout,v=()=>{c(s),a(Cr())},g=()=>{o&&o.removeEventListener("abort",v)},I=new Promise((N,S)=>{i=()=>{g(),N(n)},a=S,s=(t??setTimeout)(i,e)});return o&&o.addEventListener("abort",v,{once:!0}),Ao.set(I,()=>{c(s),s=null,i()}),I}}var Po=So(),zt=Po;function Co(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var Tr=Co;function To(r){return r[Symbol.asyncIterator]!=null}function Uo(r,t){let e=0;if(To(r))return async function*(){for await(let c of r)yield t(c,e++)}();let n=Tr(r),{value:o,done:s}=n.next();if(s===!0)return function*(){}();let i=t(o,e++);if(typeof i.then=="function")return async function*(){yield await i;for await(let c of n)yield t(c,e++)}();let a=t;return function*(){yield i;for(let c of n)yield a(c,e++)}()}var Fe=Uo;function $t(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Vt=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},it=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Vt(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Vt(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var Le=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function ze(r={}){return Do(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Do(r,t){t=t??{};let e=t.onEnd,n=new it,o,s,i,a=$t(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((p,E)=>{s=U=>{s=null,n.push(U);try{p(r(n))}catch(A){E(A)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=$t()})}},v=p=>s!=null?s(p):(n.push(p),o),g=p=>(n=new it,s!=null?s({error:p}):(n.push({error:p}),o)),I=p=>{if(i)return o;if(t?.objectMode!==!0&&p?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return v({done:!1,value:p})},N=p=>i?o:(i=!0,p!=null?g(p):v({done:!0})),S=()=>(n=new it,N(),{done:!0}),d=p=>(N(p),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:S,throw:d,push:I,end:N,get readableLength(){return n.size},onEmpty:async p=>{let E=p?.signal;if(E?.throwIfAborted(),n.isEmpty())return;let U,A;E!=null&&(U=new Promise((M,F)=>{A=()=>{F(new Le)},E.addEventListener("abort",A)}));try{await Promise.race([a.promise,U])}finally{A!=null&&E!=null&&E?.removeEventListener("abort",A)}}},e==null)return o;let y=o;return o={[Symbol.asyncIterator](){return this},next(){return y.next()},throw(p){return y.throw(p),e!=null&&(e(p),e=void 0),{done:!0}},return(){return y.return(),e!=null&&(e(),e=void 0),{done:!0}},push:I,end(p){return y.end(p),e!=null&&(e(p),e=void 0),o},get readableLength(){return y.readableLength},onEmpty:p=>y.onEmpty(p)},o}var at=new Map,Bt=class{components;init;connections;latency;constructor(t,e){this.components=t,this.init=e,this.connections=new Set,this.latency=e.latency??0}async dial(t){let e=ze(),n=ze(),o=this,s={source:async function*(){yield*Fe(n,async a=>(o.latency>0&&await zt(o.latency),a))}(),sink:async a=>{for await(let c of a)e.push(c)},close:async()=>{e.end(),this.connections.delete(s),s.timeline.close=Date.now(),n.end(),this.connections.delete(i),i.timeline.close=Date.now()},abort:a=>{e.end(a),this.connections.delete(s),s.timeline.close=Date.now(),n.end(a),this.connections.delete(i),i.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}/p2p/${this.components.peerId}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")},i={source:async function*(){yield*Fe(e,async a=>(o.latency>0&&await zt(o.latency),a))}(),sink:async a=>{for await(let c of a)n.push(c)},close:async()=>{n.end(),this.connections.delete(i),i.timeline.close=Date.now(),e.end(),this.connections.delete(s),s.timeline.close=Date.now()},abort:a=>{n.end(a),this.connections.delete(i),i.timeline.close=Date.now(),e.end(a),this.connections.delete(s),s.timeline.close=Date.now()},timeline:{open:Date.now()},remoteAddr:W(`${this.init.address}-outgoing/p2p/${t}`),log:this.components.logger.forComponent("libp2p:memory:outgoing:1")};return this.connections.add(s),this.connections.add(i),await zt(this.latency),this.init.onConnection(i),s}close(){[...this.connections].forEach(t=>{t.abort(new H("Memory Connection closed"))})}};var Ur="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Dr=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Ur[e[r]&63];return t};var Ot=class extends wt{listenAddr;connection;components;init;constructor(t,e){super(),this.components=t,this.init=e}async listen(t){let[[,e]]=t.stringTuples(),n=`/memory/${e??Dr()}`;if(e!=null&&at.has(n))throw new gt(`Memory address ${n} already in use`);this.connection=new Bt(this.components,{...this.init,onConnection:this.onConnection.bind(this),address:n}),this.listenAddr=W(n),at.set(n,this.connection),queueMicrotask(()=>{this.safeDispatchEvent("listening")})}onConnection(t){let e;this.init.inboundUpgradeTimeout!=null&&(e=AbortSignal.timeout(this.init.inboundUpgradeTimeout)),this.init.upgrader.upgradeInbound(t,{...this.init.upgraderOptions,signal:e}).catch(n=>{t.abort(n)})}getAddrs(){return this.listenAddr==null?[]:[this.listenAddr]}updateAnnounceAddrs(){}async close(){this.connection?.close(),this.listenAddr!=null&&at.delete(this.listenAddr.toString()),queueMicrotask(()=>{this.safeDispatchEvent("close")})}};var Rt=class{components;init;constructor(t,e={}){this.components=t,this.init=e}[Ve]=!0;[Symbol.toStringTag]="@libp2p/memory";[Be]=["@libp2p/transport"];async dial(t,e){e.signal?.throwIfAborted();let n=at.get(`${t.getPeerId()==null?t:t.decapsulate("/p2p")}`);if(n==null)throw new H(`No memory listener found at ${t}`);let o=await n.dial(this.components.peerId);try{return e.signal?.throwIfAborted(),await e.upgrader.upgradeOutbound(o,{...e,...this.init.upgraderOptions})}catch(s){throw o.abort(s),s}}createListener(t){return new Ot(this.components,{...t,...this.init})}listenFilter(t){return t.filter(e=>Ye.exactMatch(e))}dialFilter(t){return this.listenFilter(t)}};function No(r){return t=>new Rt(t,r)}return Lr(Mo);})();
|
|
3
3
|
return Libp2PMemory}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/memory",
|
|
3
|
-
"version": "1.1.0-
|
|
3
|
+
"version": "1.1.0-e7e01f58f",
|
|
4
4
|
"description": "A memory transport for libp2p",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-memory#readme",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"test:electron-main": "aegir test -t electron-main"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@libp2p/interface": "2.6.0-
|
|
54
|
+
"@libp2p/interface": "2.6.0-e7e01f58f",
|
|
55
55
|
"@multiformats/multiaddr": "^12.3.3",
|
|
56
56
|
"@multiformats/multiaddr-matcher": "^1.6.0",
|
|
57
57
|
"@types/sinon": "^17.0.3",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"uint8arraylist": "^2.4.8"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@libp2p/logger": "5.1.9-
|
|
66
|
-
"@libp2p/peer-id": "5.0.13-
|
|
65
|
+
"@libp2p/logger": "5.1.9-e7e01f58f",
|
|
66
|
+
"@libp2p/peer-id": "5.0.13-e7e01f58f",
|
|
67
67
|
"aegir": "^45.0.5",
|
|
68
68
|
"sinon": "^19.0.2",
|
|
69
69
|
"sinon-ts": "^2.0.0"
|