libp2p 1.7.0 → 1.8.0-3319ff41e
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 +13 -13
- package/dist/src/connection-manager/dial-queue.d.ts +5 -8
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +8 -1
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +2 -0
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +2 -2
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/transport-manager.d.ts +3 -3
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +5 -0
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +3 -0
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +19 -18
- package/src/connection-manager/dial-queue.ts +15 -11
- package/src/connection-manager/index.ts +2 -0
- package/src/libp2p.ts +2 -2
- package/src/transport-manager.ts +9 -3
- package/src/upgrader.ts +5 -0
- package/src/version.ts +1 -1
- package/dist/typedoc-urls.json +0 -14
package/dist/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAA;AACxC,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libp2p",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0-3319ff41e",
|
|
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",
|
|
@@ -85,16 +85,16 @@
|
|
|
85
85
|
"test:webkit": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" -- --browser webkit"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@libp2p/crypto": "
|
|
89
|
-
"@libp2p/interface": "
|
|
90
|
-
"@libp2p/interface-internal": "
|
|
91
|
-
"@libp2p/logger": "
|
|
92
|
-
"@libp2p/multistream-select": "
|
|
93
|
-
"@libp2p/peer-collections": "
|
|
94
|
-
"@libp2p/peer-id": "
|
|
95
|
-
"@libp2p/peer-id-factory": "
|
|
96
|
-
"@libp2p/peer-store": "
|
|
97
|
-
"@libp2p/utils": "
|
|
88
|
+
"@libp2p/crypto": "4.1.5-3319ff41e",
|
|
89
|
+
"@libp2p/interface": "1.6.0-3319ff41e",
|
|
90
|
+
"@libp2p/interface-internal": "1.3.0-3319ff41e",
|
|
91
|
+
"@libp2p/logger": "4.0.16-3319ff41e",
|
|
92
|
+
"@libp2p/multistream-select": "5.1.13-3319ff41e",
|
|
93
|
+
"@libp2p/peer-collections": "5.2.5-3319ff41e",
|
|
94
|
+
"@libp2p/peer-id": "4.2.0-3319ff41e",
|
|
95
|
+
"@libp2p/peer-id-factory": "4.2.0-3319ff41e",
|
|
96
|
+
"@libp2p/peer-store": "10.1.1-3319ff41e",
|
|
97
|
+
"@libp2p/utils": "5.4.5-3319ff41e",
|
|
98
98
|
"@multiformats/dns": "^1.0.6",
|
|
99
99
|
"@multiformats/multiaddr": "^12.2.3",
|
|
100
100
|
"@multiformats/multiaddr-matcher": "^1.2.1",
|
|
@@ -106,19 +106,20 @@
|
|
|
106
106
|
"merge-options": "^3.0.4",
|
|
107
107
|
"multiformats": "^13.1.0",
|
|
108
108
|
"p-defer": "^4.0.1",
|
|
109
|
+
"progress-events": "^1.0.0",
|
|
109
110
|
"race-event": "^1.3.0",
|
|
110
111
|
"race-signal": "^1.0.2",
|
|
111
112
|
"uint8arrays": "^5.1.0"
|
|
112
113
|
},
|
|
113
114
|
"devDependencies": {
|
|
114
115
|
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
115
|
-
"@libp2p/circuit-relay-v2": "
|
|
116
|
-
"@libp2p/identify": "
|
|
117
|
-
"@libp2p/interface-compliance-tests": "
|
|
118
|
-
"@libp2p/mplex": "
|
|
119
|
-
"@libp2p/plaintext": "
|
|
120
|
-
"@libp2p/tcp": "
|
|
121
|
-
"@libp2p/websockets": "
|
|
116
|
+
"@libp2p/circuit-relay-v2": "1.1.1-3319ff41e",
|
|
117
|
+
"@libp2p/identify": "2.1.1-3319ff41e",
|
|
118
|
+
"@libp2p/interface-compliance-tests": "5.4.8-3319ff41e",
|
|
119
|
+
"@libp2p/mplex": "10.1.1-3319ff41e",
|
|
120
|
+
"@libp2p/plaintext": "1.1.1-3319ff41e",
|
|
121
|
+
"@libp2p/tcp": "9.1.1-3319ff41e",
|
|
122
|
+
"@libp2p/websockets": "8.1.1-3319ff41e",
|
|
122
123
|
"@multiformats/mafmt": "^12.1.6",
|
|
123
124
|
"aegir": "^43.0.1",
|
|
124
125
|
"delay": "^6.0.0",
|
|
@@ -7,6 +7,7 @@ import { type Multiaddr, type Resolver, resolvers, multiaddr } from '@multiforma
|
|
|
7
7
|
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
|
|
8
8
|
import { Circuit } from '@multiformats/multiaddr-matcher'
|
|
9
9
|
import { type ClearableSignal, anySignal } from 'any-signal'
|
|
10
|
+
import { CustomProgressEvent } from 'progress-events'
|
|
10
11
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
11
12
|
import { codes } from '../errors.js'
|
|
12
13
|
import { getPeerAddress } from '../get-peer.js'
|
|
@@ -19,21 +20,17 @@ import {
|
|
|
19
20
|
} from './constants.js'
|
|
20
21
|
import { resolveMultiaddrs } from './utils.js'
|
|
21
22
|
import { DEFAULT_DIAL_PRIORITY } from './index.js'
|
|
22
|
-
import type { AddressSorter,
|
|
23
|
-
import type { TransportManager } from '@libp2p/interface-internal'
|
|
23
|
+
import type { AddressSorter, ComponentLogger, Logger, Connection, ConnectionGater, Metrics, PeerId, Address, PeerStore, PeerRouting, IsDialableOptions, OpenConnectionProgressEvents } from '@libp2p/interface'
|
|
24
|
+
import type { OpenConnectionOptions, TransportManager } from '@libp2p/interface-internal'
|
|
24
25
|
import type { DNS } from '@multiformats/dns'
|
|
26
|
+
import type { ProgressOptions } from 'progress-events'
|
|
25
27
|
|
|
26
28
|
export interface PendingDialTarget {
|
|
27
29
|
resolve(value: any): void
|
|
28
30
|
reject(err: Error): void
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
priority?: number
|
|
33
|
-
force?: boolean
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface DialQueueJobOptions extends PriorityQueueJobOptions {
|
|
33
|
+
interface DialQueueJobOptions extends PriorityQueueJobOptions, ProgressOptions<OpenConnectionProgressEvents> {
|
|
37
34
|
peerId?: PeerId
|
|
38
35
|
multiaddrs: Set<string>
|
|
39
36
|
}
|
|
@@ -134,7 +131,7 @@ export class DialQueue {
|
|
|
134
131
|
* The dial to the first address that is successfully able to upgrade a
|
|
135
132
|
* connection will be used, all other dials will be aborted when that happens.
|
|
136
133
|
*/
|
|
137
|
-
async dial (peerIdOrMultiaddr: PeerId | Multiaddr | Multiaddr[], options:
|
|
134
|
+
async dial (peerIdOrMultiaddr: PeerId | Multiaddr | Multiaddr[], options: OpenConnectionOptions = {}): Promise<Connection> {
|
|
138
135
|
const { peerId, multiaddrs } = getPeerAddress(peerIdOrMultiaddr)
|
|
139
136
|
|
|
140
137
|
// make sure we don't have an existing connection to any of the addresses we
|
|
@@ -155,6 +152,7 @@ export class DialQueue {
|
|
|
155
152
|
|
|
156
153
|
if (existingConnection != null) {
|
|
157
154
|
this.log('already connected to %a', existingConnection.remoteAddr)
|
|
155
|
+
options.onProgress?.(new CustomProgressEvent('dial-queue:already-connected'))
|
|
158
156
|
return existingConnection
|
|
159
157
|
}
|
|
160
158
|
|
|
@@ -189,6 +187,7 @@ export class DialQueue {
|
|
|
189
187
|
existingDial.options.multiaddrs.add(multiaddr.toString())
|
|
190
188
|
}
|
|
191
189
|
|
|
190
|
+
options.onProgress?.(new CustomProgressEvent('dial-queue:already-in-dial-queue'))
|
|
192
191
|
return existingDial.join(options)
|
|
193
192
|
}
|
|
194
193
|
|
|
@@ -198,7 +197,9 @@ export class DialQueue {
|
|
|
198
197
|
|
|
199
198
|
this.log('creating dial target for %p', peerId, multiaddrs.map(ma => ma.toString()))
|
|
200
199
|
|
|
200
|
+
options.onProgress?.(new CustomProgressEvent('dial-queue:add-to-dial-queue'))
|
|
201
201
|
return this.queue.add(async (options) => {
|
|
202
|
+
options?.onProgress?.(new CustomProgressEvent('dial-queue:start-dial'))
|
|
202
203
|
// create abort conditions - need to do this before `calculateMultiaddrs` as
|
|
203
204
|
// we may be about to resolve a dns addr which can time out
|
|
204
205
|
const signal = this.createDialAbortController(options?.signal)
|
|
@@ -212,6 +213,8 @@ export class DialQueue {
|
|
|
212
213
|
signal
|
|
213
214
|
})
|
|
214
215
|
|
|
216
|
+
options?.onProgress?.(new CustomProgressEvent<Address[]>('dial-queue:calculated-addresses', addrsToDial))
|
|
217
|
+
|
|
215
218
|
addrsToDial.map(({ multiaddr }) => multiaddr.toString()).forEach(addr => {
|
|
216
219
|
options?.multiaddrs.add(addr)
|
|
217
220
|
})
|
|
@@ -280,7 +283,8 @@ export class DialQueue {
|
|
|
280
283
|
peerId,
|
|
281
284
|
priority: options.priority ?? DEFAULT_DIAL_PRIORITY,
|
|
282
285
|
multiaddrs: new Set(multiaddrs.map(ma => ma.toString())),
|
|
283
|
-
signal: options.signal
|
|
286
|
+
signal: options.signal,
|
|
287
|
+
onProgress: options.onProgress
|
|
284
288
|
})
|
|
285
289
|
}
|
|
286
290
|
|
|
@@ -299,7 +303,7 @@ export class DialQueue {
|
|
|
299
303
|
}
|
|
300
304
|
|
|
301
305
|
// eslint-disable-next-line complexity
|
|
302
|
-
private async calculateMultiaddrs (peerId?: PeerId, multiaddrs: Set<string> = new Set<string>(), options:
|
|
306
|
+
private async calculateMultiaddrs (peerId?: PeerId, multiaddrs: Set<string> = new Set<string>(), options: OpenConnectionOptions = {}): Promise<Address[]> {
|
|
303
307
|
const addrs: Address[] = [...multiaddrs].map(ma => ({
|
|
304
308
|
multiaddr: multiaddr(ma),
|
|
305
309
|
isCertified: false
|
|
@@ -4,6 +4,7 @@ import { defaultAddressSort } from '@libp2p/utils/address-sort'
|
|
|
4
4
|
import { RateLimiter } from '@libp2p/utils/rate-limiter'
|
|
5
5
|
import { type Multiaddr, type Resolver, multiaddr } from '@multiformats/multiaddr'
|
|
6
6
|
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
|
|
7
|
+
import { CustomProgressEvent } from 'progress-events'
|
|
7
8
|
import { codes } from '../errors.js'
|
|
8
9
|
import { getPeerAddress } from '../get-peer.js'
|
|
9
10
|
import { AutoDial } from './auto-dial.js'
|
|
@@ -509,6 +510,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
|
|
|
509
510
|
if (existingConnection != null) {
|
|
510
511
|
this.log('had an existing non-transient connection to %p', peerId)
|
|
511
512
|
|
|
513
|
+
options.onProgress?.(new CustomProgressEvent('dial-queue:already-connected'))
|
|
512
514
|
return existingConnection
|
|
513
515
|
}
|
|
514
516
|
}
|
package/src/libp2p.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { DefaultUpgrader } from './upgrader.js'
|
|
|
24
24
|
import * as pkg from './version.js'
|
|
25
25
|
import type { Components } from './components.js'
|
|
26
26
|
import type { Libp2p, Libp2pInit, Libp2pOptions } from './index.js'
|
|
27
|
-
import type { PeerRouting, ContentRouting, Libp2pEvents, PendingDial, ServiceMap, AbortOptions, ComponentLogger, Logger, Connection, NewStreamOptions, Stream, Metrics, PeerId, PeerInfo, PeerStore, Topology, Libp2pStatus, IsDialableOptions } from '@libp2p/interface'
|
|
27
|
+
import type { PeerRouting, ContentRouting, Libp2pEvents, PendingDial, ServiceMap, AbortOptions, ComponentLogger, Logger, Connection, NewStreamOptions, Stream, Metrics, PeerId, PeerInfo, PeerStore, Topology, Libp2pStatus, IsDialableOptions, DialOptions } from '@libp2p/interface'
|
|
28
28
|
import type { StreamHandler, StreamHandlerOptions } from '@libp2p/interface-internal'
|
|
29
29
|
|
|
30
30
|
export class Libp2pNode<T extends ServiceMap = ServiceMap> extends TypedEventEmitter<Libp2pEvents> implements Libp2p<T> {
|
|
@@ -272,7 +272,7 @@ export class Libp2pNode<T extends ServiceMap = ServiceMap> extends TypedEventEmi
|
|
|
272
272
|
return Array.from(peerSet)
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
async dial (peer: PeerId | Multiaddr | Multiaddr[], options:
|
|
275
|
+
async dial (peer: PeerId | Multiaddr | Multiaddr[], options: DialOptions = {}): Promise<Connection> {
|
|
276
276
|
return this.components.connectionManager.openConnection(peer, {
|
|
277
277
|
// ensure any userland dials take top priority in the queue
|
|
278
278
|
priority: 75,
|
package/src/transport-manager.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CodeError, FaultTolerance } from '@libp2p/interface'
|
|
2
2
|
import { trackedMap } from '@libp2p/utils/tracked-map'
|
|
3
|
+
import { CustomProgressEvent } from 'progress-events'
|
|
3
4
|
import { codes } from './errors.js'
|
|
4
|
-
import type { Libp2pEvents,
|
|
5
|
-
import type { AddressManager, TransportManager } from '@libp2p/interface-internal'
|
|
5
|
+
import type { Libp2pEvents, ComponentLogger, Logger, Connection, TypedEventTarget, Metrics, Startable, Listener, Transport, Upgrader } from '@libp2p/interface'
|
|
6
|
+
import type { AddressManager, TransportManager, TransportManagerDialOptions } from '@libp2p/interface-internal'
|
|
6
7
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
7
8
|
|
|
8
9
|
export interface TransportManagerInit {
|
|
@@ -107,14 +108,19 @@ export class DefaultTransportManager implements TransportManager, Startable {
|
|
|
107
108
|
/**
|
|
108
109
|
* Dials the given Multiaddr over it's supported transport
|
|
109
110
|
*/
|
|
110
|
-
async dial (ma: Multiaddr, options?:
|
|
111
|
+
async dial (ma: Multiaddr, options?: TransportManagerDialOptions): Promise<Connection> {
|
|
111
112
|
const transport = this.dialTransportForMultiaddr(ma)
|
|
112
113
|
|
|
113
114
|
if (transport == null) {
|
|
114
115
|
throw new CodeError(`No transport available for address ${String(ma)}`, codes.ERR_TRANSPORT_UNAVAILABLE)
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
options?.onProgress?.(new CustomProgressEvent<string>('transport-manager:selected-transport', transport[Symbol.toStringTag]))
|
|
119
|
+
|
|
117
120
|
try {
|
|
121
|
+
// @ts-expect-error the transport has a typed onProgress option but we
|
|
122
|
+
// can't predict what transport implementation we selected so all we can
|
|
123
|
+
// do is pass the onProgress handler in and hope for the best
|
|
118
124
|
return await transport.dial(ma, {
|
|
119
125
|
...options,
|
|
120
126
|
upgrader: this.components.upgrader
|
package/src/upgrader.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CodeError, ERR_TIMEOUT, setMaxListeners } from '@libp2p/interface'
|
|
2
2
|
import * as mss from '@libp2p/multistream-select'
|
|
3
3
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
4
|
+
import { CustomProgressEvent } from 'progress-events'
|
|
4
5
|
import { createConnection } from './connection/index.js'
|
|
5
6
|
import { INBOUND_UPGRADE_TIMEOUT } from './connection-manager/constants.js'
|
|
6
7
|
import { codes } from './errors.js'
|
|
@@ -185,6 +186,8 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
185
186
|
// Encrypt the connection
|
|
186
187
|
encryptedConn = protectedConn
|
|
187
188
|
if (opts?.skipEncryption !== true) {
|
|
189
|
+
opts?.onProgress?.(new CustomProgressEvent('upgrader:encrypt-inbound-connection'));
|
|
190
|
+
|
|
188
191
|
({
|
|
189
192
|
conn: encryptedConn,
|
|
190
193
|
remotePeer,
|
|
@@ -214,6 +217,8 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
214
217
|
if (opts?.muxerFactory != null) {
|
|
215
218
|
muxerFactory = opts.muxerFactory
|
|
216
219
|
} else if (this.muxers.size > 0) {
|
|
220
|
+
opts?.onProgress?.(new CustomProgressEvent('upgrader:multiplex-inbound-connection'))
|
|
221
|
+
|
|
217
222
|
// Multiplex the connection
|
|
218
223
|
const multiplexed = await this._multiplexInbound({
|
|
219
224
|
...protectedConn,
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '1.
|
|
1
|
+
export const version = '1.8.0-3319ff41e'
|
|
2
2
|
export const name = 'libp2p'
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.Libp2pInit.html",
|
|
3
|
-
".:Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.Libp2pInit.html",
|
|
4
|
-
"Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html",
|
|
5
|
-
".:Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html",
|
|
6
|
-
"ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.index.ServiceFactoryMap.html",
|
|
7
|
-
".:ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.index.ServiceFactoryMap.html",
|
|
8
|
-
"createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.index.createLibp2p.html",
|
|
9
|
-
".:createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.index.createLibp2p.html",
|
|
10
|
-
"name": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.name.html",
|
|
11
|
-
"./version:name": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.name.html",
|
|
12
|
-
"version": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.version.html",
|
|
13
|
-
"./version:version": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.version.html"
|
|
14
|
-
}
|