New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

libp2p

Package Overview
Dependencies
Maintainers
2
Versions
1051
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libp2p - npm Package Compare versions

Comparing version 2.6.0 to 2.6.1-2e35b6055

17

dist/src/connection-manager/index.d.ts

@@ -60,2 +60,4 @@ import { PeerMap } from '@libp2p/peer-collections';

*
* Does not apply if an abort signal is passed to the `.dial` method.
*
* @default 3000

@@ -68,5 +70,20 @@ */

* @default 2000
* @deprecated use outboundStreamProtocolNegotiationTimeout or inboundStreamProtocolNegotiationTimeout instead
*/
protocolNegotiationTimeout?: number;
/**
* Outbound protocol negotiation must complete within this number of ms.
*
* Does not apply if an abort signal is passed to the `.dial` method.
*
* @default 2000
*/
outboundStreamProtocolNegotiationTimeout?: number;
/**
* Inbound protocol negotiation must complete within this number of ms
*
* @default 2000
*/
inboundStreamProtocolNegotiationTimeout?: number;
/**
* Multiaddr resolvers to use when dialling

@@ -73,0 +90,0 @@ */

5

dist/src/libp2p.js

@@ -35,2 +35,3 @@ import { publicKeyFromProtobuf } from '@libp2p/crypto/keys';

log;
// eslint-disable-next-line complexity
constructor(init) {

@@ -99,3 +100,5 @@ super();

inboundUpgradeTimeout: init.connectionManager?.inboundUpgradeTimeout,
outboundUpgradeTimeout: init.connectionManager?.outboundUpgradeTimeout
outboundUpgradeTimeout: init.connectionManager?.outboundUpgradeTimeout,
inboundStreamProtocolNegotiationTimeout: init.connectionManager?.inboundStreamProtocolNegotiationTimeout ?? init.connectionManager?.protocolNegotiationTimeout,
outboundStreamProtocolNegotiationTimeout: init.connectionManager?.outboundStreamProtocolNegotiationTimeout ?? init.connectionManager?.protocolNegotiationTimeout
});

@@ -102,0 +105,0 @@ // Setup the transport manager

24

dist/src/upgrader.js
import { InvalidMultiaddrError, TooManyInboundProtocolStreamsError, TooManyOutboundProtocolStreamsError, LimitedConnectionError, setMaxListeners, InvalidPeerIdError } from '@libp2p/interface';
import * as mss from '@libp2p/multistream-select';
import { peerIdFromString } from '@libp2p/peer-id';
import { anySignal } from 'any-signal';
import { CustomProgressEvent } from 'progress-events';

@@ -148,6 +147,8 @@ import { createConnection } from './connection/index.js';

let cryptoProtocol;
const upgradeTimeoutSignal = AbortSignal.timeout(direction === 'inbound' ? this.inboundUpgradeTimeout : this.outboundUpgradeTimeout);
const signal = anySignal([upgradeTimeoutSignal, opts.signal]);
setMaxListeners(Infinity, upgradeTimeoutSignal, signal);
opts.signal = signal;
if (opts.signal == null) {
maConn.log('no abort signal was passed while trying to upgrade connection, falling back to default timeout');
const upgradeTimeoutSignal = AbortSignal.timeout(direction === 'inbound' ? this.inboundUpgradeTimeout : this.outboundUpgradeTimeout);
setMaxListeners(Infinity, upgradeTimeoutSignal);
opts.signal = upgradeTimeoutSignal;
}
this.components.metrics?.trackMultiaddrConnection(maConn);

@@ -174,10 +175,4 @@ maConn.log.trace('starting the %s connection upgrade', direction);

} = await (direction === 'inbound'
? this._encryptInbound(protectedConn, {
...opts,
signal
})
: this._encryptOutbound(protectedConn, {
...opts,
signal
})));
? this._encryptInbound(protectedConn, opts)
: this._encryptOutbound(protectedConn, opts)));
const maConn = {

@@ -229,5 +224,2 @@ ...protectedConn,

}
finally {
signal.clear();
}
await this.shouldBlockConnection(direction === 'inbound' ? 'denyInboundUpgradedConnection' : 'denyOutboundUpgradedConnection', remotePeer, maConn);

@@ -234,0 +226,0 @@ maConn.log('successfully upgraded %s connection', direction);

@@ -1,3 +0,3 @@

export declare const version = "2.6.0";
export declare const version = "2.6.1-2e35b6055";
export declare const name = "js-libp2p";
//# sourceMappingURL=version.d.ts.map

@@ -1,3 +0,3 @@

export const version = '2.6.0';
export const version = '2.6.1-2e35b6055';
export const name = 'js-libp2p';
//# sourceMappingURL=version.js.map
{
"name": "libp2p",
"version": "2.6.0",
"version": "2.6.1-2e35b6055",
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack",

@@ -57,2 +57,3 @@ "license": "Apache-2.0 OR MIT",

"types": "./dist/src/user-agent.d.ts",
"browser": "./dist/src/user-agent.browser.js",
"import": "./dist/src/user-agent.js"

@@ -95,11 +96,11 @@ },

"@chainsafe/netmask": "^2.0.0",
"@libp2p/crypto": "^5.0.11",
"@libp2p/interface": "^2.5.0",
"@libp2p/interface-internal": "^2.3.0",
"@libp2p/logger": "^5.1.8",
"@libp2p/multistream-select": "^6.0.13",
"@libp2p/peer-collections": "^6.0.17",
"@libp2p/peer-id": "^5.0.12",
"@libp2p/peer-store": "^11.0.17",
"@libp2p/utils": "^6.5.1",
"@libp2p/crypto": "5.0.11-2e35b6055",
"@libp2p/interface": "2.5.0-2e35b6055",
"@libp2p/interface-internal": "2.3.0-2e35b6055",
"@libp2p/logger": "5.1.8-2e35b6055",
"@libp2p/multistream-select": "6.0.13-2e35b6055",
"@libp2p/peer-collections": "6.0.17-2e35b6055",
"@libp2p/peer-id": "5.0.12-2e35b6055",
"@libp2p/peer-store": "11.0.17-2e35b6055",
"@libp2p/utils": "6.5.1-2e35b6055",
"@multiformats/dns": "^1.0.6",

