@libp2p/daemon-protocol 1.0.6 → 2.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.
@@ -3,6 +3,7 @@ import { handshake } from 'it-handshake'
3
3
  import { logger } from '@libp2p/logger'
4
4
  import type { Duplex, Source } from 'it-stream-types'
5
5
  import type { Handshake } from 'it-handshake'
6
+ import type { Uint8ArrayList } from 'uint8arraylist'
6
7
 
7
8
  const log = logger('libp2p:daemon-protocol:stream-handler')
8
9
 
@@ -14,7 +15,7 @@ export interface StreamHandlerOptions {
14
15
  export class StreamHandler {
15
16
  private readonly stream: Duplex<Uint8Array>
16
17
  private readonly shake: Handshake
17
- public decoder: Source<Uint8Array>
18
+ public decoder: Source<Uint8ArrayList>
18
19
  /**
19
20
  * Create a stream handler for connection
20
21
  */
@@ -41,10 +42,10 @@ export class StreamHandler {
41
42
  await this.close()
42
43
  }
43
44
 
44
- write (msg: Uint8Array) {
45
+ write (msg: Uint8Array | Uint8ArrayList) {
45
46
  log('write message')
46
47
  this.shake.write(
47
- lp.encode.single(msg).slice()
48
+ lp.encode.single(msg).subarray()
48
49
  )
49
50
  }
50
51
 
package/src/upgrader.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Upgrader } from '@libp2p/interfaces/transport'
1
+ import type { Upgrader } from '@libp2p/interface-transport'
2
2
 
3
3
  export const passThroughUpgrader: Upgrader = {
4
4
  // @ts-expect-error should return a connection
package/dist/index.min.js DELETED
@@ -1,17 +0,0 @@
1
- (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDaemonProtocol = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- var Libp2PDaemonProtocol=(()=>{var Ne=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Mt=Object.prototype.hasOwnProperty;var D=(t,e)=>{for(var n in e)Ne(t,n,{get:e[n],enumerable:!0})},zt=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Gt(e))!Mt.call(t,o)&&o!==n&&Ne(t,o,{get:()=>e[o],enumerable:!(r=Rt(e,o))||r.enumerable});return t};var Ft=t=>zt(Ne({},"__esModule",{value:!0}),t);var Qr={};D(Qr,{ConnManagerRequest:()=>xe,ConnectRequest:()=>pe,DHTRequest:()=>be,DHTResponse:()=>Ee,DisconnectRequest:()=>ye,ErrorResponse:()=>le,IdentifyResponse:()=>ue,PSMessage:()=>Ze,PSRequest:()=>Le,PSResponse:()=>Ae,PeerInfo:()=>W,PeerstoreRequest:()=>Ie,PeerstoreResponse:()=>Ue,Request:()=>We,Response:()=>_e,StreamHandlerRequest:()=>me,StreamInfo:()=>we,StreamOpenRequest:()=>ge});function Se(t,e){e||(e=t.reduce((o,c)=>o+c.length,0));let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}var Be={};D(Be,{identity:()=>Kt});function Vt(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<t.length;o++){var c=t.charAt(o),i=c.charCodeAt(0);if(n[i]!==255)throw new TypeError(c+" is ambiguous");n[i]=o}var a=t.length,l=t.charAt(0),m=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function p(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var b=0,Y=0,T=0,B=f.length;T!==B&&f[T]===0;)T++,b++;for(var v=(B-T)*u+1>>>0,S=new Uint8Array(v);T!==B;){for(var P=f[T],V=0,O=v-1;(P!==0||V<Y)&&O!==-1;O--,V++)P+=256*S[O]>>>0,S[O]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");Y=V,T++}for(var M=v-Y;M!==v&&S[M]===0;)M++;for(var te=l.repeat(b);M<v;++M)te+=t.charAt(S[M]);return te}function U(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var b=0;if(f[b]!==" "){for(var Y=0,T=0;f[b]===l;)Y++,b++;for(var B=(f.length-b)*m+1>>>0,v=new Uint8Array(B);f[b];){var S=n[f.charCodeAt(b)];if(S===255)return;for(var P=0,V=B-1;(S!==0||P<T)&&V!==-1;V--,P++)S+=a*v[V]>>>0,v[V]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");T=P,b++}if(f[b]!==" "){for(var O=B-T;O!==B&&v[O]===0;)O++;for(var M=new Uint8Array(Y+(B-O)),te=Y;O!==B;)M[te++]=v[O++];return M}}}function N(f){var b=U(f);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:U,decode:N}}var kt=Vt,$t=kt,qe=$t;var to=new Uint8Array(0);var et=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==e[n])return!1;return!0},z=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var tt=t=>new TextEncoder().encode(t),nt=t=>new TextDecoder().decode(t);var De=class{constructor(e,n,r){this.name=e,this.prefix=n,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ce=class{constructor(e,n,r){this.name=e,this.prefix=n,this.baseDecode=r}decode(e){if(typeof e=="string")switch(e[0]){case this.prefix:return this.baseDecode(e.slice(1));default:throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`)}else throw Error("Can only multibase decode strings")}or(e){return ot(this,e)}},Te=class{constructor(e){this.decoders=e}or(e){return ot(this,e)}decode(e){let n=e[0],r=this.decoders[n];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`)}},ot=(t,e)=>new Te({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Oe=class{constructor(e,n,r,o){this.name=e,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new De(e,n,r),this.decoder=new Ce(e,n,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ne=({name:t,prefix:e,encode:n,decode:r})=>new Oe(t,e,n,r),k=({prefix:t,name:e,alphabet:n})=>{let{encode:r,decode:o}=qe(n,e);return ne({prefix:t,name:e,encode:r,decode:c=>z(o(c))})},Yt=(t,e,n,r)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let c=t.length;for(;t[c-1]==="=";)--c;let i=new Uint8Array(c*n/8|0),a=0,l=0,m=0;for(let u=0;u<c;++u){let p=o[t[u]];if(p===void 0)throw new SyntaxError(`Non-${r} character`);l=l<<n|p,a+=n,a>=8&&(a-=8,i[m++]=255&l>>a)}if(a>=n||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return i},jt=(t,e,n)=>{let r=e[e.length-1]==="=",o=(1<<n)-1,c="",i=0,a=0;for(let l=0;l<t.length;++l)for(a=a<<8|t[l],i+=8;i>n;)i-=n,c+=e[o&a>>i];if(i&&(c+=e[o&a<<n-i]),r)for(;c.length*n&7;)c+="=";return c},E=({name:t,prefix:e,bitsPerChar:n,alphabet:r})=>ne({prefix:e,name:t,encode(o){return jt(o,r,n)},decode(o){return Yt(o,r,n,t)}});var Kt=ne({prefix:"\0",name:"identity",encode:t=>nt(t),decode:t=>tt(t)});var ve={};D(ve,{base2:()=>Jt});var Jt=E({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Pe={};D(Pe,{base8:()=>Ht});var Ht=E({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Re={};D(Re,{base10:()=>Xt});var Xt=k({prefix:"9",name:"base10",alphabet:"0123456789"});var Ge={};D(Ge,{base16:()=>Qt,base16upper:()=>Wt});var Qt=E({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Wt=E({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Me={};D(Me,{base32:()=>K,base32hex:()=>en,base32hexpad:()=>nn,base32hexpadupper:()=>rn,base32hexupper:()=>tn,base32pad:()=>Zt,base32padupper:()=>qt,base32upper:()=>_t,base32z:()=>on});var K=E({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_t=E({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zt=E({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),qt=E({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),en=E({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),tn=E({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),nn=E({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),rn=E({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),on=E({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ze={};D(ze,{base36:()=>cn,base36upper:()=>sn});var cn=k({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),sn=k({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Fe={};D(Fe,{base58btc:()=>R,base58flickr:()=>dn});var R=k({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),dn=k({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ve={};D(Ve,{base64:()=>an,base64pad:()=>fn,base64url:()=>hn,base64urlpad:()=>un});var an=E({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),fn=E({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),hn=E({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),un=E({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var je={};D(je,{sha256:()=>On,sha512:()=>Bn});var pn=st,ct=128,gn=127,mn=~gn,ln=Math.pow(2,31);function st(t,e,n){e=e||[],n=n||0;for(var r=n;t>=ln;)e[n++]=t&255|ct,t/=128;for(;t&mn;)e[n++]=t&255|ct,t>>>=7;return e[n]=t|0,st.bytes=n-r+1,e}var wn=ke,bn=128,it=127;function ke(t,r){var n=0,r=r||0,o=0,c=r,i,a=t.length;do{if(c>=a)throw ke.bytes=0,new RangeError("Could not decode varint");i=t[c++],n+=o<28?(i&it)<<o:(i&it)*Math.pow(2,o),o+=7}while(i>=bn);return ke.bytes=c-r,n}var En=Math.pow(2,7),xn=Math.pow(2,14),yn=Math.pow(2,21),Ln=Math.pow(2,28),An=Math.pow(2,35),In=Math.pow(2,42),Un=Math.pow(2,49),Nn=Math.pow(2,56),Sn=Math.pow(2,63),Dn=function(t){return t<En?1:t<xn?2:t<yn?3:t<Ln?4:t<An?5:t<In?6:t<Un?7:t<Nn?8:t<Sn?9:10},Cn={encode:pn,decode:wn,encodingLength:Dn},Tn=Cn,_=Tn;var Z=t=>[_.decode(t),_.decode.bytes],J=(t,e,n=0)=>(_.encode(t,e,n),e),H=t=>_.encodingLength(t);var j=(t,e)=>{let n=e.byteLength,r=H(t),o=r+H(n),c=new Uint8Array(o+n);return J(t,c,0),J(n,c,r),c.set(e,o),new X(t,n,e,c)},dt=t=>{let e=z(t),[n,r]=Z(e),[o,c]=Z(e.subarray(r)),i=e.subarray(r+c);if(i.byteLength!==o)throw new Error("Incorrect length");return new X(n,o,i,e)},at=(t,e)=>t===e?!0:t.code===e.code&&t.size===e.size&&et(t.bytes,e.bytes),X=class{constructor(e,n,r,o){this.code=e,this.size=n,this.digest=r,this.bytes=o}};var Ye=({name:t,code:e,encode:n})=>new $e(t,e,n),$e=class{constructor(e,n,r){this.name=e,this.code=n,this.encode=r}digest(e){if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?j(this.code,n):n.then(r=>j(this.code,r))}else throw Error("Unknown type, must be binary type")}};var ht=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),On=Ye({name:"sha2-256",code:18,encode:ht("SHA-256")}),Bn=Ye({name:"sha2-512",code:19,encode:ht("SHA-512")});var Ke={};D(Ke,{identity:()=>Rn});var ut=0,vn="identity",pt=z,Pn=t=>j(ut,pt(t)),Rn={code:ut,name:vn,encode:pt,digest:Pn};var Lo=new TextEncoder,Ao=new TextDecoder;var A=class{constructor(e,n,r,o){this.code=n,this.version=e,this.multihash=r,this.bytes=o,this.byteOffset=o.byteOffset,this.byteLength=o.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:ce,byteLength:ce,code:oe,version:oe,multihash:oe,bytes:oe,_baseCache:ce,asCID:ce})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:n}=this;if(e!==ee)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==kn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return A.createV0(n)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:n}=this.multihash,r=j(e,n);return A.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&at(this.multihash,e.multihash)}toString(e){let{bytes:n,version:r,_baseCache:o}=this;switch(r){case 0:return Fn(n,o,e||R.encoder);default:return Vn(n,o,e||K.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return Yn(/^0\.0/,jn),!!(e&&(e[mt]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof A)return e;if(e!=null&&e.asCID===e){let{version:n,code:r,multihash:o,bytes:c}=e;return new A(n,r,o,c||gt(n,r,o.bytes))}else if(e!=null&&e[mt]===!0){let{version:n,multihash:r,code:o}=e,c=dt(r);return A.create(n,o,c)}else return null}static create(e,n,r){if(typeof n!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(n!==ee)throw new Error(`Version 0 CID must use dag-pb (code: ${ee}) block encoding`);return new A(e,n,r,r.bytes)}case 1:{let o=gt(e,n,r.bytes);return new A(e,n,r,o)}default:throw new Error("Invalid version")}}static createV0(e){return A.create(0,ee,e)}static createV1(e,n){return A.create(1,e,n)}static decode(e){let[n,r]=A.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return n}static decodeFirst(e){let n=A.inspectBytes(e),r=n.size-n.multihashSize,o=z(e.subarray(r,r+n.multihashSize));if(o.byteLength!==n.multihashSize)throw new Error("Incorrect length");let c=o.subarray(n.multihashSize-n.digestSize),i=new X(n.multihashCode,n.digestSize,c,o);return[n.version===0?A.createV0(i):A.createV1(n.codec,i),e.subarray(n.size)]}static inspectBytes(e){let n=0,r=()=>{let[p,U]=Z(e.subarray(n));return n+=U,p},o=r(),c=ee;if(o===18?(o=0,n=0):o===1&&(c=r()),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=n,a=r(),l=r(),m=n+l,u=m-i;return{version:o,codec:c,multihashCode:a,digestSize:l,multihashSize:u,size:m}}static parse(e,n){let[r,o]=zn(e,n),c=A.decode(o);return c._baseCache.set(r,e),c}},zn=(t,e)=>{switch(t[0]){case"Q":{let n=e||R;return[R.prefix,n.decode(`${R.prefix}${t}`)]}case R.prefix:{let n=e||R;return[R.prefix,n.decode(t)]}case K.prefix:{let n=e||K;return[K.prefix,n.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Fn=(t,e,n)=>{let{prefix:r}=n;if(r!==R.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let o=e.get(r);if(o==null){let c=n.encode(t).slice(1);return e.set(r,c),c}else return o},Vn=(t,e,n)=>{let{prefix:r}=n,o=e.get(r);if(o==null){let c=n.encode(t);return e.set(r,c),c}else return o},ee=112,kn=18,gt=(t,e,n)=>{let r=H(t),o=r+H(e),c=new Uint8Array(o+n.byteLength);return J(t,c,0),J(e,c,r),c.set(n,o),c},mt=Symbol.for("@ipld/js-cid/CID"),oe={writable:!1,configurable:!1,enumerable:!0},ce={writable:!1,enumerable:!1,configurable:!1},$n="0.0.0-dev",Yn=(t,e)=>{if(t.test($n))console.warn(e);else throw new Error(e)},jn=`CID.isCID(v) is deprecated and will be removed in the next major release.
3
- Following code pattern:
4
-
5
- if (CID.isCID(value)) {
6
- doSomethingWithCID(value)
7
- }
8
-
9
- Is replaced with:
10
-
11
- const cid = CID.asCID(value)
12
- if (cid) {
13
- // Make sure to use cid instead of value
14
- doSomethingWithCID(cid)
15
- }
16
- `;var Je={...Be,...ve,...Pe,...Re,...Ge,...Me,...ze,...Fe,...Ve},Oo={...je,...Ke};function wt(t,e,n,r){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:n},decoder:{decode:r}}}var lt=wt("utf8","u",t=>{let e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),He=wt("ascii","a",t=>{let e="a";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return e},t=>{t=t.substring(1);let e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}),Kn={utf8:lt,"utf-8":lt,hex:Je.base16,latin1:He,ascii:He,binary:He,...Je},ie=Kn;function se(t,e="utf8"){let n=ie[e];if(!n)throw new Error(`Unsupported encoding "${e}"`);return n.decoder.decode(`${n.prefix}${t}`)}function Xe(t,e="utf8"){let n=ie[e];if(!n)throw new Error(`Unsupported encoding "${e}"`);return n.encoder.encode(t).substring(1)}var xt=Symbol.for("@achingbrain/uint8arraylist");function bt(t,e,n){if(e==null||e<0||e>=n)throw new RangeError("index is out of bounds");let r=0;for(let o of t){let c=r+o.byteLength;if(e<c)return{buf:o,index:e-r};r=c}throw new RangeError("index is out of bounds")}function Et(t){return Boolean(t?.[xt])}var w=class{constructor(...e){Object.defineProperty(this,xt,{value:!0}),this.bufs=[],this.length=0,this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let n=0;for(let r of e)if(r instanceof Uint8Array)n+=r.byteLength,this.bufs.push(r);else if(Et(r))n+=r.length,this.bufs=this.bufs.concat(r.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=n}get(e){let n=bt(this.bufs,e,this.length);return n.buf[n.index]}set(e,n){let r=bt(this.bufs,e,this.length);r.buf[r.index]=n}write(e,n=0){if(e instanceof Uint8Array)for(let r=0;r<e.length;r++)this.set(n+r,e[r]);else if(Et(e))for(let r=0;r<e.length;r++)this.set(n+r,e.get(r));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0))for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}slice(e,n){let{bufs:r,length:o}=this._subList(e,n);return Se(r,o)}subarray(e,n){let{bufs:r}=this._subList(e,n),o=new w;return o.appendAll(r),o}_subList(e,n){if(e==null&&n==null)return{bufs:this.bufs,length:this.length};if(e=e??0,n=n??(this.length>0?this.length:0),e<0||n>this.length)throw new RangeError("index out of bounds");if(e===n)return{bufs:[],length:0};let r=[],o=0;for(let c of this.bufs){let i=o,a=i+c.byteLength,l=e>=i&&e<a,m=n>i&&n<=a,u=e<i&&n>=a;o=a;let p,U;if(l&&(p=e-i,U=c.byteLength),m&&(U=n-i,p==null&&(p=0)),u&&(p=0,U=c.byteLength),p!=null&&U!=null&&r.push(c.subarray(p,U)),m)break}return{bufs:r,length:n-e}}getInt8(e){let n=this.slice(e,e+1);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt8(0)}setInt8(e,n){let r=new Uint8Array(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,n),this.write(r,e)}getInt16(e,n){let r=this.slice(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,n)}setInt16(e,n,r){let o=new Uint8Array(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,n,r),this.write(o,e)}getInt32(e,n){let r=this.slice(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,n)}setInt32(e,n,r){let o=new Uint8Array(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,n,r),this.write(o,e)}getBigInt64(e,n){let r=this.slice(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,n)}setBigInt64(e,n,r){let o=new Uint8Array(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,n,r),this.write(o,e)}getUint8(e){let n=this.slice(e,e+1);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint8(0)}setUint8(e,n){let r=new Uint8Array(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,n),this.write(r,e)}getUint16(e,n){let r=this.slice(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,n)}setUint16(e,n,r){let o=new Uint8Array(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,n,r),this.write(o,e)}getUint32(e,n){let r=this.slice(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,n)}setUint32(e,n,r){let o=new Uint8Array(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,n,r),this.write(o,e)}getBigUint64(e,n){let r=this.slice(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,n)}setBigUint64(e,n,r){let o=new Uint8Array(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,n,r),this.write(o,e)}getFloat32(e,n){let r=this.slice(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,n)}setFloat32(e,n,r){let o=new Uint8Array(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,n,r),this.write(o,e)}getFloat64(e,n){let r=this.slice(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,n)}setFloat64(e,n,r){let o=new Uint8Array(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,n,r),this.write(o,e)}};function G(t){return t instanceof Uint8Array?{get(e){return t[e]},set(e,n){t[e]=n}}:{get(e){return t.get(e)},set(e,n){t.set(e,n)}}}var yt=4294967296,I=class{constructor(e=0,n=0){this.hi=e,this.lo=n}toBigInt(e){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){let n=~this.lo+1>>>0,r=~this.hi>>>0;return n===0&&(r=r+1>>>0),-(BigInt(n)+(BigInt(r)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}zzDecode(){let e=-(this.lo&1),n=((this.lo>>>1|this.hi<<31)^e)>>>0,r=(this.hi>>>1^e)>>>0;return new I(r,n)}zzEncode(){let e=this.hi>>31,n=((this.hi<<1|this.lo>>>31)^e)>>>0,r=(this.lo<<1^e)>>>0;return new I(n,r)}toBytes(e,n=0){let r=G(e);for(;this.hi>0;)r.set(n++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)r.set(n++,this.lo&127|128),this.lo=this.lo>>>7;r.set(n++,this.lo)}static fromBigInt(e){if(e===0n)return new I;let n=e<0;n&&(e=-e);let r=Number(e>>32n)|0,o=Number(e-(BigInt(r)<<32n))|0;return n&&(r=~r>>>0,o=~o>>>0,++o>yt&&(o=0,++r>yt&&(r=0))),new I(r,o)}static fromNumber(e){if(e===0)return new I;let n=e<0;n&&(e=-e);let r=e>>>0,o=(e-r)/4294967296>>>0;return n&&(o=~o>>>0,r=~r>>>0,++r>4294967295&&(r=0,++o>4294967295&&(o=0))),new I(o,r)}static fromBytes(e,n){let r=G(e),o=new I,c=0;if(e.length-n>4){for(;c<4;++c)if(o.lo=(o.lo|(r.get(n)&127)<<c*7)>>>0,r.get(n++)<128)return o;if(o.lo=(o.lo|(r.get(n)&127)<<28)>>>0,o.hi=(o.hi|(r.get(n)&127)>>4)>>>0,r.get(n++)<128)return o;c=0}else{for(;c<3;++c){if(n>=e.length)throw RangeError(`index out of range: ${n} > ${e.length}`);if(o.lo=(o.lo|(r.get(n)&127)<<c*7)>>>0,r.get(n++)<128)return o}return o.lo=(o.lo|(r.get(n++)&127)<<c*7)>>>0,o}if(e.length-n>4){for(;c<5;++c)if(o.hi=(o.hi|(r.get(n)&127)<<c*7+3)>>>0,r.get(n++)<128)return o}else for(;c<5;++c){if(n>=e.length)throw RangeError(`index out of range: ${n} > ${e.length}`);if(o.hi=(o.hi|(r.get(n)&127)<<c*7+3)>>>0,r.get(n++)<128)return o}throw Error("invalid varint encoding")}};var Lt=128,Jn=127,Hn=~Jn,Xn=Math.pow(2,31),Qn=Math.pow(2,7),Wn=Math.pow(2,14),_n=Math.pow(2,21),Zn=Math.pow(2,28),qn=Math.pow(2,35),er=Math.pow(2,42),tr=Math.pow(2,49),nr=Math.pow(2,56),rr=Math.pow(2,63),s={encodingLength(t){return t<Qn?1:t<Wn?2:t<_n?3:t<Zn?4:t<qn?5:t<er?6:t<tr?7:t<nr?8:t<rr?9:10},encode(t,e){let n=0,r=G(e);for(;t>=Xn;)r.set(n++,t&255|Lt),t/=128;for(;(t&Hn)>0;)r.set(n++,t&255|Lt),t>>>=7;r.set(n,t|0)},decode(t,e=0){let n=G(t),r=4294967295;if(r=(n.get(e)&127)>>>0,n.get(e++)<128||(r=(r|(n.get(e)&127)<<7)>>>0,n.get(e++)<128)||(r=(r|(n.get(e)&127)<<14)>>>0,n.get(e++)<128)||(r=(r|(n.get(e)&127)<<21)>>>0,n.get(e++)<128)||(r=(r|(n.get(e)&15)<<28)>>>0,n.get(e++)<128))return r;if((e+=5)>t.length)throw RangeError(`index out of range: ${e} > ${t.length}`);return r}},de={encodingLength(t){return t<0?10:s.encodingLength(t)},encode(t,e){if(t<0){let n=0,r=G(e),o=I.fromNumber(t);for(;o.hi>0;)r.set(n++,o.lo&127|128),o.lo=(o.lo>>>7|o.hi<<25)>>>0,o.hi>>>=7;for(;o.lo>127;)r.set(n++,o.lo&127|128),o.lo=o.lo>>>7;r.set(n++,o.lo);return}s.encode(t,e)},decode(t,e=0){return s.decode(t,e)|0}},ae={encodingLength(t){return t=(t<<1^t>>31)>>>0,s.encodingLength(t)},encode(t,e,n=0){return t=(t<<1^t>>31)>>>0,s.encode(t,e)},decode(t,e=0){let n=s.decode(t,e);return n>>>1^-(n&1)|0}};function x(t,e){let n=new Uint8Array(s.encodingLength(t.length));return s.encode(t.length,n),e.decode(new w(n,t),0)}function y(t,e){let n=e.encode(t),r=s.encodingLength(s.decode(n));return n.slice(r)}var d;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(d||(d={}));function h(t,e,n,r,o){return{name:t,type:e,encode:n,decode:r,encodingLength:o}}var or=function(){return 1},cr=function(e){return Uint8Array.from([e?1:0])},ir=function(e,n){return e.get(n)>0},sr=h("bool",d.VARINT,cr,ir,or);var dr=function(e){let n=e.byteLength;return s.encodingLength(n)+n},ar=function(e){let n=new Uint8Array(s.encodingLength(e.byteLength));return s.encode(e.byteLength,n),new w(n,e)},fr=function(e,n){let r=s.decode(e,n);return n+=s.encodingLength(r),e.slice(n,n+r)},g=h("bytes",d.LENGTH_DELIMITED,ar,fr,dr);var At=function(){return 8},hr=function(e){let n=new w(new Uint8Array(At(e)));return n.setFloat64(0,e,!0),n},ur=function(e,n){return e.getFloat64(n,!0)},pr=h("double",d.BIT64,hr,ur,At);function F(t){function e(c){if(t[c.toString()]==null)throw new Error("Invalid enum value");return typeof c=="number"?c:t[c]}let n=function(i){return s.encodingLength(e(i))},r=function(i){let a=e(i),l=new Uint8Array(s.encodingLength(a));return s.encode(a,l),l},o=function(i,a){let m=s.decode(i,a).toString();if(t[m]==null)throw new Error("Invalid enum value");return t[m]};return h("enum",d.VARINT,r,o,n)}var It=function(){return 4},gr=function(e){let n=new w(new Uint8Array(It(e)));return n.setInt32(0,e,!0),n},mr=function(e,n){return e.getInt32(n,!0)},lr=h("fixed32",d.BIT32,gr,mr,It);var Ut=function(e){return 8},wr=function(e){let n=new w(new Uint8Array(Ut(e)));return n.setBigInt64(0,e,!0),n},br=function(e,n){return e.getBigInt64(n,!0)},Er=h("fixed64",d.BIT64,wr,br,Ut);var Nt=function(){return 4},xr=function(e){let n=new w(new Uint8Array(Nt(1)));return n.setFloat32(0,e,!0),n},yr=function(e,n){return e.getFloat32(n,!0)},Lr=h("float",d.BIT32,xr,yr,Nt);var St=function(e){return de.encodingLength(e)},Ar=function(e){let n=new Uint8Array(St(e));return de.encode(e,n),n},Ir=function(e,n){return de.decode(e,n)},Qe=h("int32",d.VARINT,Ar,Ir,St);var Dt=0x7fn,$={encodingLength(t){let e=0;for(;t>=0x80n;e++)t>>=7n;return e+1},encode(t,e){let n=G(e),r=0;for(;Dt<t;)n.set(r++,Number(t&Dt)|128),t>>=7n;n.set(r,Number(t))},decode(t,e=0){return I.fromBytes(t,e).toBigInt(!0)}},fe={encodingLength(t){return t<0n?10:$.encodingLength(t)},encode(t,e,n=0){if(t<0n){I.fromBigInt(t).toBytes(e,n);return}return $.encode(t,e)},decode(t,e=0){return I.fromBytes(t,e).toBigInt(!1)}},he={encodingLength(t){return $.encodingLength(t>=0?t*2n:t*-2n-1n)},encode(t,e,n=0){I.fromBigInt(t).zzEncode().toBytes(e,n)},decode(t,e=0){return I.fromBytes(t,e).zzDecode().toBigInt(!1)}};var Ct=function(e){return fe.encodingLength(e)},Ur=function(e){let n=new Uint8Array(Ct(e));return fe.encode(e,n),n},Nr=function(e,n){return fe.decode(e,n)|0n},Q=h("int64",d.VARINT,Ur,Nr,Ct);function L(t){let e=function(c){let i=0;for(let a of Object.values(t))i+=a.codec.encodingLength(c[a.name]);return s.encodingLength(i)+i},n=function(c){let i=new w;function a(m,u,p){if(m==null){if(p.optional===!0)return;throw new Error(`Non optional field "${p.name}" was ${m===null?"null":"undefined"}`)}let U=u<<3|p.codec.type,N=new Uint8Array(s.encodingLength(U));s.encode(U,N);let f=p.codec.encode(m);i.append(N),i.append(f)}for(let[m,u]of Object.entries(t)){let p=parseInt(m);if(u.repeats===!0){if(!Array.isArray(c[u.name]))throw new Error(`Repeating field "${u.name}" was not an array`);for(let U of c[u.name])a(U,p,u)}else a(c[u.name],p,u)}let l=new Uint8Array(s.encodingLength(i.length));return s.encode(i.length,l),new w(l,i)},r=function(c,i){let a=s.decode(c,i);i+=s.encodingLength(a);let l=i+a,m={};for(;i<l;){let u=s.decode(c,i);i+=s.encodingLength(u);let p=u&7,U=u>>3,N=t[U],f=0;if(p===d.VARINT)if(N!=null){let b=N.codec.decode(c,i);f=N.codec.encodingLength(b)}else{let b=s.decode(c,i);f=s.encodingLength(b)}else if(p===d.BIT64)f=8;else if(p===d.LENGTH_DELIMITED){let b=s.decode(c,i);f=b+s.encodingLength(b)}else if(p===d.BIT32)f=4;else{if(p===d.START_GROUP)throw new Error("Unsupported wire type START_GROUP");if(p===d.END_GROUP)throw new Error("Unsupported wire type END_GROUP")}if(N!=null){let b=N.codec.decode(c,i);N.repeats===!0?(m[N.name]==null&&(m[N.name]=[]),m[N.name].push(b)):m[N.name]=b}i+=f}for(let u of Object.values(t))u.repeats===!0&&m[u.name]==null&&(m[u.name]=[]);return m};return h("message",d.LENGTH_DELIMITED,n,r,e)}var Tt=function(){return 4},Sr=function(e){let n=new w(new Uint8Array(Tt(e)));return n.setInt32(0,e,!0),n},Dr=function(e,n){return e.getInt32(n,!0)},Cr=h("sfixed32",d.BIT32,Sr,Dr,Tt);var Ot=function(){return 8},Tr=function(e){let n=new w(new Uint8Array(Ot(e)));return n.setBigInt64(0,e,!0),n},Or=function(e,n){return e.getBigInt64(n,!0)},Br=h("sfixed64",d.BIT64,Tr,Or,Ot);var Bt=function(e){return ae.encodingLength(e)},vr=function(e){let n=new Uint8Array(Bt(e));return ae.encode(e,n),n},Pr=function(e,n){return ae.decode(e,n)},Rr=h("sint32",d.VARINT,vr,Pr,Bt);var vt=function(e){return he.encodingLength(e)},Gr=function(e){let n=new Uint8Array(vt(e));return he.encode(e,n),n},Mr=function(e,n){return he.decode(e,n)},zr=h("sint64",d.VARINT,Gr,Mr,vt);var Fr=function(e){let n=se(e).byteLength;return s.encodingLength(n)+n},Vr=function(e){let n=se(e),r=new Uint8Array(s.encodingLength(n.byteLength));return s.encode(n.length,r),new w(r,n)},kr=function(e,n){let r=s.decode(e,n);return n+=s.encodingLength(r),Xe(e.slice(n,n+r))},C=h("string",d.LENGTH_DELIMITED,Vr,kr,Fr);var Pt=function(e){return s.encodingLength(e)},$r=function(e){let n=new Uint8Array(Pt(e));return s.encode(e,n),n},Yr=function(e,n){return s.decode(e,n)},jr=h("uint32",d.VARINT,$r,Yr,Pt);var Kr=function(e){return $.encodingLength(e)},Jr=function(e){let n=new Uint8Array($.encodingLength(e));return $.encode(e,n),n},Hr=function(e,n){return $.decode(e,n)},Xr=h("uint64",d.VARINT,Jr,Hr,Kr);var We;(function(t){let e;(function(r){r.IDENTIFY="IDENTIFY",r.CONNECT="CONNECT",r.STREAM_OPEN="STREAM_OPEN",r.STREAM_HANDLER="STREAM_HANDLER",r.DHT="DHT",r.LIST_PEERS="LIST_PEERS",r.CONNMANAGER="CONNMANAGER",r.DISCONNECT="DISCONNECT",r.PUBSUB="PUBSUB",r.PEERSTORE="PEERSTORE"})(e=t.Type||(t.Type={}));let n;(function(r){r[r.IDENTIFY=0]="IDENTIFY",r[r.CONNECT=1]="CONNECT",r[r.STREAM_OPEN=2]="STREAM_OPEN",r[r.STREAM_HANDLER=3]="STREAM_HANDLER",r[r.DHT=4]="DHT",r[r.LIST_PEERS=5]="LIST_PEERS",r[r.CONNMANAGER=6]="CONNMANAGER",r[r.DISCONNECT=7]="DISCONNECT",r[r.PUBSUB=8]="PUBSUB",r[r.PEERSTORE=9]="PEERSTORE"})(n||(n={})),function(r){r.codec=()=>F(n)}(e=t.Type||(t.Type={})),t.codec=()=>L({1:{name:"type",codec:t.Type.codec()},2:{name:"connect",codec:pe.codec(),optional:!0},3:{name:"streamOpen",codec:ge.codec(),optional:!0},4:{name:"streamHandler",codec:me.codec(),optional:!0},5:{name:"dht",codec:be.codec(),optional:!0},6:{name:"connManager",codec:xe.codec(),optional:!0},7:{name:"disconnect",codec:ye.codec(),optional:!0},8:{name:"pubsub",codec:Le.codec(),optional:!0},9:{name:"peerStore",codec:Ie.codec(),optional:!0}}),t.encode=r=>y(r,t.codec()),t.decode=r=>x(r,t.codec())})(We||(We={}));var _e;(function(t){let e;(function(r){r.OK="OK",r.ERROR="ERROR"})(e=t.Type||(t.Type={}));let n;(function(r){r[r.OK=0]="OK",r[r.ERROR=1]="ERROR"})(n||(n={})),function(r){r.codec=()=>F(n)}(e=t.Type||(t.Type={})),t.codec=()=>L({1:{name:"type",codec:t.Type.codec()},2:{name:"error",codec:le.codec(),optional:!0},3:{name:"streamInfo",codec:we.codec(),optional:!0},4:{name:"identify",codec:ue.codec(),optional:!0},5:{name:"dht",codec:Ee.codec(),optional:!0},6:{name:"peers",codec:W.codec(),repeats:!0},7:{name:"pubsub",codec:Ae.codec(),optional:!0},8:{name:"peerStore",codec:Ue.codec(),optional:!0}}),t.encode=r=>y(r,t.codec()),t.decode=r=>x(r,t.codec())})(_e||(_e={}));var ue;(function(t){t.codec=()=>L({1:{name:"id",codec:g},2:{name:"addrs",codec:g,repeats:!0}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(ue||(ue={}));var pe;(function(t){t.codec=()=>L({1:{name:"peer",codec:g},2:{name:"addrs",codec:g,repeats:!0},3:{name:"timeout",codec:Q,optional:!0}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(pe||(pe={}));var ge;(function(t){t.codec=()=>L({1:{name:"peer",codec:g},2:{name:"proto",codec:C,repeats:!0},3:{name:"timeout",codec:Q,optional:!0}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(ge||(ge={}));var me;(function(t){t.codec=()=>L({1:{name:"addr",codec:g},2:{name:"proto",codec:C,repeats:!0}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(me||(me={}));var le;(function(t){t.codec=()=>L({1:{name:"msg",codec:C}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(le||(le={}));var we;(function(t){t.codec=()=>L({1:{name:"peer",codec:g},2:{name:"addr",codec:g},3:{name:"proto",codec:C}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(we||(we={}));var be;(function(t){let e;(function(r){r.FIND_PEER="FIND_PEER",r.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",r.FIND_PROVIDERS="FIND_PROVIDERS",r.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",r.GET_PUBLIC_KEY="GET_PUBLIC_KEY",r.GET_VALUE="GET_VALUE",r.SEARCH_VALUE="SEARCH_VALUE",r.PUT_VALUE="PUT_VALUE",r.PROVIDE="PROVIDE"})(e=t.Type||(t.Type={}));let n;(function(r){r[r.FIND_PEER=0]="FIND_PEER",r[r.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",r[r.FIND_PROVIDERS=2]="FIND_PROVIDERS",r[r.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",r[r.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",r[r.GET_VALUE=5]="GET_VALUE",r[r.SEARCH_VALUE=6]="SEARCH_VALUE",r[r.PUT_VALUE=7]="PUT_VALUE",r[r.PROVIDE=8]="PROVIDE"})(n||(n={})),function(r){r.codec=()=>F(n)}(e=t.Type||(t.Type={})),t.codec=()=>L({1:{name:"type",codec:t.Type.codec()},2:{name:"peer",codec:g,optional:!0},3:{name:"cid",codec:g,optional:!0},4:{name:"key",codec:g,optional:!0},5:{name:"value",codec:g,optional:!0},6:{name:"count",codec:Qe,optional:!0},7:{name:"timeout",codec:Q,optional:!0}}),t.encode=r=>y(r,t.codec()),t.decode=r=>x(r,t.codec())})(be||(be={}));var Ee;(function(t){let e;(function(r){r.BEGIN="BEGIN",r.VALUE="VALUE",r.END="END"})(e=t.Type||(t.Type={}));let n;(function(r){r[r.BEGIN=0]="BEGIN",r[r.VALUE=1]="VALUE",r[r.END=2]="END"})(n||(n={})),function(r){r.codec=()=>F(n)}(e=t.Type||(t.Type={})),t.codec=()=>L({1:{name:"type",codec:t.Type.codec()},2:{name:"peer",codec:W.codec(),optional:!0},3:{name:"value",codec:g,optional:!0}}),t.encode=r=>y(r,t.codec()),t.decode=r=>x(r,t.codec())})(Ee||(Ee={}));var W;(function(t){t.codec=()=>L({1:{name:"id",codec:g},2:{name:"addrs",codec:g,repeats:!0}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(W||(W={}));var xe;(function(t){let e;(function(r){r.TAG_PEER="TAG_PEER",r.UNTAG_PEER="UNTAG_PEER",r.TRIM="TRIM"})(e=t.Type||(t.Type={}));let n;(function(r){r[r.TAG_PEER=0]="TAG_PEER",r[r.UNTAG_PEER=1]="UNTAG_PEER",r[r.TRIM=2]="TRIM"})(n||(n={})),function(r){r.codec=()=>F(n)}(e=t.Type||(t.Type={})),t.codec=()=>L({1:{name:"type",codec:t.Type.codec()},2:{name:"peer",codec:g,optional:!0},3:{name:"tag",codec:C,optional:!0},4:{name:"weight",codec:Q,optional:!0}}),t.encode=r=>y(r,t.codec()),t.decode=r=>x(r,t.codec())})(xe||(xe={}));var ye;(function(t){t.codec=()=>L({1:{name:"peer",codec:g}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(ye||(ye={}));var Le;(function(t){let e;(function(r){r.GET_TOPICS="GET_TOPICS",r.LIST_PEERS="LIST_PEERS",r.PUBLISH="PUBLISH",r.SUBSCRIBE="SUBSCRIBE"})(e=t.Type||(t.Type={}));let n;(function(r){r[r.GET_TOPICS=0]="GET_TOPICS",r[r.LIST_PEERS=1]="LIST_PEERS",r[r.PUBLISH=2]="PUBLISH",r[r.SUBSCRIBE=3]="SUBSCRIBE"})(n||(n={})),function(r){r.codec=()=>F(n)}(e=t.Type||(t.Type={})),t.codec=()=>L({1:{name:"type",codec:t.Type.codec()},2:{name:"topic",codec:C,optional:!0},3:{name:"data",codec:g,optional:!0}}),t.encode=r=>y(r,t.codec()),t.decode=r=>x(r,t.codec())})(Le||(Le={}));var Ze;(function(t){t.codec=()=>L({1:{name:"from",codec:g,optional:!0},2:{name:"data",codec:g,optional:!0},3:{name:"seqno",codec:g,optional:!0},4:{name:"topicIDs",codec:C,repeats:!0},5:{name:"signature",codec:g,optional:!0},6:{name:"key",codec:g,optional:!0}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(Ze||(Ze={}));var Ae;(function(t){t.codec=()=>L({1:{name:"topics",codec:C,repeats:!0},2:{name:"peerIDs",codec:g,repeats:!0}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(Ae||(Ae={}));var Ie;(function(t){let e;(function(r){r.GET_PROTOCOLS="GET_PROTOCOLS",r.GET_PEER_INFO="GET_PEER_INFO"})(e=t.Type||(t.Type={}));let n;(function(r){r[r.GET_PROTOCOLS=1]="GET_PROTOCOLS",r[r.GET_PEER_INFO=2]="GET_PEER_INFO"})(n||(n={})),function(r){r.codec=()=>F(n)}(e=t.Type||(t.Type={})),t.codec=()=>L({1:{name:"type",codec:t.Type.codec()},2:{name:"id",codec:g,optional:!0},3:{name:"protos",codec:C,repeats:!0}}),t.encode=r=>y(r,t.codec()),t.decode=r=>x(r,t.codec())})(Ie||(Ie={}));var Ue;(function(t){t.codec=()=>L({1:{name:"peer",codec:W.codec(),optional:!0},2:{name:"protos",codec:C,repeats:!0}}),t.encode=e=>y(e,t.codec()),t.decode=e=>x(e,t.codec())})(Ue||(Ue={}));return Ft(Qr);})();
17
- return Libp2PDaemonProtocol}));