libp2p 0.45.0 → 0.45.1-98fb4bc1
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 +27 -30
- package/dist/index.min.js +27 -27
- package/dist/src/address-manager/index.d.ts +3 -3
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +8 -2
- package/dist/src/address-manager/index.js.map +1 -1
- package/dist/src/autonat/index.d.ts +1 -1
- package/dist/src/autonat/index.d.ts.map +1 -1
- package/dist/src/autonat/index.js +40 -31
- package/dist/src/autonat/index.js.map +1 -1
- package/dist/src/circuit-relay/index.d.ts +1 -1
- package/dist/src/circuit-relay/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.d.ts +2 -2
- package/dist/src/circuit-relay/server/advert-service.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.js +7 -3
- package/dist/src/circuit-relay/server/advert-service.js.map +1 -1
- package/dist/src/circuit-relay/server/index.d.ts +8 -8
- package/dist/src/circuit-relay/server/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/index.js +23 -10
- package/dist/src/circuit-relay/server/index.js.map +1 -1
- package/dist/src/circuit-relay/server/reservation-store.d.ts +5 -5
- package/dist/src/circuit-relay/server/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/reservation-store.js +10 -3
- package/dist/src/circuit-relay/server/reservation-store.js.map +1 -1
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/reservation-voucher.js +5 -2
- package/dist/src/circuit-relay/server/reservation-voucher.js.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.d.ts +4 -4
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.js +9 -3
- package/dist/src/circuit-relay/transport/discovery.js.map +1 -1
- package/dist/src/circuit-relay/transport/index.d.ts +8 -9
- package/dist/src/circuit-relay/transport/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/index.js +25 -15
- package/dist/src/circuit-relay/transport/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/listener.js +15 -19
- package/dist/src/circuit-relay/transport/listener.js.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.d.ts +5 -5
- package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +55 -49
- package/dist/src/circuit-relay/transport/reservation-store.js.map +1 -1
- package/dist/src/circuit-relay/utils.d.ts.map +1 -1
- package/dist/src/circuit-relay/utils.js +3 -3
- package/dist/src/circuit-relay/utils.js.map +1 -1
- package/dist/src/components.d.ts +6 -6
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/components.js +2 -2
- package/dist/src/components.js.map +1 -1
- package/dist/src/config/connection-gater.browser.d.ts.map +1 -1
- package/dist/src/config/connection-gater.browser.js.map +1 -1
- package/dist/src/config.d.ts +2 -2
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +4 -7
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection/index.d.ts +3 -3
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js +38 -8
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +3 -3
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dial.js +9 -1
- package/dist/src/connection-manager/auto-dial.js.map +1 -1
- package/dist/src/connection-manager/connection-pruner.d.ts +2 -2
- package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -1
- package/dist/src/connection-manager/connection-pruner.js +5 -0
- package/dist/src/connection-manager/connection-pruner.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +6 -6
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +25 -11
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +12 -12
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +21 -7
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/connection-manager/utils.d.ts +2 -3
- package/dist/src/connection-manager/utils.d.ts.map +1 -1
- package/dist/src/connection-manager/utils.js +3 -3
- package/dist/src/connection-manager/utils.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +2 -2
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +7 -4
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/content-routing/utils.d.ts +1 -1
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/fetch/index.d.ts +2 -2
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +12 -7
- package/dist/src/fetch/index.js.map +1 -1
- package/dist/src/get-peer.d.ts +1 -1
- package/dist/src/get-peer.d.ts.map +1 -1
- package/dist/src/get-peer.js +3 -3
- package/dist/src/get-peer.js.map +1 -1
- package/dist/src/identify/identify.d.ts +3 -3
- package/dist/src/identify/identify.d.ts.map +1 -1
- package/dist/src/identify/identify.js +91 -79
- package/dist/src/identify/identify.js.map +1 -1
- package/dist/src/identify/index.d.ts +5 -4
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js +1 -1
- package/dist/src/identify/index.js.map +1 -1
- package/dist/src/index.d.ts +19 -15
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/insecure/index.js +6 -8
- package/dist/src/insecure/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +11 -11
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +60 -59
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +2 -2
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +8 -6
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/ping/index.d.ts +2 -2
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +14 -8
- package/dist/src/ping/index.js.map +1 -1
- package/dist/src/pnet/crypto.js +3 -3
- package/dist/src/pnet/crypto.js.map +1 -1
- package/dist/src/pnet/index.d.ts.map +1 -1
- package/dist/src/pnet/index.js +9 -6
- package/dist/src/pnet/index.js.map +1 -1
- package/dist/src/pnet/key-generator.js +1 -1
- package/dist/src/pnet/key-generator.js.map +1 -1
- package/dist/src/pubsub/dummy-pubsub.d.ts.map +1 -1
- package/dist/src/pubsub/dummy-pubsub.js +2 -5
- package/dist/src/pubsub/dummy-pubsub.js.map +1 -1
- package/dist/src/registrar.d.ts +3 -4
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +6 -3
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts +5 -5
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +8 -3
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +8 -8
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +11 -6
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/upnp-nat/index.d.ts +32 -3
- package/dist/src/upnp-nat/index.d.ts.map +1 -1
- package/dist/src/upnp-nat/index.js +13 -4
- package/dist/src/upnp-nat/index.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 +7 -8
- package/src/address-manager/index.ts +6 -6
- package/src/autonat/index.ts +41 -41
- package/src/circuit-relay/index.ts +1 -1
- package/src/circuit-relay/server/advert-service.ts +4 -4
- package/src/circuit-relay/server/index.ts +18 -18
- package/src/circuit-relay/server/reservation-store.ts +5 -5
- package/src/circuit-relay/server/reservation-voucher.ts +1 -1
- package/src/circuit-relay/transport/discovery.ts +7 -7
- package/src/circuit-relay/transport/index.ts +26 -24
- package/src/circuit-relay/transport/listener.ts +8 -8
- package/src/circuit-relay/transport/reservation-store.ts +10 -10
- package/src/circuit-relay/utils.ts +6 -6
- package/src/components.ts +6 -6
- package/src/config/connection-gater.browser.ts +1 -1
- package/src/config.ts +8 -12
- package/src/connection/index.ts +6 -10
- package/src/connection-manager/auto-dial.ts +5 -5
- package/src/connection-manager/connection-pruner.ts +4 -4
- package/src/connection-manager/dial-queue.ts +18 -17
- package/src/connection-manager/index.ts +18 -18
- package/src/connection-manager/utils.ts +4 -5
- package/src/content-routing/index.ts +6 -6
- package/src/content-routing/utils.ts +1 -1
- package/src/fetch/index.ts +12 -12
- package/src/get-peer.ts +4 -4
- package/src/identify/identify.ts +27 -26
- package/src/identify/index.ts +6 -6
- package/src/index.ts +15 -15
- package/src/insecure/index.ts +6 -6
- package/src/libp2p.ts +38 -35
- package/src/peer-routing.ts +9 -9
- package/src/ping/index.ts +12 -12
- package/src/pnet/crypto.ts +3 -3
- package/src/pnet/index.ts +6 -6
- package/src/pnet/key-generator.ts +1 -1
- package/src/pubsub/dummy-pubsub.ts +2 -2
- package/src/registrar.ts +5 -6
- package/src/transport-manager.ts +8 -8
- package/src/upgrader.ts +17 -17
- package/src/upnp-nat/index.ts +9 -9
- package/src/version.ts +1 -1
- package/dist/typedoc-urls.json +0 -56
package/src/libp2p.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { setMaxListeners } from 'events'
|
|
2
|
+
import { unmarshalPublicKey } from '@libp2p/crypto/keys'
|
|
3
|
+
import { type ContentRouting, contentRouting } from '@libp2p/interface-content-routing'
|
|
4
|
+
import { peerDiscovery } from '@libp2p/interface-peer-discovery'
|
|
5
|
+
import { type PeerRouting, peerRouting } from '@libp2p/interface-peer-routing'
|
|
6
|
+
import { CodeError } from '@libp2p/interfaces/errors'
|
|
3
7
|
import { EventEmitter, CustomEvent } from '@libp2p/interfaces/events'
|
|
4
|
-
import {
|
|
8
|
+
import { DefaultKeyChain } from '@libp2p/keychain'
|
|
9
|
+
import { logger } from '@libp2p/logger'
|
|
10
|
+
import { PeerSet } from '@libp2p/peer-collections'
|
|
11
|
+
import { peerIdFromString } from '@libp2p/peer-id'
|
|
12
|
+
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
13
|
+
import { PersistentPeerStore } from '@libp2p/peer-store'
|
|
14
|
+
import { isMultiaddr, type Multiaddr } from '@multiformats/multiaddr'
|
|
5
15
|
import { MemoryDatastore } from 'datastore-core/memory'
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
16
|
+
import mergeOptions from 'merge-options'
|
|
17
|
+
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
|
18
|
+
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
9
19
|
import { DefaultAddressManager } from './address-manager/index.js'
|
|
20
|
+
import { defaultComponents } from './components.js'
|
|
21
|
+
import { connectionGater } from './config/connection-gater.js'
|
|
22
|
+
import { validateConfig } from './config.js'
|
|
10
23
|
import { DefaultConnectionManager } from './connection-manager/index.js'
|
|
11
|
-
import {
|
|
24
|
+
import { CompoundContentRouting } from './content-routing/index.js'
|
|
25
|
+
import { codes } from './errors.js'
|
|
26
|
+
import { DefaultPeerRouting } from './peer-routing.js'
|
|
27
|
+
import { DefaultRegistrar } from './registrar.js'
|
|
12
28
|
import { DefaultTransportManager } from './transport-manager.js'
|
|
13
29
|
import { DefaultUpgrader } from './upgrader.js'
|
|
14
|
-
import { DefaultRegistrar } from './registrar.js'
|
|
15
|
-
import { PersistentPeerStore } from '@libp2p/peer-store'
|
|
16
|
-
import { defaultComponents } from './components.js'
|
|
17
30
|
import type { Components } from './components.js'
|
|
18
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
19
|
-
import type { Connection, Stream } from '@libp2p/interface-connection'
|
|
20
|
-
import type { StreamHandler, StreamHandlerOptions, Topology } from '@libp2p/interface-registrar'
|
|
21
|
-
import type { PeerInfo } from '@libp2p/interface-peer-info'
|
|
22
31
|
import type { Libp2p, Libp2pInit, Libp2pOptions } from './index.js'
|
|
23
|
-
import type {
|
|
24
|
-
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
|
25
|
-
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
26
|
-
import { CodeError } from '@libp2p/interfaces/errors'
|
|
27
|
-
import type { Metrics } from '@libp2p/interface-metrics'
|
|
28
|
-
import { PeerSet } from '@libp2p/peer-collections'
|
|
32
|
+
import type { Connection, Stream } from '@libp2p/interface-connection'
|
|
29
33
|
import type { KeyChain } from '@libp2p/interface-keychain'
|
|
30
34
|
import type { Libp2pEvents, PendingDial, ServiceMap } from '@libp2p/interface-libp2p'
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
35
|
+
import type { Metrics } from '@libp2p/interface-metrics'
|
|
36
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
37
|
+
import type { PeerInfo } from '@libp2p/interface-peer-info'
|
|
38
|
+
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
39
|
+
import type { StreamHandler, StreamHandlerOptions, Topology } from '@libp2p/interface-registrar'
|
|
40
|
+
import type { AbortOptions } from '@libp2p/interfaces'
|
|
34
41
|
import type { Datastore } from 'interface-datastore'
|
|
35
|
-
import mergeOptions from 'merge-options'
|
|
36
|
-
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
37
|
-
import { validateConfig } from './config.js'
|
|
38
|
-
import { ContentRouting, contentRouting } from '@libp2p/interface-content-routing'
|
|
39
|
-
import { PeerRouting, peerRouting } from '@libp2p/interface-peer-routing'
|
|
40
|
-
import { peerDiscovery } from '@libp2p/interface-peer-discovery'
|
|
41
|
-
import { connectionGater } from './config/connection-gater.js'
|
|
42
42
|
|
|
43
43
|
const log = logger('libp2p')
|
|
44
44
|
|
|
45
|
-
export class Libp2pNode<T extends ServiceMap =
|
|
45
|
+
export class Libp2pNode<T extends ServiceMap = Record<string, unknown>> extends EventEmitter<Libp2pEvents> implements Libp2p<T> {
|
|
46
46
|
public peerId: PeerId
|
|
47
47
|
public peerStore: PeerStore
|
|
48
48
|
public contentRouting: ContentRouting
|
|
@@ -227,6 +227,8 @@ export class Libp2pNode<T extends ServiceMap = {}> extends EventEmitter<Libp2pEv
|
|
|
227
227
|
await this.components.beforeStart?.()
|
|
228
228
|
await this.components.start()
|
|
229
229
|
await this.components.afterStart?.()
|
|
230
|
+
|
|
231
|
+
this.safeDispatchEvent('start', { detail: this })
|
|
230
232
|
log('libp2p has started')
|
|
231
233
|
} catch (err: any) {
|
|
232
234
|
log.error('An error occurred starting libp2p', err)
|
|
@@ -251,6 +253,7 @@ export class Libp2pNode<T extends ServiceMap = {}> extends EventEmitter<Libp2pEv
|
|
|
251
253
|
await this.components.stop()
|
|
252
254
|
await this.components.afterStop?.()
|
|
253
255
|
|
|
256
|
+
this.safeDispatchEvent('stop', { detail: this })
|
|
254
257
|
log('libp2p has stopped')
|
|
255
258
|
}
|
|
256
259
|
|
|
@@ -277,7 +280,7 @@ export class Libp2pNode<T extends ServiceMap = {}> extends EventEmitter<Libp2pEv
|
|
|
277
280
|
}
|
|
278
281
|
|
|
279
282
|
async dial (peer: PeerId | Multiaddr | Multiaddr[], options: AbortOptions = {}): Promise<Connection> {
|
|
280
|
-
return
|
|
283
|
+
return this.components.connectionManager.openConnection(peer, options)
|
|
281
284
|
}
|
|
282
285
|
|
|
283
286
|
async dialProtocol (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options: AbortOptions = {}): Promise<Stream> {
|
|
@@ -293,7 +296,7 @@ export class Libp2pNode<T extends ServiceMap = {}> extends EventEmitter<Libp2pEv
|
|
|
293
296
|
|
|
294
297
|
const connection = await this.dial(peer, options)
|
|
295
298
|
|
|
296
|
-
return
|
|
299
|
+
return connection.newStream(protocols, options)
|
|
297
300
|
}
|
|
298
301
|
|
|
299
302
|
getMultiaddrs (): Multiaddr[] {
|
|
@@ -370,7 +373,7 @@ export class Libp2pNode<T extends ServiceMap = {}> extends EventEmitter<Libp2pEv
|
|
|
370
373
|
}
|
|
371
374
|
|
|
372
375
|
async register (protocol: string, topology: Topology): Promise<string> {
|
|
373
|
-
return
|
|
376
|
+
return this.components.registrar.register(protocol, topology)
|
|
374
377
|
}
|
|
375
378
|
|
|
376
379
|
unregister (id: string): void {
|
|
@@ -401,7 +404,7 @@ export class Libp2pNode<T extends ServiceMap = {}> extends EventEmitter<Libp2pEv
|
|
|
401
404
|
* Returns a new Libp2pNode instance - this exposes more of the internals than the
|
|
402
405
|
* libp2p interface and is useful for testing and debugging.
|
|
403
406
|
*/
|
|
404
|
-
export async function createLibp2pNode <T extends ServiceMap =
|
|
407
|
+
export async function createLibp2pNode <T extends ServiceMap = Record<string, unknown>> (options: Libp2pOptions<T>): Promise<Libp2pNode<T>> {
|
|
405
408
|
if (options.peerId == null) {
|
|
406
409
|
const datastore = options.datastore as Datastore | undefined
|
|
407
410
|
|
package/src/peer-routing.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { logger } from '@libp2p/logger'
|
|
2
1
|
import { CodeError } from '@libp2p/interfaces/errors'
|
|
3
|
-
import {
|
|
2
|
+
import { logger } from '@libp2p/logger'
|
|
3
|
+
import filter from 'it-filter'
|
|
4
|
+
import first from 'it-first'
|
|
5
|
+
import merge from 'it-merge'
|
|
6
|
+
import { pipe } from 'it-pipe'
|
|
4
7
|
import {
|
|
5
8
|
storeAddresses,
|
|
6
9
|
uniquePeers,
|
|
7
10
|
requirePeers
|
|
8
11
|
} from './content-routing/utils.js'
|
|
9
|
-
import
|
|
10
|
-
import { pipe } from 'it-pipe'
|
|
11
|
-
import first from 'it-first'
|
|
12
|
-
import filter from 'it-filter'
|
|
12
|
+
import { codes, messages } from './errors.js'
|
|
13
13
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
14
|
-
import type { PeerRouting } from '@libp2p/interface-peer-routing'
|
|
15
|
-
import type { AbortOptions } from '@libp2p/interfaces'
|
|
16
14
|
import type { PeerInfo } from '@libp2p/interface-peer-info'
|
|
15
|
+
import type { PeerRouting } from '@libp2p/interface-peer-routing'
|
|
17
16
|
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
17
|
+
import type { AbortOptions } from '@libp2p/interfaces'
|
|
18
18
|
|
|
19
19
|
const log = logger('libp2p:peer-routing')
|
|
20
20
|
|
|
@@ -60,7 +60,7 @@ export class DefaultPeerRouting implements PeerRouting {
|
|
|
60
60
|
),
|
|
61
61
|
(source) => filter(source, Boolean),
|
|
62
62
|
(source) => storeAddresses(source, this.components.peerStore),
|
|
63
|
-
async (source) =>
|
|
63
|
+
async (source) => first(source)
|
|
64
64
|
)
|
|
65
65
|
|
|
66
66
|
if (output != null) {
|
package/src/ping/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CodeError } from '@libp2p/interfaces/errors'
|
|
3
|
-
import { codes } from '../errors.js'
|
|
1
|
+
import { setMaxListeners } from 'events'
|
|
4
2
|
import { randomBytes } from '@libp2p/crypto'
|
|
5
|
-
import {
|
|
3
|
+
import { CodeError } from '@libp2p/interfaces/errors'
|
|
4
|
+
import { logger } from '@libp2p/logger'
|
|
5
|
+
import { abortableDuplex } from 'abortable-iterator'
|
|
6
|
+
import { anySignal } from 'any-signal'
|
|
6
7
|
import first from 'it-first'
|
|
8
|
+
import { pipe } from 'it-pipe'
|
|
7
9
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
10
|
+
import { codes } from '../errors.js'
|
|
8
11
|
import { PROTOCOL_PREFIX, PROTOCOL_NAME, PING_LENGTH, PROTOCOL_VERSION, TIMEOUT, MAX_INBOUND_STREAMS, MAX_OUTBOUND_STREAMS } from './constants.js'
|
|
9
|
-
import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar'
|
|
10
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
11
|
-
import type { Startable } from '@libp2p/interfaces/startable'
|
|
12
|
-
import type { AbortOptions } from '@libp2p/interfaces'
|
|
13
|
-
import { abortableDuplex } from 'abortable-iterator'
|
|
14
12
|
import type { Stream } from '@libp2p/interface-connection'
|
|
15
|
-
import { setMaxListeners } from 'events'
|
|
16
13
|
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
17
|
-
import {
|
|
14
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
15
|
+
import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar'
|
|
16
|
+
import type { AbortOptions } from '@libp2p/interfaces'
|
|
17
|
+
import type { Startable } from '@libp2p/interfaces/startable'
|
|
18
18
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
19
19
|
|
|
20
20
|
const log = logger('libp2p:ping')
|
|
@@ -117,7 +117,7 @@ class DefaultPingService implements Startable, PingService {
|
|
|
117
117
|
const result = await pipe(
|
|
118
118
|
[data],
|
|
119
119
|
source,
|
|
120
|
-
async (source) =>
|
|
120
|
+
async (source) => first(source)
|
|
121
121
|
)
|
|
122
122
|
const end = Date.now()
|
|
123
123
|
|
package/src/pnet/crypto.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { logger } from '@libp2p/logger'
|
|
2
|
-
import * as Errors from './errors.js'
|
|
3
|
-
import xsalsa20 from 'xsalsa20'
|
|
4
|
-
import { KEY_LENGTH } from './key-generator.js'
|
|
5
2
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
6
3
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
4
|
+
import xsalsa20 from 'xsalsa20'
|
|
5
|
+
import * as Errors from './errors.js'
|
|
6
|
+
import { KEY_LENGTH } from './key-generator.js'
|
|
7
7
|
import type { Source } from 'it-stream-types'
|
|
8
8
|
|
|
9
9
|
const log = logger('libp2p:pnet')
|
package/src/pnet/index.ts
CHANGED
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import {
|
|
26
|
-
import { pipe } from 'it-pipe'
|
|
25
|
+
import { randomBytes } from '@libp2p/crypto'
|
|
27
26
|
import { CodeError } from '@libp2p/interfaces/errors'
|
|
27
|
+
import { logger } from '@libp2p/logger'
|
|
28
|
+
import { handshake } from 'it-handshake'
|
|
29
|
+
import map from 'it-map'
|
|
28
30
|
import { duplexPair } from 'it-pair/duplex'
|
|
29
|
-
import {
|
|
30
|
-
import * as Errors from './errors.js'
|
|
31
|
+
import { pipe } from 'it-pipe'
|
|
31
32
|
import { codes } from '../errors.js'
|
|
32
33
|
import {
|
|
33
34
|
createBoxStream,
|
|
34
35
|
createUnboxStream,
|
|
35
36
|
decodeV1PSK
|
|
36
37
|
} from './crypto.js'
|
|
37
|
-
import
|
|
38
|
+
import * as Errors from './errors.js'
|
|
38
39
|
import { NONCE_LENGTH } from './key-generator.js'
|
|
39
40
|
import type { ConnectionProtector, MultiaddrConnection } from '@libp2p/interface-connection'
|
|
40
|
-
import map from 'it-map'
|
|
41
41
|
|
|
42
42
|
const log = logger('libp2p:pnet')
|
|
43
43
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomBytes } from '@libp2p/crypto'
|
|
2
|
-
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
3
2
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
3
|
+
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Generates a PSK that can be used in a libp2p-pnet private network
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { CodeError } from '@libp2p/interfaces/errors'
|
|
1
2
|
import { EventEmitter } from '@libp2p/interfaces/events'
|
|
3
|
+
import { messages, codes } from '../errors.js'
|
|
2
4
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
3
5
|
import type { PublishResult, PubSub, PubSubEvents, StrictNoSign, StrictSign, TopicValidatorFn } from '@libp2p/interface-pubsub'
|
|
4
|
-
import { CodeError } from '@libp2p/interfaces/errors'
|
|
5
|
-
import { messages, codes } from '../errors.js'
|
|
6
6
|
|
|
7
7
|
export class DummyPubSub extends EventEmitter<PubSubEvents> implements PubSub {
|
|
8
8
|
public topicValidators = new Map<string, TopicValidatorFn>()
|
package/src/registrar.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isTopology, type StreamHandlerOptions, type StreamHandlerRecord, type Registrar, type StreamHandler, type Topology } from '@libp2p/interface-registrar'
|
|
2
2
|
import { CodeError } from '@libp2p/interfaces/errors'
|
|
3
|
-
import {
|
|
4
|
-
import { isTopology, StreamHandlerOptions, StreamHandlerRecord } from '@libp2p/interface-registrar'
|
|
3
|
+
import { logger } from '@libp2p/logger'
|
|
5
4
|
import merge from 'merge-options'
|
|
6
|
-
import
|
|
7
|
-
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
5
|
+
import { codes } from './errors.js'
|
|
8
6
|
import type { Connection } from '@libp2p/interface-connection'
|
|
9
7
|
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
8
|
+
import type { Libp2pEvents, PeerUpdate } from '@libp2p/interface-libp2p'
|
|
10
9
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
10
|
+
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
11
11
|
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
12
|
-
import type { Libp2pEvents, PeerUpdate } from '@libp2p/interface-libp2p'
|
|
13
12
|
|
|
14
13
|
const log = logger('libp2p:registrar')
|
|
15
14
|
|
package/src/transport-manager.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { FaultTolerance } from '@libp2p/interface-transport'
|
|
2
|
+
import { CodeError } from '@libp2p/interfaces/errors'
|
|
1
3
|
import { logger } from '@libp2p/logger'
|
|
4
|
+
import { trackedMap } from '@libp2p/tracked-map'
|
|
2
5
|
import { codes } from './errors.js'
|
|
3
|
-
import {
|
|
4
|
-
import { FaultTolerance } from '@libp2p/interface-transport'
|
|
5
|
-
import type { Listener, Transport, TransportManager, Upgrader } from '@libp2p/interface-transport'
|
|
6
|
-
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
6
|
+
import type { AddressManager } from '@libp2p/interface-address-manager'
|
|
7
7
|
import type { Connection } from '@libp2p/interface-connection'
|
|
8
|
+
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
9
|
+
import type { Metrics } from '@libp2p/interface-metrics'
|
|
10
|
+
import type { Listener, Transport, TransportManager, Upgrader } from '@libp2p/interface-transport'
|
|
8
11
|
import type { AbortOptions } from '@libp2p/interfaces'
|
|
9
12
|
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
10
13
|
import type { Startable } from '@libp2p/interfaces/startable'
|
|
11
|
-
import {
|
|
12
|
-
import type { Metrics } from '@libp2p/interface-metrics'
|
|
13
|
-
import type { AddressManager } from '@libp2p/interface-address-manager'
|
|
14
|
-
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
14
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
15
15
|
|
|
16
16
|
const log = logger('libp2p:transports')
|
|
17
17
|
|
package/src/upgrader.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setMaxListeners } from 'events'
|
|
2
2
|
import { CodeError } from '@libp2p/interfaces/errors'
|
|
3
|
+
import { logger } from '@libp2p/logger'
|
|
3
4
|
import * as mss from '@libp2p/multistream-select'
|
|
4
|
-
import { codes } from './errors.js'
|
|
5
|
-
import { createConnection } from './connection/index.js'
|
|
6
|
-
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
7
5
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
6
|
+
import { abortableDuplex } from 'abortable-iterator'
|
|
7
|
+
import { anySignal } from 'any-signal'
|
|
8
|
+
import { createConnection } from './connection/index.js'
|
|
9
|
+
import { INBOUND_UPGRADE_TIMEOUT } from './connection-manager/constants.js'
|
|
10
|
+
import { codes } from './errors.js'
|
|
11
|
+
import { DEFAULT_MAX_INBOUND_STREAMS, DEFAULT_MAX_OUTBOUND_STREAMS } from './registrar.js'
|
|
8
12
|
import type { MultiaddrConnection, Connection, Stream, ConnectionProtector } from '@libp2p/interface-connection'
|
|
9
13
|
import type { ConnectionEncrypter, SecuredConnection } from '@libp2p/interface-connection-encrypter'
|
|
10
|
-
import type {
|
|
14
|
+
import type { ConnectionGater } from '@libp2p/interface-connection-gater'
|
|
15
|
+
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
16
|
+
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
17
|
+
import type { Metrics } from '@libp2p/interface-metrics'
|
|
11
18
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
19
|
+
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
20
|
+
import type { Registrar } from '@libp2p/interface-registrar'
|
|
21
|
+
import type { StreamMuxer, StreamMuxerFactory } from '@libp2p/interface-stream-muxer'
|
|
12
22
|
import type { Upgrader, UpgraderOptions } from '@libp2p/interface-transport'
|
|
13
|
-
import type { Duplex, Source } from 'it-stream-types'
|
|
14
23
|
import type { AbortOptions } from '@libp2p/interfaces'
|
|
15
|
-
import type {
|
|
16
|
-
import {
|
|
17
|
-
import { abortableDuplex } from 'abortable-iterator'
|
|
18
|
-
import { setMaxListeners } from 'events'
|
|
19
|
-
import type { Metrics } from '@libp2p/interface-metrics'
|
|
20
|
-
import type { ConnectionManager } from '@libp2p/interface-connection-manager'
|
|
21
|
-
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
22
|
-
import type { ConnectionGater } from '@libp2p/interface-connection-gater'
|
|
23
|
-
import { INBOUND_UPGRADE_TIMEOUT } from './connection-manager/constants.js'
|
|
24
|
-
import { anySignal } from 'any-signal'
|
|
25
|
-
import type { Libp2pEvents } from '@libp2p/interface-libp2p'
|
|
24
|
+
import type { EventEmitter } from '@libp2p/interfaces/events'
|
|
25
|
+
import type { Duplex, Source } from 'it-stream-types'
|
|
26
26
|
|
|
27
27
|
const log = logger('libp2p:upgrader')
|
|
28
28
|
|
package/src/upnp-nat/index.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { upnpNat, NatAPI } from '@achingbrain/nat-port-mapper'
|
|
1
|
+
import { upnpNat, type NatAPI } from '@achingbrain/nat-port-mapper'
|
|
2
|
+
import { CodeError } from '@libp2p/interfaces/errors'
|
|
2
3
|
import { logger } from '@libp2p/logger'
|
|
4
|
+
import { isLoopback } from '@libp2p/utils/multiaddr/is-loopback'
|
|
3
5
|
import { fromNodeAddress } from '@multiformats/multiaddr'
|
|
4
|
-
import { isBrowser } from 'wherearewe'
|
|
5
6
|
import isPrivateIp from 'private-ip'
|
|
6
|
-
import
|
|
7
|
-
import { CodeError } from '@libp2p/interfaces/errors'
|
|
7
|
+
import { isBrowser } from 'wherearewe'
|
|
8
8
|
import { codes } from '../errors.js'
|
|
9
|
-
import
|
|
10
|
-
import type { Startable } from '@libp2p/interfaces/startable'
|
|
11
|
-
import type { TransportManager } from '@libp2p/interface-transport'
|
|
12
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
9
|
+
import * as pkg from '../version.js'
|
|
13
10
|
import type { AddressManager } from '@libp2p/interface-address-manager'
|
|
11
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
12
|
+
import type { TransportManager } from '@libp2p/interface-transport'
|
|
13
|
+
import type { Startable } from '@libp2p/interfaces/startable'
|
|
14
14
|
|
|
15
15
|
const log = logger('libp2p:upnp-nat')
|
|
16
16
|
const DEFAULT_TTL = 7200
|
|
@@ -205,7 +205,7 @@ class UPnPNAT implements Startable {
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
export function uPnPNATService (init: UPnPNATInit = {}): (components: UPnPNATComponents) =>
|
|
208
|
+
export function uPnPNATService (init: UPnPNATInit = {}): (components: UPnPNATComponents) => UPnPNAT {
|
|
209
209
|
return (components: UPnPNATComponents) => {
|
|
210
210
|
return new UPnPNAT(components, init)
|
|
211
211
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '0.45.
|
|
1
|
+
export const version = '0.45.1-98fb4bc1'
|
|
2
2
|
export const name = 'libp2p'
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"AutoNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/autonat.AutoNATComponents.html",
|
|
3
|
-
"AutoNATServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/autonat.AutoNATServiceInit.html",
|
|
4
|
-
"autoNATService": "https://libp2p.github.io/js-libp2p/functions/autonat.autoNATService.html",
|
|
5
|
-
"codec": "https://libp2p.github.io/js-libp2p/functions/circuit_relay._internal_.Limit.codec.html",
|
|
6
|
-
"decode": "https://libp2p.github.io/js-libp2p/functions/circuit_relay._internal_.Limit.decode.html",
|
|
7
|
-
"encode": "https://libp2p.github.io/js-libp2p/functions/circuit_relay._internal_.Limit.encode.html",
|
|
8
|
-
"AdvertServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay._internal_.AdvertServiceComponents.html",
|
|
9
|
-
"AdvertServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay._internal_.AdvertServiceInit.html",
|
|
10
|
-
"CircuitRelayServerComponents": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay._internal_.CircuitRelayServerComponents.html",
|
|
11
|
-
"CircuitRelayServerInit": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay._internal_.CircuitRelayServerInit.html",
|
|
12
|
-
"CircuitRelayTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay._internal_.CircuitRelayTransportComponents.html",
|
|
13
|
-
"CircuitRelayTransportInit": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay._internal_.CircuitRelayTransportInit.html",
|
|
14
|
-
"Limit": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay._internal_.Limit-1.html",
|
|
15
|
-
"RelayDiscoveryComponents": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay._internal_.RelayDiscoveryComponents.html",
|
|
16
|
-
"RelayStoreInit": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay._internal_.RelayStoreInit.html",
|
|
17
|
-
"ReservationStoreInit": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay._internal_.ReservationStoreInit.html",
|
|
18
|
-
"CircuitRelayService": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay.CircuitRelayService.html",
|
|
19
|
-
"CircuitRelayServiceEvents": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay.CircuitRelayServiceEvents.html",
|
|
20
|
-
"RelayReservation": "https://libp2p.github.io/js-libp2p/interfaces/circuit_relay.RelayReservation.html",
|
|
21
|
-
"circuitRelayServer": "https://libp2p.github.io/js-libp2p/functions/circuit_relay.circuitRelayServer.html",
|
|
22
|
-
"circuitRelayTransport": "https://libp2p.github.io/js-libp2p/functions/circuit_relay.circuitRelayTransport.html",
|
|
23
|
-
"FetchService": "https://libp2p.github.io/js-libp2p/interfaces/fetch.FetchService.html",
|
|
24
|
-
"FetchServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/fetch.FetchServiceComponents.html",
|
|
25
|
-
"FetchServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/fetch.FetchServiceInit.html",
|
|
26
|
-
"HandleMessageOptions": "https://libp2p.github.io/js-libp2p/interfaces/fetch.HandleMessageOptions.html",
|
|
27
|
-
"LookupFunction": "https://libp2p.github.io/js-libp2p/interfaces/fetch.LookupFunction.html",
|
|
28
|
-
"fetchService": "https://libp2p.github.io/js-libp2p/functions/fetch.fetchService-1.html",
|
|
29
|
-
"Identify": "https://libp2p.github.io/js-libp2p/interfaces/identify._internal_.Identify-1.html",
|
|
30
|
-
"IdentifyServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/identify.IdentifyServiceComponents.html",
|
|
31
|
-
"IdentifyServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/identify.IdentifyServiceInit.html",
|
|
32
|
-
"Message": "https://libp2p.github.io/js-libp2p/variables/identify.Message.html",
|
|
33
|
-
"multicodecs": "https://libp2p.github.io/js-libp2p/variables/identify.multicodecs.html",
|
|
34
|
-
"identifyService": "https://libp2p.github.io/js-libp2p/functions/identify.identifyService.html",
|
|
35
|
-
"AddressFilter": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.AddressFilter.html",
|
|
36
|
-
"AddressManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.AddressManagerInit.html",
|
|
37
|
-
"Components": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.Components.html",
|
|
38
|
-
"ConnectionManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerInit.html",
|
|
39
|
-
"TransportManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/index._internal_.TransportManagerInit.html",
|
|
40
|
-
"Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/index.Libp2pInit.html",
|
|
41
|
-
"Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/index.Libp2pOptions.html",
|
|
42
|
-
"ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/index.ServiceFactoryMap.html",
|
|
43
|
-
"createLibp2p": "https://libp2p.github.io/js-libp2p/functions/index.createLibp2p.html",
|
|
44
|
-
"plaintext": "https://libp2p.github.io/js-libp2p/functions/insecure.plaintext.html",
|
|
45
|
-
"PingService": "https://libp2p.github.io/js-libp2p/interfaces/ping.PingService.html",
|
|
46
|
-
"PingServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/ping.PingServiceComponents.html",
|
|
47
|
-
"PingServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/ping.PingServiceInit.html",
|
|
48
|
-
"pingService": "https://libp2p.github.io/js-libp2p/functions/ping.pingService-1.html",
|
|
49
|
-
"ProtectorInit": "https://libp2p.github.io/js-libp2p/interfaces/pnet.ProtectorInit.html",
|
|
50
|
-
"generateKey": "https://libp2p.github.io/js-libp2p/functions/pnet.generateKey.html",
|
|
51
|
-
"preSharedKey": "https://libp2p.github.io/js-libp2p/functions/pnet.preSharedKey.html",
|
|
52
|
-
"PMPOptions": "https://libp2p.github.io/js-libp2p/interfaces/upnp_nat.PMPOptions.html",
|
|
53
|
-
"UPnPNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/upnp_nat.UPnPNATComponents.html",
|
|
54
|
-
"UPnPNATInit": "https://libp2p.github.io/js-libp2p/interfaces/upnp_nat.UPnPNATInit.html",
|
|
55
|
-
"uPnPNATService": "https://libp2p.github.io/js-libp2p/functions/upnp_nat.uPnPNATService.html"
|
|
56
|
-
}
|