@@ -106,0 +107,0 @@ "@multiformats/multiaddr": "^12.3.5",

@@ -11,6 +11,35 @@ <h1 align="center">

[![Matrix](https://img.shields.io/badge/matrix-%23libp2p--implementers%3Aipfs.io-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![Discord](https://img.shields.io/discord/806902334369824788?color=blueviolet\&label=discord\&style=flat-square)](https://discord.com/invite/Ae4TbahHaT)
[![Discord](https://img.shields.io/discord/806902334369824788?color=blueviolet&label=discord&style=flat-square)](https://discord.com/invite/Ae4TbahHaT)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=main\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amain)
# About
<!--
!IMPORTANT!
Everything in this README between "# About" and "# Install" is automatically
generated and will be overwritten the next time the doc generator is run.
To make changes to this section, please update the @packageDocumentation section
of src/index.js or src/index.ts
To experiment with formatting, please run "npm run docs" from the root of this
repo and examine the changes made.
-->
Use the `createLibp2p` function to create a libp2p node.
## Example
```typescript
import { createLibp2p } from 'libp2p'
const node = await createLibp2p({
// ...other options
})
```
# Background

@@ -17,0 +46,0 @@

@@ -78,2 +78,4 @@ import { ConnectionClosedError, InvalidMultiaddrError, InvalidParametersError, InvalidPeerIdError, NotStartedError, start, stop } from '@libp2p/interface'

*
* Does not apply if an abort signal is passed to the `.dial` method.
*
* @default 3000

@@ -87,2 +89,3 @@ */

* @default 2000
* @deprecated use outboundStreamProtocolNegotiationTimeout or inboundStreamProtocolNegotiationTimeout instead
*/

@@ -92,2 +95,18 @@ protocolNegotiationTimeout?: number

/**
* Outbound protocol negotiation must complete within this number of ms.
*
* Does not apply if an abort signal is passed to the `.dial` method.
*
* @default 2000
*/
outboundStreamProtocolNegotiationTimeout?: number
/**
* Inbound protocol negotiation must complete within this number of ms
*
* @default 2000
*/
inboundStreamProtocolNegotiationTimeout?: number
/**
* Multiaddr resolvers to use when dialling

@@ -94,0 +113,0 @@ */

@@ -41,2 +41,3 @@ import { publicKeyFromProtobuf } from '@libp2p/crypto/keys'

// eslint-disable-next-line complexity
constructor (init: Libp2pInit<T> & { peerId: PeerId }) {

@@ -120,3 +121,5 @@ super()

inboundUpgradeTimeout: init.connectionManager?.inboundUpgradeTimeout,
outboundUpgradeTimeout: init.connectionManager?.outboundUpgradeTimeout
outboundUpgradeTimeout: init.connectionManager?.outboundUpgradeTimeout,
inboundStreamProtocolNegotiationTimeout: init.connectionManager?.inboundStreamProtocolNegotiationTimeout ?? init.connectionManager?.protocolNegotiationTimeout,
outboundStreamProtocolNegotiationTimeout: init.connectionManager?.outboundStreamProtocolNegotiationTimeout ?? init.connectionManager?.protocolNegotiationTimeout
})

@@ -123,0 +126,0 @@

import { InvalidMultiaddrError, TooManyInboundProtocolStreamsError, TooManyOutboundProtocolStreamsError, LimitedConnectionError, setMaxListeners, InvalidPeerIdError } from '@libp2p/interface'
import * as mss from '@libp2p/multistream-select'
import { peerIdFromString } from '@libp2p/peer-id'
import { anySignal } from 'any-signal'
import { CustomProgressEvent } from 'progress-events'

@@ -255,7 +254,10 @@ import { createConnection } from './connection/index.js'

const upgradeTimeoutSignal = AbortSignal.timeout(direction === 'inbound' ? this.inboundUpgradeTimeout : this.outboundUpgradeTimeout)
const signal = anySignal([upgradeTimeoutSignal, opts.signal])
setMaxListeners(Infinity, upgradeTimeoutSignal, signal)
opts.signal = signal
if (opts.signal == null) {
maConn.log('no abort signal was passed while trying to upgrade connection, falling back to default timeout')
const upgradeTimeoutSignal = AbortSignal.timeout(direction === 'inbound' ? this.inboundUpgradeTimeout : this.outboundUpgradeTimeout)
setMaxListeners(Infinity, upgradeTimeoutSignal)
opts.signal = upgradeTimeoutSignal
}
this.components.metrics?.trackMultiaddrConnection(maConn)

@@ -288,10 +290,4 @@

} = await (direction === 'inbound'
? this._encryptInbound(protectedConn, {
...opts,
signal
})
: this._encryptOutbound(protectedConn, {
...opts,
signal
})
? this._encryptInbound(protectedConn, opts)
: this._encryptOutbound(protectedConn, opts)
))

@@ -348,4 +344,2 @@

throw err
} finally {
signal.clear()
}

@@ -352,0 +346,0 @@

@@ -1,2 +0,2 @@

export const version = '2.6.0'
export const version = '2.6.1-2e35b6055'
export const name = 'js-libp2p'

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc