libp2p 1.2.3-e1c01370b → 1.2.3-f0d2b52d0

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/README.md CHANGED
@@ -30,6 +30,21 @@
30
30
 
31
31
  # About
32
32
 
33
+ <!--
34
+
35
+ !IMPORTANT!
36
+
37
+ Everything in this README between "# About" and "# Install" is automatically
38
+ generated and will be overwritten the next time the doc generator is run.
39
+
40
+ To make changes to this section, please update the @packageDocumentation section
41
+ of src/index.js or src/index.ts
42
+
43
+ To experiment with formatting, please run "npm run docs" from the root of this
44
+ repo and examine the changes made.
45
+
46
+ -->
47
+
33
48
  Use the `createLibp2p` function to create a libp2p node.
34
49
 
35
50
  ## Example
package/dist/index.min.js CHANGED
@@ -17,7 +17,7 @@ ${e.join(`
17
17
  `),t),t.log.trace('handle: responded with "%s" for "%s"',o,o),{stream:n.unwrap(),protocol:o};if(o==="ls"){let s=new ye(...e.map(i=>Di.single(D(`${i}
18
18
  `))),D(`
19
19
  `));t.log.trace('handle: respond with "%s" for %s',e,o),await Dr(n,s,t),t.log.trace('handle: responded with "%s" for %s',e,o);continue}t.log('handle: respond with "na" for "%s"',o),await Dr(n,D(`na
20
- `),t),t.log('handle: responded with "na" for "%s"',o)}}var tw=500,vl=class{id;remoteAddr;remotePeer;direction;timeline;multiplexer;encryption;status;transient;log;tags;_newStream;_close;_abort;_getStreams;constructor(e){let{remoteAddr:t,remotePeer:n,newStream:o,close:s,abort:i,getStreams:a}=e;this.id=`${parseInt(String(Math.random()*1e9)).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=n,this.direction=e.direction,this.status="open",this.timeline=e.timeline,this.multiplexer=e.multiplexer,this.encryption=e.encryption,this.transient=e.transient??!1,this.log=e.logger.forComponent(`libp2p:connection:${this.direction}:${this.id}`),this.remoteAddr.getPeerId()==null&&(this.remoteAddr=this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`)),this._newStream=o,this._close=s,this._abort=i,this._getStreams=a,this.tags=[]}[Symbol.toStringTag]="Connection";[kl]=!0;get streams(){return this._getStreams()}async newStream(e,t){if(this.status==="closing")throw new w("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if(this.status==="closed")throw new w("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(e)||(e=[e]),this.transient&&t?.runOnTransientConnection!==!0)throw new w("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");let n=await this._newStream(e,t);return n.direction="outbound",n}async close(e={}){if(!(this.status==="closed"||this.status==="closing")){if(this.log("closing connection to %a",this.remoteAddr),this.status="closing",e.signal==null){let t=AbortSignal.timeout(tw);Pe(1/0,t),e={...e,signal:t}}try{this.log.trace("closing all streams"),await Promise.all(this.streams.map(async t=>t.close(e))),this.log.trace("closing underlying transport"),await this._close(e),this.log.trace("updating timeline with close time"),this.status="closed",this.timeline.close=Date.now()}catch(t){this.log.error("error encountered during graceful close of connection to %a",this.remoteAddr,t),this.abort(t)}}}abort(e){this.log.error("aborting connection to %a due to error",this.remoteAddr,e),this.status="closing",this.streams.forEach(t=>{t.abort(e)}),this.log.error("all streams aborted",this.streams.length),this._abort(e),this.timeline.close=Date.now(),this.status="closed"}};function vd(r){return new vl(r)}var rw=3e4;function nw(r,e){try{let{options:t}=e.getHandler(r);return t.maxInboundStreams}catch(t){if(t.code!==B.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return pl}function ow(r,e,t={}){try{let{options:n}=e.getHandler(r);if(n.maxOutboundStreams!=null)return n.maxOutboundStreams}catch(n){if(n.code!==B.ERR_NO_HANDLER_FOR_PROTOCOL)throw n}return t.maxOutboundStreams??ml}function Ad(r,e,t){let n=0;return t.streams.forEach(o=>{o.direction===e&&o.protocol===r&&n++}),n}var Pi=class{components;connectionEncryption;muxers;inboundUpgradeTimeout;events;constructor(e,t){this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach(n=>{this.connectionEncryption.set(n.protocol,n)}),this.muxers=new Map,t.muxers.forEach(n=>{this.muxers.set(n.protocol,n)}),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout??3e4,this.events=e.events}async shouldBlockConnection(e,t,n){let o=this.components.connectionGater[n];if(o!==void 0&&await o(e,t))throw new w(`The multiaddr connection is blocked by gater.${n}`,B.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(e,t){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw new w("connection denied",B.ERR_CONNECTION_DENIED);let o,s,i,a,c,u=AbortSignal.timeout(this.inboundUpgradeTimeout),f=()=>{e.abort(new w("inbound upgrade timeout",Eo))};u.addEventListener("abort",f,{once:!0}),Pe(1/0,u);try{if(await this.components.connectionGater.denyInboundConnection?.(e)===!0)throw new w("The multiaddr connection is blocked by gater.acceptConnection",B.ERR_CONNECTION_INTERCEPTED);this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the inbound connection upgrade");let l=e;if(t?.skipProtection!==!0){let h=this.components.connectionProtector;h!=null&&(e.log("protecting the inbound connection"),l=await h.protect(e))}try{if(o=l,t?.skipEncryption!==!0){({conn:o,remotePeer:s,protocol:c}=await this._encryptInbound(l));let h={...l,...o};await this.shouldBlockConnection(s,h,"denyInboundEncryptedConnection")}else{let h=e.remoteAddr.getPeerId();if(h==null)throw new w("inbound connection that skipped encryption must have a peer id",B.ERR_INVALID_MULTIADDR);let g=ge(h);c="native",s=g}if(i=o,t?.muxerFactory!=null)a=t.muxerFactory;else if(this.muxers.size>0){let h=await this._multiplexInbound({...l,...o},this.muxers);a=h.muxerFactory,i=h.stream}}catch(h){throw e.log.error("failed to upgrade inbound connection",h),h}return await this.shouldBlockConnection(s,e,"denyInboundUpgradedConnection"),e.log("successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:c,direction:"inbound",maConn:e,upgradedConn:i,muxerFactory:a,remotePeer:s,transient:t?.transient})}finally{u.removeEventListener("abort",f),this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(e,t){let n=e.remoteAddr.getPeerId(),o;n!=null&&(o=ge(n),await this.shouldBlockConnection(o,e,"denyOutboundConnection"));let s,i,a,c,u;this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the outbound connection upgrade");let f=e;if(t?.skipProtection!==!0){let l=this.components.connectionProtector;l!=null&&(f=await l.protect(e))}try{if(s=f,t?.skipEncryption!==!0){({conn:s,remotePeer:i,protocol:c}=await this._encryptOutbound(f,o));let l={...f,...s};await this.shouldBlockConnection(i,l,"denyOutboundEncryptedConnection")}else{if(o==null)throw new w("Encryption was skipped but no peer id was passed",B.ERR_INVALID_PEER);c="native",i=o}if(a=s,t?.muxerFactory!=null)u=t.muxerFactory;else if(this.muxers.size>0){let l=await this._multiplexOutbound({...f,...s},this.muxers);u=l.muxerFactory,a=l.stream}}catch(l){throw e.log.error("failed to upgrade outbound connection",l),await e.close(l),l}return await this.shouldBlockConnection(i,e,"denyOutboundUpgradedConnection"),e.log("successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:c,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:u,remotePeer:i,transient:t?.transient})}_createConnection(e){let{cryptoProtocol:t,direction:n,maConn:o,upgradedConn:s,remotePeer:i,muxerFactory:a,transient:c}=e,u,f,l;a!=null&&(u=a.createStreamMuxer({direction:n,onIncomingStream:d=>{l!=null&&Promise.resolve().then(async()=>{let p=this.components.registrar.getProtocols(),{stream:m,protocol:y}=await go(d,p,{log:d.log,yieldBytes:!1});if(l==null)return;l.log("incoming stream opened on %s",y);let x=nw(y,this.components.registrar);if(Ad(y,"inbound",l)===x){let A=new w(`Too many inbound protocol streams for protocol "${y}" - limit ${x}`,B.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw d.abort(A),A}d.source=m.source,d.sink=m.sink,d.protocol=y,m.closeWrite!=null&&(d.closeWrite=m.closeWrite),m.closeRead!=null&&(d.closeRead=m.closeRead),m.close!=null&&(d.close=m.close),await this.components.peerStore.merge(i,{protocols:[y]}),this.components.metrics?.trackProtocolStream(d,l),this._onStream({connection:l,stream:d,protocol:y})}).catch(async p=>{l.log.error("error handling incoming stream id %s",d.id,p.message,p.code,p.stack),d.timeline.close==null&&await d.close()})}}),f=async(d,p={})=>{if(u==null)throw new w("Stream is not multiplexed",B.ERR_MUXER_UNAVAILABLE);l.log("starting new stream for protocols %s",d);let m=await u.newStream();l.log.trace("started new stream %s for protocols %s",m.id,d);try{if(p.signal==null){m.log("no abort signal was passed while trying to negotiate protocols %s falling back to default timeout",d);let v=AbortSignal.timeout(rw);Pe(1/0,v),p={...p,signal:v}}m.log.trace("selecting protocol from protocols %s",d);let{stream:y,protocol:x}=await mo(m,d,{...p,log:m.log,yieldBytes:!0});m.log("selected protocol %s",x);let b=ow(x,this.components.registrar,p);if(Ad(x,"outbound",l)>=b){let v=new w(`Too many outbound protocol streams for protocol "${x}" - limit ${b}`,B.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw m.abort(v),v}return await this.components.peerStore.merge(i,{protocols:[x]}),m.source=y.source,m.sink=y.sink,m.protocol=x,y.closeWrite!=null&&(m.closeWrite=y.closeWrite),y.closeRead!=null&&(m.closeRead=y.closeRead),y.close!=null&&(m.close=y.close),this.components.metrics?.trackProtocolStream(m,l),m}catch(y){throw l.log.error("could not create new stream for protocols %s",d,y),m.timeline.close==null&&m.abort(y),y.code!=null?y:new w(String(y),B.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([u.sink(s.source),s.sink(u.source)]).catch(d=>{l.log.error("error piping data through muxer",d)}));let h=o.timeline;o.timeline=new Proxy(h,{set:(...d)=>(l!=null&&d[1]==="close"&&d[2]!=null&&h.close==null&&(async()=>{try{l.status==="open"&&await l.close()}catch(p){l.log.error("error closing connection after timeline close",p)}finally{this.events.safeDispatchEvent("connection:close",{detail:l})}})().catch(p=>{l.log.error("error thrown while dispatching connection:close event",p)}),Reflect.set(...d))}),o.timeline.upgraded=Date.now();let g=()=>{throw new w("connection is not multiplexed",B.ERR_CONNECTION_NOT_MULTIPLEXED)};return l=vd({remoteAddr:o.remoteAddr,remotePeer:i,status:"open",direction:n,timeline:o.timeline,multiplexer:u?.protocol,encryption:t,transient:c,logger:this.components.logger,newStream:f??g,getStreams:()=>u!=null?u.streams:[],close:async d=>{u!=null&&(l.log.trace("close muxer"),await u.close(d)),l.log.trace("close maconn"),await o.close(d),l.log.trace("closed maconn")},abort:d=>{o.abort(d),u?.abort(d)}}),this.events.safeDispatchEvent("connection:open",{detail:l}),l}_onStream(e){let{connection:t,stream:n,protocol:o}=e,{handler:s,options:i}=this.components.registrar.getHandler(o);if(t.transient&&i.runOnTransientConnection!==!0)throw new w("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");s({connection:t,stream:n})}async _encryptInbound(e){let t=Array.from(this.connectionEncryption.keys());e.log("handling inbound crypto protocol selection",t);try{let{stream:n,protocol:o}=await go(e,t,{log:e.log}),s=this.connectionEncryption.get(o);if(s==null)throw new Error(`no crypto module found for ${o}`);return e.log("encrypting inbound connection using",o),{...await s.secureInbound(this.components.peerId,n),protocol:o}}catch(n){throw e.log.error("encrypting inbound connection to %p failed",n),new w(n.message,B.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t){let n=Array.from(this.connectionEncryption.keys());e.log("selecting outbound crypto protocol",n);try{e.log.trace("selecting encrypter from %s",n);let{stream:o,protocol:s}=await mo(e,n,{log:e.log,yieldBytes:!0}),i=this.connectionEncryption.get(s);if(i==null)throw new Error(`no crypto module found for ${s}`);return e.log("encrypting outbound connection to %p using %s",t,i),{...await i.secureOutbound(this.components.peerId,o,t),protocol:s}}catch(o){throw e.log.error("encrypting outbound connection to %p failed",o),new w(o.message,B.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){let n=Array.from(t.keys());e.log("outbound selecting muxer %s",n);try{e.log.trace("selecting stream muxer from %s",n);let{stream:o,protocol:s}=await mo(e,n,{log:e.log,yieldBytes:!0});e.log("selected %s as muxer protocol",s);let i=t.get(s);return{stream:o,muxerFactory:i}}catch(o){throw e.log.error("error multiplexing outbound connection",o),new w(String(o),B.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){let n=Array.from(t.keys());e.log("inbound handling muxers %s",n);try{let{stream:o,protocol:s}=await go(e,n,{log:e.log}),i=t.get(s);return{stream:o,muxerFactory:i}}catch(o){throw e.log.error("error multiplexing inbound connection",o),new w(String(o),B.ERR_MUXER_UNAVAILABLE)}}};var Rd="1.2.3-e1c01370b",_d="libp2p";var Al=class extends ur{peerId;peerStore;contentRouting;peerRouting;metrics;services;logger;status;components;log;constructor(e){super(),this.status="stopped";let t=new ur,n=t.dispatchEvent.bind(t);t.dispatchEvent=a=>{let c=n(a),u=this.dispatchEvent(new Hi(a.type,{detail:a.detail}));return c||u},Pe(1/0,t),this.peerId=e.peerId,this.logger=e.logger??Ls(),this.log=this.logger.forComponent("libp2p"),this.services={};let o=this.components=Uh({peerId:e.peerId,privateKey:e.privateKey,nodeInfo:e.nodeInfo??{name:_d,version:Rd},logger:this.logger,events:t,datastore:e.datastore??new Ws,connectionGater:Vh(e.connectionGater)});this.peerStore=this.configureComponent("peerStore",new Ys(o,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore})),e.metrics!=null&&(this.metrics=this.configureComponent("metrics",e.metrics(this.components))),o.events.addEventListener("peer:update",a=>{if(a.detail.previous==null){let c={id:a.detail.peer.id,multiaddrs:a.detail.peer.addresses.map(u=>u.multiaddr)};o.events.safeDispatchEvent("peer:discovery",{detail:c})}}),e.connectionProtector!=null&&this.configureComponent("connectionProtector",e.connectionProtector(o)),this.components.upgrader=new Pi(this.components,{connectionEncryption:(e.connectionEncryption??[]).map((a,c)=>this.configureComponent(`connection-encryption-${c}`,a(this.components))),muxers:(e.streamMuxers??[]).map((a,c)=>this.configureComponent(`stream-muxers-${c}`,a(this.components))),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout}),this.configureComponent("transportManager",new Ti(this.components,e.transportManager)),this.configureComponent("connectionManager",new Ri(this.components,e.connectionManager)),this.configureComponent("registrar",new Bi(this.components)),this.configureComponent("addressManager",new Xs(this.components,e.addresses));let s=(e.peerRouters??[]).map((a,c)=>this.configureComponent(`peer-router-${c}`,a(this.components)));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new Ii(this.components,{routers:s}));let i=(e.contentRouters??[]).map((a,c)=>this.configureComponent(`content-router-${c}`,a(this.components)));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new _i(this.components,{routers:i})),(e.peerDiscovery??[]).forEach((a,c)=>{this.configureComponent(`peer-discovery-${c}`,a(this.components)).addEventListener("peer",f=>{this.#e(f)})}),e.transports?.forEach((a,c)=>{this.components.transportManager.add(this.configureComponent(`transport-${c}`,a(this.components)))}),e.services!=null)for(let a of Object.keys(e.services)){let c=e.services[a],u=c(this.components);if(u==null){this.log.error("service factory %s returned null or undefined instance",a);continue}this.services[a]=u,this.configureComponent(a,u),u[Ui]!=null&&(this.log("registering service %s for content routing",a),i.push(u[Ui])),u[Vi]!=null&&(this.log("registering service %s for peer routing",a),s.push(u[Vi])),u[Mi]!=null&&(this.log("registering service %s for peer discovery",a),u[Mi].addEventListener?.("peer",f=>{this.#e(f)}))}}configureComponent(e,t){return t==null&&this.log.error("component %s was null or undefined",e),this.components[e]=t,t}async start(){if(this.status==="stopped"){this.status="starting",this.log("libp2p is starting");try{await this.components.beforeStart?.(),await this.components.start(),await this.components.afterStart?.(),this.status="started",this.safeDispatchEvent("start",{detail:this}),this.log("libp2p has started")}catch(e){throw this.log.error("An error occurred starting libp2p",e),this.status="started",await this.stop(),e}}}async stop(){this.status==="started"&&(this.log("libp2p is stopping"),this.status="stopping",await this.components.beforeStop?.(),await this.components.stop(),await this.components.afterStop?.(),this.status="stopped",this.safeDispatchEvent("stop",{detail:this}),this.log("libp2p has stopped"))}getConnections(e){return this.components.connectionManager.getConnections(e)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){let e=new lt;for(let t of this.components.connectionManager.getConnections())e.add(t.remotePeer);return Array.from(e)}async dial(e,t={}){return this.components.connectionManager.openConnection(e,{priority:75,...t})}async dialProtocol(e,t,n={}){if(t==null)throw new w("no protocols were provided to open a stream",B.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(t=Array.isArray(t)?t:[t],t.length===0)throw new w("no protocols were provided to open a stream",B.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this.dial(e,n)).newStream(t,n)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(e,t={}){or(e)&&(e=ge(e.getPeerId()??"")),await this.components.connectionManager.closeConnections(e,t)}async getPublicKey(e,t={}){if(this.log("getPublicKey %p",e),e.publicKey!=null)return e.publicKey;try{let s=await this.peerStore.get(e);if(s.id.publicKey!=null)return s.id.publicKey}catch(s){if(s.code!==B.ERR_NOT_FOUND)throw s}let n=Re([D("/pk/"),e.multihash.digest]),o=await this.contentRouting.get(n,t);return Jn(o),await this.peerStore.patch(e,{publicKey:o}),o}async handle(e,t,n){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async o=>{await this.components.registrar.handle(o,t,n)}))}async unhandle(e){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async t=>{await this.components.registrar.unhandle(t)}))}async register(e,t){return this.components.registrar.register(e,t)}unregister(e){this.components.registrar.unregister(e)}#e(e){let{detail:t}=e;if(t.id.toString()===this.peerId.toString()){this.log.error(new Error(B.ERR_DISCOVERED_SELF));return}this.components.peerStore.merge(t.id,{multiaddrs:t.multiaddrs}).catch(n=>{this.log.error(n)})}};async function Sd(r={}){let e=r.peerId??=await Zf();if(e.privateKey==null)throw new w("peer id was missing private key","ERR_MISSING_PRIVATE_KEY");return r.privateKey??=await Qn(e.privateKey),new Al(await fd(r))}async function iw(r={}){let e=await Sd(r);return r.start!==!1&&await e.start(),e}return Vd(aw);})();
20
+ `),t),t.log('handle: responded with "na" for "%s"',o)}}var tw=500,vl=class{id;remoteAddr;remotePeer;direction;timeline;multiplexer;encryption;status;transient;log;tags;_newStream;_close;_abort;_getStreams;constructor(e){let{remoteAddr:t,remotePeer:n,newStream:o,close:s,abort:i,getStreams:a}=e;this.id=`${parseInt(String(Math.random()*1e9)).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=n,this.direction=e.direction,this.status="open",this.timeline=e.timeline,this.multiplexer=e.multiplexer,this.encryption=e.encryption,this.transient=e.transient??!1,this.log=e.logger.forComponent(`libp2p:connection:${this.direction}:${this.id}`),this.remoteAddr.getPeerId()==null&&(this.remoteAddr=this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`)),this._newStream=o,this._close=s,this._abort=i,this._getStreams=a,this.tags=[]}[Symbol.toStringTag]="Connection";[kl]=!0;get streams(){return this._getStreams()}async newStream(e,t){if(this.status==="closing")throw new w("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if(this.status==="closed")throw new w("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(e)||(e=[e]),this.transient&&t?.runOnTransientConnection!==!0)throw new w("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");let n=await this._newStream(e,t);return n.direction="outbound",n}async close(e={}){if(!(this.status==="closed"||this.status==="closing")){if(this.log("closing connection to %a",this.remoteAddr),this.status="closing",e.signal==null){let t=AbortSignal.timeout(tw);Pe(1/0,t),e={...e,signal:t}}try{this.log.trace("closing all streams"),await Promise.all(this.streams.map(async t=>t.close(e))),this.log.trace("closing underlying transport"),await this._close(e),this.log.trace("updating timeline with close time"),this.status="closed",this.timeline.close=Date.now()}catch(t){this.log.error("error encountered during graceful close of connection to %a",this.remoteAddr,t),this.abort(t)}}}abort(e){this.log.error("aborting connection to %a due to error",this.remoteAddr,e),this.status="closing",this.streams.forEach(t=>{t.abort(e)}),this.log.error("all streams aborted",this.streams.length),this._abort(e),this.timeline.close=Date.now(),this.status="closed"}};function vd(r){return new vl(r)}var rw=3e4;function nw(r,e){try{let{options:t}=e.getHandler(r);return t.maxInboundStreams}catch(t){if(t.code!==B.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return pl}function ow(r,e,t={}){try{let{options:n}=e.getHandler(r);if(n.maxOutboundStreams!=null)return n.maxOutboundStreams}catch(n){if(n.code!==B.ERR_NO_HANDLER_FOR_PROTOCOL)throw n}return t.maxOutboundStreams??ml}function Ad(r,e,t){let n=0;return t.streams.forEach(o=>{o.direction===e&&o.protocol===r&&n++}),n}var Pi=class{components;connectionEncryption;muxers;inboundUpgradeTimeout;events;constructor(e,t){this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach(n=>{this.connectionEncryption.set(n.protocol,n)}),this.muxers=new Map,t.muxers.forEach(n=>{this.muxers.set(n.protocol,n)}),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout??3e4,this.events=e.events}async shouldBlockConnection(e,t,n){let o=this.components.connectionGater[n];if(o!==void 0&&await o(e,t))throw new w(`The multiaddr connection is blocked by gater.${n}`,B.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(e,t){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw new w("connection denied",B.ERR_CONNECTION_DENIED);let o,s,i,a,c,u=AbortSignal.timeout(this.inboundUpgradeTimeout),f=()=>{e.abort(new w("inbound upgrade timeout",Eo))};u.addEventListener("abort",f,{once:!0}),Pe(1/0,u);try{if(await this.components.connectionGater.denyInboundConnection?.(e)===!0)throw new w("The multiaddr connection is blocked by gater.acceptConnection",B.ERR_CONNECTION_INTERCEPTED);this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the inbound connection upgrade");let l=e;if(t?.skipProtection!==!0){let h=this.components.connectionProtector;h!=null&&(e.log("protecting the inbound connection"),l=await h.protect(e))}try{if(o=l,t?.skipEncryption!==!0){({conn:o,remotePeer:s,protocol:c}=await this._encryptInbound(l));let h={...l,...o};await this.shouldBlockConnection(s,h,"denyInboundEncryptedConnection")}else{let h=e.remoteAddr.getPeerId();if(h==null)throw new w("inbound connection that skipped encryption must have a peer id",B.ERR_INVALID_MULTIADDR);let g=ge(h);c="native",s=g}if(i=o,t?.muxerFactory!=null)a=t.muxerFactory;else if(this.muxers.size>0){let h=await this._multiplexInbound({...l,...o},this.muxers);a=h.muxerFactory,i=h.stream}}catch(h){throw e.log.error("failed to upgrade inbound connection",h),h}return await this.shouldBlockConnection(s,e,"denyInboundUpgradedConnection"),e.log("successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:c,direction:"inbound",maConn:e,upgradedConn:i,muxerFactory:a,remotePeer:s,transient:t?.transient})}finally{u.removeEventListener("abort",f),this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(e,t){let n=e.remoteAddr.getPeerId(),o;n!=null&&(o=ge(n),await this.shouldBlockConnection(o,e,"denyOutboundConnection"));let s,i,a,c,u;this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the outbound connection upgrade");let f=e;if(t?.skipProtection!==!0){let l=this.components.connectionProtector;l!=null&&(f=await l.protect(e))}try{if(s=f,t?.skipEncryption!==!0){({conn:s,remotePeer:i,protocol:c}=await this._encryptOutbound(f,o));let l={...f,...s};await this.shouldBlockConnection(i,l,"denyOutboundEncryptedConnection")}else{if(o==null)throw new w("Encryption was skipped but no peer id was passed",B.ERR_INVALID_PEER);c="native",i=o}if(a=s,t?.muxerFactory!=null)u=t.muxerFactory;else if(this.muxers.size>0){let l=await this._multiplexOutbound({...f,...s},this.muxers);u=l.muxerFactory,a=l.stream}}catch(l){throw e.log.error("failed to upgrade outbound connection",l),await e.close(l),l}return await this.shouldBlockConnection(i,e,"denyOutboundUpgradedConnection"),e.log("successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:c,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:u,remotePeer:i,transient:t?.transient})}_createConnection(e){let{cryptoProtocol:t,direction:n,maConn:o,upgradedConn:s,remotePeer:i,muxerFactory:a,transient:c}=e,u,f,l;a!=null&&(u=a.createStreamMuxer({direction:n,onIncomingStream:d=>{l!=null&&Promise.resolve().then(async()=>{let p=this.components.registrar.getProtocols(),{stream:m,protocol:y}=await go(d,p,{log:d.log,yieldBytes:!1});if(l==null)return;l.log("incoming stream opened on %s",y);let x=nw(y,this.components.registrar);if(Ad(y,"inbound",l)===x){let A=new w(`Too many inbound protocol streams for protocol "${y}" - limit ${x}`,B.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw d.abort(A),A}d.source=m.source,d.sink=m.sink,d.protocol=y,m.closeWrite!=null&&(d.closeWrite=m.closeWrite),m.closeRead!=null&&(d.closeRead=m.closeRead),m.close!=null&&(d.close=m.close),await this.components.peerStore.merge(i,{protocols:[y]}),this.components.metrics?.trackProtocolStream(d,l),this._onStream({connection:l,stream:d,protocol:y})}).catch(async p=>{l.log.error("error handling incoming stream id %s",d.id,p.message,p.code,p.stack),d.timeline.close==null&&await d.close()})}}),f=async(d,p={})=>{if(u==null)throw new w("Stream is not multiplexed",B.ERR_MUXER_UNAVAILABLE);l.log("starting new stream for protocols %s",d);let m=await u.newStream();l.log.trace("started new stream %s for protocols %s",m.id,d);try{if(p.signal==null){m.log("no abort signal was passed while trying to negotiate protocols %s falling back to default timeout",d);let v=AbortSignal.timeout(rw);Pe(1/0,v),p={...p,signal:v}}m.log.trace("selecting protocol from protocols %s",d);let{stream:y,protocol:x}=await mo(m,d,{...p,log:m.log,yieldBytes:!0});m.log("selected protocol %s",x);let b=ow(x,this.components.registrar,p);if(Ad(x,"outbound",l)>=b){let v=new w(`Too many outbound protocol streams for protocol "${x}" - limit ${b}`,B.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw m.abort(v),v}return await this.components.peerStore.merge(i,{protocols:[x]}),m.source=y.source,m.sink=y.sink,m.protocol=x,y.closeWrite!=null&&(m.closeWrite=y.closeWrite),y.closeRead!=null&&(m.closeRead=y.closeRead),y.close!=null&&(m.close=y.close),this.components.metrics?.trackProtocolStream(m,l),m}catch(y){throw l.log.error("could not create new stream for protocols %s",d,y),m.timeline.close==null&&m.abort(y),y.code!=null?y:new w(String(y),B.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([u.sink(s.source),s.sink(u.source)]).catch(d=>{l.log.error("error piping data through muxer",d)}));let h=o.timeline;o.timeline=new Proxy(h,{set:(...d)=>(l!=null&&d[1]==="close"&&d[2]!=null&&h.close==null&&(async()=>{try{l.status==="open"&&await l.close()}catch(p){l.log.error("error closing connection after timeline close",p)}finally{this.events.safeDispatchEvent("connection:close",{detail:l})}})().catch(p=>{l.log.error("error thrown while dispatching connection:close event",p)}),Reflect.set(...d))}),o.timeline.upgraded=Date.now();let g=()=>{throw new w("connection is not multiplexed",B.ERR_CONNECTION_NOT_MULTIPLEXED)};return l=vd({remoteAddr:o.remoteAddr,remotePeer:i,status:"open",direction:n,timeline:o.timeline,multiplexer:u?.protocol,encryption:t,transient:c,logger:this.components.logger,newStream:f??g,getStreams:()=>u!=null?u.streams:[],close:async d=>{u!=null&&(l.log.trace("close muxer"),await u.close(d)),l.log.trace("close maconn"),await o.close(d),l.log.trace("closed maconn")},abort:d=>{o.abort(d),u?.abort(d)}}),this.events.safeDispatchEvent("connection:open",{detail:l}),l}_onStream(e){let{connection:t,stream:n,protocol:o}=e,{handler:s,options:i}=this.components.registrar.getHandler(o);if(t.transient&&i.runOnTransientConnection!==!0)throw new w("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");s({connection:t,stream:n})}async _encryptInbound(e){let t=Array.from(this.connectionEncryption.keys());e.log("handling inbound crypto protocol selection",t);try{let{stream:n,protocol:o}=await go(e,t,{log:e.log}),s=this.connectionEncryption.get(o);if(s==null)throw new Error(`no crypto module found for ${o}`);return e.log("encrypting inbound connection using",o),{...await s.secureInbound(this.components.peerId,n),protocol:o}}catch(n){throw e.log.error("encrypting inbound connection to %p failed",n),new w(n.message,B.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t){let n=Array.from(this.connectionEncryption.keys());e.log("selecting outbound crypto protocol",n);try{e.log.trace("selecting encrypter from %s",n);let{stream:o,protocol:s}=await mo(e,n,{log:e.log,yieldBytes:!0}),i=this.connectionEncryption.get(s);if(i==null)throw new Error(`no crypto module found for ${s}`);return e.log("encrypting outbound connection to %p using %s",t,i),{...await i.secureOutbound(this.components.peerId,o,t),protocol:s}}catch(o){throw e.log.error("encrypting outbound connection to %p failed",o),new w(o.message,B.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){let n=Array.from(t.keys());e.log("outbound selecting muxer %s",n);try{e.log.trace("selecting stream muxer from %s",n);let{stream:o,protocol:s}=await mo(e,n,{log:e.log,yieldBytes:!0});e.log("selected %s as muxer protocol",s);let i=t.get(s);return{stream:o,muxerFactory:i}}catch(o){throw e.log.error("error multiplexing outbound connection",o),new w(String(o),B.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){let n=Array.from(t.keys());e.log("inbound handling muxers %s",n);try{let{stream:o,protocol:s}=await go(e,n,{log:e.log}),i=t.get(s);return{stream:o,muxerFactory:i}}catch(o){throw e.log.error("error multiplexing inbound connection",o),new w(String(o),B.ERR_MUXER_UNAVAILABLE)}}};var Rd="1.2.3-f0d2b52d0",_d="libp2p";var Al=class extends ur{peerId;peerStore;contentRouting;peerRouting;metrics;services;logger;status;components;log;constructor(e){super(),this.status="stopped";let t=new ur,n=t.dispatchEvent.bind(t);t.dispatchEvent=a=>{let c=n(a),u=this.dispatchEvent(new Hi(a.type,{detail:a.detail}));return c||u},Pe(1/0,t),this.peerId=e.peerId,this.logger=e.logger??Ls(),this.log=this.logger.forComponent("libp2p"),this.services={};let o=this.components=Uh({peerId:e.peerId,privateKey:e.privateKey,nodeInfo:e.nodeInfo??{name:_d,version:Rd},logger:this.logger,events:t,datastore:e.datastore??new Ws,connectionGater:Vh(e.connectionGater)});this.peerStore=this.configureComponent("peerStore",new Ys(o,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore})),e.metrics!=null&&(this.metrics=this.configureComponent("metrics",e.metrics(this.components))),o.events.addEventListener("peer:update",a=>{if(a.detail.previous==null){let c={id:a.detail.peer.id,multiaddrs:a.detail.peer.addresses.map(u=>u.multiaddr)};o.events.safeDispatchEvent("peer:discovery",{detail:c})}}),e.connectionProtector!=null&&this.configureComponent("connectionProtector",e.connectionProtector(o)),this.components.upgrader=new Pi(this.components,{connectionEncryption:(e.connectionEncryption??[]).map((a,c)=>this.configureComponent(`connection-encryption-${c}`,a(this.components))),muxers:(e.streamMuxers??[]).map((a,c)=>this.configureComponent(`stream-muxers-${c}`,a(this.components))),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout}),this.configureComponent("transportManager",new Ti(this.components,e.transportManager)),this.configureComponent("connectionManager",new Ri(this.components,e.connectionManager)),this.configureComponent("registrar",new Bi(this.components)),this.configureComponent("addressManager",new Xs(this.components,e.addresses));let s=(e.peerRouters??[]).map((a,c)=>this.configureComponent(`peer-router-${c}`,a(this.components)));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new Ii(this.components,{routers:s}));let i=(e.contentRouters??[]).map((a,c)=>this.configureComponent(`content-router-${c}`,a(this.components)));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new _i(this.components,{routers:i})),(e.peerDiscovery??[]).forEach((a,c)=>{this.configureComponent(`peer-discovery-${c}`,a(this.components)).addEventListener("peer",f=>{this.#e(f)})}),e.transports?.forEach((a,c)=>{this.components.transportManager.add(this.configureComponent(`transport-${c}`,a(this.components)))}),e.services!=null)for(let a of Object.keys(e.services)){let c=e.services[a],u=c(this.components);if(u==null){this.log.error("service factory %s returned null or undefined instance",a);continue}this.services[a]=u,this.configureComponent(a,u),u[Ui]!=null&&(this.log("registering service %s for content routing",a),i.push(u[Ui])),u[Vi]!=null&&(this.log("registering service %s for peer routing",a),s.push(u[Vi])),u[Mi]!=null&&(this.log("registering service %s for peer discovery",a),u[Mi].addEventListener?.("peer",f=>{this.#e(f)}))}}configureComponent(e,t){return t==null&&this.log.error("component %s was null or undefined",e),this.components[e]=t,t}async start(){if(this.status==="stopped"){this.status="starting",this.log("libp2p is starting");try{await this.components.beforeStart?.(),await this.components.start(),await this.components.afterStart?.(),this.status="started",this.safeDispatchEvent("start",{detail:this}),this.log("libp2p has started")}catch(e){throw this.log.error("An error occurred starting libp2p",e),this.status="started",await this.stop(),e}}}async stop(){this.status==="started"&&(this.log("libp2p is stopping"),this.status="stopping",await this.components.beforeStop?.(),await this.components.stop(),await this.components.afterStop?.(),this.status="stopped",this.safeDispatchEvent("stop",{detail:this}),this.log("libp2p has stopped"))}getConnections(e){return this.components.connectionManager.getConnections(e)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){let e=new lt;for(let t of this.components.connectionManager.getConnections())e.add(t.remotePeer);return Array.from(e)}async dial(e,t={}){return this.components.connectionManager.openConnection(e,{priority:75,...t})}async dialProtocol(e,t,n={}){if(t==null)throw new w("no protocols were provided to open a stream",B.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(t=Array.isArray(t)?t:[t],t.length===0)throw new w("no protocols were provided to open a stream",B.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this.dial(e,n)).newStream(t,n)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(e,t={}){or(e)&&(e=ge(e.getPeerId()??"")),await this.components.connectionManager.closeConnections(e,t)}async getPublicKey(e,t={}){if(this.log("getPublicKey %p",e),e.publicKey!=null)return e.publicKey;try{let s=await this.peerStore.get(e);if(s.id.publicKey!=null)return s.id.publicKey}catch(s){if(s.code!==B.ERR_NOT_FOUND)throw s}let n=Re([D("/pk/"),e.multihash.digest]),o=await this.contentRouting.get(n,t);return Jn(o),await this.peerStore.patch(e,{publicKey:o}),o}async handle(e,t,n){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async o=>{await this.components.registrar.handle(o,t,n)}))}async unhandle(e){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async t=>{await this.components.registrar.unhandle(t)}))}async register(e,t){return this.components.registrar.register(e,t)}unregister(e){this.components.registrar.unregister(e)}#e(e){let{detail:t}=e;if(t.id.toString()===this.peerId.toString()){this.log.error(new Error(B.ERR_DISCOVERED_SELF));return}this.components.peerStore.merge(t.id,{multiaddrs:t.multiaddrs}).catch(n=>{this.log.error(n)})}};async function Sd(r={}){let e=r.peerId??=await Zf();if(e.privateKey==null)throw new w("peer id was missing private key","ERR_MISSING_PRIVATE_KEY");return r.privateKey??=await Qn(e.privateKey),new Al(await fd(r))}async function iw(r={}){let e=await Sd(r);return r.start!==!1&&await e.start(),e}return Vd(aw);})();
21
21
  /*! Bundled license information:
22
22
 
23
23
  pvtsutils/build/index.js:
@@ -103,7 +103,7 @@ export interface Libp2pInit<T extends ServiceMap = {
103
103
  *
104
104
  * Browsers:
105
105
  *
106
- * ```javascript
106
+ * ```TypeScript
107
107
  * localStorage.setItem('debug', '*libp2p:*')
108
108
  * ```
109
109
  */
@@ -121,7 +121,7 @@ export type Libp2pOptions<T extends ServiceMap = Record<string, unknown>> = Recu
121
121
  *
122
122
  * @example
123
123
  *
124
- * ```js
124
+ * ```TypeScript
125
125
  * import { createLibp2p } from 'libp2p'
126
126
  * import { tcp } from '@libp2p/tcp'
127
127
  * import { mplex } from '@libp2p/mplex'
package/dist/src/index.js CHANGED
@@ -22,7 +22,7 @@ import { createLibp2pNode } from './libp2p.js';
22
22
  *
23
23
  * @example
24
24
  *
25
- * ```js
25
+ * ```TypeScript
26
26
  * import { createLibp2p } from 'libp2p'
27
27
  * import { tcp } from '@libp2p/tcp'
28
28
  * import { mplex } from '@libp2p/mplex'
@@ -1,3 +1,3 @@
1
- export declare const version = "1.2.3-e1c01370b";
1
+ export declare const version = "1.2.3-f0d2b52d0";
2
2
  export declare const name = "libp2p";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
- export const version = '1.2.3-e1c01370b';
1
+ export const version = '1.2.3-f0d2b52d0';
2
2
  export const name = 'libp2p';
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libp2p",
3
- "version": "1.2.3-e1c01370b",
3
+ "version": "1.2.3-f0d2b52d0",
4
4
  "description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/libp2p#readme",
@@ -73,6 +73,7 @@
73
73
  "clean": "aegir clean",
74
74
  "lint": "aegir lint",
75
75
  "dep-check": "aegir dep-check",
76
+ "doc-check": "aegir doc-check",
76
77
  "prepublishOnly": "node scripts/update-version.js && npm run build",
77
78
  "build": "aegir build",
78
79
  "test": "aegir test",
@@ -84,38 +85,38 @@
84
85
  "test:webkit": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" -- --browser webkit"
85
86
  },
86
87
  "dependencies": {
87
- "@libp2p/crypto": "4.0.2-e1c01370b",
88
- "@libp2p/interface": "1.1.3-e1c01370b",
89
- "@libp2p/interface-internal": "1.0.8-e1c01370b",
90
- "@libp2p/logger": "4.0.6-e1c01370b",
91
- "@libp2p/multistream-select": "5.1.3-e1c01370b",
92
- "@libp2p/peer-collections": "5.1.6-e1c01370b",
93
- "@libp2p/peer-id": "4.0.6-e1c01370b",
94
- "@libp2p/peer-id-factory": "4.0.6-e1c01370b",
95
- "@libp2p/peer-store": "10.0.10-e1c01370b",
96
- "@libp2p/utils": "5.2.5-e1c01370b",
88
+ "@libp2p/crypto": "4.0.2-f0d2b52d0",
89
+ "@libp2p/interface": "1.1.3-f0d2b52d0",
90
+ "@libp2p/interface-internal": "1.0.8-f0d2b52d0",
91
+ "@libp2p/logger": "4.0.6-f0d2b52d0",
92
+ "@libp2p/multistream-select": "5.1.3-f0d2b52d0",
93
+ "@libp2p/peer-collections": "5.1.6-f0d2b52d0",
94
+ "@libp2p/peer-id": "4.0.6-f0d2b52d0",
95
+ "@libp2p/peer-id-factory": "4.0.6-f0d2b52d0",
96
+ "@libp2p/peer-store": "10.0.10-f0d2b52d0",
97
+ "@libp2p/utils": "5.2.5-f0d2b52d0",
97
98
  "@multiformats/multiaddr": "^12.1.14",
98
99
  "any-signal": "^4.1.1",
99
- "datastore-core": "^9.2.7",
100
- "interface-datastore": "^8.2.10",
100
+ "datastore-core": "^9.2.8",
101
+ "interface-datastore": "^8.2.11",
101
102
  "it-merge": "^3.0.3",
102
103
  "it-parallel": "^3.0.6",
103
104
  "merge-options": "^3.0.4",
104
- "multiformats": "^13.0.1",
105
- "uint8arrays": "^5.0.1"
105
+ "multiformats": "^13.1.0",
106
+ "uint8arrays": "^5.0.2"
106
107
  },
107
108
  "devDependencies": {
108
- "@chainsafe/libp2p-yamux": "^6.0.1",
109
- "@libp2p/circuit-relay-v2": "1.0.15-e1c01370b",
110
- "@libp2p/identify": "1.0.14-e1c01370b",
111
- "@libp2p/interface-compliance-tests": "5.3.1-e1c01370b",
112
- "@libp2p/mplex": "10.0.15-e1c01370b",
113
- "@libp2p/plaintext": "1.0.15-e1c01370b",
114
- "@libp2p/tcp": "9.0.15-e1c01370b",
115
- "@libp2p/websockets": "8.0.15-e1c01370b",
109
+ "@chainsafe/libp2p-yamux": "^6.0.2",
110
+ "@libp2p/circuit-relay-v2": "1.0.15-f0d2b52d0",
111
+ "@libp2p/identify": "1.0.14-f0d2b52d0",
112
+ "@libp2p/interface-compliance-tests": "5.3.1-f0d2b52d0",
113
+ "@libp2p/mplex": "10.0.15-f0d2b52d0",
114
+ "@libp2p/plaintext": "1.0.15-f0d2b52d0",
115
+ "@libp2p/tcp": "9.0.15-f0d2b52d0",
116
+ "@libp2p/websockets": "8.0.15-f0d2b52d0",
116
117
  "@multiformats/mafmt": "^12.1.6",
117
118
  "@multiformats/multiaddr-matcher": "^1.1.2",
118
- "aegir": "^42.2.3",
119
+ "aegir": "^42.2.4",
119
120
  "delay": "^6.0.0",
120
121
  "it-all": "^3.0.4",
121
122
  "it-drain": "^3.0.5",
package/src/index.ts CHANGED
@@ -118,7 +118,7 @@ export interface Libp2pInit<T extends ServiceMap = { x: Record<string, unknown>
118
118
  *
119
119
  * Browsers:
120
120
  *
121
- * ```javascript
121
+ * ```TypeScript
122
122
  * localStorage.setItem('debug', '*libp2p:*')
123
123
  * ```
124
124
  */
@@ -137,7 +137,7 @@ export type Libp2pOptions<T extends ServiceMap = Record<string, unknown>> = Recu
137
137
  *
138
138
  * @example
139
139
  *
140
- * ```js
140
+ * ```TypeScript
141
141
  * import { createLibp2p } from 'libp2p'
142
142
  * import { tcp } from '@libp2p/tcp'
143
143
  * import { mplex } from '@libp2p/mplex'
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '1.2.3-e1c01370b'
1
+ export const version = '1.2.3-f0d2b52d0'
2
2
  export const name = 'libp2p'