libp2p 2.8.5 → 2.8.6-aa25d38ab

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.
Files changed (49) hide show
  1. package/README.md +29 -0
  2. package/dist/index.min.js +16 -29
  3. package/dist/index.min.js.map +7 -0
  4. package/dist/src/address-manager/ip-mappings.d.ts.map +1 -1
  5. package/dist/src/address-manager/ip-mappings.js +0 -1
  6. package/dist/src/address-manager/ip-mappings.js.map +1 -1
  7. package/dist/src/components.d.ts +1 -1
  8. package/dist/src/components.d.ts.map +1 -1
  9. package/dist/src/components.js +1 -2
  10. package/dist/src/components.js.map +1 -1
  11. package/dist/src/config.js +2 -2
  12. package/dist/src/config.js.map +1 -1
  13. package/dist/src/connection-manager/index.d.ts +1 -1
  14. package/dist/src/connection-manager/index.d.ts.map +1 -1
  15. package/dist/src/connection-manager/index.js.map +1 -1
  16. package/dist/src/connection-manager/utils.d.ts +1 -1
  17. package/dist/src/connection-manager/utils.d.ts.map +1 -1
  18. package/dist/src/connection-manager/utils.js.map +1 -1
  19. package/dist/src/content-routing.d.ts.map +1 -1
  20. package/dist/src/content-routing.js +15 -5
  21. package/dist/src/content-routing.js.map +1 -1
  22. package/dist/src/libp2p.d.ts +1 -1
  23. package/dist/src/libp2p.d.ts.map +1 -1
  24. package/dist/src/libp2p.js.map +1 -1
  25. package/dist/src/peer-routing.d.ts.map +1 -1
  26. package/dist/src/peer-routing.js +6 -2
  27. package/dist/src/peer-routing.js.map +1 -1
  28. package/dist/src/random-walk.d.ts.map +1 -1
  29. package/dist/src/random-walk.js +1 -1
  30. package/dist/src/random-walk.js.map +1 -1
  31. package/dist/src/registrar.js +2 -2
  32. package/dist/src/registrar.js.map +1 -1
  33. package/dist/src/version.d.ts +1 -1
  34. package/dist/src/version.d.ts.map +1 -1
  35. package/dist/src/version.js +1 -1
  36. package/dist/src/version.js.map +1 -1
  37. package/package.json +24 -37
  38. package/src/address-manager/ip-mappings.ts +0 -1
  39. package/src/components.ts +2 -2
  40. package/src/config.ts +2 -2
  41. package/src/connection-manager/index.ts +2 -1
  42. package/src/connection-manager/utils.ts +2 -1
  43. package/src/content-routing.ts +30 -13
  44. package/src/libp2p.ts +2 -1
  45. package/src/peer-routing.ts +12 -8
  46. package/src/random-walk.ts +2 -1
  47. package/src/registrar.ts +2 -2
  48. package/src/version.ts +1 -1
  49. package/dist/typedoc-urls.json +0 -21
@@ -1,3 +1,3 @@
1
- export const version = '2.8.5';
1
+ export const version = '2.8.6-aa25d38ab';
2
2
  export const name = 'js-libp2p';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AAC9B,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAA"}
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,WAAW,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libp2p",
3
- "version": "2.8.5",
3
+ "version": "2.8.6-aa25d38ab",
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",
@@ -62,18 +62,6 @@
62
62
  "import": "./dist/src/version.js"
63
63
  }
64
64
  },
65
- "eslintConfig": {
66
- "extends": "ipfs",
67
- "parserOptions": {
68
- "project": true,
69
- "sourceType": "module"
70
- },
71
- "ignorePatterns": [
72
- "!.aegir.js",
73
- "test/ts-use",
74
- "*.d.ts"
75
- ]
76
- },
77
65
  "scripts": {
78
66
  "clean": "aegir clean",
79
67
  "lint": "aegir lint",
@@ -90,48 +78,47 @@
90
78
  "test:webkit": "aegir test -t browser -- --browser webkit"
91
79
  },
92
80
  "dependencies": {
93
- "@chainsafe/is-ip": "^2.0.2",
81
+ "@chainsafe/is-ip": "^2.1.0",
94
82
  "@chainsafe/netmask": "^2.0.0",
95
- "@libp2p/crypto": "^5.1.1",
96
- "@libp2p/interface": "^2.9.0",
97
- "@libp2p/interface-internal": "^2.3.11",
98
- "@libp2p/logger": "^5.1.15",
99
- "@libp2p/multistream-select": "^6.0.22",
100
- "@libp2p/peer-collections": "^6.0.27",
101
- "@libp2p/peer-id": "^5.1.2",
102
- "@libp2p/peer-store": "^11.1.4",
103
- "@libp2p/utils": "^6.6.2",
83
+ "@libp2p/crypto": "5.1.2-aa25d38ab",
84
+ "@libp2p/interface": "2.10.0-aa25d38ab",
85
+ "@libp2p/interface-internal": "2.3.12-aa25d38ab",
86
+ "@libp2p/logger": "5.1.16-aa25d38ab",
87
+ "@libp2p/multistream-select": "6.0.23-aa25d38ab",
88
+ "@libp2p/peer-collections": "6.0.28-aa25d38ab",
89
+ "@libp2p/peer-id": "5.1.3-aa25d38ab",
90
+ "@libp2p/peer-store": "11.2.0-aa25d38ab",
91
+ "@libp2p/utils": "6.6.3-aa25d38ab",
104
92
  "@multiformats/dns": "^1.0.6",
105
- "@multiformats/multiaddr": "^12.3.5",
106
- "@multiformats/multiaddr-matcher": "^1.7.0",
93
+ "@multiformats/multiaddr": "^12.4.0",
94
+ "@multiformats/multiaddr-matcher": "^1.7.2",
107
95
  "any-signal": "^4.1.1",
108
96
  "datastore-core": "^10.0.2",
109
97
  "interface-datastore": "^8.3.1",
110
- "it-byte-stream": "^2.0.1",
111
- "it-merge": "^3.0.5",
112
- "it-parallel": "^3.0.8",
113
- "merge-options": "^3.0.4",
114
- "multiformats": "^13.3.1",
98
+ "it-byte-stream": "^2.0.2",
99
+ "it-merge": "^3.0.11",
100
+ "it-parallel": "^3.0.11",
101
+ "multiformats": "^13.3.4",
115
102
  "p-defer": "^4.0.1",
116
103
  "p-retry": "^6.2.1",
117
104
  "progress-events": "^1.0.1",
118
105
  "race-event": "^1.3.0",
119
- "race-signal": "^1.1.2",
106
+ "race-signal": "^1.1.3",
120
107
  "uint8arrays": "^5.1.0"
121
108
  },
