@libp2p/daemon-protocol 3.0.5 → 4.0.0
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 pe=Object.create;var q=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty;var m=(i,n)=>()=>(n||i((n={exports:{}}).exports,n),n.exports),ke=(i,n)=>{for(var e in n)q(i,e,{get:n[e],enumerable:!0})},At=(i,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of ye(n))!me.call(i,t)&&t!==e&&q(i,t,{get:()=>n[t],enumerable:!(r=Ee(n,t))||r.enumerable});return i};var F=(i,n,e)=>(e=i!=null?pe(ge(i)):{},At(n||!i||!i.__esModule?q(e,"default",{value:i,enumerable:!0}):e,i)),_e=i=>At(q({},"__esModule",{value:!0}),i);var It=m((Ce,Bt)=>{"use strict";Bt.exports=Ne;function Ne(i,n){for(var e=new Array(arguments.length-1),r=0,t=2,o=!0;t<arguments.length;)e[r++]=arguments[t++];return new Promise(function(s,u){e[r]=function(h){if(o)if(o=!1,h)u(h);else{for(var k=new Array(arguments.length-1),O=0;O<k.length;)k[O++]=arguments[O];s.apply(null,k)}};try{i.apply(n||null,e)}catch(l){o&&(o=!1,u(l))}})}});var Ot=m(Lt=>{"use strict";var j=Lt;j.length=function(n){var e=n.length;if(!e)return 0;for(var r=0;--e%4>1&&n.charAt(e)==="=";)++r;return Math.ceil(n.length*3)/4-r};var U=new Array(64),Dt=new Array(123);for(N=0;N<64;)Dt[U[N]=N<26?N+65:N<52?N+71:N<62?N-4:N-59|43]=N++;var N;j.encode=function(n,e,r){for(var t=null,o=[],c=0,s=0,u;e<r;){var l=n[e++];switch(s){case 0:o[c++]=U[l>>2],u=(l&3)<<4,s=1;break;case 1:o[c++]=U[u|l>>4],u=(l&15)<<2,s=2;break;case 2:o[c++]=U[u|l>>6],o[c++]=U[l&63],s=0;break}c>8191&&((t||(t=[])).push(String.fromCharCode.apply(String,o)),c=0)}return s&&(o[c++]=U[u],o[c++]=61,s===1&&(o[c++]=61)),t?(c&&t.push(String.fromCharCode.apply(String,o.slice(0,c))),t.join("")):String.fromCharCode.apply(String,o.slice(0,c))};var St="invalid encoding";j.decode=function(n,e,r){for(var t=r,o=0,c,s=0;s<n.length;){var u=n.charCodeAt(s++);if(u===61&&o>1)break;if((u=Dt[u])===void 0)throw Error(St);switch(o){case 0:c=u,o=1;break;case 1:e[r++]=c<<2|(u&48)>>4,c=u,o=2;break;case 2:e[r++]=(c&15)<<4|(u&60)>>2,c=u,o=3;break;case 3:e[r++]=(c&3)<<6|u,o=0;break}}if(o===1)throw Error(St);return r-t};j.test=function(n){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(n)}});var xt=m((Pe,Tt)=>{"use strict";Tt.exports=tt;function tt(){this._listeners={}}tt.prototype.on=function(n,e,r){return(this._listeners[n]||(this._listeners[n]=[])).push({fn:e,ctx:r||this}),this};tt.prototype.off=function(n,e){if(n===void 0)this._listeners={};else if(e===void 0)this._listeners[n]=[];else for(var r=this._listeners[n],t=0;t<r.length;)r[t].fn===e?r.splice(t,1):++t;return this};tt.prototype.emit=function(n){var e=this._listeners[n];if(e){for(var r=[],t=1;t<arguments.length;)r.push(arguments[t++]);for(t=0;t<e.length;)e[t].fn.apply(e[t++].ctx,r)}return this}});var Mt=m((Ge,Gt)=>{"use strict";Gt.exports=vt(vt);function vt(i){return typeof Float32Array<"u"?function(){var n=new Float32Array([-0]),e=new Uint8Array(n.buffer),r=e[3]===128;function t(u,l,h){n[0]=u,l[h]=e[0],l[h+1]=e[1],l[h+2]=e[2],l[h+3]=e[3]}function o(u,l,h){n[0]=u,l[h]=e[3],l[h+1]=e[2],l[h+2]=e[1],l[h+3]=e[0]}i.writeFloatLE=r?t:o,i.writeFloatBE=r?o:t;function c(u,l){return e[0]=u[l],e[1]=u[l+1],e[2]=u[l+2],e[3]=u[l+3],n[0]}function s(u,l){return e[3]=u[l],e[2]=u[l+1],e[1]=u[l+2],e[0]=u[l+3],n[0]}i.readFloatLE=r?c:s,i.readFloatBE=r?s:c}():function(){function n(r,t,o,c){var s=t<0?1:0;if(s&&(t=-t),t===0)r(1/t>0?0:2147483648,o,c);else if(isNaN(t))r(2143289344,o,c);else if(t>34028234663852886e22)r((s<<31|2139095040)>>>0,o,c);else if(t<11754943508222875e-54)r((s<<31|Math.round(t/1401298464324817e-60))>>>0,o,c);else{var u=Math.floor(Math.log(t)/Math.LN2),l=Math.round(t*Math.pow(2,-u)*8388608)&8388607;r((s<<31|u+127<<23|l)>>>0,o,c)}}i.writeFloatLE=n.bind(null,Ut),i.writeFloatBE=n.bind(null,Ct);function e(r,t,o){var c=r(t,o),s=(c>>31)*2+1,u=c>>>23&255,l=c&8388607;return u===255?l?NaN:s*(1/0):u===0?s*1401298464324817e-60*l:s*Math.pow(2,u-150)*(l+8388608)}i.readFloatLE=e.bind(null,Ft),i.readFloatBE=e.bind(null,Pt)}(),typeof Float64Array<"u"?function(){var n=new Float64Array([-0]),e=new Uint8Array(n.buffer),r=e[7]===128;function t(u,l,h){n[0]=u,l[h]=e[0],l[h+1]=e[1],l[h+2]=e[2],l[h+3]=e[3],l[h+4]=e[4],l[h+5]=e[5],l[h+6]=e[6],l[h+7]=e[7]}function o(u,l,h){n[0]=u,l[h]=e[7],l[h+1]=e[6],l[h+2]=e[5],l[h+3]=e[4],l[h+4]=e[3],l[h+5]=e[2],l[h+6]=e[1],l[h+7]=e[0]}i.writeDoubleLE=r?t:o,i.writeDoubleBE=r?o:t;function c(u,l){return e[0]=u[l],e[1]=u[l+1],e[2]=u[l+2],e[3]=u[l+3],e[4]=u[l+4],e[5]=u[l+5],e[6]=u[l+6],e[7]=u[l+7],n[0]}function s(u,l){return e[7]=u[l],e[6]=u[l+1],e[5]=u[l+2],e[4]=u[l+3],e[3]=u[l+4],e[2]=u[l+5],e[1]=u[l+6],e[0]=u[l+7],n[0]}i.readDoubleLE=r?c:s,i.readDoubleBE=r?s:c}():function(){function n(r,t,o,c,s,u){var l=c<0?1:0;if(l&&(c=-c),c===0)r(0,s,u+t),r(1/c>0?0:2147483648,s,u+o);else if(isNaN(c))r(0,s,u+t),r(2146959360,s,u+o);else if(c>17976931348623157e292)r(0,s,u+t),r((l<<31|2146435072)>>>0,s,u+o);else{var h;if(c<22250738585072014e-324)h=c/5e-324,r(h>>>0,s,u+t),r((l<<31|h/4294967296)>>>0,s,u+o);else{var k=Math.floor(Math.log(c)/Math.LN2);k===1024&&(k=1023),h=c*Math.pow(2,-k),r(h*4503599627370496>>>0,s,u+t),r((l<<31|k+1023<<20|h*1048576&1048575)>>>0,s,u+o)}}}i.writeDoubleLE=n.bind(null,Ut,0,4),i.writeDoubleBE=n.bind(null,Ct,4,0);function e(r,t,o,c,s){var u=r(c,s+t),l=r(c,s+o),h=(l>>31)*2+1,k=l>>>20&2047,O=4294967296*(l&1048575)+u;return k===2047?O?NaN:h*(1/0):k===0?h*5e-324*O:h*Math.pow(2,k-1075)*(O+4503599627370496)}i.readDoubleLE=e.bind(null,Ft,0,4),i.readDoubleBE=e.bind(null,Pt,4,0)}(),i}function Ut(i,n,e){n[e]=i&255,n[e+1]=i>>>8&255,n[e+2]=i>>>16&255,n[e+3]=i>>>24}function Ct(i,n,e){n[e]=i>>>24,n[e+1]=i>>>16&255,n[e+2]=i>>>8&255,n[e+3]=i&255}function Ft(i,n){return(i[n]|i[n+1]<<8|i[n+2]<<16|i[n+3]<<24)>>>0}function Pt(i,n){return(i[n]<<24|i[n+1]<<16|i[n+2]<<8|i[n+3])>>>0}});var Rt=m((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(i){}return null}});var zt=m(wt=>{"use strict";var rt=wt;rt.length=function(n){for(var e=0,r=0,t=0;t<n.length;++t)r=n.charCodeAt(t),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(n.charCodeAt(t+1)&64512)===56320?(++t,e+=4):e+=3;return e};rt.read=function(n,e,r){var t=r-e;if(t<1)return"";for(var o=null,c=[],s=0,u;e<r;)u=n[e++],u<128?c[s++]=u:u>191&&u<224?c[s++]=(u&31)<<6|n[e++]&63:u>239&&u<365?(u=((u&7)<<18|(n[e++]&63)<<12|(n[e++]&63)<<6|n[e++]&63)-65536,c[s++]=55296+(u>>10),c[s++]=56320+(u&1023)):c[s++]=(u&15)<<12|(n[e++]&63)<<6|n[e++]&63,s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,c)),s=0);return o?(s&&o.push(String.fromCharCode.apply(String,c.slice(0,s))),o.join("")):String.fromCharCode.apply(String,c.slice(0,s))};rt.write=function(n,e,r){for(var t=r,o,c,s=0;s<n.length;++s)o=n.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((c=n.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(c&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-t}});var Wt=m((Re,Ht)=>{"use strict";Ht.exports=be;function be(i,n,e){var r=e||8192,t=r>>>1,o=null,c=r;return function(u){if(u<1||u>t)return i(u);c+u>r&&(o=i(r),c=0);var l=n.call(o,c,c+=u);return c&7&&(c=(c|7)+1),l}}});var Zt=m((we,Kt)=>{"use strict";Kt.exports=g;var P=x();function g(i,n){this.lo=i>>>0,this.hi=n>>>0}var T=g.zero=new g(0,0);T.toNumber=function(){return 0};T.zzEncode=T.zzDecode=function(){return this};T.length=function(){return 1};var Ae=g.zeroHash="\0\0\0\0\0\0\0\0";g.fromNumber=function(n){if(n===0)return T;var e=n<0;e&&(n=-n);var r=n>>>0,t=(n-r)/4294967296>>>0;return e&&(t=~t>>>0,r=~r>>>0,++r>4294967295&&(r=0,++t>4294967295&&(t=0))),new g(r,t)};g.from=function(n){if(typeof n=="number")return g.fromNumber(n);if(P.isString(n))if(P.Long)n=P.Long.fromString(n);else return g.fromNumber(parseInt(n,10));return n.low||n.high?new g(n.low>>>0,n.high>>>0):T};g.prototype.toNumber=function(n){if(!n&&this.hi>>>31){var e=~this.lo+1>>>0,r=~this.hi>>>0;return e||(r=r+1>>>0),-(e+r*4294967296)}return this.lo+this.hi*4294967296};g.prototype.toLong=function(n){return P.Long?new P.Long(this.lo|0,this.hi|0,Boolean(n)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(n)}};var D=String.prototype.charCodeAt;g.fromHash=function(n){return n===Ae?T:new g((D.call(n,0)|D.call(n,1)<<8|D.call(n,2)<<16|D.call(n,3)<<24)>>>0,(D.call(n,4)|D.call(n,5)<<8|D.call(n,6)<<16|D.call(n,7)<<24)>>>0)};g.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};g.prototype.zzEncode=function(){var n=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^n)>>>0,this.lo=(this.lo<<1^n)>>>0,this};g.prototype.zzDecode=function(){var n=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^n)>>>0,this.hi=(this.hi>>>1^n)>>>0,this};g.prototype.length=function(){var n=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return r===0?e===0?n<16384?n<128?1:2:n<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:r<128?9:10}});var x=m(ot=>{"use strict";var f=ot;f.asPromise=It();f.base64=Ot();f.EventEmitter=xt();f.float=Mt();f.inquire=Rt();f.utf8=zt();f.pool=Wt();f.LongBits=Zt();f.isNode=Boolean(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);f.global=f.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||ot;f.emptyArray=Object.freeze?Object.freeze([]):[];f.emptyObject=Object.freeze?Object.freeze({}):{};f.isInteger=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};f.isString=function(n){return typeof n=="string"||n instanceof String};f.isObject=function(n){return n&&typeof n=="object"};f.isset=f.isSet=function(n,e){var r=n[e];return r!=null&&n.hasOwnProperty(e)?typeof r!="object"||(Array.isArray(r)?r.length:Object.keys(r).length)>0:!1};f.Buffer=function(){try{var i=f.inquire("buffer").Buffer;return i.prototype.utf8Write?i:null}catch{return null}}();f._Buffer_from=null;f._Buffer_allocUnsafe=null;f.newBuffer=function(n){return typeof n=="number"?f.Buffer?f._Buffer_allocUnsafe(n):new f.Array(n):f.Buffer?f._Buffer_from(n):typeof Uint8Array>"u"?n:new Uint8Array(n)};f.Array=typeof Uint8Array<"u"?Uint8Array:Array;f.Long=f.global.dcodeIO&&f.global.dcodeIO.Long||f.global.Long||f.inquire("long");f.key2Re=/^true|false|0|1$/;f.key32Re=/^-?(?:0|[1-9][0-9]*)$/;f.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;f.longToHash=function(n){return n?f.LongBits.from(n).toHash():f.LongBits.zeroHash};f.longFromHash=function(n,e){var r=f.LongBits.fromHash(n);return f.Long?f.Long.fromBits(r.lo,r.hi,e):r.toNumber(Boolean(e))};function $t(i,n,e){for(var r=Object.keys(n),t=0;t<r.length;++t)(i[r[t]]===void 0||!e)&&(i[r[t]]=n[r[t]]);return i}f.merge=$t;f.lcFirst=function(n){return n.charAt(0).toLowerCase()+n.substring(1)};function Jt(i){function n(e,r){if(!(this instanceof n))return new n(e,r);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,n):Object.defineProperty(this,"stack",{value:new Error().stack||""}),r&&$t(this,r)}return n.prototype=Object.create(Error.prototype,{constructor:{value:n,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return i},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),n}f.newError=Jt;f.ProtocolError=Jt("ProtocolError");f.oneOfGetter=function(n){for(var e={},r=0;r<n.length;++r)e[n[r]]=1;return function(){for(var t=Object.keys(this),o=t.length-1;o>-1;--o)if(e[t[o]]===1&&this[t[o]]!==void 0&&this[t[o]]!==null)return t[o]}};f.oneOfSetter=function(n){return function(e){for(var r=0;r<n.length;++r)n[r]!==e&&delete this[n[r]]}};f.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};f._configure=function(){var i=f.Buffer;if(!i){f._Buffer_from=f._Buffer_allocUnsafe=null;return}f._Buffer_from=i.from!==Uint8Array.from&&i.from||function(e,r){return new i(e,r)},f._Buffer_allocUnsafe=i.allocUnsafe||function(e){return new i(e)}}});var lt=m((He,qt)=>{"use strict";qt.exports=d;var A=x(),ut,Yt=A.LongBits,Be=A.utf8;function b(i,n){return RangeError("index out of range: "+i.pos+" + "+(n||1)+" > "+i.len)}function d(i){this.buf=i,this.pos=0,this.len=i.length}var Xt=typeof Uint8Array<"u"?function(n){if(n instanceof Uint8Array||Array.isArray(n))return new d(n);throw Error("illegal buffer")}:function(n){if(Array.isArray(n))return new d(n);throw Error("illegal buffer")},Vt=function(){return A.Buffer?function(e){return(d.create=function(t){return A.Buffer.isBuffer(t)?new ut(t):Xt(t)})(e)}:Xt};d.create=Vt();d.prototype._slice=A.Array.prototype.subarray||A.Array.prototype.slice;d.prototype.uint32=function(){var n=4294967295;return function(){if(n=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(n=(n|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(n=(n|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(n=(n|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(n=(n|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return n;if((this.pos+=5)>this.len)throw this.pos=this.len,b(this,10);return n}}();d.prototype.int32=function(){return this.uint32()|0};d.prototype.sint32=function(){var n=this.uint32();return n>>>1^-(n&1)|0};function ct(){var i=new Yt(0,0),n=0;if(this.len-this.pos>4){for(;n<4;++n)if(i.lo=(i.lo|(this.buf[this.pos]&127)<<n*7)>>>0,this.buf[this.pos++]<128)return i;if(i.lo=(i.lo|(this.buf[this.pos]&127)<<28)>>>0,i.hi=(i.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return i;n=0}else{for(;n<3;++n){if(this.pos>=this.len)throw b(this);if(i.lo=(i.lo|(this.buf[this.pos]&127)<<n*7)>>>0,this.buf[this.pos++]<128)return i}return i.lo=(i.lo|(this.buf[this.pos++]&127)<<n*7)>>>0,i}if(this.len-this.pos>4){for(;n<5;++n)if(i.hi=(i.hi|(this.buf[this.pos]&127)<<n*7+3)>>>0,this.buf[this.pos++]<128)return i}else for(;n<5;++n){if(this.pos>=this.len)throw b(this);if(i.hi=(i.hi|(this.buf[this.pos]&127)<<n*7+3)>>>0,this.buf[this.pos++]<128)return i}throw Error("invalid varint encoding")}d.prototype.bool=function(){return this.uint32()!==0};function et(i,n){return(i[n-4]|i[n-3]<<8|i[n-2]<<16|i[n-1]<<24)>>>0}d.prototype.fixed32=function(){if(this.pos+4>this.len)throw b(this,4);return et(this.buf,this.pos+=4)};d.prototype.sfixed32=function(){if(this.pos+4>this.len)throw b(this,4);return et(this.buf,this.pos+=4)|0};function Qt(){if(this.pos+8>this.len)throw b(this,8);return new Yt(et(this.buf,this.pos+=4),et(this.buf,this.pos+=4))}d.prototype.float=function(){if(this.pos+4>this.len)throw b(this,4);var n=A.float.readFloatLE(this.buf,this.pos);return this.pos+=4,n};d.prototype.double=function(){if(this.pos+8>this.len)throw b(this,4);var n=A.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,n};d.prototype.bytes=function(){var n=this.uint32(),e=this.pos,r=this.pos+n;if(r>this.len)throw b(this,n);return this.pos+=n,Array.isArray(this.buf)?this.buf.slice(e,r):e===r?new this.buf.constructor(0):this._slice.call(this.buf,e,r)};d.prototype.string=function(){var n=this.bytes();return Be.read(n,0,n.length)};d.prototype.skip=function(n){if(typeof n=="number"){if(this.pos+n>this.len)throw b(this,n);this.pos+=n}else do if(this.pos>=this.len)throw b(this);while(this.buf[this.pos++]&128);return this};d.prototype.skipType=function(i){switch(i){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(i=this.uint32()&7)!==4;)this.skipType(i);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+i+" at offset "+this.pos)}return this};d._configure=function(i){ut=i,d.create=Vt(),ut._configure();var n=A.Long?"toLong":"toNumber";A.merge(d.prototype,{int64:function(){return ct.call(this)[n](!1)},uint64:function(){return ct.call(this)[n](!0)},sint64:function(){return ct.call(this).zzDecode()[n](!1)},fixed64:function(){return Qt.call(this)[n](!0)},sfixed64:function(){return Qt.call(this)[n](!1)}})}});var ne=m((We,ee)=>{"use strict";ee.exports=v;var te=lt();(v.prototype=Object.create(te.prototype)).constructor=v;var jt=x();function v(i){te.call(this,i)}v._configure=function(){jt.Buffer&&(v.prototype._slice=jt.Buffer.prototype.slice)};v.prototype.string=function(){var n=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+n,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+n,this.len))};v._configure()});var Et=m((Ke,ce)=>{"use strict";ce.exports=a;var _=x(),st,nt=_.LongBits,ie=_.base64,re=_.utf8;function G(i,n,e){this.fn=i,this.len=n,this.next=void 0,this.val=e}function ht(){}function Ie(i){this.head=i.head,this.tail=i.tail,this.len=i.len,this.next=i.states}function a(){this.len=0,this.head=new G(ht,0,0),this.tail=this.head,this.states=null}var oe=function(){return _.Buffer?function(){return(a.create=function(){return new st})()}:function(){return new a}};a.create=oe();a.alloc=function(n){return new _.Array(n)};_.Array!==Array&&(a.alloc=_.pool(a.alloc,_.Array.prototype.subarray));a.prototype._push=function(n,e,r){return this.tail=this.tail.next=new G(n,e,r),this.len+=e,this};function at(i,n,e){n[e]=i&255}function Se(i,n,e){for(;i>127;)n[e++]=i&127|128,i>>>=7;n[e]=i}function dt(i,n){this.len=i,this.next=void 0,this.val=n}dt.prototype=Object.create(G.prototype);dt.prototype.fn=Se;a.prototype.uint32=function(n){return this.len+=(this.tail=this.tail.next=new dt((n=n>>>0)<128?1:n<16384?2:n<2097152?3:n<268435456?4:5,n)).len,this};a.prototype.int32=function(n){return n<0?this._push(pt,10,nt.fromNumber(n)):this.uint32(n)};a.prototype.sint32=function(n){return this.uint32((n<<1^n>>31)>>>0)};function pt(i,n,e){for(;i.hi;)n[e++]=i.lo&127|128,i.lo=(i.lo>>>7|i.hi<<25)>>>0,i.hi>>>=7;for(;i.lo>127;)n[e++]=i.lo&127|128,i.lo=i.lo>>>7;n[e++]=i.lo}a.prototype.uint64=function(n){var e=nt.from(n);return this._push(pt,e.length(),e)};a.prototype.int64=a.prototype.uint64;a.prototype.sint64=function(n){var e=nt.from(n).zzEncode();return this._push(pt,e.length(),e)};a.prototype.bool=function(n){return this._push(at,1,n?1:0)};function ft(i,n,e){n[e]=i&255,n[e+1]=i>>>8&255,n[e+2]=i>>>16&255,n[e+3]=i>>>24}a.prototype.fixed32=function(n){return this._push(ft,4,n>>>0)};a.prototype.sfixed32=a.prototype.fixed32;a.prototype.fixed64=function(n){var e=nt.from(n);return this._push(ft,4,e.lo)._push(ft,4,e.hi)};a.prototype.sfixed64=a.prototype.fixed64;a.prototype.float=function(n){return this._push(_.float.writeFloatLE,4,n)};a.prototype.double=function(n){return this._push(_.float.writeDoubleLE,8,n)};var De=_.Array.prototype.set?function(n,e,r){e.set(n,r)}:function(n,e,r){for(var t=0;t<n.length;++t)e[r+t]=n[t]};a.prototype.bytes=function(n){var e=n.length>>>0;if(!e)return this._push(at,1,0);if(_.isString(n)){var r=a.alloc(e=ie.length(n));ie.decode(n,r,0),n=r}return this.uint32(e)._push(De,e,n)};a.prototype.string=function(n){var e=re.length(n);return e?this.uint32(e)._push(re.write,e,n):this._push(at,1,0)};a.prototype.fork=function(){return this.states=new Ie(this),this.head=this.tail=new G(ht,0,0),this.len=0,this};a.prototype.reset=function(){return this.states?(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 G(ht,0,0),this.len=0),this};a.prototype.ldelim=function(){var n=this.head,e=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=n.next,this.tail=e,this.len+=r),this};a.prototype.finish=function(){for(var n=this.head.next,e=this.constructor.alloc(this.len),r=0;n;)n.fn(n.val,e,r),r+=n.len,n=n.next;return e};a._configure=function(i){st=i,a.create=oe(),st._configure()}});var se=m((Ze,le)=>{"use strict";le.exports=B;var ue=Et();(B.prototype=Object.create(ue.prototype)).constructor=B;var L=x();function B(){ue.call(this)}B._configure=function(){B.alloc=L._Buffer_allocUnsafe,B.writeBytesBuffer=L.Buffer&&L.Buffer.prototype instanceof Uint8Array&&L.Buffer.prototype.set.name==="set"?function(n,e,r){e.set(n,r)}:function(n,e,r){if(n.copy)n.copy(e,r,0,n.length);else for(var t=0;t<n.length;)e[r++]=n[t++]}};B.prototype.bytes=function(n){L.isString(n)&&(n=L._Buffer_from(n,"base64"));var e=n.length>>>0;return this.uint32(e),e&&this._push(B.writeBytesBuffer,e,n),this};function Le(i,n,e){i.length<40?L.utf8.write(i,n,e):n.utf8Write?n.utf8Write(i,e):n.write(i,e)}B.prototype.string=function(n){var e=L.Buffer.byteLength(n);return this.uint32(e),e&&this._push(Le,e,n),this};B._configure()});var ve={};ke(ve,{ConnManagerRequest:()=>$,ConnectRequest:()=>R,DHTRequest:()=>K,DHTResponse:()=>Z,DisconnectRequest:()=>J,ErrorResponse:()=>H,IdentifyResponse:()=>M,PSMessage:()=>bt,PSRequest:()=>X,PSResponse:()=>Q,PeerInfo:()=>S,PeerstoreRequest:()=>Y,PeerstoreResponse:()=>V,Request:()=>_t,Response:()=>Nt,StreamHandlerRequest:()=>z,StreamInfo:()=>W,StreamOpenRequest:()=>w});var yt=F(lt(),1),fe=F(ne(),1),he=F(x(),1),gt=F(Et(),1),ae=F(se(),1);function Oe(){he.default._configure(),yt.default._configure(fe.default),gt.default._configure(ae.default)}Oe();var de=["uint64","int64","sint64","fixed64","sfixed64"];function Te(i){for(let n of de){if(i[n]==null)continue;let e=i[n];i[n]=function(){return BigInt(e.call(this).toString())}}return i}function mt(i){return Te(new yt.default(i))}function xe(i){for(let n of de){if(i[n]==null)continue;let e=i[n];i[n]=function(r){return e.call(this,r.toString())}}return i}function kt(){return xe(gt.default.create())}function p(i,n){let e=mt(i instanceof Uint8Array?i:i.subarray());return n.decode(e)}function E(i,n){let e=kt();return n.encode(i,e,{lengthDelimited:!1}),e.finish()}var C;(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"})(C||(C={}));function it(i,n,e,r){return{name:i,type:n,encode:e,decode:r}}function I(i){function n(t){if(i[t.toString()]==null)throw new Error("Invalid enum value");return i[t]}let e=function(o,c){let s=n(o);c.int32(s)},r=function(o){let c=o.int32();return n(c)};return it("enum",C.VARINT,e,r)}function y(i,n){return it("message",C.LENGTH_DELIMITED,i,n)}var _t;(function(i){let n;(function(t){t.IDENTIFY="IDENTIFY",t.CONNECT="CONNECT",t.STREAM_OPEN="STREAM_OPEN",t.STREAM_HANDLER="STREAM_HANDLER",t.DHT="DHT",t.LIST_PEERS="LIST_PEERS",t.CONNMANAGER="CONNMANAGER",t.DISCONNECT="DISCONNECT",t.PUBSUB="PUBSUB",t.PEERSTORE="PEERSTORE"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.IDENTIFY=0]="IDENTIFY",t[t.CONNECT=1]="CONNECT",t[t.STREAM_OPEN=2]="STREAM_OPEN",t[t.STREAM_HANDLER=3]="STREAM_HANDLER",t[t.DHT=4]="DHT",t[t.LIST_PEERS=5]="LIST_PEERS",t[t.CONNMANAGER=6]="CONNMANAGER",t[t.DISCONNECT=7]="DISCONNECT",t[t.PUBSUB=8]="PUBSUB",t[t.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.connect!=null&&(o.uint32(18),R.codec().encode(t.connect,o)),t.streamOpen!=null&&(o.uint32(26),w.codec().encode(t.streamOpen,o)),t.streamHandler!=null&&(o.uint32(34),z.codec().encode(t.streamHandler,o)),t.dht!=null&&(o.uint32(42),K.codec().encode(t.dht,o)),t.connManager!=null&&(o.uint32(50),$.codec().encode(t.connManager,o)),t.disconnect!=null&&(o.uint32(58),J.codec().encode(t.disconnect,o)),t.pubsub!=null&&(o.uint32(66),X.codec().encode(t.pubsub,o)),t.peerStore!=null&&(o.uint32(74),Y.codec().encode(t.peerStore,o)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.connect=R.codec().decode(t,t.uint32());break;case 3:c.streamOpen=w.codec().decode(t,t.uint32());break;case 4:c.streamHandler=z.codec().decode(t,t.uint32());break;case 5:c.dht=K.codec().decode(t,t.uint32());break;case 6:c.connManager=$.codec().decode(t,t.uint32());break;case 7:c.disconnect=J.codec().decode(t,t.uint32());break;case 8:c.pubsub=X.codec().decode(t,t.uint32());break;case 9:c.peerStore=Y.codec().decode(t,t.uint32());break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(_t||(_t={}));var Nt;(function(i){let n;(function(t){t.OK="OK",t.ERROR="ERROR"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.OK=0]="OK",t[t.ERROR=1]="ERROR"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{if(c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.error!=null&&(o.uint32(18),H.codec().encode(t.error,o)),t.streamInfo!=null&&(o.uint32(26),W.codec().encode(t.streamInfo,o)),t.identify!=null&&(o.uint32(34),M.codec().encode(t.identify,o)),t.dht!=null&&(o.uint32(42),Z.codec().encode(t.dht,o)),t.peers!=null)for(let s of t.peers)o.uint32(50),S.codec().encode(s,o);t.pubsub!=null&&(o.uint32(58),Q.codec().encode(t.pubsub,o)),t.peerStore!=null&&(o.uint32(66),V.codec().encode(t.peerStore,o)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={peers:[]},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.error=H.codec().decode(t,t.uint32());break;case 3:c.streamInfo=W.codec().decode(t,t.uint32());break;case 4:c.identify=M.codec().decode(t,t.uint32());break;case 5:c.dht=Z.codec().decode(t,t.uint32());break;case 6:c.peers.push(S.codec().decode(t,t.uint32()));break;case 7:c.pubsub=Q.codec().decode(t,t.uint32());break;case 8:c.peerStore=V.codec().decode(t,t.uint32());break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(Nt||(Nt={}));var M;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.id!=null&&e.id.byteLength>0&&(r.uint32(10),r.bytes(e.id)),e.addrs!=null)for(let o of e.addrs)r.uint32(18),r.bytes(o);t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={id:new Uint8Array(0),addrs:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.id=e.bytes();break;case 2:t.addrs.push(e.bytes());break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(M||(M={}));var R;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.peer!=null&&e.peer.byteLength>0&&(r.uint32(10),r.bytes(e.peer)),e.addrs!=null)for(let o of e.addrs)r.uint32(18),r.bytes(o);e.timeout!=null&&(r.uint32(24),r.int64(e.timeout)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={peer:new Uint8Array(0),addrs:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.peer=e.bytes();break;case 2:t.addrs.push(e.bytes());break;case 3:t.timeout=e.int64();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(R||(R={}));var w;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.peer!=null&&e.peer.byteLength>0&&(r.uint32(10),r.bytes(e.peer)),e.proto!=null)for(let o of e.proto)r.uint32(18),r.string(o);e.timeout!=null&&(r.uint32(24),r.int64(e.timeout)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={peer:new Uint8Array(0),proto:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.peer=e.bytes();break;case 2:t.proto.push(e.string());break;case 3:t.timeout=e.int64();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(w||(w={}));var z;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.addr!=null&&e.addr.byteLength>0&&(r.uint32(10),r.bytes(e.addr)),e.proto!=null)for(let o of e.proto)r.uint32(18),r.string(o);t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={addr:new Uint8Array(0),proto:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.addr=e.bytes();break;case 2:t.proto.push(e.string());break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(z||(z={}));var H;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{t.lengthDelimited!==!1&&r.fork(),e.msg!=null&&e.msg!==""&&(r.uint32(10),r.string(e.msg)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={msg:""},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.msg=e.string();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(H||(H={}));var W;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{t.lengthDelimited!==!1&&r.fork(),e.peer!=null&&e.peer.byteLength>0&&(r.uint32(10),r.bytes(e.peer)),e.addr!=null&&e.addr.byteLength>0&&(r.uint32(18),r.bytes(e.addr)),e.proto!=null&&e.proto!==""&&(r.uint32(26),r.string(e.proto)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.peer=e.bytes();break;case 2:t.addr=e.bytes();break;case 3:t.proto=e.string();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(W||(W={}));var K;(function(i){let n;(function(t){t.FIND_PEER="FIND_PEER",t.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",t.FIND_PROVIDERS="FIND_PROVIDERS",t.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",t.GET_PUBLIC_KEY="GET_PUBLIC_KEY",t.GET_VALUE="GET_VALUE",t.SEARCH_VALUE="SEARCH_VALUE",t.PUT_VALUE="PUT_VALUE",t.PROVIDE="PROVIDE"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.FIND_PEER=0]="FIND_PEER",t[t.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",t[t.FIND_PROVIDERS=2]="FIND_PROVIDERS",t[t.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",t[t.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",t[t.GET_VALUE=5]="GET_VALUE",t[t.SEARCH_VALUE=6]="SEARCH_VALUE",t[t.PUT_VALUE=7]="PUT_VALUE",t[t.PROVIDE=8]="PROVIDE"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.peer!=null&&(o.uint32(18),o.bytes(t.peer)),t.cid!=null&&(o.uint32(26),o.bytes(t.cid)),t.key!=null&&(o.uint32(34),o.bytes(t.key)),t.value!=null&&(o.uint32(42),o.bytes(t.value)),t.count!=null&&(o.uint32(48),o.int32(t.count)),t.timeout!=null&&(o.uint32(56),o.int64(t.timeout)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.peer=t.bytes();break;case 3:c.cid=t.bytes();break;case 4:c.key=t.bytes();break;case 5:c.value=t.bytes();break;case 6:c.count=t.int32();break;case 7:c.timeout=t.int64();break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(K||(K={}));var Z;(function(i){let n;(function(t){t.BEGIN="BEGIN",t.VALUE="VALUE",t.END="END"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.BEGIN=0]="BEGIN",t[t.VALUE=1]="VALUE",t[t.END=2]="END"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.peer!=null&&(o.uint32(18),S.codec().encode(t.peer,o)),t.value!=null&&(o.uint32(26),o.bytes(t.value)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.peer=S.codec().decode(t,t.uint32());break;case 3:c.value=t.bytes();break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(Z||(Z={}));var S;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.id!=null&&e.id.byteLength>0&&(r.uint32(10),r.bytes(e.id)),e.addrs!=null)for(let o of e.addrs)r.uint32(18),r.bytes(o);t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={id:new Uint8Array(0),addrs:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.id=e.bytes();break;case 2:t.addrs.push(e.bytes());break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(S||(S={}));var $;(function(i){let n;(function(t){t.TAG_PEER="TAG_PEER",t.UNTAG_PEER="UNTAG_PEER",t.TRIM="TRIM"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.TAG_PEER=0]="TAG_PEER",t[t.UNTAG_PEER=1]="UNTAG_PEER",t[t.TRIM=2]="TRIM"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.peer!=null&&(o.uint32(18),o.bytes(t.peer)),t.tag!=null&&(o.uint32(26),o.string(t.tag)),t.weight!=null&&(o.uint32(32),o.int64(t.weight)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.peer=t.bytes();break;case 3:c.tag=t.string();break;case 4:c.weight=t.int64();break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})($||($={}));var J;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{t.lengthDelimited!==!1&&r.fork(),e.peer!=null&&e.peer.byteLength>0&&(r.uint32(10),r.bytes(e.peer)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={peer:new Uint8Array(0)},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.peer=e.bytes();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(J||(J={}));var X;(function(i){let n;(function(t){t.GET_TOPICS="GET_TOPICS",t.LIST_PEERS="LIST_PEERS",t.PUBLISH="PUBLISH",t.SUBSCRIBE="SUBSCRIBE"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.GET_TOPICS=0]="GET_TOPICS",t[t.LIST_PEERS=1]="LIST_PEERS",t[t.PUBLISH=2]="PUBLISH",t[t.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.topic!=null&&(o.uint32(18),o.string(t.topic)),t.data!=null&&(o.uint32(26),o.bytes(t.data)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.topic=t.string();break;case 3:c.data=t.bytes();break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(X||(X={}));var bt;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.from!=null&&(r.uint32(10),r.bytes(e.from)),e.data!=null&&(r.uint32(18),r.bytes(e.data)),e.seqno!=null&&(r.uint32(26),r.bytes(e.seqno)),e.topicIDs!=null)for(let o of e.topicIDs)r.uint32(34),r.string(o);e.signature!=null&&(r.uint32(42),r.bytes(e.signature)),e.key!=null&&(r.uint32(50),r.bytes(e.key)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={topicIDs:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.from=e.bytes();break;case 2:t.data=e.bytes();break;case 3:t.seqno=e.bytes();break;case 4:t.topicIDs.push(e.string());break;case 5:t.signature=e.bytes();break;case 6:t.key=e.bytes();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(bt||(bt={}));var Q;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.topics!=null)for(let o of e.topics)r.uint32(10),r.string(o);if(e.peerIDs!=null)for(let o of e.peerIDs)r.uint32(18),r.bytes(o);t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={topics:[],peerIDs:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.topics.push(e.string());break;case 2:t.peerIDs.push(e.bytes());break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(Q||(Q={}));var Y;(function(i){let n;(function(t){t.UNSPECIFIED="UNSPECIFIED",t.GET_PROTOCOLS="GET_PROTOCOLS",t.GET_PEER_INFO="GET_PEER_INFO"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.GET_PROTOCOLS=1]="GET_PROTOCOLS",t[t.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{if(c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.id!=null&&(o.uint32(18),o.bytes(t.id)),t.protos!=null)for(let s of t.protos)o.uint32(26),o.string(s);c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={protos:[]},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.id=t.bytes();break;case 3:c.protos.push(t.string());break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(Y||(Y={}));var V;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.peer!=null&&(r.uint32(10),S.codec().encode(e.peer,r)),e.protos!=null)for(let o of e.protos)r.uint32(18),r.string(o);t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={protos:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.peer=S.codec().decode(e,e.uint32());break;case 2:t.protos.push(e.string());break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(V||(V={}));return _e(ve);})();
|
|
2
|
+
"use strict";var Libp2PDaemonProtocol=(()=>{var pe=Object.create;var q=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty;var m=(i,n)=>()=>(n||i((n={exports:{}}).exports,n),n.exports),ke=(i,n)=>{for(var e in n)q(i,e,{get:n[e],enumerable:!0})},At=(i,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of ye(n))!me.call(i,t)&&t!==e&&q(i,t,{get:()=>n[t],enumerable:!(r=Ee(n,t))||r.enumerable});return i};var F=(i,n,e)=>(e=i!=null?pe(ge(i)):{},At(n||!i||!i.__esModule?q(e,"default",{value:i,enumerable:!0}):e,i)),_e=i=>At(q({},"__esModule",{value:!0}),i);var It=m((Ce,Bt)=>{"use strict";Bt.exports=Ne;function Ne(i,n){for(var e=new Array(arguments.length-1),r=0,t=2,o=!0;t<arguments.length;)e[r++]=arguments[t++];return new Promise(function(s,u){e[r]=function(h){if(o)if(o=!1,h)u(h);else{for(var k=new Array(arguments.length-1),O=0;O<k.length;)k[O++]=arguments[O];s.apply(null,k)}};try{i.apply(n||null,e)}catch(l){o&&(o=!1,u(l))}})}});var Ot=m(Lt=>{"use strict";var j=Lt;j.length=function(n){var e=n.length;if(!e)return 0;for(var r=0;--e%4>1&&n.charAt(e)==="=";)++r;return Math.ceil(n.length*3)/4-r};var U=new Array(64),Dt=new Array(123);for(N=0;N<64;)Dt[U[N]=N<26?N+65:N<52?N+71:N<62?N-4:N-59|43]=N++;var N;j.encode=function(n,e,r){for(var t=null,o=[],c=0,s=0,u;e<r;){var l=n[e++];switch(s){case 0:o[c++]=U[l>>2],u=(l&3)<<4,s=1;break;case 1:o[c++]=U[u|l>>4],u=(l&15)<<2,s=2;break;case 2:o[c++]=U[u|l>>6],o[c++]=U[l&63],s=0;break}c>8191&&((t||(t=[])).push(String.fromCharCode.apply(String,o)),c=0)}return s&&(o[c++]=U[u],o[c++]=61,s===1&&(o[c++]=61)),t?(c&&t.push(String.fromCharCode.apply(String,o.slice(0,c))),t.join("")):String.fromCharCode.apply(String,o.slice(0,c))};var St="invalid encoding";j.decode=function(n,e,r){for(var t=r,o=0,c,s=0;s<n.length;){var u=n.charCodeAt(s++);if(u===61&&o>1)break;if((u=Dt[u])===void 0)throw Error(St);switch(o){case 0:c=u,o=1;break;case 1:e[r++]=c<<2|(u&48)>>4,c=u,o=2;break;case 2:e[r++]=(c&15)<<4|(u&60)>>2,c=u,o=3;break;case 3:e[r++]=(c&3)<<6|u,o=0;break}}if(o===1)throw Error(St);return r-t};j.test=function(n){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(n)}});var xt=m((Pe,Tt)=>{"use strict";Tt.exports=tt;function tt(){this._listeners={}}tt.prototype.on=function(n,e,r){return(this._listeners[n]||(this._listeners[n]=[])).push({fn:e,ctx:r||this}),this};tt.prototype.off=function(n,e){if(n===void 0)this._listeners={};else if(e===void 0)this._listeners[n]=[];else for(var r=this._listeners[n],t=0;t<r.length;)r[t].fn===e?r.splice(t,1):++t;return this};tt.prototype.emit=function(n){var e=this._listeners[n];if(e){for(var r=[],t=1;t<arguments.length;)r.push(arguments[t++]);for(t=0;t<e.length;)e[t].fn.apply(e[t++].ctx,r)}return this}});var Mt=m((Ge,Gt)=>{"use strict";Gt.exports=vt(vt);function vt(i){return typeof Float32Array<"u"?function(){var n=new Float32Array([-0]),e=new Uint8Array(n.buffer),r=e[3]===128;function t(u,l,h){n[0]=u,l[h]=e[0],l[h+1]=e[1],l[h+2]=e[2],l[h+3]=e[3]}function o(u,l,h){n[0]=u,l[h]=e[3],l[h+1]=e[2],l[h+2]=e[1],l[h+3]=e[0]}i.writeFloatLE=r?t:o,i.writeFloatBE=r?o:t;function c(u,l){return e[0]=u[l],e[1]=u[l+1],e[2]=u[l+2],e[3]=u[l+3],n[0]}function s(u,l){return e[3]=u[l],e[2]=u[l+1],e[1]=u[l+2],e[0]=u[l+3],n[0]}i.readFloatLE=r?c:s,i.readFloatBE=r?s:c}():function(){function n(r,t,o,c){var s=t<0?1:0;if(s&&(t=-t),t===0)r(1/t>0?0:2147483648,o,c);else if(isNaN(t))r(2143289344,o,c);else if(t>34028234663852886e22)r((s<<31|2139095040)>>>0,o,c);else if(t<11754943508222875e-54)r((s<<31|Math.round(t/1401298464324817e-60))>>>0,o,c);else{var u=Math.floor(Math.log(t)/Math.LN2),l=Math.round(t*Math.pow(2,-u)*8388608)&8388607;r((s<<31|u+127<<23|l)>>>0,o,c)}}i.writeFloatLE=n.bind(null,Ut),i.writeFloatBE=n.bind(null,Ct);function e(r,t,o){var c=r(t,o),s=(c>>31)*2+1,u=c>>>23&255,l=c&8388607;return u===255?l?NaN:s*(1/0):u===0?s*1401298464324817e-60*l:s*Math.pow(2,u-150)*(l+8388608)}i.readFloatLE=e.bind(null,Ft),i.readFloatBE=e.bind(null,Pt)}(),typeof Float64Array<"u"?function(){var n=new Float64Array([-0]),e=new Uint8Array(n.buffer),r=e[7]===128;function t(u,l,h){n[0]=u,l[h]=e[0],l[h+1]=e[1],l[h+2]=e[2],l[h+3]=e[3],l[h+4]=e[4],l[h+5]=e[5],l[h+6]=e[6],l[h+7]=e[7]}function o(u,l,h){n[0]=u,l[h]=e[7],l[h+1]=e[6],l[h+2]=e[5],l[h+3]=e[4],l[h+4]=e[3],l[h+5]=e[2],l[h+6]=e[1],l[h+7]=e[0]}i.writeDoubleLE=r?t:o,i.writeDoubleBE=r?o:t;function c(u,l){return e[0]=u[l],e[1]=u[l+1],e[2]=u[l+2],e[3]=u[l+3],e[4]=u[l+4],e[5]=u[l+5],e[6]=u[l+6],e[7]=u[l+7],n[0]}function s(u,l){return e[7]=u[l],e[6]=u[l+1],e[5]=u[l+2],e[4]=u[l+3],e[3]=u[l+4],e[2]=u[l+5],e[1]=u[l+6],e[0]=u[l+7],n[0]}i.readDoubleLE=r?c:s,i.readDoubleBE=r?s:c}():function(){function n(r,t,o,c,s,u){var l=c<0?1:0;if(l&&(c=-c),c===0)r(0,s,u+t),r(1/c>0?0:2147483648,s,u+o);else if(isNaN(c))r(0,s,u+t),r(2146959360,s,u+o);else if(c>17976931348623157e292)r(0,s,u+t),r((l<<31|2146435072)>>>0,s,u+o);else{var h;if(c<22250738585072014e-324)h=c/5e-324,r(h>>>0,s,u+t),r((l<<31|h/4294967296)>>>0,s,u+o);else{var k=Math.floor(Math.log(c)/Math.LN2);k===1024&&(k=1023),h=c*Math.pow(2,-k),r(h*4503599627370496>>>0,s,u+t),r((l<<31|k+1023<<20|h*1048576&1048575)>>>0,s,u+o)}}}i.writeDoubleLE=n.bind(null,Ut,0,4),i.writeDoubleBE=n.bind(null,Ct,4,0);function e(r,t,o,c,s){var u=r(c,s+t),l=r(c,s+o),h=(l>>31)*2+1,k=l>>>20&2047,O=4294967296*(l&1048575)+u;return k===2047?O?NaN:h*(1/0):k===0?h*5e-324*O:h*Math.pow(2,k-1075)*(O+4503599627370496)}i.readDoubleLE=e.bind(null,Ft,0,4),i.readDoubleBE=e.bind(null,Pt,4,0)}(),i}function Ut(i,n,e){n[e]=i&255,n[e+1]=i>>>8&255,n[e+2]=i>>>16&255,n[e+3]=i>>>24}function Ct(i,n,e){n[e]=i>>>24,n[e+1]=i>>>16&255,n[e+2]=i>>>8&255,n[e+3]=i&255}function Ft(i,n){return(i[n]|i[n+1]<<8|i[n+2]<<16|i[n+3]<<24)>>>0}function Pt(i,n){return(i[n]<<24|i[n+1]<<16|i[n+2]<<8|i[n+3])>>>0}});var Rt=m((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(i){}return null}});var zt=m(wt=>{"use strict";var rt=wt;rt.length=function(n){for(var e=0,r=0,t=0;t<n.length;++t)r=n.charCodeAt(t),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(n.charCodeAt(t+1)&64512)===56320?(++t,e+=4):e+=3;return e};rt.read=function(n,e,r){var t=r-e;if(t<1)return"";for(var o=null,c=[],s=0,u;e<r;)u=n[e++],u<128?c[s++]=u:u>191&&u<224?c[s++]=(u&31)<<6|n[e++]&63:u>239&&u<365?(u=((u&7)<<18|(n[e++]&63)<<12|(n[e++]&63)<<6|n[e++]&63)-65536,c[s++]=55296+(u>>10),c[s++]=56320+(u&1023)):c[s++]=(u&15)<<12|(n[e++]&63)<<6|n[e++]&63,s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,c)),s=0);return o?(s&&o.push(String.fromCharCode.apply(String,c.slice(0,s))),o.join("")):String.fromCharCode.apply(String,c.slice(0,s))};rt.write=function(n,e,r){for(var t=r,o,c,s=0;s<n.length;++s)o=n.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((c=n.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(c&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-t}});var Wt=m((Re,Ht)=>{"use strict";Ht.exports=be;function be(i,n,e){var r=e||8192,t=r>>>1,o=null,c=r;return function(u){if(u<1||u>t)return i(u);c+u>r&&(o=i(r),c=0);var l=n.call(o,c,c+=u);return c&7&&(c=(c|7)+1),l}}});var Zt=m((we,Kt)=>{"use strict";Kt.exports=g;var P=x();function g(i,n){this.lo=i>>>0,this.hi=n>>>0}var T=g.zero=new g(0,0);T.toNumber=function(){return 0};T.zzEncode=T.zzDecode=function(){return this};T.length=function(){return 1};var Ae=g.zeroHash="\0\0\0\0\0\0\0\0";g.fromNumber=function(n){if(n===0)return T;var e=n<0;e&&(n=-n);var r=n>>>0,t=(n-r)/4294967296>>>0;return e&&(t=~t>>>0,r=~r>>>0,++r>4294967295&&(r=0,++t>4294967295&&(t=0))),new g(r,t)};g.from=function(n){if(typeof n=="number")return g.fromNumber(n);if(P.isString(n))if(P.Long)n=P.Long.fromString(n);else return g.fromNumber(parseInt(n,10));return n.low||n.high?new g(n.low>>>0,n.high>>>0):T};g.prototype.toNumber=function(n){if(!n&&this.hi>>>31){var e=~this.lo+1>>>0,r=~this.hi>>>0;return e||(r=r+1>>>0),-(e+r*4294967296)}return this.lo+this.hi*4294967296};g.prototype.toLong=function(n){return P.Long?new P.Long(this.lo|0,this.hi|0,!!n):{low:this.lo|0,high:this.hi|0,unsigned:!!n}};var D=String.prototype.charCodeAt;g.fromHash=function(n){return n===Ae?T:new g((D.call(n,0)|D.call(n,1)<<8|D.call(n,2)<<16|D.call(n,3)<<24)>>>0,(D.call(n,4)|D.call(n,5)<<8|D.call(n,6)<<16|D.call(n,7)<<24)>>>0)};g.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};g.prototype.zzEncode=function(){var n=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^n)>>>0,this.lo=(this.lo<<1^n)>>>0,this};g.prototype.zzDecode=function(){var n=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^n)>>>0,this.hi=(this.hi>>>1^n)>>>0,this};g.prototype.length=function(){var n=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return r===0?e===0?n<16384?n<128?1:2:n<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:r<128?9:10}});var x=m(ot=>{"use strict";var f=ot;f.asPromise=It();f.base64=Ot();f.EventEmitter=xt();f.float=Mt();f.inquire=Rt();f.utf8=zt();f.pool=Wt();f.LongBits=Zt();f.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);f.global=f.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||ot;f.emptyArray=Object.freeze?Object.freeze([]):[];f.emptyObject=Object.freeze?Object.freeze({}):{};f.isInteger=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};f.isString=function(n){return typeof n=="string"||n instanceof String};f.isObject=function(n){return n&&typeof n=="object"};f.isset=f.isSet=function(n,e){var r=n[e];return r!=null&&n.hasOwnProperty(e)?typeof r!="object"||(Array.isArray(r)?r.length:Object.keys(r).length)>0:!1};f.Buffer=function(){try{var i=f.inquire("buffer").Buffer;return i.prototype.utf8Write?i:null}catch{return null}}();f._Buffer_from=null;f._Buffer_allocUnsafe=null;f.newBuffer=function(n){return typeof n=="number"?f.Buffer?f._Buffer_allocUnsafe(n):new f.Array(n):f.Buffer?f._Buffer_from(n):typeof Uint8Array>"u"?n:new Uint8Array(n)};f.Array=typeof Uint8Array<"u"?Uint8Array:Array;f.Long=f.global.dcodeIO&&f.global.dcodeIO.Long||f.global.Long||f.inquire("long");f.key2Re=/^true|false|0|1$/;f.key32Re=/^-?(?:0|[1-9][0-9]*)$/;f.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;f.longToHash=function(n){return n?f.LongBits.from(n).toHash():f.LongBits.zeroHash};f.longFromHash=function(n,e){var r=f.LongBits.fromHash(n);return f.Long?f.Long.fromBits(r.lo,r.hi,e):r.toNumber(!!e)};function $t(i,n,e){for(var r=Object.keys(n),t=0;t<r.length;++t)(i[r[t]]===void 0||!e)&&(i[r[t]]=n[r[t]]);return i}f.merge=$t;f.lcFirst=function(n){return n.charAt(0).toLowerCase()+n.substring(1)};function Jt(i){function n(e,r){if(!(this instanceof n))return new n(e,r);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,n):Object.defineProperty(this,"stack",{value:new Error().stack||""}),r&&$t(this,r)}return n.prototype=Object.create(Error.prototype,{constructor:{value:n,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return i},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),n}f.newError=Jt;f.ProtocolError=Jt("ProtocolError");f.oneOfGetter=function(n){for(var e={},r=0;r<n.length;++r)e[n[r]]=1;return function(){for(var t=Object.keys(this),o=t.length-1;o>-1;--o)if(e[t[o]]===1&&this[t[o]]!==void 0&&this[t[o]]!==null)return t[o]}};f.oneOfSetter=function(n){return function(e){for(var r=0;r<n.length;++r)n[r]!==e&&delete this[n[r]]}};f.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};f._configure=function(){var i=f.Buffer;if(!i){f._Buffer_from=f._Buffer_allocUnsafe=null;return}f._Buffer_from=i.from!==Uint8Array.from&&i.from||function(e,r){return new i(e,r)},f._Buffer_allocUnsafe=i.allocUnsafe||function(e){return new i(e)}}});var lt=m((He,qt)=>{"use strict";qt.exports=d;var A=x(),ut,Yt=A.LongBits,Be=A.utf8;function b(i,n){return RangeError("index out of range: "+i.pos+" + "+(n||1)+" > "+i.len)}function d(i){this.buf=i,this.pos=0,this.len=i.length}var Xt=typeof Uint8Array<"u"?function(n){if(n instanceof Uint8Array||Array.isArray(n))return new d(n);throw Error("illegal buffer")}:function(n){if(Array.isArray(n))return new d(n);throw Error("illegal buffer")},Vt=function(){return A.Buffer?function(e){return(d.create=function(t){return A.Buffer.isBuffer(t)?new ut(t):Xt(t)})(e)}:Xt};d.create=Vt();d.prototype._slice=A.Array.prototype.subarray||A.Array.prototype.slice;d.prototype.uint32=function(){var n=4294967295;return function(){if(n=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(n=(n|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(n=(n|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(n=(n|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(n=(n|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return n;if((this.pos+=5)>this.len)throw this.pos=this.len,b(this,10);return n}}();d.prototype.int32=function(){return this.uint32()|0};d.prototype.sint32=function(){var n=this.uint32();return n>>>1^-(n&1)|0};function ct(){var i=new Yt(0,0),n=0;if(this.len-this.pos>4){for(;n<4;++n)if(i.lo=(i.lo|(this.buf[this.pos]&127)<<n*7)>>>0,this.buf[this.pos++]<128)return i;if(i.lo=(i.lo|(this.buf[this.pos]&127)<<28)>>>0,i.hi=(i.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return i;n=0}else{for(;n<3;++n){if(this.pos>=this.len)throw b(this);if(i.lo=(i.lo|(this.buf[this.pos]&127)<<n*7)>>>0,this.buf[this.pos++]<128)return i}return i.lo=(i.lo|(this.buf[this.pos++]&127)<<n*7)>>>0,i}if(this.len-this.pos>4){for(;n<5;++n)if(i.hi=(i.hi|(this.buf[this.pos]&127)<<n*7+3)>>>0,this.buf[this.pos++]<128)return i}else for(;n<5;++n){if(this.pos>=this.len)throw b(this);if(i.hi=(i.hi|(this.buf[this.pos]&127)<<n*7+3)>>>0,this.buf[this.pos++]<128)return i}throw Error("invalid varint encoding")}d.prototype.bool=function(){return this.uint32()!==0};function et(i,n){return(i[n-4]|i[n-3]<<8|i[n-2]<<16|i[n-1]<<24)>>>0}d.prototype.fixed32=function(){if(this.pos+4>this.len)throw b(this,4);return et(this.buf,this.pos+=4)};d.prototype.sfixed32=function(){if(this.pos+4>this.len)throw b(this,4);return et(this.buf,this.pos+=4)|0};function Qt(){if(this.pos+8>this.len)throw b(this,8);return new Yt(et(this.buf,this.pos+=4),et(this.buf,this.pos+=4))}d.prototype.float=function(){if(this.pos+4>this.len)throw b(this,4);var n=A.float.readFloatLE(this.buf,this.pos);return this.pos+=4,n};d.prototype.double=function(){if(this.pos+8>this.len)throw b(this,4);var n=A.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,n};d.prototype.bytes=function(){var n=this.uint32(),e=this.pos,r=this.pos+n;if(r>this.len)throw b(this,n);return this.pos+=n,Array.isArray(this.buf)?this.buf.slice(e,r):e===r?new this.buf.constructor(0):this._slice.call(this.buf,e,r)};d.prototype.string=function(){var n=this.bytes();return Be.read(n,0,n.length)};d.prototype.skip=function(n){if(typeof n=="number"){if(this.pos+n>this.len)throw b(this,n);this.pos+=n}else do if(this.pos>=this.len)throw b(this);while(this.buf[this.pos++]&128);return this};d.prototype.skipType=function(i){switch(i){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(i=this.uint32()&7)!==4;)this.skipType(i);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+i+" at offset "+this.pos)}return this};d._configure=function(i){ut=i,d.create=Vt(),ut._configure();var n=A.Long?"toLong":"toNumber";A.merge(d.prototype,{int64:function(){return ct.call(this)[n](!1)},uint64:function(){return ct.call(this)[n](!0)},sint64:function(){return ct.call(this).zzDecode()[n](!1)},fixed64:function(){return Qt.call(this)[n](!0)},sfixed64:function(){return Qt.call(this)[n](!1)}})}});var ne=m((We,ee)=>{"use strict";ee.exports=v;var te=lt();(v.prototype=Object.create(te.prototype)).constructor=v;var jt=x();function v(i){te.call(this,i)}v._configure=function(){jt.Buffer&&(v.prototype._slice=jt.Buffer.prototype.slice)};v.prototype.string=function(){var n=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+n,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+n,this.len))};v._configure()});var Et=m((Ke,ce)=>{"use strict";ce.exports=a;var _=x(),st,nt=_.LongBits,ie=_.base64,re=_.utf8;function G(i,n,e){this.fn=i,this.len=n,this.next=void 0,this.val=e}function ht(){}function Ie(i){this.head=i.head,this.tail=i.tail,this.len=i.len,this.next=i.states}function a(){this.len=0,this.head=new G(ht,0,0),this.tail=this.head,this.states=null}var oe=function(){return _.Buffer?function(){return(a.create=function(){return new st})()}:function(){return new a}};a.create=oe();a.alloc=function(n){return new _.Array(n)};_.Array!==Array&&(a.alloc=_.pool(a.alloc,_.Array.prototype.subarray));a.prototype._push=function(n,e,r){return this.tail=this.tail.next=new G(n,e,r),this.len+=e,this};function at(i,n,e){n[e]=i&255}function Se(i,n,e){for(;i>127;)n[e++]=i&127|128,i>>>=7;n[e]=i}function dt(i,n){this.len=i,this.next=void 0,this.val=n}dt.prototype=Object.create(G.prototype);dt.prototype.fn=Se;a.prototype.uint32=function(n){return this.len+=(this.tail=this.tail.next=new dt((n=n>>>0)<128?1:n<16384?2:n<2097152?3:n<268435456?4:5,n)).len,this};a.prototype.int32=function(n){return n<0?this._push(pt,10,nt.fromNumber(n)):this.uint32(n)};a.prototype.sint32=function(n){return this.uint32((n<<1^n>>31)>>>0)};function pt(i,n,e){for(;i.hi;)n[e++]=i.lo&127|128,i.lo=(i.lo>>>7|i.hi<<25)>>>0,i.hi>>>=7;for(;i.lo>127;)n[e++]=i.lo&127|128,i.lo=i.lo>>>7;n[e++]=i.lo}a.prototype.uint64=function(n){var e=nt.from(n);return this._push(pt,e.length(),e)};a.prototype.int64=a.prototype.uint64;a.prototype.sint64=function(n){var e=nt.from(n).zzEncode();return this._push(pt,e.length(),e)};a.prototype.bool=function(n){return this._push(at,1,n?1:0)};function ft(i,n,e){n[e]=i&255,n[e+1]=i>>>8&255,n[e+2]=i>>>16&255,n[e+3]=i>>>24}a.prototype.fixed32=function(n){return this._push(ft,4,n>>>0)};a.prototype.sfixed32=a.prototype.fixed32;a.prototype.fixed64=function(n){var e=nt.from(n);return this._push(ft,4,e.lo)._push(ft,4,e.hi)};a.prototype.sfixed64=a.prototype.fixed64;a.prototype.float=function(n){return this._push(_.float.writeFloatLE,4,n)};a.prototype.double=function(n){return this._push(_.float.writeDoubleLE,8,n)};var De=_.Array.prototype.set?function(n,e,r){e.set(n,r)}:function(n,e,r){for(var t=0;t<n.length;++t)e[r+t]=n[t]};a.prototype.bytes=function(n){var e=n.length>>>0;if(!e)return this._push(at,1,0);if(_.isString(n)){var r=a.alloc(e=ie.length(n));ie.decode(n,r,0),n=r}return this.uint32(e)._push(De,e,n)};a.prototype.string=function(n){var e=re.length(n);return e?this.uint32(e)._push(re.write,e,n):this._push(at,1,0)};a.prototype.fork=function(){return this.states=new Ie(this),this.head=this.tail=new G(ht,0,0),this.len=0,this};a.prototype.reset=function(){return this.states?(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 G(ht,0,0),this.len=0),this};a.prototype.ldelim=function(){var n=this.head,e=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=n.next,this.tail=e,this.len+=r),this};a.prototype.finish=function(){for(var n=this.head.next,e=this.constructor.alloc(this.len),r=0;n;)n.fn(n.val,e,r),r+=n.len,n=n.next;return e};a._configure=function(i){st=i,a.create=oe(),st._configure()}});var se=m((Ze,le)=>{"use strict";le.exports=B;var ue=Et();(B.prototype=Object.create(ue.prototype)).constructor=B;var L=x();function B(){ue.call(this)}B._configure=function(){B.alloc=L._Buffer_allocUnsafe,B.writeBytesBuffer=L.Buffer&&L.Buffer.prototype instanceof Uint8Array&&L.Buffer.prototype.set.name==="set"?function(n,e,r){e.set(n,r)}:function(n,e,r){if(n.copy)n.copy(e,r,0,n.length);else for(var t=0;t<n.length;)e[r++]=n[t++]}};B.prototype.bytes=function(n){L.isString(n)&&(n=L._Buffer_from(n,"base64"));var e=n.length>>>0;return this.uint32(e),e&&this._push(B.writeBytesBuffer,e,n),this};function Le(i,n,e){i.length<40?L.utf8.write(i,n,e):n.utf8Write?n.utf8Write(i,e):n.write(i,e)}B.prototype.string=function(n){var e=L.Buffer.byteLength(n);return this.uint32(e),e&&this._push(Le,e,n),this};B._configure()});var ve={};ke(ve,{ConnManagerRequest:()=>$,ConnectRequest:()=>R,DHTRequest:()=>K,DHTResponse:()=>Z,DisconnectRequest:()=>J,ErrorResponse:()=>H,IdentifyResponse:()=>M,PSMessage:()=>bt,PSRequest:()=>X,PSResponse:()=>Q,PeerInfo:()=>S,PeerstoreRequest:()=>Y,PeerstoreResponse:()=>V,Request:()=>_t,Response:()=>Nt,StreamHandlerRequest:()=>z,StreamInfo:()=>W,StreamOpenRequest:()=>w});var yt=F(lt(),1),fe=F(ne(),1),he=F(x(),1),gt=F(Et(),1),ae=F(se(),1);function Oe(){he.default._configure(),yt.default._configure(fe.default),gt.default._configure(ae.default)}Oe();var de=["uint64","int64","sint64","fixed64","sfixed64"];function Te(i){for(let n of de){if(i[n]==null)continue;let e=i[n];i[n]=function(){return BigInt(e.call(this).toString())}}return i}function mt(i){return Te(new yt.default(i))}function xe(i){for(let n of de){if(i[n]==null)continue;let e=i[n];i[n]=function(r){return e.call(this,r.toString())}}return i}function kt(){return xe(gt.default.create())}function p(i,n){let e=mt(i instanceof Uint8Array?i:i.subarray());return n.decode(e)}function E(i,n){let e=kt();return n.encode(i,e,{lengthDelimited:!1}),e.finish()}var C;(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"})(C||(C={}));function it(i,n,e,r){return{name:i,type:n,encode:e,decode:r}}function I(i){function n(t){if(i[t.toString()]==null)throw new Error("Invalid enum value");return i[t]}let e=function(o,c){let s=n(o);c.int32(s)},r=function(o){let c=o.int32();return n(c)};return it("enum",C.VARINT,e,r)}function y(i,n){return it("message",C.LENGTH_DELIMITED,i,n)}var _t;(function(i){let n;(function(t){t.IDENTIFY="IDENTIFY",t.CONNECT="CONNECT",t.STREAM_OPEN="STREAM_OPEN",t.STREAM_HANDLER="STREAM_HANDLER",t.DHT="DHT",t.LIST_PEERS="LIST_PEERS",t.CONNMANAGER="CONNMANAGER",t.DISCONNECT="DISCONNECT",t.PUBSUB="PUBSUB",t.PEERSTORE="PEERSTORE"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.IDENTIFY=0]="IDENTIFY",t[t.CONNECT=1]="CONNECT",t[t.STREAM_OPEN=2]="STREAM_OPEN",t[t.STREAM_HANDLER=3]="STREAM_HANDLER",t[t.DHT=4]="DHT",t[t.LIST_PEERS=5]="LIST_PEERS",t[t.CONNMANAGER=6]="CONNMANAGER",t[t.DISCONNECT=7]="DISCONNECT",t[t.PUBSUB=8]="PUBSUB",t[t.PEERSTORE=9]="PEERSTORE"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.connect!=null&&(o.uint32(18),R.codec().encode(t.connect,o)),t.streamOpen!=null&&(o.uint32(26),w.codec().encode(t.streamOpen,o)),t.streamHandler!=null&&(o.uint32(34),z.codec().encode(t.streamHandler,o)),t.dht!=null&&(o.uint32(42),K.codec().encode(t.dht,o)),t.connManager!=null&&(o.uint32(50),$.codec().encode(t.connManager,o)),t.disconnect!=null&&(o.uint32(58),J.codec().encode(t.disconnect,o)),t.pubsub!=null&&(o.uint32(66),X.codec().encode(t.pubsub,o)),t.peerStore!=null&&(o.uint32(74),Y.codec().encode(t.peerStore,o)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.connect=R.codec().decode(t,t.uint32());break;case 3:c.streamOpen=w.codec().decode(t,t.uint32());break;case 4:c.streamHandler=z.codec().decode(t,t.uint32());break;case 5:c.dht=K.codec().decode(t,t.uint32());break;case 6:c.connManager=$.codec().decode(t,t.uint32());break;case 7:c.disconnect=J.codec().decode(t,t.uint32());break;case 8:c.pubsub=X.codec().decode(t,t.uint32());break;case 9:c.peerStore=Y.codec().decode(t,t.uint32());break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(_t||(_t={}));var Nt;(function(i){let n;(function(t){t.OK="OK",t.ERROR="ERROR"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.OK=0]="OK",t[t.ERROR=1]="ERROR"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{if(c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.error!=null&&(o.uint32(18),H.codec().encode(t.error,o)),t.streamInfo!=null&&(o.uint32(26),W.codec().encode(t.streamInfo,o)),t.identify!=null&&(o.uint32(34),M.codec().encode(t.identify,o)),t.dht!=null&&(o.uint32(42),Z.codec().encode(t.dht,o)),t.peers!=null)for(let s of t.peers)o.uint32(50),S.codec().encode(s,o);t.pubsub!=null&&(o.uint32(58),Q.codec().encode(t.pubsub,o)),t.peerStore!=null&&(o.uint32(66),V.codec().encode(t.peerStore,o)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={peers:[]},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.error=H.codec().decode(t,t.uint32());break;case 3:c.streamInfo=W.codec().decode(t,t.uint32());break;case 4:c.identify=M.codec().decode(t,t.uint32());break;case 5:c.dht=Z.codec().decode(t,t.uint32());break;case 6:c.peers.push(S.codec().decode(t,t.uint32()));break;case 7:c.pubsub=Q.codec().decode(t,t.uint32());break;case 8:c.peerStore=V.codec().decode(t,t.uint32());break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(Nt||(Nt={}));var M;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.id!=null&&e.id.byteLength>0&&(r.uint32(10),r.bytes(e.id)),e.addrs!=null)for(let o of e.addrs)r.uint32(18),r.bytes(o);t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={id:new Uint8Array(0),addrs:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.id=e.bytes();break;case 2:t.addrs.push(e.bytes());break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(M||(M={}));var R;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.peer!=null&&e.peer.byteLength>0&&(r.uint32(10),r.bytes(e.peer)),e.addrs!=null)for(let o of e.addrs)r.uint32(18),r.bytes(o);e.timeout!=null&&(r.uint32(24),r.int64(e.timeout)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={peer:new Uint8Array(0),addrs:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.peer=e.bytes();break;case 2:t.addrs.push(e.bytes());break;case 3:t.timeout=e.int64();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(R||(R={}));var w;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.peer!=null&&e.peer.byteLength>0&&(r.uint32(10),r.bytes(e.peer)),e.proto!=null)for(let o of e.proto)r.uint32(18),r.string(o);e.timeout!=null&&(r.uint32(24),r.int64(e.timeout)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={peer:new Uint8Array(0),proto:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.peer=e.bytes();break;case 2:t.proto.push(e.string());break;case 3:t.timeout=e.int64();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(w||(w={}));var z;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.addr!=null&&e.addr.byteLength>0&&(r.uint32(10),r.bytes(e.addr)),e.proto!=null)for(let o of e.proto)r.uint32(18),r.string(o);t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={addr:new Uint8Array(0),proto:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.addr=e.bytes();break;case 2:t.proto.push(e.string());break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(z||(z={}));var H;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{t.lengthDelimited!==!1&&r.fork(),e.msg!=null&&e.msg!==""&&(r.uint32(10),r.string(e.msg)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={msg:""},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.msg=e.string();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(H||(H={}));var W;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{t.lengthDelimited!==!1&&r.fork(),e.peer!=null&&e.peer.byteLength>0&&(r.uint32(10),r.bytes(e.peer)),e.addr!=null&&e.addr.byteLength>0&&(r.uint32(18),r.bytes(e.addr)),e.proto!=null&&e.proto!==""&&(r.uint32(26),r.string(e.proto)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.peer=e.bytes();break;case 2:t.addr=e.bytes();break;case 3:t.proto=e.string();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(W||(W={}));var K;(function(i){let n;(function(t){t.FIND_PEER="FIND_PEER",t.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",t.FIND_PROVIDERS="FIND_PROVIDERS",t.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",t.GET_PUBLIC_KEY="GET_PUBLIC_KEY",t.GET_VALUE="GET_VALUE",t.SEARCH_VALUE="SEARCH_VALUE",t.PUT_VALUE="PUT_VALUE",t.PROVIDE="PROVIDE"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.FIND_PEER=0]="FIND_PEER",t[t.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",t[t.FIND_PROVIDERS=2]="FIND_PROVIDERS",t[t.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",t[t.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",t[t.GET_VALUE=5]="GET_VALUE",t[t.SEARCH_VALUE=6]="SEARCH_VALUE",t[t.PUT_VALUE=7]="PUT_VALUE",t[t.PROVIDE=8]="PROVIDE"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.peer!=null&&(o.uint32(18),o.bytes(t.peer)),t.cid!=null&&(o.uint32(26),o.bytes(t.cid)),t.key!=null&&(o.uint32(34),o.bytes(t.key)),t.value!=null&&(o.uint32(42),o.bytes(t.value)),t.count!=null&&(o.uint32(48),o.int32(t.count)),t.timeout!=null&&(o.uint32(56),o.int64(t.timeout)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.peer=t.bytes();break;case 3:c.cid=t.bytes();break;case 4:c.key=t.bytes();break;case 5:c.value=t.bytes();break;case 6:c.count=t.int32();break;case 7:c.timeout=t.int64();break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(K||(K={}));var Z;(function(i){let n;(function(t){t.BEGIN="BEGIN",t.VALUE="VALUE",t.END="END"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.BEGIN=0]="BEGIN",t[t.VALUE=1]="VALUE",t[t.END=2]="END"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.peer!=null&&(o.uint32(18),S.codec().encode(t.peer,o)),t.value!=null&&(o.uint32(26),o.bytes(t.value)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.peer=S.codec().decode(t,t.uint32());break;case 3:c.value=t.bytes();break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(Z||(Z={}));var S;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.id!=null&&e.id.byteLength>0&&(r.uint32(10),r.bytes(e.id)),e.addrs!=null)for(let o of e.addrs)r.uint32(18),r.bytes(o);t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={id:new Uint8Array(0),addrs:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.id=e.bytes();break;case 2:t.addrs.push(e.bytes());break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(S||(S={}));var $;(function(i){let n;(function(t){t.TAG_PEER="TAG_PEER",t.UNTAG_PEER="UNTAG_PEER",t.TRIM="TRIM"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.TAG_PEER=0]="TAG_PEER",t[t.UNTAG_PEER=1]="UNTAG_PEER",t[t.TRIM=2]="TRIM"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.peer!=null&&(o.uint32(18),o.bytes(t.peer)),t.tag!=null&&(o.uint32(26),o.string(t.tag)),t.weight!=null&&(o.uint32(32),o.int64(t.weight)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.peer=t.bytes();break;case 3:c.tag=t.string();break;case 4:c.weight=t.int64();break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})($||($={}));var J;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{t.lengthDelimited!==!1&&r.fork(),e.peer!=null&&e.peer.byteLength>0&&(r.uint32(10),r.bytes(e.peer)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={peer:new Uint8Array(0)},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.peer=e.bytes();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(J||(J={}));var X;(function(i){let n;(function(t){t.GET_TOPICS="GET_TOPICS",t.LIST_PEERS="LIST_PEERS",t.PUBLISH="PUBLISH",t.SUBSCRIBE="SUBSCRIBE"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.GET_TOPICS=0]="GET_TOPICS",t[t.LIST_PEERS=1]="LIST_PEERS",t[t.PUBLISH=2]="PUBLISH",t[t.SUBSCRIBE=3]="SUBSCRIBE"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.topic!=null&&(o.uint32(18),o.string(t.topic)),t.data!=null&&(o.uint32(26),o.bytes(t.data)),c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.topic=t.string();break;case 3:c.data=t.bytes();break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(X||(X={}));var bt;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.from!=null&&(r.uint32(10),r.bytes(e.from)),e.data!=null&&(r.uint32(18),r.bytes(e.data)),e.seqno!=null&&(r.uint32(26),r.bytes(e.seqno)),e.topicIDs!=null)for(let o of e.topicIDs)r.uint32(34),r.string(o);e.signature!=null&&(r.uint32(42),r.bytes(e.signature)),e.key!=null&&(r.uint32(50),r.bytes(e.key)),t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={topicIDs:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.from=e.bytes();break;case 2:t.data=e.bytes();break;case 3:t.seqno=e.bytes();break;case 4:t.topicIDs.push(e.string());break;case 5:t.signature=e.bytes();break;case 6:t.key=e.bytes();break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(bt||(bt={}));var Q;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.topics!=null)for(let o of e.topics)r.uint32(10),r.string(o);if(e.peerIDs!=null)for(let o of e.peerIDs)r.uint32(18),r.bytes(o);t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={topics:[],peerIDs:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.topics.push(e.string());break;case 2:t.peerIDs.push(e.bytes());break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(Q||(Q={}));var Y;(function(i){let n;(function(t){t.UNSPECIFIED="UNSPECIFIED",t.GET_PROTOCOLS="GET_PROTOCOLS",t.GET_PEER_INFO="GET_PEER_INFO"})(n=i.Type||(i.Type={}));let e;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.GET_PROTOCOLS=1]="GET_PROTOCOLS",t[t.GET_PEER_INFO=2]="GET_PEER_INFO"})(e||(e={})),function(t){t.codec=()=>I(e)}(n=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=y((t,o,c={})=>{if(c.lengthDelimited!==!1&&o.fork(),t.type!=null&&(o.uint32(8),i.Type.codec().encode(t.type,o)),t.id!=null&&(o.uint32(18),o.bytes(t.id)),t.protos!=null)for(let s of t.protos)o.uint32(26),o.string(s);c.lengthDelimited!==!1&&o.ldelim()},(t,o)=>{let c={protos:[]},s=o==null?t.len:t.pos+o;for(;t.pos<s;){let u=t.uint32();switch(u>>>3){case 1:c.type=i.Type.codec().decode(t);break;case 2:c.id=t.bytes();break;case 3:c.protos.push(t.string());break;default:t.skipType(u&7);break}}return c})),r),i.encode=t=>E(t,i.codec()),i.decode=t=>p(t,i.codec())})(Y||(Y={}));var V;(function(i){let n;i.codec=()=>(n==null&&(n=y((e,r,t={})=>{if(t.lengthDelimited!==!1&&r.fork(),e.peer!=null&&(r.uint32(10),S.codec().encode(e.peer,r)),e.protos!=null)for(let o of e.protos)r.uint32(18),r.string(o);t.lengthDelimited!==!1&&r.ldelim()},(e,r)=>{let t={protos:[]},o=r==null?e.len:e.pos+r;for(;e.pos<o;){let c=e.uint32();switch(c>>>3){case 1:t.peer=S.codec().decode(e,e.uint32());break;case 2:t.protos.push(e.string());break;default:e.skipType(c&7);break}}return t})),n),i.encode=e=>E(e,i.codec()),i.decode=e=>p(e,i.codec())})(V||(V={}));return _e(ve);})();
|
|
3
3
|
return Libp2PDaemonProtocol}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Duplex, Source } from 'it-stream-types';
|
|
2
2
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
3
3
|
export interface StreamHandlerOptions {
|
|
4
|
-
stream: Duplex<Uint8Array
|
|
4
|
+
stream: Duplex<AsyncIterable<Uint8Array>, Source<Uint8Array>, Promise<void>>;
|
|
5
5
|
maxLength?: number;
|
|
6
6
|
}
|
|
7
7
|
export declare class StreamHandler {
|
|
@@ -20,7 +20,7 @@ export declare class StreamHandler {
|
|
|
20
20
|
/**
|
|
21
21
|
* Return the handshake rest stream and invalidate handler
|
|
22
22
|
*/
|
|
23
|
-
rest(): Duplex<Uint8ArrayList
|
|
23
|
+
rest(): Duplex<AsyncGenerator<Uint8ArrayList | Uint8Array>, Source<Uint8Array>, Promise<void>>;
|
|
24
24
|
/**
|
|
25
25
|
* Close the stream
|
|
26
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-handler.d.ts","sourceRoot":"","sources":["../../src/stream-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIpD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"stream-handler.d.ts","sourceRoot":"","sources":["../../src/stream-handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIpD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsE;IAC7F,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IACtC,OAAO,EAAE,MAAM,CAAC,cAAc,CAAC,CAAA;IAEtC;;OAEG;gBACU,IAAI,EAAE,oBAAoB;IAQvC;;OAEG;IACG,IAAI,IAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAY9C,KAAK,CAAE,GAAG,EAAE,UAAU,GAAG,cAAc,GAAG,IAAI;IAO9C;;OAEG;IACH,IAAI,IAAK,MAAM,CAAC,cAAc,CAAC,cAAc,GAAG,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAK/F;;OAEG;IACG,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;CAI9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-handler.js","sourceRoot":"","sources":["../../src/stream-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAKvC,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAA;AAO3D,MAAM,OAAO,aAAa;
|
|
1
|
+
{"version":3,"file":"stream-handler.js","sourceRoot":"","sources":["../../src/stream-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAKvC,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAA;AAO3D,MAAM,OAAO,aAAa;IAKxB;;OAEG;IACH,YAAa,IAA0B;QACrC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;QAElC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,SAAS,IAAI,IAAI,EAAE,CAAC,CAAA;IAC9F,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,iDAAiD;QACjD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;QACrC,IAAI,GAAG,CAAC,KAAK,IAAI,IAAI,EAAE;YACrB,OAAO,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA;SAC5B;QAED,GAAG,CAAC,wCAAwC,CAAC,CAAA;QAC7C,qCAAqC;QACrC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAED,KAAK,CAAE,GAAgC;QACrC,GAAG,CAAC,eAAe,CAAC,CAAA;QACpB,IAAI,CAAC,KAAK,CAAC,KAAK,CACd,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CACjC,CAAA;IACH,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAA;IAC1B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,GAAG,CAAC,oBAAoB,CAAC,CAAA;QACzB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/daemon-protocol",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Communication protocol between libp2p daemons and clients",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
@@ -157,13 +157,13 @@
|
|
|
157
157
|
"release": "aegir release"
|
|
158
158
|
},
|
|
159
159
|
"dependencies": {
|
|
160
|
-
"@libp2p/interface-transport": "^
|
|
160
|
+
"@libp2p/interface-transport": "^3.0.0",
|
|
161
161
|
"it-handshake": "^4.0.0",
|
|
162
162
|
"protons-runtime": "^5.0.0",
|
|
163
163
|
"uint8arraylist": "^2.3.2"
|
|
164
164
|
},
|
|
165
165
|
"devDependencies": {
|
|
166
|
-
"aegir": "^
|
|
166
|
+
"aegir": "^38.1.6",
|
|
167
167
|
"protons": "^7.0.2"
|
|
168
168
|
}
|
|
169
169
|
}
|
package/src/stream-handler.ts
CHANGED
|
@@ -8,14 +8,15 @@ import type { Uint8ArrayList } from 'uint8arraylist'
|
|
|
8
8
|
const log = logger('libp2p:daemon-protocol:stream-handler')
|
|
9
9
|
|
|
10
10
|
export interface StreamHandlerOptions {
|
|
11
|
-
stream: Duplex<Uint8Array
|
|
11
|
+
stream: Duplex<AsyncIterable<Uint8Array>, Source<Uint8Array>, Promise<void>>
|
|
12
12
|
maxLength?: number
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export class StreamHandler {
|
|
16
|
-
private readonly stream: Duplex<Uint8Array
|
|
16
|
+
private readonly stream: Duplex<AsyncIterable<Uint8Array>, Source<Uint8Array>, Promise<void>>
|
|
17
17
|
private readonly shake: Handshake<Uint8Array>
|
|
18
18
|
public decoder: Source<Uint8ArrayList>
|
|
19
|
+
|
|
19
20
|
/**
|
|
20
21
|
* Create a stream handler for connection
|
|
21
22
|
*/
|
|
@@ -42,7 +43,7 @@ export class StreamHandler {
|
|
|
42
43
|
await this.close()
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
write (msg: Uint8Array | Uint8ArrayList) {
|
|
46
|
+
write (msg: Uint8Array | Uint8ArrayList): void {
|
|
46
47
|
log('write message')
|
|
47
48
|
this.shake.write(
|
|
48
49
|
lp.encode.single(msg).subarray()
|
|
@@ -52,7 +53,7 @@ export class StreamHandler {
|
|
|
52
53
|
/**
|
|
53
54
|
* Return the handshake rest stream and invalidate handler
|
|
54
55
|
*/
|
|
55
|
-
rest (): Duplex<Uint8ArrayList
|
|
56
|
+
rest (): Duplex<AsyncGenerator<Uint8ArrayList | Uint8Array>, Source<Uint8Array>, Promise<void>> {
|
|
56
57
|
this.shake.rest()
|
|
57
58
|
return this.shake.stream
|
|
58
59
|
}
|