@libp2p/daemon-protocol 6.0.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDaemonProtocol = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PDaemonProtocol=(()=>{var It=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Me=Object.prototype.hasOwnProperty;var b=(i,e)=>{for(var t in e)It(i,t,{get:e[t],enumerable:!0})},ze=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ge(e))!Me.call(i,n)&&n!==t&&It(i,n,{get:()=>e[n],enumerable:!(r=Pe(e,n))||r.enumerable});return i};var Re=i=>ze(It({},"__esModule",{value:!0}),i);var ri={};b(ri,{ConnManagerRequest:()=>lt,ConnectRequest:()=>et,DHTRequest:()=>st,DHTResponse:()=>ct,DisconnectRequest:()=>ht,ErrorResponse:()=>rt,IdentifyResponse:()=>tt,PSMessage:()=>ie,PSRequest:()=>at,PSResponse:()=>ut,PeerInfo:()=>B,PeerstoreRequest:()=>ft,PeerstoreResponse:()=>dt,Request:()=>ee,Response:()=>ne,StreamHandlerRequest:()=>it,StreamInfo:()=>ot,StreamOpenRequest:()=>nt});var kt=new Float32Array([-0]),w=new Uint8Array(kt.buffer);function re(i,e,t){kt[0]=i,e[t]=w[0],e[t+1]=w[1],e[t+2]=w[2],e[t+3]=w[3]}function oe(i,e){return w[0]=i[e],w[1]=i[e+1],w[2]=i[e+2],w[3]=i[e+3],kt[0]}var Nt=new Float64Array([-0]),p=new Uint8Array(Nt.buffer);function se(i,e,t){Nt[0]=i,e[t]=p[0],e[t+1]=p[1],e[t+2]=p[2],e[t+3]=p[3],e[t+4]=p[4],e[t+5]=p[5],e[t+6]=p[6],e[t+7]=p[7]}function ce(i,e){return p[0]=i[e],p[1]=i[e+1],p[2]=i[e+2],p[3]=i[e+3],p[4]=i[e+4],p[5]=i[e+5],p[6]=i[e+6],p[7]=i[e+7],Nt[0]}var $e=BigInt(Number.MAX_SAFE_INTEGER),_e=BigInt(Number.MIN_SAFE_INTEGER),g=class i{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,r=~this.hi>>>0;return t===0&&(r=r+1>>>0),-(t+r*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,r=~this.hi>>>0;return t===0&&(r=r+1>>>0),-(BigInt(t)+(BigInt(r)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return r===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(e===0n)return F;if(e<$e&&e>_e)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=~r|0n,n=~n|0n,++n>le&&(n=0n,++r>le&&(r=0n))),new i(Number(n),Number(r))}static fromNumber(e){if(e===0)return F;let t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new i(r,n)}static from(e){return typeof e=="number"?i.fromNumber(e):typeof e=="bigint"?i.fromBigInt(e):typeof e=="string"?i.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new i(e.low>>>0,e.high>>>0):F}},F=new g(0,0);F.toBigInt=function(){return 0n};F.zzEncode=F.zzDecode=function(){return this};F.length=function(){return 1};var le=4294967296n;function he(i){let e=0,t=0;for(let r=0;r<i.length;++r)t=i.charCodeAt(r),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(i.charCodeAt(r+1)&64512)===56320?(++r,e+=4):e+=3;return e}function ae(i,e,t){if(t-e<1)return"";let n,o=[],s=0,c;for(;e<t;)c=i[e++],c<128?o[s++]=c:c>191&&c<224?o[s++]=(c&31)<<6|i[e++]&63:c>239&&c<365?(c=((c&7)<<18|(i[e++]&63)<<12|(i[e++]&63)<<6|i[e++]&63)-65536,o[s++]=55296+(c>>10),o[s++]=56320+(c&1023)):o[s++]=(c&15)<<12|(i[e++]&63)<<6|i[e++]&63,s>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,o)),s=0);return n!=null?(s>0&&n.push(String.fromCharCode.apply(String,o.slice(0,s))),n.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function St(i,e,t){let r=t,n,o;for(let s=0;s<i.length;++s)n=i.charCodeAt(s),n<128?e[t++]=n:n<2048?(e[t++]=n>>6|192,e[t++]=n&63|128):(n&64512)===55296&&((o=i.charCodeAt(s+1))&64512)===56320?(n=65536+((n&1023)<<10)+(o&1023),++s,e[t++]=n>>18|240,e[t++]=n>>12&63|128,e[t++]=n>>6&63|128,e[t++]=n&63|128):(e[t++]=n>>12|224,e[t++]=n>>6&63|128,e[t++]=n&63|128);return t-r}function k(i,e){return RangeError(`index out of range: ${i.pos} + ${e??1} > ${i.len}`)}function gt(i,e){return(i[e-4]|i[e-3]<<8|i[e-2]<<16|i[e-1]<<24)>>>0}var At=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,k(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw k(this,4);return gt(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw k(this,4);return gt(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw k(this,4);let e=oe(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw k(this,4);let e=ce(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw k(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){let e=this.bytes();return ae(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw k(this,e);this.pos+=e}else do if(this.pos>=this.len)throw k(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new g(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw k(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw k(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw k(this,8);let e=gt(this.buf,this.pos+=4),t=gt(this.buf,this.pos+=4);return new g(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Dt(i){return new At(i instanceof Uint8Array?i:i.subarray())}function u(i,e){let t=Dt(i);return e.decode(t)}function bt(i){return globalThis.Buffer!=null?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):i}function P(i=0){return globalThis.Buffer?.allocUnsafe!=null?bt(globalThis.Buffer.allocUnsafe(i)):new Uint8Array(i)}var Lt={};b(Lt,{base10:()=>Qe});function Ke(i,e){if(i.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<i.length;n++){var o=i.charAt(n),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=n}var c=i.length,l=i.charAt(0),z=Math.log(c)/Math.log(256),E=Math.log(256)/Math.log(c);function R(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var m=0,O=0,y=0,N=h.length;y!==N&&h[y]===0;)y++,m++;for(var S=(N-y)*E+1>>>0,x=new Uint8Array(S);y!==N;){for(var A=h[y],L=0,I=S-1;(A!==0||L<O)&&I!==-1;I--,L++)A+=256*x[I]>>>0,x[I]=A%c>>>0,A=A/c>>>0;if(A!==0)throw new Error("Non-zero carry");O=L,y++}for(var U=S-O;U!==S&&x[U]===0;)U++;for(var mt=l.repeat(m);U<S;++U)mt+=i.charAt(x[U]);return mt}function pt(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var m=0;if(h[m]!==" "){for(var O=0,y=0;h[m]===l;)O++,m++;for(var N=(h.length-m)*z+1>>>0,S=new Uint8Array(N);h[m];){var x=t[h.charCodeAt(m)];if(x===255)return;for(var A=0,L=N-1;(x!==0||A<y)&&L!==-1;L--,A++)x+=c*S[L]>>>0,S[L]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");y=A,m++}if(h[m]!==" "){for(var I=N-y;I!==N&&S[I]===0;)I++;for(var U=new Uint8Array(O+(N-I)),mt=O;I!==N;)U[mt++]=S[I++];return U}}}function Fe(h){var m=pt(h);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:R,decodeUnsafe:pt,decode:Fe}}var Je=Ke,Xe=Je,fe=Xe;var bi=new Uint8Array(0);var de=(i,e)=>{if(i===e)return!0;if(i.byteLength!==e.byteLength)return!1;for(let t=0;t<i.byteLength;t++)if(i[t]!==e[t])return!1;return!0},T=i=>{if(i instanceof Uint8Array&&i.constructor.name==="Uint8Array")return i;if(i instanceof ArrayBuffer)return new Uint8Array(i);if(ArrayBuffer.isView(i))return new Uint8Array(i.buffer,i.byteOffset,i.byteLength);throw new Error("Unknown type, must be binary type")};var pe=i=>new TextEncoder().encode(i),me=i=>new TextDecoder().decode(i);var Ut=class{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Tt=class{constructor(e,t,r){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=r}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 be(this,e)}},Ct=class{constructor(e){this.decoders=e}or(e){return be(this,e)}decode(e){let t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},be=(i,e)=>new Ct({...i.decoders||{[i.prefix]:i},...e.decoders||{[e.prefix]:e}}),Bt=class{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Ut(e,t,r),this.decoder=new Tt(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},$=({name:i,prefix:e,encode:t,decode:r})=>new Bt(i,e,t,r),v=({prefix:i,name:e,alphabet:t})=>{let{encode:r,decode:n}=fe(t,e);return $({prefix:i,name:e,encode:r,decode:o=>T(n(o))})},We=(i,e,t,r)=>{let n={};for(let E=0;E<e.length;++E)n[e[E]]=E;let o=i.length;for(;i[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),c=0,l=0,z=0;for(let E=0;E<o;++E){let R=n[i[E]];if(R===void 0)throw new SyntaxError(`Non-${r} character`);l=l<<t|R,c+=t,c>=8&&(c-=8,s[z++]=255&l>>c)}if(c>=t||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return s},Ve=(i,e,t)=>{let r=e[e.length-1]==="=",n=(1<<t)-1,o="",s=0,c=0;for(let l=0;l<i.length;++l)for(c=c<<8|i[l],s+=8;s>t;)s-=t,o+=e[n&c>>s];if(s&&(o+=e[n&c<<t-s]),r)for(;o.length*t&7;)o+="=";return o},a=({name:i,prefix:e,bitsPerChar:t,alphabet:r})=>$({prefix:e,name:i,encode(n){return Ve(n,r,t)},decode(n){return We(n,r,t,i)}});var Qe=v({prefix:"9",name:"base10",alphabet:"0123456789"});var wt={};b(wt,{base16:()=>He,base16upper:()=>Ze});var He=a({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ze=a({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var vt={};b(vt,{base2:()=>Ye});var Ye=a({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ot={};b(Ot,{base256emoji:()=>nn});var Ee=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}"),qe=Ee.reduce((i,e,t)=>(i[t]=e,i),[]),je=Ee.reduce((i,e,t)=>(i[e.codePointAt(0)]=t,i),[]);function tn(i){return i.reduce((e,t)=>(e+=qe[t],e),"")}function en(i){let e=[];for(let t of i){let r=je[t.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(r)}return new Uint8Array(e)}var nn=$({prefix:"\u{1F680}",name:"base256emoji",encode:tn,decode:en});var Ft={};b(Ft,{base32:()=>_,base32hex:()=>cn,base32hexpad:()=>hn,base32hexpadupper:()=>an,base32hexupper:()=>ln,base32pad:()=>on,base32padupper:()=>sn,base32upper:()=>rn,base32z:()=>un});var _=a({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),rn=a({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),on=a({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),sn=a({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),cn=a({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ln=a({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),hn=a({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),an=a({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),un=a({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pt={};b(Pt,{base36:()=>fn,base36upper:()=>dn});var fn=v({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),dn=v({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Gt={};b(Gt,{base58btc:()=>D,base58flickr:()=>pn});var D=v({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pn=v({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Mt={};b(Mt,{base64:()=>mn,base64pad:()=>gn,base64url:()=>bn,base64urlpad:()=>En});var mn=a({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),gn=a({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),bn=a({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),En=a({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var zt={};b(zt,{base8:()=>xn});var xn=a({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Rt={};b(Rt,{identity:()=>yn});var yn=$({prefix:"\0",name:"identity",encode:i=>me(i),decode:i=>pe(i)});var wi=new TextEncoder,vi=new TextDecoder;var _t={};b(_t,{identity:()=>Kn});var Nn=Ie,xe=128,Sn=127,An=~Sn,Dn=Math.pow(2,31);function Ie(i,e,t){e=e||[],t=t||0;for(var r=t;i>=Dn;)e[t++]=i&255|xe,i/=128;for(;i&An;)e[t++]=i&255|xe,i>>>=7;return e[t]=i|0,Ie.bytes=t-r+1,e}var Un=$t,Tn=128,ye=127;function $t(i,r){var t=0,r=r||0,n=0,o=r,s,c=i.length;do{if(o>=c)throw $t.bytes=0,new RangeError("Could not decode varint");s=i[o++],t+=n<28?(s&ye)<<n:(s&ye)*Math.pow(2,n),n+=7}while(s>=Tn);return $t.bytes=o-r,t}var Cn=Math.pow(2,7),Bn=Math.pow(2,14),Ln=Math.pow(2,21),wn=Math.pow(2,28),vn=Math.pow(2,35),On=Math.pow(2,42),Fn=Math.pow(2,49),Pn=Math.pow(2,56),Gn=Math.pow(2,63),Mn=function(i){return i<Cn?1:i<Bn?2:i<Ln?3:i<wn?4:i<vn?5:i<On?6:i<Fn?7:i<Pn?8:i<Gn?9:10},zn={encode:Nn,decode:Un,encodingLength:Mn},Rn=zn,V=Rn;var Q=(i,e=0)=>[V.decode(i,e),V.decode.bytes],K=(i,e,t=0)=>(V.encode(i,e,t),e),J=i=>V.encodingLength(i);var G=(i,e)=>{let t=e.byteLength,r=J(i),n=r+J(t),o=new Uint8Array(n+t);return K(i,o,0),K(t,o,r),o.set(e,n),new X(i,t,e,o)},ke=i=>{let e=T(i),[t,r]=Q(e),[n,o]=Q(e.subarray(r)),s=e.subarray(r+o);if(s.byteLength!==n)throw new Error("Incorrect length");return new X(t,n,s,e)},Ne=(i,e)=>{if(i===e)return!0;{let t=e;return i.code===t.code&&i.size===t.size&&t.bytes instanceof Uint8Array&&de(i.bytes,t.bytes)}},X=class{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}};var Se=0,$n="identity",Ae=T,_n=i=>G(Se,Ae(i)),Kn={code:Se,name:$n,encode:Ae,digest:_n};var Xt={};b(Xt,{sha256:()=>Jn,sha512:()=>Xn});var Jt=({name:i,code:e,encode:t})=>new Kt(i,e,t),Kt=class{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?G(this.code,t):t.then(r=>G(this.code,r))}else throw Error("Unknown type, must be binary type")}};var Ue=i=>async e=>new Uint8Array(await crypto.subtle.digest(i,e)),Jn=Jt({name:"sha2-256",code:18,encode:Ue("SHA-256")}),Xn=Jt({name:"sha2-512",code:19,encode:Ue("SHA-512")});var Te=(i,e)=>{let{bytes:t,version:r}=i;switch(r){case 0:return Vn(t,Wt(i),e||D.encoder);default:return Qn(t,Wt(i),e||_.encoder)}};var Ce=new WeakMap,Wt=i=>{let e=Ce.get(i);if(e==null){let t=new Map;return Ce.set(i,t),t}return e},xt=class i{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Z)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Hn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return i.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,r=G(e,t);return i.createV1(this.code,r)}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 i.equals(this,e)}static equals(e,t){let r=t;return r&&e.code===r.code&&e.version===r.version&&Ne(e.multihash,r.multihash)}toString(e){return Te(this,e)}toJSON(){return{"/":Te(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof i)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:r,code:n,multihash:o,bytes:s}=t;return new i(r,n,o,s||Be(r,n,o.bytes))}else if(t[Zn]===!0){let{version:r,multihash:n,code:o}=t,s=ke(n);return i.create(r,o,s)}else return null}static create(e,t,r){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Z)throw new Error(`Version 0 CID must use dag-pb (code: ${Z}) block encoding`);return new i(e,t,r,r.bytes)}case 1:{let n=Be(e,t,r.bytes);return new i(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return i.create(0,Z,e)}static createV1(e,t){return i.create(1,e,t)}static decode(e){let[t,r]=i.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=i.inspectBytes(e),r=t.size-t.multihashSize,n=T(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=n.subarray(t.multihashSize-t.digestSize),s=new X(t.multihashCode,t.digestSize,o,n);return[t.version===0?i.createV0(s):i.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,r=()=>{let[R,pt]=Q(e.subarray(t));return t+=pt,R},n=r(),o=Z;if(n===18?(n=0,t=0):o=r(),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let s=t,c=r(),l=r(),z=t+l,E=z-s;return{version:n,codec:o,multihashCode:c,digestSize:l,multihashSize:E,size:z}}static parse(e,t){let[r,n]=Wn(e,t),o=i.decode(n);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Wt(o).set(r,e),o}},Wn=(i,e)=>{switch(i[0]){case"Q":{let t=e||D;return[D.prefix,t.decode(`${D.prefix}${i}`)]}case D.prefix:{let t=e||D;return[D.prefix,t.decode(i)]}case _.prefix:{let t=e||_;return[_.prefix,t.decode(i)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[i[0],e.decode(i)]}}},Vn=(i,e,t)=>{let{prefix:r}=t;if(r!==D.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(r);if(n==null){let o=t.encode(i).slice(1);return e.set(r,o),o}else return n},Qn=(i,e,t)=>{let{prefix:r}=t,n=e.get(r);if(n==null){let o=t.encode(i);return e.set(r,o),o}else return n},Z=112,Hn=18,Be=(i,e,t)=>{let r=J(i),n=r+J(e),o=new Uint8Array(n+t.byteLength);return K(i,o,0),K(e,o,r),o.set(t,n),o},Zn=Symbol.for("@ipld/js-cid/CID");var Vt={...Rt,...vt,...zt,...Lt,...wt,...Ft,...Pt,...Gt,...Mt,...Ot},Hi={...Xt,..._t};function we(i,e,t,r){return{name:i,prefix:e,encoder:{name:i,prefix:e,encode:t},decoder:{decode:r}}}var Le=we("utf8","u",i=>"u"+new TextDecoder("utf8").decode(i),i=>new TextEncoder().encode(i.substring(1))),Qt=we("ascii","a",i=>{let e="a";for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]);return e},i=>{i=i.substring(1);let e=P(i.length);for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t);return e}),Yn={utf8:Le,"utf-8":Le,hex:Vt.base16,latin1:Qt,ascii:Qt,binary:Qt,...Vt},ve=Yn;function Oe(i,e="utf8"){let t=ve[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?bt(globalThis.Buffer.from(i,"utf-8")):t.decoder.decode(`${t.prefix}${i}`)}function Ht(i){let e=i??8192,t=e>>>1,r,n=e;return function(s){if(s<1||s>t)return P(s);n+s>e&&(r=P(e),n=0);let c=r.subarray(n,n+=s);return n&7&&(n=(n|7)+1),c}}var M=class{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}};function Zt(){}var qt=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},qn=Ht();function jn(i){return globalThis.Buffer!=null?P(i):qn(i)}var j=class{len;head;tail;states;constructor(){this.len=0,this.head=new M(Zt,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new M(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new jt((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Y,10,g.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=g.fromBigInt(e);return this._push(Y,t.length(),t)}uint64Number(e){let t=g.fromNumber(e);return this._push(Y,t.length(),t)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=g.fromBigInt(e).zzEncode();return this._push(Y,t.length(),t)}sint64Number(e){let t=g.fromNumber(e).zzEncode();return this._push(Y,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Yt,1,e?1:0)}fixed32(e){return this._push(q,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=g.fromBigInt(e);return this._push(q,4,t.lo)._push(q,4,t.hi)}fixed64Number(e){let t=g.fromNumber(e);return this._push(q,4,t.lo)._push(q,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(re,4,e)}double(e){return this._push(se,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Yt,1,0):this.uint32(t)._push(ei,t,e)}string(e){let t=he(e);return t!==0?this.uint32(t)._push(St,t,e):this._push(Yt,1,0)}fork(){return this.states=new qt(this),this.head=this.tail=new M(Zt,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new M(Zt,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r!==0&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next,t=jn(this.len),r=0;for(;e!=null;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t}};function Yt(i,e,t){e[t]=i&255}function ti(i,e,t){for(;i>127;)e[t++]=i&127|128,i>>>=7;e[t]=i}var jt=class extends M{next;constructor(e,t){super(ti,e,t),this.next=void 0}};function Y(i,e,t){for(;i.hi!==0;)e[t++]=i.lo&127|128,i.lo=(i.lo>>>7|i.hi<<25)>>>0,i.hi>>>=7;for(;i.lo>127;)e[t++]=i.lo&127|128,i.lo=i.lo>>>7;e[t++]=i.lo}function q(i,e,t){e[t]=i&255,e[t+1]=i>>>8&255,e[t+2]=i>>>16&255,e[t+3]=i>>>24}function ei(i,e,t){e.set(i,t)}globalThis.Buffer!=null&&(j.prototype.bytes=function(i){let e=i.length>>>0;return this.uint32(e),e>0&&this._push(ni,e,i),this},j.prototype.string=function(i){let e=globalThis.Buffer.byteLength(i);return this.uint32(e),e>0&&this._push(ii,e,i),this});function ni(i,e,t){e.set(i,t)}function ii(i,e,t){i.length<40?St(i,e,t):e.utf8Write!=null?e.utf8Write(i,t):e.set(Oe(i),t)}function te(){return new j}function f(i,e){let t=te();return e.encode(i,t,{lengthDelimited:!1}),t.finish()}var W;(function(i){i[i.VARINT=0]="VARINT",i[i.BIT64=1]="BIT64",i[i.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",i[i.START_GROUP=3]="START_GROUP",i[i.END_GROUP=4]="END_GROUP",i[i.BIT32=5]="BIT32"})(W||(W={}));function yt(i,e,t,r){return{name:i,type:e,encode:t,decode:r}}function C(i){function e(n){if(i[n.toString()]==null)throw new Error("Invalid enum value");return i[n]}let t=function(o,s){let c=e(o);s.int32(c)},r=function(o){let s=o.int32();return e(s)};return yt("enum",W.VARINT,t,r)}function d(i,e){return yt("message",W.LENGTH_DELIMITED,i,e)}var ee;(function(i){let e;(function(n){n.IDENTIFY="IDENTIFY",n.CONNECT="CONNECT",n.STREAM_OPEN="STREAM_OPEN",n.STREAM_HANDLER="STREAM_HANDLER",n.DHT="DHT",n.LIST_PEERS="LIST_PEERS",n.CONNMANAGER="CONNMANAGER",n.DISCONNECT="DISCONNECT",n.PUBSUB="PUBSUB",n.PEERSTORE="PEERSTORE"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.IDENTIFY=0]="IDENTIFY",n[n.CONNECT=1]="CONNECT",n[n.STREAM_OPEN=2]="STREAM_OPEN",n[n.STREAM_HANDLER=3]="STREAM_HANDLER",n[n.DHT=4]="DHT",n[n.LIST_PEERS=5]="LIST_PEERS",n[n.CONNMANAGER=6]="CONNMANAGER",n[n.DISCONNECT=7]="DISCONNECT",n[n.PUBSUB=8]="PUBSUB",n[n.PEERSTORE=9]="PEERSTORE"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=d((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.connect!=null&&(o.uint32(18),et.codec().encode(n.connect,o)),n.streamOpen!=null&&(o.uint32(26),nt.codec().encode(n.streamOpen,o)),n.streamHandler!=null&&(o.uint32(34),it.codec().encode(n.streamHandler,o)),n.dht!=null&&(o.uint32(42),st.codec().encode(n.dht,o)),n.connManager!=null&&(o.uint32(50),lt.codec().encode(n.connManager,o)),n.disconnect!=null&&(o.uint32(58),ht.codec().encode(n.disconnect,o)),n.pubsub!=null&&(o.uint32(66),at.codec().encode(n.pubsub,o)),n.peerStore!=null&&(o.uint32(74),ft.codec().encode(n.peerStore,o)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.connect=et.codec().decode(n,n.uint32());break;case 3:s.streamOpen=nt.codec().decode(n,n.uint32());break;case 4:s.streamHandler=it.codec().decode(n,n.uint32());break;case 5:s.dht=st.codec().decode(n,n.uint32());break;case 6:s.connManager=lt.codec().decode(n,n.uint32());break;case 7:s.disconnect=ht.codec().decode(n,n.uint32());break;case 8:s.pubsub=at.codec().decode(n,n.uint32());break;case 9:s.peerStore=ft.codec().decode(n,n.uint32());break;default:n.skipType(l&7);break}}return s})),r),i.encode=n=>f(n,i.codec()),i.decode=n=>u(n,i.codec())})(ee||(ee={}));var ne;(function(i){let e;(function(n){n.OK="OK",n.ERROR="ERROR"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.OK=0]="OK",n[n.ERROR=1]="ERROR"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=d((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.error!=null&&(o.uint32(18),rt.codec().encode(n.error,o)),n.streamInfo!=null&&(o.uint32(26),ot.codec().encode(n.streamInfo,o)),n.identify!=null&&(o.uint32(34),tt.codec().encode(n.identify,o)),n.dht!=null&&(o.uint32(42),ct.codec().encode(n.dht,o)),n.peers!=null)for(let c of n.peers)o.uint32(50),B.codec().encode(c,o);n.pubsub!=null&&(o.uint32(58),ut.codec().encode(n.pubsub,o)),n.peerStore!=null&&(o.uint32(66),dt.codec().encode(n.peerStore,o)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={peers:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.error=rt.codec().decode(n,n.uint32());break;case 3:s.streamInfo=ot.codec().decode(n,n.uint32());break;case 4:s.identify=tt.codec().decode(n,n.uint32());break;case 5:s.dht=ct.codec().decode(n,n.uint32());break;case 6:s.peers.push(B.codec().decode(n,n.uint32()));break;case 7:s.pubsub=ut.codec().decode(n,n.uint32());break;case 8:s.peerStore=dt.codec().decode(n,n.uint32());break;default:n.skipType(l&7);break}}return s})),r),i.encode=n=>f(n,i.codec()),i.decode=n=>u(n,i.codec())})(ne||(ne={}));var tt;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.id!=null&&t.id.byteLength>0&&(r.uint32(10),r.bytes(t.id)),t.addrs!=null)for(let o of t.addrs)r.uint32(18),r.bytes(o);n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={id:new Uint8Array(0),addrs:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.id=t.bytes();break;case 2:n.addrs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(tt||(tt={}));var et;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.peer!=null&&t.peer.byteLength>0&&(r.uint32(10),r.bytes(t.peer)),t.addrs!=null)for(let o of t.addrs)r.uint32(18),r.bytes(o);t.timeout!=null&&(r.uint32(24),r.int64(t.timeout)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={peer:new Uint8Array(0),addrs:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.addrs.push(t.bytes());break;case 3:n.timeout=t.int64();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(et||(et={}));var nt;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.peer!=null&&t.peer.byteLength>0&&(r.uint32(10),r.bytes(t.peer)),t.proto!=null)for(let o of t.proto)r.uint32(18),r.string(o);t.timeout!=null&&(r.uint32(24),r.int64(t.timeout)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={peer:new Uint8Array(0),proto:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.proto.push(t.string());break;case 3:n.timeout=t.int64();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(nt||(nt={}));var it;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.addr!=null&&t.addr.byteLength>0&&(r.uint32(10),r.bytes(t.addr)),t.proto!=null)for(let o of t.proto)r.uint32(18),r.string(o);n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={addr:new Uint8Array(0),proto:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.addr=t.bytes();break;case 2:n.proto.push(t.string());break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(it||(it={}));var rt;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{n.lengthDelimited!==!1&&r.fork(),t.msg!=null&&t.msg!==""&&(r.uint32(10),r.string(t.msg)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={msg:""},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.msg=t.string();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(rt||(rt={}));var ot;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{n.lengthDelimited!==!1&&r.fork(),t.peer!=null&&t.peer.byteLength>0&&(r.uint32(10),r.bytes(t.peer)),t.addr!=null&&t.addr.byteLength>0&&(r.uint32(18),r.bytes(t.addr)),t.proto!=null&&t.proto!==""&&(r.uint32(26),r.string(t.proto)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.addr=t.bytes();break;case 3:n.proto=t.string();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(ot||(ot={}));var st;(function(i){let e;(function(n){n.FIND_PEER="FIND_PEER",n.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",n.FIND_PROVIDERS="FIND_PROVIDERS",n.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",n.GET_PUBLIC_KEY="GET_PUBLIC_KEY",n.GET_VALUE="GET_VALUE",n.SEARCH_VALUE="SEARCH_VALUE",n.PUT_VALUE="PUT_VALUE",n.PROVIDE="PROVIDE"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.FIND_PEER=0]="FIND_PEER",n[n.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",n[n.FIND_PROVIDERS=2]="FIND_PROVIDERS",n[n.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",n[n.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",n[n.GET_VALUE=5]="GET_VALUE",n[n.SEARCH_VALUE=6]="SEARCH_VALUE",n[n.PUT_VALUE=7]="PUT_VALUE",n[n.PROVIDE=8]="PROVIDE"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=d((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),o.bytes(n.peer)),n.cid!=null&&(o.uint32(26),o.bytes(n.cid)),n.key!=null&&(o.uint32(34),o.bytes(n.key)),n.value!=null&&(o.uint32(42),o.bytes(n.value)),n.count!=null&&(o.uint32(48),o.int32(n.count)),n.timeout!=null&&(o.uint32(56),o.int64(n.timeout)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.cid=n.bytes();break;case 4:s.key=n.bytes();break;case 5:s.value=n.bytes();break;case 6:s.count=n.int32();break;case 7:s.timeout=n.int64();break;default:n.skipType(l&7);break}}return s})),r),i.encode=n=>f(n,i.codec()),i.decode=n=>u(n,i.codec())})(st||(st={}));var ct;(function(i){let e;(function(n){n.BEGIN="BEGIN",n.VALUE="VALUE",n.END="END"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.BEGIN=0]="BEGIN",n[n.VALUE=1]="VALUE",n[n.END=2]="END"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=d((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),B.codec().encode(n.peer,o)),n.value!=null&&(o.uint32(26),o.bytes(n.value)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.peer=B.codec().decode(n,n.uint32());break;case 3:s.value=n.bytes();break;default:n.skipType(l&7);break}}return s})),r),i.encode=n=>f(n,i.codec()),i.decode=n=>u(n,i.codec())})(ct||(ct={}));var B;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.id!=null&&t.id.byteLength>0&&(r.uint32(10),r.bytes(t.id)),t.addrs!=null)for(let o of t.addrs)r.uint32(18),r.bytes(o);n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={id:new Uint8Array(0),addrs:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.id=t.bytes();break;case 2:n.addrs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(B||(B={}));var lt;(function(i){let e;(function(n){n.TAG_PEER="TAG_PEER",n.UNTAG_PEER="UNTAG_PEER",n.TRIM="TRIM"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.TAG_PEER=0]="TAG_PEER",n[n.UNTAG_PEER=1]="UNTAG_PEER",n[n.TRIM=2]="TRIM"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=d((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),o.bytes(n.peer)),n.tag!=null&&(o.uint32(26),o.string(n.tag)),n.weight!=null&&(o.uint32(32),o.int64(n.weight)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.tag=n.string();break;case 4:s.weight=n.int64();break;default:n.skipType(l&7);break}}return s})),r),i.encode=n=>f(n,i.codec()),i.decode=n=>u(n,i.codec())})(lt||(lt={}));var ht;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{n.lengthDelimited!==!1&&r.fork(),t.peer!=null&&t.peer.byteLength>0&&(r.uint32(10),r.bytes(t.peer)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={peer:new Uint8Array(0)},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(ht||(ht={}));var at;(function(i){let e;(function(n){n.GET_TOPICS="GET_TOPICS",n.LIST_PEERS="LIST_PEERS",n.PUBLISH="PUBLISH",n.SUBSCRIBE="SUBSCRIBE"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.GET_TOPICS=0]="GET_TOPICS",n[n.LIST_PEERS=1]="LIST_PEERS",n[n.PUBLISH=2]="PUBLISH",n[n.SUBSCRIBE=3]="SUBSCRIBE"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=d((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.topic!=null&&(o.uint32(18),o.string(n.topic)),n.data!=null&&(o.uint32(26),o.bytes(n.data)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.topic=n.string();break;case 3:s.data=n.bytes();break;default:n.skipType(l&7);break}}return s})),r),i.encode=n=>f(n,i.codec()),i.decode=n=>u(n,i.codec())})(at||(at={}));var ie;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.from!=null&&(r.uint32(10),r.bytes(t.from)),t.data!=null&&(r.uint32(18),r.bytes(t.data)),t.seqno!=null&&(r.uint32(26),r.bytes(t.seqno)),t.topicIDs!=null)for(let o of t.topicIDs)r.uint32(34),r.string(o);t.signature!=null&&(r.uint32(42),r.bytes(t.signature)),t.key!=null&&(r.uint32(50),r.bytes(t.key)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={topicIDs:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.from=t.bytes();break;case 2:n.data=t.bytes();break;case 3:n.seqno=t.bytes();break;case 4:n.topicIDs.push(t.string());break;case 5:n.signature=t.bytes();break;case 6:n.key=t.bytes();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(ie||(ie={}));var ut;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.topics!=null)for(let o of t.topics)r.uint32(10),r.string(o);if(t.peerIDs!=null)for(let o of t.peerIDs)r.uint32(18),r.bytes(o);n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={topics:[],peerIDs:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.topics.push(t.string());break;case 2:n.peerIDs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(ut||(ut={}));var ft;(function(i){let e;(function(n){n.UNSPECIFIED="UNSPECIFIED",n.GET_PROTOCOLS="GET_PROTOCOLS",n.GET_PEER_INFO="GET_PEER_INFO"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.GET_PROTOCOLS=1]="GET_PROTOCOLS",n[n.GET_PEER_INFO=2]="GET_PEER_INFO"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=d((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.id!=null&&(o.uint32(18),o.bytes(n.id)),n.protos!=null)for(let c of n.protos)o.uint32(26),o.string(c);s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={protos:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.id=n.bytes();break;case 3:s.protos.push(n.string());break;default:n.skipType(l&7);break}}return s})),r),i.encode=n=>f(n,i.codec()),i.decode=n=>u(n,i.codec())})(ft||(ft={}));var dt;(function(i){let e;i.codec=()=>(e==null&&(e=d((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.peer!=null&&(r.uint32(10),B.codec().encode(t.peer,r)),t.protos!=null)for(let o of t.protos)r.uint32(18),r.string(o);n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={protos:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=B.codec().decode(t,t.uint32());break;case 2:n.protos.push(t.string());break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>f(t,i.codec()),i.decode=t=>u(t,i.codec())})(dt||(dt={}));return Re(ri);})();
|
|
2
|
+
"use strict";var Libp2PDaemonProtocol=(()=>{var At=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var x=(r,e)=>{for(var t in e)At(r,t,{get:e[t],enumerable:!0})},Ve=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of We(e))!Qe.call(r,n)&&n!==t&&At(r,n,{get:()=>e[n],enumerable:!(i=Je(e,n))||i.enumerable});return r};var He=r=>Ve(At({},"__esModule",{value:!0}),r);var gr={};x(gr,{ConnManagerRequest:()=>at,ConnectRequest:()=>rt,DHTRequest:()=>lt,DHTResponse:()=>ht,DisconnectRequest:()=>ut,ErrorResponse:()=>st,IdentifyResponse:()=>nt,PSMessage:()=>se,PSRequest:()=>dt,PSResponse:()=>ft,PeerInfo:()=>C,PeerstoreRequest:()=>pt,PeerstoreResponse:()=>mt,Request:()=>ie,Response:()=>oe,StreamHandlerRequest:()=>ot,StreamInfo:()=>ct,StreamOpenRequest:()=>it});var Ze=Math.pow(2,7),Ye=Math.pow(2,14),qe=Math.pow(2,21),ce=Math.pow(2,28),le=Math.pow(2,35),he=Math.pow(2,42),ae=Math.pow(2,49),m=128,L=127;function H(r){if(r<Ze)return 1;if(r<Ye)return 2;if(r<qe)return 3;if(r<ce)return 4;if(r<le)return 5;if(r<he)return 6;if(r<ae)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ue(r,e,t=0){switch(H(r)){case 8:e[t++]=r&255|m,r/=128;case 7:e[t++]=r&255|m,r/=128;case 6:e[t++]=r&255|m,r/=128;case 5:e[t++]=r&255|m,r/=128;case 4:e[t++]=r&255|m,r>>>=7;case 3:e[t++]=r&255|m,r>>>=7;case 2:e[t++]=r&255|m,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function de(r,e){let t=r[e],i=0;if(i+=t&L,t<m||(t=r[e+1],i+=(t&L)<<7,t<m)||(t=r[e+2],i+=(t&L)<<14,t<m)||(t=r[e+3],i+=(t&L)<<21,t<m)||(t=r[e+4],i+=(t&L)*ce,t<m)||(t=r[e+5],i+=(t&L)*le,t<m)||(t=r[e+6],i+=(t&L)*he,t<m)||(t=r[e+7],i+=(t&L)*ae,t<m))return i;throw new RangeError("Could not decode varint")}var St=new Float32Array([-0]),O=new Uint8Array(St.buffer);function fe(r,e,t){St[0]=r,e[t]=O[0],e[t+1]=O[1],e[t+2]=O[2],e[t+3]=O[3]}function pe(r,e){return O[0]=r[e],O[1]=r[e+1],O[2]=r[e+2],O[3]=r[e+3],St[0]}var Dt=new Float64Array([-0]),p=new Uint8Array(Dt.buffer);function me(r,e,t){Dt[0]=r,e[t]=p[0],e[t+1]=p[1],e[t+2]=p[2],e[t+3]=p[3],e[t+4]=p[4],e[t+5]=p[5],e[t+6]=p[6],e[t+7]=p[7]}function ge(r,e){return p[0]=r[e],p[1]=r[e+1],p[2]=r[e+2],p[3]=r[e+3],p[4]=r[e+4],p[5]=r[e+5],p[6]=r[e+6],p[7]=r[e+7],Dt[0]}var je=BigInt(Number.MAX_SAFE_INTEGER),tn=BigInt(Number.MIN_SAFE_INTEGER),E=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,i=~this.hi>>>0;return t===0&&(i=i+1>>>0),-(t+i*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,i=~this.hi>>>0;return t===0&&(i=i+1>>>0),-(BigInt(t)+(BigInt(i)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return i===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:i<128?9:10}static fromBigInt(e){if(e===0n)return G;if(e<je&&e>tn)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let i=e>>32n,n=e-(i<<32n);return t&&(i=~i|0n,n=~n|0n,++n>xe&&(n=0n,++i>xe&&(i=0n))),new r(Number(n),Number(i))}static fromNumber(e){if(e===0)return G;let t=e<0;t&&(e=-e);let i=e>>>0,n=(e-i)/4294967296>>>0;return t&&(n=~n>>>0,i=~i>>>0,++i>4294967295&&(i=0,++n>4294967295&&(n=0))),new r(i,n)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):G}},G=new E(0,0);G.toBigInt=function(){return 0n};G.zzEncode=G.zzDecode=function(){return this};G.length=function(){return 1};var xe=4294967296n;function Ee(r){let e=0,t=0;for(let i=0;i<r.length;++i)t=r.charCodeAt(i),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(i+1)&64512)===56320?(++i,e+=4):e+=3;return e}function be(r,e,t){if(t-e<1)return"";let n,o=[],s=0,c;for(;e<t;)c=r[e++],c<128?o[s++]=c:c>191&&c<224?o[s++]=(c&31)<<6|r[e++]&63:c>239&&c<365?(c=((c&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,o[s++]=55296+(c>>10),o[s++]=56320+(c&1023)):o[s++]=(c&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,o)),s=0);return n!=null?(s>0&&n.push(String.fromCharCode.apply(String,o.slice(0,s))),n.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function Ut(r,e,t){let i=t,n,o;for(let s=0;s<r.length;++s)n=r.charCodeAt(s),n<128?e[t++]=n:n<2048?(e[t++]=n>>6|192,e[t++]=n&63|128):(n&64512)===55296&&((o=r.charCodeAt(s+1))&64512)===56320?(n=65536+((n&1023)<<10)+(o&1023),++s,e[t++]=n>>18|240,e[t++]=n>>12&63|128,e[t++]=n>>6&63|128,e[t++]=n&63|128):(e[t++]=n>>12|224,e[t++]=n>>6&63|128,e[t++]=n&63|128);return t-i}function I(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Et(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Tt=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,I(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw I(this,4);return Et(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw I(this,4);return Et(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw I(this,4);let e=pe(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw I(this,4);let e=ge(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw I(this,e);return this.pos+=e,t===i?new Uint8Array(0):this.buf.subarray(t,i)}string(){let e=this.bytes();return be(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw I(this,e);this.pos+=e}else do if(this.pos>=this.len)throw I(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new E(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw I(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw I(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw I(this,8);let e=Et(this.buf,this.pos+=4),t=Et(this.buf,this.pos+=4);return new E(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=de(this.buf,this.pos);return this.pos+=H(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function wt(r){return new Tt(r instanceof Uint8Array?r:r.subarray())}function u(r,e,t){let i=wt(r);return e.decode(i,void 0,t)}function bt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function v(r=0){return globalThis.Buffer?.allocUnsafe!=null?bt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}var Ot={};x(Ot,{base10:()=>cn});var Mr=new Uint8Array(0);function Ne(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function w(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 ke(r){return new TextEncoder().encode(r)}function Ie(r){return new TextDecoder().decode(r)}function en(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var o=r.charAt(n),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=n}var c=r.length,l=r.charAt(0),_=Math.log(c)/Math.log(256),b=Math.log(256)/Math.log(c);function $(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var g=0,M=0,N=0,A=h.length;N!==A&&h[N]===0;)N++,g++;for(var S=(A-N)*b+1>>>0,y=new Uint8Array(S);N!==A;){for(var D=h[N],F=0,k=S-1;(D!==0||F<M)&&k!==-1;k--,F++)D+=256*y[k]>>>0,y[k]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");M=F,N++}for(var T=S-M;T!==S&&y[T]===0;)T++;for(var xt=l.repeat(g);T<S;++T)xt+=r.charAt(y[T]);return xt}function gt(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var g=0;if(h[g]!==" "){for(var M=0,N=0;h[g]===l;)M++,g++;for(var A=(h.length-g)*_+1>>>0,S=new Uint8Array(A);h[g];){var y=t[h.charCodeAt(g)];if(y===255)return;for(var D=0,F=A-1;(y!==0||D<N)&&F!==-1;F--,D++)y+=c*S[F]>>>0,S[F]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");N=D,g++}if(h[g]!==" "){for(var k=A-N;k!==A&&S[k]===0;)k++;for(var T=new Uint8Array(M+(A-k)),xt=M;k!==A;)T[xt++]=S[k++];return T}}}function Xe(h){var g=gt(h);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:$,decodeUnsafe:gt,decode:Xe}}var nn=en,rn=nn,Se=rn;var Bt=class{name;prefix;baseEncode;constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ct=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,i){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=i}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 De(this,e)}},Ft=class{decoders;constructor(e){this.decoders=e}or(e){return De(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i!=null)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function De(r,e){return new Ft({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Lt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new Bt(e,t,i),this.decoder=new Ct(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function K({name:r,prefix:e,encode:t,decode:i}){return new Lt(r,e,t,i)}function P({name:r,prefix:e,alphabet:t}){let{encode:i,decode:n}=Se(t,r);return K({prefix:e,name:r,encode:i,decode:o=>w(n(o))})}function on(r,e,t,i){let n={};for(let b=0;b<e.length;++b)n[e[b]]=b;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),c=0,l=0,_=0;for(let b=0;b<o;++b){let $=n[r[b]];if($===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<t|$,c+=t,c>=8&&(c-=8,s[_++]=255&l>>c)}if(c>=t||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return s}function sn(r,e,t){let i=e[e.length-1]==="=",n=(1<<t)-1,o="",s=0,c=0;for(let l=0;l<r.length;++l)for(c=c<<8|r[l],s+=8;s>t;)s-=t,o+=e[n&c>>s];if(s!==0&&(o+=e[n&c<<t-s]),i)for(;o.length*t&7;)o+="=";return o}function a({name:r,prefix:e,bitsPerChar:t,alphabet:i}){return K({prefix:e,name:r,encode(n){return sn(n,i,t)},decode(n){return on(n,i,t,r)}})}var cn=P({prefix:"9",name:"base10",alphabet:"0123456789"});var Pt={};x(Pt,{base16:()=>ln,base16upper:()=>hn});var ln=a({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hn=a({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mt={};x(Mt,{base2:()=>an});var an=a({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Gt={};x(Gt,{base256emoji:()=>mn});var Ue=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}"),un=Ue.reduce((r,e,t)=>(r[t]=e,r),[]),dn=Ue.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function fn(r){return r.reduce((e,t)=>(e+=un[t],e),"")}function pn(r){let e=[];for(let t of r){let i=dn[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var mn=K({prefix:"\u{1F680}",name:"base256emoji",encode:fn,decode:pn});var vt={};x(vt,{base32:()=>X,base32hex:()=>bn,base32hexpad:()=>Nn,base32hexpadupper:()=>kn,base32hexupper:()=>yn,base32pad:()=>xn,base32padupper:()=>En,base32upper:()=>gn,base32z:()=>In});var X=a({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gn=a({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xn=a({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),En=a({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bn=a({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yn=a({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Nn=a({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),kn=a({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),In=a({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Rt={};x(Rt,{base36:()=>An,base36upper:()=>Sn});var An=P({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sn=P({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var zt={};x(zt,{base58btc:()=>U,base58flickr:()=>Dn});var U=P({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Dn=P({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var _t={};x(_t,{base64:()=>Un,base64pad:()=>Tn,base64url:()=>wn,base64urlpad:()=>Bn});var Un=a({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Tn=a({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),wn=a({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Bn=a({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $t={};x($t,{base8:()=>Cn});var Cn=a({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Kt={};x(Kt,{identity:()=>Fn});var Fn=K({prefix:"\0",name:"identity",encode:r=>Ie(r),decode:r=>ke(r)});var qr=new TextEncoder,jr=new TextDecoder;var Jt={};x(Jt,{identity:()=>er});var Pn=Be,Te=128,Mn=127,Gn=~Mn,vn=Math.pow(2,31);function Be(r,e,t){e=e||[],t=t||0;for(var i=t;r>=vn;)e[t++]=r&255|Te,r/=128;for(;r&Gn;)e[t++]=r&255|Te,r>>>=7;return e[t]=r|0,Be.bytes=t-i+1,e}var Rn=Xt,zn=128,we=127;function Xt(r,i){var t=0,i=i||0,n=0,o=i,s,c=r.length;do{if(o>=c)throw Xt.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=n<28?(s&we)<<n:(s&we)*Math.pow(2,n),n+=7}while(s>=zn);return Xt.bytes=o-i,t}var _n=Math.pow(2,7),$n=Math.pow(2,14),Kn=Math.pow(2,21),Xn=Math.pow(2,28),Jn=Math.pow(2,35),Wn=Math.pow(2,42),Qn=Math.pow(2,49),Vn=Math.pow(2,56),Hn=Math.pow(2,63),Zn=function(r){return r<_n?1:r<$n?2:r<Kn?3:r<Xn?4:r<Jn?5:r<Wn?6:r<Qn?7:r<Vn?8:r<Hn?9:10},Yn={encode:Pn,decode:Rn,encodingLength:Zn},qn=Yn,Z=qn;function Y(r,e=0){return[Z.decode(r,e),Z.decode.bytes]}function J(r,e,t=0){return Z.encode(r,e,t),e}function W(r){return Z.encodingLength(r)}function R(r,e){let t=e.byteLength,i=W(r),n=i+W(t),o=new Uint8Array(n+t);return J(r,o,0),J(t,o,i),o.set(e,n),new Q(r,t,e,o)}function Ce(r){let e=w(r),[t,i]=Y(e),[n,o]=Y(e.subarray(i)),s=e.subarray(i+o);if(s.byteLength!==n)throw new Error("Incorrect length");return new Q(t,n,s,e)}function Fe(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ne(r.bytes,t.bytes)}}var Q=class{code;size;digest;bytes;constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var Le=0,jn="identity",Oe=w;function tr(r){return R(Le,Oe(r))}var er={code:Le,name:jn,encode:Oe,digest:tr};var Vt={};x(Vt,{sha256:()=>nr,sha512:()=>rr});function Qt({name:r,code:e,encode:t}){return new Wt(r,e,t)}var Wt=class{name;code;encode;constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?R(this.code,t):t.then(i=>R(this.code,i))}else throw Error("Unknown type, must be binary type")}};function Me(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var nr=Qt({name:"sha2-256",code:18,encode:Me("SHA-256")}),rr=Qt({name:"sha2-512",code:19,encode:Me("SHA-512")});function Ge(r,e){let{bytes:t,version:i}=r;switch(i){case 0:return or(t,Ht(r),e??U.encoder);default:return sr(t,Ht(r),e??X.encoder)}}var ve=new WeakMap;function Ht(r){let e=ve.get(r);if(e==null){let t=new Map;return ve.set(r,t),t}return e}var Nt=class r{code;version;multihash;bytes;"/";constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this["/"]=n}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==j)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==cr)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,i=R(e,t);return r.createV1(this.code,i)}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 i=t;return i!=null&&e.code===i.code&&e.version===i.version&&Fe(e.multihash,i.multihash)}toString(e){return Ge(this,e)}toJSON(){return{"/":Ge(this)}}link(){return this}[Symbol.toStringTag]="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:i,code:n,multihash:o,bytes:s}=t;return new r(i,n,o,s??Re(i,n,o.bytes))}else if(t[lr]===!0){let{version:i,multihash:n,code:o}=t,s=Ce(n);return r.create(i,o,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(i.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==j)throw new Error(`Version 0 CID must use dag-pb (code: ${j}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=Re(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,j,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=w(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=n.subarray(t.multihashSize-t.digestSize),s=new Q(t.multihashCode,t.digestSize,o,n);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[$,gt]=Y(e.subarray(t));return t+=gt,$},n=i(),o=j;if(n===18?(n=0,t=0):o=i(),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let s=t,c=i(),l=i(),_=t+l,b=_-s;return{version:n,codec:o,multihashCode:c,digestSize:l,multihashSize:b,size:_}}static parse(e,t){let[i,n]=ir(e,t),o=r.decode(n);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ht(o).set(i,e),o}};function ir(r,e){switch(r[0]){case"Q":{let t=e??U;return[U.prefix,t.decode(`${U.prefix}${r}`)]}case U.prefix:{let t=e??U;return[U.prefix,t.decode(r)]}case X.prefix:{let t=e??X;return[X.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)]}}}function or(r,e,t){let{prefix:i}=t;if(i!==U.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let o=t.encode(r).slice(1);return e.set(i,o),o}else return n}function sr(r,e,t){let{prefix:i}=t,n=e.get(i);if(n==null){let o=t.encode(r);return e.set(i,o),o}else return n}var j=112,cr=18;function Re(r,e,t){let i=W(r),n=i+W(e),o=new Uint8Array(n+t.byteLength);return J(r,o,0),J(e,o,i),o.set(t,n),o}var lr=Symbol.for("@ipld/js-cid/CID");var Zt={...Kt,...Mt,...$t,...Ot,...Pt,...vt,...Rt,...zt,..._t,...Gt},yi={...Vt,...Jt};function _e(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var ze=_e("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yt=_e("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=v(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),hr={utf8:ze,"utf-8":ze,hex:Zt.base16,latin1:Yt,ascii:Yt,binary:Yt,...Zt},$e=hr;function Ke(r,e="utf8"){let t=$e[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?bt(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function qt(r){let e=r??8192,t=e>>>1,i,n=e;return function(s){if(s<1||s>t)return v(s);n+s>e&&(i=v(e),n=0);let c=i.subarray(n,n+=s);return n&7&&(n=(n|7)+1),c}}var z=class{fn;len;next;val;constructor(e,t,i){this.fn=e,this.len=t,this.next=void 0,this.val=i}};function jt(){}var ee=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},ar=qt();function ur(r){return globalThis.Buffer!=null?v(r):ar(r)}var et=class{len;head;tail;states;constructor(){this.len=0,this.head=new z(jt,0,0),this.tail=this.head,this.states=null}_push(e,t,i){return this.tail=this.tail.next=new z(e,t,i),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ne((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(kt,10,E.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=E.fromBigInt(e);return this._push(kt,t.length(),t)}uint64Number(e){return this._push(ue,H(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=E.fromBigInt(e).zzEncode();return this._push(kt,t.length(),t)}sint64Number(e){let t=E.fromNumber(e).zzEncode();return this._push(kt,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(te,1,e?1:0)}fixed32(e){return this._push(tt,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=E.fromBigInt(e);return this._push(tt,4,t.lo)._push(tt,4,t.hi)}fixed64Number(e){let t=E.fromNumber(e);return this._push(tt,4,t.lo)._push(tt,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(fe,4,e)}double(e){return this._push(me,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(te,1,0):this.uint32(t)._push(fr,t,e)}string(e){let t=Ee(e);return t!==0?this.uint32(t)._push(Ut,t,e):this._push(te,1,0)}fork(){return this.states=new ee(this),this.head=this.tail=new z(jt,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new z(jt,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,i=this.len;return this.reset().uint32(i),i!==0&&(this.tail.next=e.next,this.tail=t,this.len+=i),this}finish(){let e=this.head.next,t=ur(this.len),i=0;for(;e!=null;)e.fn(e.val,t,i),i+=e.len,e=e.next;return t}};function te(r,e,t){e[t]=r&255}function dr(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var ne=class extends z{next;constructor(e,t){super(dr,e,t),this.next=void 0}};function kt(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function tt(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function fr(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(et.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(pr,e,r),this},et.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(mr,e,r),this});function pr(r,e,t){e.set(r,t)}function mr(r,e,t){r.length<40?Ut(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Ke(r),t)}function re(){return new et}function d(r,e){let t=re();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var V;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(V||(V={}));function It(r,e,t,i){return{name:r,type:e,encode:t,decode:i}}function B(r){function e(n){if(r[n.toString()]==null)throw new Error("Invalid enum value");return r[n]}let t=function(o,s){let c=e(o);s.int32(c)},i=function(o){let s=o.int32();return e(s)};return It("enum",V.VARINT,t,i)}function f(r,e){return It("message",V.LENGTH_DELIMITED,r,e)}var ie;(function(r){let e;(function(n){n.IDENTIFY="IDENTIFY",n.CONNECT="CONNECT",n.STREAM_OPEN="STREAM_OPEN",n.STREAM_HANDLER="STREAM_HANDLER",n.DHT="DHT",n.LIST_PEERS="LIST_PEERS",n.CONNMANAGER="CONNMANAGER",n.DISCONNECT="DISCONNECT",n.PUBSUB="PUBSUB",n.PEERSTORE="PEERSTORE"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.IDENTIFY=0]="IDENTIFY",n[n.CONNECT=1]="CONNECT",n[n.STREAM_OPEN=2]="STREAM_OPEN",n[n.STREAM_HANDLER=3]="STREAM_HANDLER",n[n.DHT=4]="DHT",n[n.LIST_PEERS=5]="LIST_PEERS",n[n.CONNMANAGER=6]="CONNMANAGER",n[n.DISCONNECT=7]="DISCONNECT",n[n.PUBSUB=8]="PUBSUB",n[n.PEERSTORE=9]="PEERSTORE"})(t||(t={})),function(n){n.codec=()=>B(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.connect!=null&&(o.uint32(18),rt.codec().encode(n.connect,o)),n.streamOpen!=null&&(o.uint32(26),it.codec().encode(n.streamOpen,o)),n.streamHandler!=null&&(o.uint32(34),ot.codec().encode(n.streamHandler,o)),n.dht!=null&&(o.uint32(42),lt.codec().encode(n.dht,o)),n.connManager!=null&&(o.uint32(50),at.codec().encode(n.connManager,o)),n.disconnect!=null&&(o.uint32(58),ut.codec().encode(n.disconnect,o)),n.pubsub!=null&&(o.uint32(66),dt.codec().encode(n.pubsub,o)),n.peerStore!=null&&(o.uint32(74),pt.codec().encode(n.peerStore,o)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.connect=rt.codec().decode(n,n.uint32());break;case 3:s.streamOpen=it.codec().decode(n,n.uint32());break;case 4:s.streamHandler=ot.codec().decode(n,n.uint32());break;case 5:s.dht=lt.codec().decode(n,n.uint32());break;case 6:s.connManager=at.codec().decode(n,n.uint32());break;case 7:s.disconnect=ut.codec().decode(n,n.uint32());break;case 8:s.pubsub=dt.codec().decode(n,n.uint32());break;case 9:s.peerStore=pt.codec().decode(n,n.uint32());break;default:n.skipType(l&7);break}}return s})),i),r.encode=n=>d(n,r.codec()),r.decode=n=>u(n,r.codec())})(ie||(ie={}));var oe;(function(r){let e;(function(n){n.OK="OK",n.ERROR="ERROR"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.OK=0]="OK",n[n.ERROR=1]="ERROR"})(t||(t={})),function(n){n.codec=()=>B(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.error!=null&&(o.uint32(18),st.codec().encode(n.error,o)),n.streamInfo!=null&&(o.uint32(26),ct.codec().encode(n.streamInfo,o)),n.identify!=null&&(o.uint32(34),nt.codec().encode(n.identify,o)),n.dht!=null&&(o.uint32(42),ht.codec().encode(n.dht,o)),n.peers!=null)for(let c of n.peers)o.uint32(50),C.codec().encode(c,o);n.pubsub!=null&&(o.uint32(58),ft.codec().encode(n.pubsub,o)),n.peerStore!=null&&(o.uint32(66),mt.codec().encode(n.peerStore,o)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={peers:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.error=st.codec().decode(n,n.uint32());break;case 3:s.streamInfo=ct.codec().decode(n,n.uint32());break;case 4:s.identify=nt.codec().decode(n,n.uint32());break;case 5:s.dht=ht.codec().decode(n,n.uint32());break;case 6:s.peers.push(C.codec().decode(n,n.uint32()));break;case 7:s.pubsub=ft.codec().decode(n,n.uint32());break;case 8:s.peerStore=mt.codec().decode(n,n.uint32());break;default:n.skipType(l&7);break}}return s})),i),r.encode=n=>d(n,r.codec()),r.decode=n=>u(n,r.codec())})(oe||(oe={}));var nt;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.id!=null&&t.id.byteLength>0&&(i.uint32(10),i.bytes(t.id)),t.addrs!=null)for(let o of t.addrs)i.uint32(18),i.bytes(o);n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={id:new Uint8Array(0),addrs:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.id=t.bytes();break;case 2:n.addrs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(nt||(nt={}));var rt;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.peer!=null&&t.peer.byteLength>0&&(i.uint32(10),i.bytes(t.peer)),t.addrs!=null)for(let o of t.addrs)i.uint32(18),i.bytes(o);t.timeout!=null&&(i.uint32(24),i.int64(t.timeout)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={peer:new Uint8Array(0),addrs:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.addrs.push(t.bytes());break;case 3:n.timeout=t.int64();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(rt||(rt={}));var it;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.peer!=null&&t.peer.byteLength>0&&(i.uint32(10),i.bytes(t.peer)),t.proto!=null)for(let o of t.proto)i.uint32(18),i.string(o);t.timeout!=null&&(i.uint32(24),i.int64(t.timeout)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={peer:new Uint8Array(0),proto:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.proto.push(t.string());break;case 3:n.timeout=t.int64();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(it||(it={}));var ot;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.addr!=null&&t.addr.byteLength>0&&(i.uint32(10),i.bytes(t.addr)),t.proto!=null)for(let o of t.proto)i.uint32(18),i.string(o);n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={addr:new Uint8Array(0),proto:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.addr=t.bytes();break;case 2:n.proto.push(t.string());break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(ot||(ot={}));var st;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{n.lengthDelimited!==!1&&i.fork(),t.msg!=null&&t.msg!==""&&(i.uint32(10),i.string(t.msg)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={msg:""},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.msg=t.string();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(st||(st={}));var ct;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{n.lengthDelimited!==!1&&i.fork(),t.peer!=null&&t.peer.byteLength>0&&(i.uint32(10),i.bytes(t.peer)),t.addr!=null&&t.addr.byteLength>0&&(i.uint32(18),i.bytes(t.addr)),t.proto!=null&&t.proto!==""&&(i.uint32(26),i.string(t.proto)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.addr=t.bytes();break;case 3:n.proto=t.string();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(ct||(ct={}));var lt;(function(r){let e;(function(n){n.FIND_PEER="FIND_PEER",n.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",n.FIND_PROVIDERS="FIND_PROVIDERS",n.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",n.GET_PUBLIC_KEY="GET_PUBLIC_KEY",n.GET_VALUE="GET_VALUE",n.SEARCH_VALUE="SEARCH_VALUE",n.PUT_VALUE="PUT_VALUE",n.PROVIDE="PROVIDE"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.FIND_PEER=0]="FIND_PEER",n[n.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",n[n.FIND_PROVIDERS=2]="FIND_PROVIDERS",n[n.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",n[n.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",n[n.GET_VALUE=5]="GET_VALUE",n[n.SEARCH_VALUE=6]="SEARCH_VALUE",n[n.PUT_VALUE=7]="PUT_VALUE",n[n.PROVIDE=8]="PROVIDE"})(t||(t={})),function(n){n.codec=()=>B(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),o.bytes(n.peer)),n.cid!=null&&(o.uint32(26),o.bytes(n.cid)),n.key!=null&&(o.uint32(34),o.bytes(n.key)),n.value!=null&&(o.uint32(42),o.bytes(n.value)),n.count!=null&&(o.uint32(48),o.int32(n.count)),n.timeout!=null&&(o.uint32(56),o.int64(n.timeout)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.cid=n.bytes();break;case 4:s.key=n.bytes();break;case 5:s.value=n.bytes();break;case 6:s.count=n.int32();break;case 7:s.timeout=n.int64();break;default:n.skipType(l&7);break}}return s})),i),r.encode=n=>d(n,r.codec()),r.decode=n=>u(n,r.codec())})(lt||(lt={}));var ht;(function(r){let e;(function(n){n.BEGIN="BEGIN",n.VALUE="VALUE",n.END="END"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.BEGIN=0]="BEGIN",n[n.VALUE=1]="VALUE",n[n.END=2]="END"})(t||(t={})),function(n){n.codec=()=>B(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),C.codec().encode(n.peer,o)),n.value!=null&&(o.uint32(26),o.bytes(n.value)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=C.codec().decode(n,n.uint32());break;case 3:s.value=n.bytes();break;default:n.skipType(l&7);break}}return s})),i),r.encode=n=>d(n,r.codec()),r.decode=n=>u(n,r.codec())})(ht||(ht={}));var C;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.id!=null&&t.id.byteLength>0&&(i.uint32(10),i.bytes(t.id)),t.addrs!=null)for(let o of t.addrs)i.uint32(18),i.bytes(o);n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={id:new Uint8Array(0),addrs:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.id=t.bytes();break;case 2:n.addrs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(C||(C={}));var at;(function(r){let e;(function(n){n.TAG_PEER="TAG_PEER",n.UNTAG_PEER="UNTAG_PEER",n.TRIM="TRIM"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.TAG_PEER=0]="TAG_PEER",n[n.UNTAG_PEER=1]="UNTAG_PEER",n[n.TRIM=2]="TRIM"})(t||(t={})),function(n){n.codec=()=>B(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),o.bytes(n.peer)),n.tag!=null&&(o.uint32(26),o.string(n.tag)),n.weight!=null&&(o.uint32(32),o.int64(n.weight)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.tag=n.string();break;case 4:s.weight=n.int64();break;default:n.skipType(l&7);break}}return s})),i),r.encode=n=>d(n,r.codec()),r.decode=n=>u(n,r.codec())})(at||(at={}));var ut;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{n.lengthDelimited!==!1&&i.fork(),t.peer!=null&&t.peer.byteLength>0&&(i.uint32(10),i.bytes(t.peer)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={peer:new Uint8Array(0)},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(ut||(ut={}));var dt;(function(r){let e;(function(n){n.GET_TOPICS="GET_TOPICS",n.LIST_PEERS="LIST_PEERS",n.PUBLISH="PUBLISH",n.SUBSCRIBE="SUBSCRIBE"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.GET_TOPICS=0]="GET_TOPICS",n[n.LIST_PEERS=1]="LIST_PEERS",n[n.PUBLISH=2]="PUBLISH",n[n.SUBSCRIBE=3]="SUBSCRIBE"})(t||(t={})),function(n){n.codec=()=>B(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.topic!=null&&(o.uint32(18),o.string(n.topic)),n.data!=null&&(o.uint32(26),o.bytes(n.data)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.topic=n.string();break;case 3:s.data=n.bytes();break;default:n.skipType(l&7);break}}return s})),i),r.encode=n=>d(n,r.codec()),r.decode=n=>u(n,r.codec())})(dt||(dt={}));var se;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.from!=null&&(i.uint32(10),i.bytes(t.from)),t.data!=null&&(i.uint32(18),i.bytes(t.data)),t.seqno!=null&&(i.uint32(26),i.bytes(t.seqno)),t.topicIDs!=null)for(let o of t.topicIDs)i.uint32(34),i.string(o);t.signature!=null&&(i.uint32(42),i.bytes(t.signature)),t.key!=null&&(i.uint32(50),i.bytes(t.key)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={topicIDs:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.from=t.bytes();break;case 2:n.data=t.bytes();break;case 3:n.seqno=t.bytes();break;case 4:n.topicIDs.push(t.string());break;case 5:n.signature=t.bytes();break;case 6:n.key=t.bytes();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(se||(se={}));var ft;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.topics!=null)for(let o of t.topics)i.uint32(10),i.string(o);if(t.peerIDs!=null)for(let o of t.peerIDs)i.uint32(18),i.bytes(o);n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={topics:[],peerIDs:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.topics.push(t.string());break;case 2:n.peerIDs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(ft||(ft={}));var pt;(function(r){let e;(function(n){n.UNSPECIFIED="UNSPECIFIED",n.GET_PROTOCOLS="GET_PROTOCOLS",n.GET_PEER_INFO="GET_PEER_INFO"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.GET_PROTOCOLS=1]="GET_PROTOCOLS",n[n.GET_PEER_INFO=2]="GET_PEER_INFO"})(t||(t={})),function(n){n.codec=()=>B(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.id!=null&&(o.uint32(18),o.bytes(n.id)),n.protos!=null)for(let c of n.protos)o.uint32(26),o.string(c);s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={protos:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let l=n.uint32();switch(l>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.id=n.bytes();break;case 3:s.protos.push(n.string());break;default:n.skipType(l&7);break}}return s})),i),r.encode=n=>d(n,r.codec()),r.decode=n=>u(n,r.codec())})(pt||(pt={}));var mt;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.peer!=null&&(i.uint32(10),C.codec().encode(t.peer,i)),t.protos!=null)for(let o of t.protos)i.uint32(18),i.string(o);n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={protos:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=C.codec().decode(t,t.uint32());break;case 2:n.protos.push(t.string());break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>d(t,r.codec()),r.decode=t=>u(t,r.codec())})(mt||(mt={}));return He(gr);})();
|
|
3
3
|
return Libp2PDaemonProtocol}));
|
|
@@ -14,7 +14,7 @@ export declare class StreamHandler {
|
|
|
14
14
|
/**
|
|
15
15
|
* Read and decode message
|
|
16
16
|
*/
|
|
17
|
-
read(): Promise<
|
|
17
|
+
read(): Promise<Uint8ArrayList | undefined>;
|
|
18
18
|
write(msg: Uint8Array | Uint8ArrayList): Promise<void>;
|
|
19
19
|
/**
|
|
20
20
|
* Return the handshake rest stream and invalidate handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-handler.d.ts","sourceRoot":"","sources":["../../src/stream-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIpD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,mBAAmB,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA2C;IAE9D;;OAEG;gBACU,IAAI,EAAE,oBAAoB;IAOvC;;OAEG;IACG,IAAI,IAAK,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"stream-handler.d.ts","sourceRoot":"","sources":["../../src/stream-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIpD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,mBAAmB,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA2C;IAE9D;;OAEG;gBACU,IAAI,EAAE,oBAAoB;IAOvC;;OAEG;IACG,IAAI,IAAK,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAQ5C,KAAK,CAAE,GAAG,EAAE,UAAU,GAAG,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7D;;OAEG;IACH,IAAI,IAAK,mBAAmB;IAI5B;;OAEG;IACG,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;CAI9B"}
|
|
@@ -16,14 +16,12 @@ export class StreamHandler {
|
|
|
16
16
|
* Read and decode message
|
|
17
17
|
*/
|
|
18
18
|
async read() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
try {
|
|
20
|
+
return await this.lp.read();
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
log.error('read received no value', err);
|
|
23
24
|
}
|
|
24
|
-
log('read received no value, closing stream');
|
|
25
|
-
// End the stream, we didn't get data
|
|
26
|
-
await this.close();
|
|
27
25
|
}
|
|
28
26
|
async write(msg) {
|
|
29
27
|
log('write message');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-handler.js","sourceRoot":"","sources":["../../src/stream-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,QAAQ,EAA6B,MAAM,2BAA2B,CAAA;AAI/E,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAA;AAO3D,MAAM,OAAO,aAAa;IACP,MAAM,CAAqB;IAC3B,EAAE,CAA2C;IAE9D;;OAEG;IACH,YAAa,IAA0B;QACrC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;QAElC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,SAAS,IAAI,IAAI,EAAE,CAAC,CAAA;IACvE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,
|
|
1
|
+
{"version":3,"file":"stream-handler.js","sourceRoot":"","sources":["../../src/stream-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,QAAQ,EAA6B,MAAM,2BAA2B,CAAA;AAI/E,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAA;AAO3D,MAAM,OAAO,aAAa;IACP,MAAM,CAAqB;IAC3B,EAAE,CAA2C;IAE9D;;OAEG;IACH,YAAa,IAA0B;QACrC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;QAElC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,SAAS,IAAI,IAAI,EAAE,CAAC,CAAA;IACvE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAA;QAC7B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK,CAAE,GAAgC;QAC3C,GAAG,CAAC,eAAe,CAAC,CAAA;QACpB,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAA;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,GAAG,CAAC,oBAAoB,CAAC,CAAA;QACzB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAA;IAC3B,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/daemon-protocol",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"description": "Communication protocol between libp2p daemons and clients",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
@@ -59,114 +59,24 @@
|
|
|
59
59
|
"parserOptions": {
|
|
60
60
|
"project": true,
|
|
61
61
|
"sourceType": "module"
|
|
62
|
-
}
|
|
63
|
-
"ignorePatterns": [
|
|
64
|
-
"*.d.ts",
|
|
65
|
-
"src/index.js"
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
"release": {
|
|
69
|
-
"branches": [
|
|
70
|
-
"main"
|
|
71
|
-
],
|
|
72
|
-
"plugins": [
|
|
73
|
-
[
|
|
74
|
-
"@semantic-release/commit-analyzer",
|
|
75
|
-
{
|
|
76
|
-
"preset": "conventionalcommits",
|
|
77
|
-
"releaseRules": [
|
|
78
|
-
{
|
|
79
|
-
"breaking": true,
|
|
80
|
-
"release": "major"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"revert": true,
|
|
84
|
-
"release": "patch"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"type": "feat",
|
|
88
|
-
"release": "minor"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"type": "fix",
|
|
92
|
-
"release": "patch"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"type": "docs",
|
|
96
|
-
"release": "patch"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"type": "test",
|
|
100
|
-
"release": "patch"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"type": "deps",
|
|
104
|
-
"release": "patch"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"scope": "no-release",
|
|
108
|
-
"release": false
|
|
109
|
-
}
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
[
|
|
114
|
-
"@semantic-release/release-notes-generator",
|
|
115
|
-
{
|
|
116
|
-
"preset": "conventionalcommits",
|
|
117
|
-
"presetConfig": {
|
|
118
|
-
"types": [
|
|
119
|
-
{
|
|
120
|
-
"type": "feat",
|
|
121
|
-
"section": "Features"
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"type": "fix",
|
|
125
|
-
"section": "Bug Fixes"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"type": "chore",
|
|
129
|
-
"section": "Trivial Changes"
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"type": "docs",
|
|
133
|
-
"section": "Documentation"
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
"type": "deps",
|
|
137
|
-
"section": "Dependencies"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"type": "test",
|
|
141
|
-
"section": "Tests"
|
|
142
|
-
}
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
],
|
|
147
|
-
"@semantic-release/changelog",
|
|
148
|
-
"@semantic-release/npm",
|
|
149
|
-
"@semantic-release/github",
|
|
150
|
-
"@semantic-release/git"
|
|
151
|
-
]
|
|
62
|
+
}
|
|
152
63
|
},
|
|
153
64
|
"scripts": {
|
|
154
65
|
"clean": "aegir clean",
|
|
155
66
|
"lint": "aegir lint",
|
|
156
67
|
"generate": "protons ./src/index.proto",
|
|
157
68
|
"build": "aegir build",
|
|
158
|
-
"release": "aegir release",
|
|
159
69
|
"dep-check": "aegir dep-check"
|
|
160
70
|
},
|
|
161
71
|
"dependencies": {
|
|
162
|
-
"@libp2p/interface": "^1.
|
|
163
|
-
"@libp2p/logger": "^4.0.
|
|
164
|
-
"it-length-prefixed-stream": "^1.1.
|
|
165
|
-
"protons-runtime": "^5.
|
|
166
|
-
"uint8arraylist": "^2.4.
|
|
72
|
+
"@libp2p/interface": "^1.1.2",
|
|
73
|
+
"@libp2p/logger": "^4.0.5",
|
|
74
|
+
"it-length-prefixed-stream": "^1.1.6",
|
|
75
|
+
"protons-runtime": "^5.4.0",
|
|
76
|
+
"uint8arraylist": "^2.4.8"
|
|
167
77
|
},
|
|
168
78
|
"devDependencies": {
|
|
169
|
-
"aegir": "^
|
|
170
|
-
"protons": "^7.0
|
|
79
|
+
"aegir": "^42.2.3",
|
|
80
|
+
"protons": "^7.5.0"
|
|
171
81
|
}
|
|
172
82
|
}
|
package/src/stream-handler.ts
CHANGED
|
@@ -27,16 +27,12 @@ export class StreamHandler {
|
|
|
27
27
|
/**
|
|
28
28
|
* Read and decode message
|
|
29
29
|
*/
|
|
30
|
-
async read (): Promise<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
async read (): Promise<Uint8ArrayList | undefined> {
|
|
31
|
+
try {
|
|
32
|
+
return await this.lp.read()
|
|
33
|
+
} catch (err) {
|
|
34
|
+
log.error('read received no value', err)
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
log('read received no value, closing stream')
|
|
38
|
-
// End the stream, we didn't get data
|
|
39
|
-
await this.close()
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
async write (msg: Uint8Array | Uint8ArrayList): Promise<void> {
|