122
109
  "devDependencies": {
123
- "aegir": "^45.1.1",
110
+ "aegir": "^47.0.6",
124
111
  "delay": "^6.0.0",
125
- "it-all": "^3.0.6",
126
- "it-drain": "^3.0.7",
112
+ "it-all": "^3.0.8",
113
+ "it-drain": "^3.0.9",
127
114
  "it-length-prefixed": "^10.0.1",
128
- "it-map": "^3.1.1",
115
+ "it-map": "^3.1.3",
129
116
  "it-pair": "^2.0.6",
130
117
  "it-stream-types": "^2.0.2",
131
- "it-take": "^3.0.6",
118
+ "it-take": "^3.0.8",
132
119
  "p-event": "^6.0.1",
133
120
  "p-wait-for": "^5.0.2",
134
- "sinon": "^19.0.2",
121
+ "sinon": "^20.0.0",
135
122
  "sinon-ts": "^2.0.0",
136
123
  "uint8arraylist": "^2.4.8",
137
124
  "wherearewe": "^2.0.1"
@@ -151,7 +151,6 @@ export class IPMappings {
151
151
 
152
152
  for (const mappings of this.mappings.values()) {
153
153
  for (const mapping of mappings) {
154
- // eslint-disable-next-line max-depth
155
154
  if (mapping.externalIp === host) {
156
155
  this.log('marking %s to %s IP mapping as verified', mapping.internalIp, mapping.externalIp)
157
156
  startingConfidence = mapping.verified
package/src/components.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { serviceCapabilities, serviceDependencies } from '@libp2p/interface'
2
- import { isStartable, type Startable, type Libp2pEvents, type ComponentLogger, type NodeInfo, type ConnectionProtector, type ConnectionGater, type ContentRouting, type TypedEventTarget, type Metrics, type PeerId, type PeerRouting, type PeerStore, type PrivateKey, type Upgrader } from '@libp2p/interface'
1
+ import { serviceCapabilities, serviceDependencies, isStartable } from '@libp2p/interface'
3
2
  import { defaultLogger } from '@libp2p/logger'
4
3
  import { MissingServiceError, UnmetServiceDependenciesError } from './errors.js'
4
+ import type { Startable, Libp2pEvents, ComponentLogger, NodeInfo, ConnectionProtector, ConnectionGater, ContentRouting, TypedEventTarget, Metrics, PeerId, PeerRouting, PeerStore, PrivateKey, Upgrader } from '@libp2p/interface'
5
5
  import type { AddressManager, ConnectionManager, RandomWalk, Registrar, TransportManager } from '@libp2p/interface-internal'
6
6
  import type { DNS } from '@multiformats/dns'
7
7
  import type { Datastore } from 'interface-datastore'
package/src/config.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FaultTolerance, InvalidParametersError } from '@libp2p/interface'
2
+ import { mergeOptions } from '@libp2p/utils/merge-options'
2
3
  import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
3
- import mergeOptions from 'merge-options'
4
4
  import type { Libp2pInit } from './index.js'
5
5
  import type { ServiceMap } from '@libp2p/interface'
6
6
  import type { Multiaddr } from '@multiformats/multiaddr'
@@ -25,7 +25,7 @@ const DefaultConfig: Libp2pInit = {
25
25
  export async function validateConfig <T extends ServiceMap = Record<string, unknown>> (opts: Libp2pInit<T>): Promise<Libp2pInit<T>> {
26
26
  const resultingOptions: Libp2pInit<T> = mergeOptions(DefaultConfig, opts)
27
27
 
28
- if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) { // eslint-disable-line no-undef
28
+ if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) {
29
29
  throw new InvalidParametersError('Private network is enforced, but no protector was provided')
30
30
  }
31
31
 
@@ -1,7 +1,7 @@
1
1
  import { ConnectionClosedError, InvalidMultiaddrError, InvalidParametersError, InvalidPeerIdError, NotStartedError, start, stop } from '@libp2p/interface'
2
2
  import { PeerMap } from '@libp2p/peer-collections'
3
3
  import { RateLimiter } from '@libp2p/utils/rate-limiter'
4
- import { type Multiaddr, type Resolver, multiaddr } from '@multiformats/multiaddr'
4
+ import { multiaddr } from '@multiformats/multiaddr'
5
5
  import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
6
6
  import { CustomProgressEvent } from 'progress-events'
7
7
  import { getPeerAddress } from '../get-peer.js'
@@ -14,6 +14,7 @@ import type { IpNet } from '@chainsafe/netmask'
14
14
  import type { PendingDial, AddressSorter, Libp2pEvents, AbortOptions, ComponentLogger, Logger, Connection, MultiaddrConnection, ConnectionGater, TypedEventTarget, Metrics, PeerId, PeerStore, Startable, PendingDialStatus, PeerRouting, IsDialableOptions } from '@libp2p/interface'
15
15
  import type { ConnectionManager, OpenConnectionOptions, TransportManager } from '@libp2p/interface-internal'
16
16
  import type { JobStatus } from '@libp2p/utils/queue'
17
+ import type { Multiaddr, Resolver } from '@multiformats/multiaddr'
17
18
 
18
19
  export const DEFAULT_DIAL_PRIORITY = 50
19
20
 
@@ -1,7 +1,8 @@
1
- import { multiaddr, resolvers, type Multiaddr, type ResolveOptions } from '@multiformats/multiaddr'
1
+ import { multiaddr, resolvers } from '@multiformats/multiaddr'
2
2
  import { convertToIpNet } from '@multiformats/multiaddr/convert'
3
3
  import type { IpNet } from '@chainsafe/netmask'
4
4
  import type { LoggerOptions } from '@libp2p/interface'
5
+ import type { Multiaddr, ResolveOptions } from '@multiformats/multiaddr'
5
6
 
6
7
  /**
7
8
  * Recursively resolve DNSADDR multiaddrs
@@ -104,7 +104,9 @@ export class CompoundContentRouting implements ContentRouting, Startable {
104
104
  const seen = new PeerSet()
105
105
 
106
106
  for await (const peer of merge(
107
- ...self.routers.map(router => router.findProviders(key, options))
107
+ ...self.routers
108
+ .filter(router => router.findProviders instanceof Function)
109
+ .map(router => router.findProviders(key, options))
108
110
  )) {
109
111
  // the peer was yielded by a content router without multiaddrs and we
110
112
  // failed to load them
@@ -139,9 +141,12 @@ export class CompoundContentRouting implements ContentRouting, Startable {
139
141
  throw new NoContentRoutersError('No content routers available')
140
142
  }
141
143
 
142
- await Promise.all(this.routers.map(async (router) => {
143
- await router.provide(key, options)
144
- }))
144
+ await Promise.all(
145
+ this.routers
146
+ .filter(router => router.provide instanceof Function)
147
+ .map(async (router) => {
148
+ await router.provide(key, options)
149
+ }))
145
150
  }
146
151
 
147
152
  async cancelReprovide (key: CID, options: AbortOptions = {}): Promise<void> {
@@ -149,9 +154,13 @@ export class CompoundContentRouting implements ContentRouting, Startable {
149
154
  throw new NoContentRoutersError('No content routers available')
150
155
  }
151
156
 
152
- await Promise.all(this.routers.map(async (router) => {
153
- await router.cancelReprovide(key, options)
154
- }))
157
+ await Promise.all(
158
+ this.routers
159
+ .filter(router => router.cancelReprovide instanceof Function)
160
+ .map(async (router) => {
161
+ await router.cancelReprovide(key, options)
162
+ })
163
+ )
155
164
  }
156
165
 
157
166
  /**
@@ -162,9 +171,13 @@ export class CompoundContentRouting implements ContentRouting, Startable {
162
171
  throw new NotStartedError()
163
172
  }
164
173
 
165
- await Promise.all(this.routers.map(async (router) => {
166
- await router.put(key, value, options)
167
- }))
174
+ await Promise.all(
175
+ this.routers
176
+ .filter(router => router.put instanceof Function)
177
+ .map(async (router) => {
178
+ await router.put(key, value, options)
179
+ })
180
+ )
168
181
  }
169
182
 
170
183
  /**
@@ -176,8 +189,12 @@ export class CompoundContentRouting implements ContentRouting, Startable {
176
189
  throw new NotStartedError()
177
190
  }
178
191
 
179
- return Promise.any(this.routers.map(async (router) => {
180
- return router.get(key, options)
181
- }))
192
+ return Promise.any(
193
+ this.routers
194
+ .filter(router => router.get instanceof Function)
195
+ .map(async (router) => {
196
+ return router.get(key, options)
197
+ })
198
+ )
182
199
  }
183
200
  }
package/src/libp2p.ts CHANGED
@@ -4,7 +4,7 @@ import { defaultLogger } from '@libp2p/logger'
4
4
  import { PeerSet } from '@libp2p/peer-collections'
5
5
  import { peerIdFromString } from '@libp2p/peer-id'
6
6
  import { persistentPeerStore } from '@libp2p/peer-store'
7
- import { isMultiaddr, type Multiaddr } from '@multiformats/multiaddr'
7
+ import { isMultiaddr } from '@multiformats/multiaddr'
8
8
  import { MemoryDatastore } from 'datastore-core/memory'
9
9
  import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
10
10
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
@@ -24,6 +24,7 @@ import * as pkg from './version.js'
24
24
  import type { Components } from './components.js'
25
25
  import type { Libp2p as Libp2pInterface, Libp2pInit } from './index.js'
26
26
  import type { PeerRouting, ContentRouting, Libp2pEvents, PendingDial, ServiceMap, AbortOptions, ComponentLogger, Logger, Connection, NewStreamOptions, Stream, Metrics, PeerId, PeerInfo, PeerStore, Topology, Libp2pStatus, IsDialableOptions, DialOptions, PublicKey, Ed25519PeerId, Secp256k1PeerId, RSAPublicKey, RSAPeerId, URLPeerId, Ed25519PublicKey, Secp256k1PublicKey, StreamHandler, StreamHandlerOptions } from '@libp2p/interface'
27
+ import type { Multiaddr } from '@multiformats/multiaddr'
27
28
 
28
29
  export class Libp2p<T extends ServiceMap = ServiceMap> extends TypedEventEmitter<Libp2pEvents> implements Libp2pInterface<T> {
29
30
  public peerId: PeerId
@@ -72,13 +72,15 @@ export class DefaultPeerRouting implements PeerRouting {
72
72
 
73
73
  const self = this
74
74
  const source = merge(
75
- ...this.routers.map(router => (async function * () {
76
- try {
77
- yield await router.findPeer(id, options)
78
- } catch (err) {
79
- self.log.error(err)
80
- }
81
- })())
75
+ ...this.routers
76
+ .filter(router => router.findPeer instanceof Function)
77
+ .map(router => (async function * () {
78
+ try {
79
+ yield await router.findPeer(id, options)
80
+ } catch (err) {
81
+ self.log.error(err)
82
+ }
83
+ })())
82
84
  )
83
85
 
84
86
  for await (const peer of source) {
@@ -113,7 +115,9 @@ export class DefaultPeerRouting implements PeerRouting {
113
115
  for await (const peer of parallel(
114
116
  async function * () {
115
117
  const source = merge(
116
- ...self.routers.map(router => router.getClosestPeers(key, options))
118
+ ...self.routers
119
+ .filter(router => router.getClosestPeers instanceof Function)
120
+ .map(router => router.getClosestPeers(key, options))
117
121
  )
118
122
 
119
123
  for await (let peer of source) {
@@ -1,11 +1,12 @@
1
1
  import { randomBytes } from '@libp2p/crypto'
2
2
  import { TypedEventEmitter, setMaxListeners } from '@libp2p/interface'
3
3
  import { anySignal } from 'any-signal'
4
- import pDefer, { type DeferredPromise } from 'p-defer'
4
+ import pDefer from 'p-defer'
5
5
  import { raceEvent } from 'race-event'
6
6
  import { raceSignal } from 'race-signal'
7
7
  import type { AbortOptions, ComponentLogger, Logger, PeerInfo, PeerRouting, Startable } from '@libp2p/interface'
8
8
  import type { RandomWalk as RandomWalkInterface } from '@libp2p/interface-internal'
9
+ import type { DeferredPromise } from 'p-defer'
9
10
 
10
11
  export interface RandomWalkComponents {
11
12
  peerRouting: PeerRouting
package/src/registrar.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { InvalidParametersError } from '@libp2p/interface'
2
- import merge from 'merge-options'
2
+ import { mergeOptions } from '@libp2p/utils/merge-options'
3
3
  import * as errorsJs from './errors.js'
4
4
  import type { IdentifyResult, Libp2pEvents, Logger, PeerUpdate, TypedEventTarget, PeerId, PeerStore, Topology, StreamHandler, StreamHandlerRecord, StreamHandlerOptions } from '@libp2p/interface'
5
5
  import type { Registrar as RegistrarInterface } from '@libp2p/interface-internal'
@@ -77,7 +77,7 @@ export class Registrar implements RegistrarInterface {
77
77
  throw new errorsJs.DuplicateProtocolHandlerError(`Handler already registered for protocol ${protocol}`)
78
78
  }
79
79
 
80
- const options = merge.bind({ ignoreUndefined: true })({
80
+ const options = mergeOptions.bind({ ignoreUndefined: true })({
81
81
  maxInboundStreams: DEFAULT_MAX_INBOUND_STREAMS,
82
82
  maxOutboundStreams: DEFAULT_MAX_OUTBOUND_STREAMS
83
83
  }, opts)
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '2.8.5'
1
+ export const version = '2.8.6-aa25d38ab'
2
2
  export const name = 'js-libp2p'
@@ -1,21 +0,0 @@
1
- {
2
- "AddressFilter": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.AddressFilter.html",
3
- "AddressManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.AddressManagerInit.html",
4
- "ConnectionManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.ConnectionManagerInit.html",
5
- "ConnectionMonitorInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.ConnectionMonitorInit.html",
6
- "Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.Libp2pInit.html",
7
- ".:Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.Libp2pInit.html",
8
- "TransportManagerInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.TransportManagerInit.html",
9
- "Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html",
10
- ".:Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html",
11
- "ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.index.ServiceFactoryMap.html",
12
- ".:ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.index.ServiceFactoryMap.html",
13
- "createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.index.createLibp2p.html",
14
- ".:createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.index.createLibp2p.html",
15
- "userAgent": "https://libp2p.github.io/js-libp2p/functions/libp2p.user_agent.userAgent.html",
16
- "./user-agent:userAgent": "https://libp2p.github.io/js-libp2p/functions/libp2p.user_agent.userAgent.html",
17
- "name": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.name.html",
18
- "./version:name": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.name.html",
19
- "version": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.version.html",
20
- "./version:version": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.version.html"
21
- }