libp2p 2.5.2 → 2.6.0-d8f003e6e
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 +30 -1
- package/dist/index.min.js +11 -11
- package/dist/src/address-manager/index.d.ts +9 -0
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +101 -10
- package/dist/src/address-manager/index.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/libp2p.d.ts +1 -2
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +9 -5
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/registrar.d.ts +3 -3
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +2 -2
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/user-agent.browser.d.ts +2 -0
- package/dist/src/user-agent.browser.d.ts.map +1 -0
- package/dist/src/user-agent.browser.js +5 -0
- package/dist/src/user-agent.browser.js.map +1 -0
- package/dist/src/user-agent.d.ts +2 -0
- package/dist/src/user-agent.d.ts.map +1 -0
- package/dist/src/user-agent.js +20 -0
- package/dist/src/user-agent.js.map +1 -0
- package/dist/src/user-agent.react-native.d.ts +2 -0
- package/dist/src/user-agent.react-native.d.ts.map +1 -0
- package/dist/src/user-agent.react-native.js +6 -0
- package/dist/src/user-agent.react-native.js.map +1 -0
- 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 +22 -14
- package/src/address-manager/index.ts +129 -11
- package/src/index.ts +1 -1
- package/src/libp2p.ts +12 -7
- package/src/registrar.ts +4 -4
- package/src/user-agent.browser.ts +5 -0
- package/src/user-agent.react-native.ts +6 -0
- package/src/user-agent.ts +24 -0
- package/src/version.ts +1 -1
- package/dist/typedoc-urls.json +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libp2p",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0-d8f003e6e",
|
|
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",
|
|
@@ -52,6 +52,11 @@
|
|
|
52
52
|
"types": "./dist/src/index.d.ts",
|
|
53
53
|
"import": "./dist/src/index.js"
|
|
54
54
|
},
|
|
55
|
+
"./user-agent": {
|
|
56
|
+
"types": "./dist/src/user-agent.d.ts",
|
|
57
|
+
"browser": "./dist/src/user-agent.browser.js",
|
|
58
|
+
"import": "./dist/src/user-agent.js"
|
|
59
|
+
},
|
|
55
60
|
"./version": {
|
|
56
61
|
"types": "./dist/src/version.d.ts",
|
|
57
62
|
"import": "./dist/src/version.js"
|
|
@@ -87,17 +92,17 @@
|
|
|
87
92
|
"dependencies": {
|
|
88
93
|
"@chainsafe/is-ip": "^2.0.2",
|
|
89
94
|
"@chainsafe/netmask": "^2.0.0",
|
|
90
|
-
"@libp2p/crypto": "
|
|
91
|
-
"@libp2p/interface": "
|
|
92
|
-
"@libp2p/interface-internal": "
|
|
93
|
-
"@libp2p/logger": "
|
|
94
|
-
"@libp2p/multistream-select": "
|
|
95
|
-
"@libp2p/peer-collections": "
|
|
96
|
-
"@libp2p/peer-id": "
|
|
97
|
-
"@libp2p/peer-store": "
|
|
98
|
-
"@libp2p/utils": "
|
|
95
|
+
"@libp2p/crypto": "5.0.11-d8f003e6e",
|
|
96
|
+
"@libp2p/interface": "2.5.0-d8f003e6e",
|
|
97
|
+
"@libp2p/interface-internal": "2.3.0-d8f003e6e",
|
|
98
|
+
"@libp2p/logger": "5.1.8-d8f003e6e",
|
|
99
|
+
"@libp2p/multistream-select": "6.0.13-d8f003e6e",
|
|
100
|
+
"@libp2p/peer-collections": "6.0.17-d8f003e6e",
|
|
101
|
+
"@libp2p/peer-id": "5.0.12-d8f003e6e",
|
|
102
|
+
"@libp2p/peer-store": "11.0.17-d8f003e6e",
|
|
103
|
+
"@libp2p/utils": "6.5.1-d8f003e6e",
|
|
99
104
|
"@multiformats/dns": "^1.0.6",
|
|
100
|
-
"@multiformats/multiaddr": "^12.3.
|
|
105
|
+
"@multiformats/multiaddr": "^12.3.5",
|
|
101
106
|
"@multiformats/multiaddr-matcher": "^1.6.0",
|
|
102
107
|
"any-signal": "^4.1.1",
|
|
103
108
|
"datastore-core": "^10.0.2",
|
|
@@ -128,15 +133,18 @@
|
|
|
128
133
|
"p-wait-for": "^5.0.2",
|
|
129
134
|
"sinon": "^19.0.2",
|
|
130
135
|
"sinon-ts": "^2.0.0",
|
|
131
|
-
"uint8arraylist": "^2.4.8"
|
|
136
|
+
"uint8arraylist": "^2.4.8",
|
|
137
|
+
"wherearewe": "^2.0.1"
|
|
132
138
|
},
|
|
133
139
|
"browser": {
|
|
134
140
|
"./dist/src/connection-manager/constants.js": "./dist/src/connection-manager/constants.browser.js",
|
|
135
|
-
"./dist/src/config/connection-gater.js": "./dist/src/config/connection-gater.browser.js"
|
|
141
|
+
"./dist/src/config/connection-gater.js": "./dist/src/config/connection-gater.browser.js",
|
|
142
|
+
"./dist/src/user-agent.js": "./dist/src/user-agent.browser.js"
|
|
136
143
|
},
|
|
137
144
|
"react-native": {
|
|
138
145
|
"./dist/src/connection-manager/constants.js": "./dist/src/connection-manager/constants.browser.js",
|
|
139
|
-
"./dist/src/config/connection-gater.js": "./dist/src/config/connection-gater.browser.js"
|
|
146
|
+
"./dist/src/config/connection-gater.js": "./dist/src/config/connection-gater.browser.js",
|
|
147
|
+
"./dist/src/user-agent.js": "./dist/src/user-agent.react-native.js"
|
|
140
148
|
},
|
|
141
149
|
"sideEffects": false
|
|
142
150
|
}
|
|
@@ -3,7 +3,9 @@ import { isIPv4 } from '@chainsafe/is-ip'
|
|
|
3
3
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
4
4
|
import { debounce } from '@libp2p/utils/debounce'
|
|
5
5
|
import { createScalableCuckooFilter } from '@libp2p/utils/filters'
|
|
6
|
+
import { isPrivateIp } from '@libp2p/utils/private-ip'
|
|
6
7
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
8
|
+
import { QUICV1, TCP, WebSockets, WebSocketsSecure } from '@multiformats/multiaddr-matcher'
|
|
7
9
|
import { DNSMappings } from './dns-mappings.js'
|
|
8
10
|
import { IPMappings } from './ip-mappings.js'
|
|
9
11
|
import { ObservedAddresses } from './observed-addresses.js'
|
|
@@ -249,20 +251,42 @@ export class AddressManager implements AddressManagerInterface {
|
|
|
249
251
|
addr = stripPeerId(addr, this.components.peerId)
|
|
250
252
|
let startingConfidence = true
|
|
251
253
|
|
|
252
|
-
if (options?.type === 'observed' || this.observed.has(addr)) {
|
|
253
|
-
startingConfidence = this.observed.confirm(addr, options?.ttl ?? this.addressVerificationTTL)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
254
|
if (options?.type === 'transport' || this.transportAddresses.has(addr)) {
|
|
257
|
-
|
|
255
|
+
const transportStartingConfidence = this.transportAddresses.confirm(addr, options?.ttl ?? this.addressVerificationTTL)
|
|
256
|
+
|
|
257
|
+
if (!transportStartingConfidence && startingConfidence) {
|
|
258
|
+
startingConfidence = false
|
|
259
|
+
}
|
|
258
260
|
}
|
|
259
261
|
|
|
260
262
|
if (options?.type === 'dns-mapping' || this.dnsMappings.has(addr)) {
|
|
261
|
-
|
|
263
|
+
const dnsMapingStartingConfidence = this.dnsMappings.confirm(addr, options?.ttl ?? this.addressVerificationTTL)
|
|
264
|
+
|
|
265
|
+
if (!dnsMapingStartingConfidence && startingConfidence) {
|
|
266
|
+
startingConfidence = false
|
|
267
|
+
}
|
|
262
268
|
}
|
|
263
269
|
|
|
264
270
|
if (options?.type === 'ip-mapping' || this.ipMappings.has(addr)) {
|
|
265
|
-
|
|
271
|
+
const ipMapingStartingConfidence = this.ipMappings.confirm(addr, options?.ttl ?? this.addressVerificationTTL)
|
|
272
|
+
|
|
273
|
+
if (!ipMapingStartingConfidence && startingConfidence) {
|
|
274
|
+
startingConfidence = false
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (options?.type === 'observed' || this.observed.has(addr)) {
|
|
279
|
+
// try to match up observed address with local transport listener
|
|
280
|
+
if (this.maybeUpgradeToIPMapping(addr)) {
|
|
281
|
+
this.ipMappings.confirm(addr, options?.ttl ?? this.addressVerificationTTL)
|
|
282
|
+
startingConfidence = false
|
|
283
|
+
} else {
|
|
284
|
+
const observedStartingConfidence = this.observed.confirm(addr, options?.ttl ?? this.addressVerificationTTL)
|
|
285
|
+
|
|
286
|
+
if (!observedStartingConfidence && startingConfidence) {
|
|
287
|
+
startingConfidence = false
|
|
288
|
+
}
|
|
289
|
+
}
|
|
266
290
|
}
|
|
267
291
|
|
|
268
292
|
// only trigger the 'self:peer:update' event if our confidence in an address has changed
|
|
@@ -277,19 +301,35 @@ export class AddressManager implements AddressManagerInterface {
|
|
|
277
301
|
let startingConfidence = false
|
|
278
302
|
|
|
279
303
|
if (this.observed.has(addr)) {
|
|
280
|
-
|
|
304
|
+
const observedStartingConfidence = this.observed.remove(addr)
|
|
305
|
+
|
|
306
|
+
if (!observedStartingConfidence && startingConfidence) {
|
|
307
|
+
startingConfidence = false
|
|
308
|
+
}
|
|
281
309
|
}
|
|
282
310
|
|
|
283
311
|
if (this.transportAddresses.has(addr)) {
|
|
284
|
-
|
|
312
|
+
const transportStartingConfidence = this.transportAddresses.unconfirm(addr, options?.ttl ?? this.addressVerificationRetry)
|
|
313
|
+
|
|
314
|
+
if (!transportStartingConfidence && startingConfidence) {
|
|
315
|
+
startingConfidence = false
|
|
316
|
+
}
|
|
285
317
|
}
|
|
286
318
|
|
|
287
319
|
if (this.dnsMappings.has(addr)) {
|
|
288
|
-
|
|
320
|
+
const dnsMapingStartingConfidence = this.dnsMappings.unconfirm(addr, options?.ttl ?? this.addressVerificationRetry)
|
|
321
|
+
|
|
322
|
+
if (!dnsMapingStartingConfidence && startingConfidence) {
|
|
323
|
+
startingConfidence = false
|
|
324
|
+
}
|
|
289
325
|
}
|
|
290
326
|
|
|
291
327
|
if (this.ipMappings.has(addr)) {
|
|
292
|
-
|
|
328
|
+
const ipMapingStartingConfidence = this.ipMappings.unconfirm(addr, options?.ttl ?? this.addressVerificationRetry)
|
|
329
|
+
|
|
330
|
+
if (!ipMapingStartingConfidence && startingConfidence) {
|
|
331
|
+
startingConfidence = false
|
|
332
|
+
}
|
|
293
333
|
}
|
|
294
334
|
|
|
295
335
|
// only trigger the 'self:peer:update' event if our confidence in an address has changed
|
|
@@ -410,4 +450,82 @@ export class AddressManager implements AddressManagerInterface {
|
|
|
410
450
|
this._updatePeerStoreAddresses()
|
|
411
451
|
}
|
|
412
452
|
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Where an external service (router, gateway, etc) is forwarding traffic to
|
|
456
|
+
* us, attempt to add an IP mapping for the external address - this will
|
|
457
|
+
* include the observed mapping in the address list where we also have a DNS
|
|
458
|
+
* mapping for the external IP.
|
|
459
|
+
*
|
|
460
|
+
* Returns true if we added a new mapping
|
|
461
|
+
*/
|
|
462
|
+
private maybeUpgradeToIPMapping (ma: Multiaddr): boolean {
|
|
463
|
+
// this address is already mapped
|
|
464
|
+
if (this.ipMappings.has(ma)) {
|
|
465
|
+
return false
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
const maOptions = ma.toOptions()
|
|
469
|
+
|
|
470
|
+
// only public IPv4 addresses
|
|
471
|
+
if (maOptions.family === 6 || maOptions.host === '127.0.0.1' || isPrivateIp(maOptions.host) === true) {
|
|
472
|
+
return false
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const listeners = this.components.transportManager.getListeners()
|
|
476
|
+
|
|
477
|
+
const transportMatchers: Array<(ma: Multiaddr) => boolean> = [
|
|
478
|
+
(ma: Multiaddr) => WebSockets.exactMatch(ma) || WebSocketsSecure.exactMatch(ma),
|
|
479
|
+
(ma: Multiaddr) => TCP.exactMatch(ma),
|
|
480
|
+
(ma: Multiaddr) => QUICV1.exactMatch(ma)
|
|
481
|
+
]
|
|
482
|
+
|
|
483
|
+
for (const matcher of transportMatchers) {
|
|
484
|
+
// is the incoming address the same type as the matcher
|
|
485
|
+
if (!matcher(ma)) {
|
|
486
|
+
continue
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// get the listeners for this transport
|
|
490
|
+
const transportListeners = listeners.filter(listener => {
|
|
491
|
+
return listener.getAddrs().filter(ma => {
|
|
492
|
+
// only IPv4 addresses of the matcher type
|
|
493
|
+
return ma.toOptions().family === 4 && matcher(ma)
|
|
494
|
+
}).length > 0
|
|
495
|
+
})
|
|
496
|
+
|
|
497
|
+
// because the NAT mapping could be forwarding different external ports to
|
|
498
|
+
// internal ones, we can only be sure enough to add a mapping if there is
|
|
499
|
+
// a single listener
|
|
500
|
+
if (transportListeners.length !== 1) {
|
|
501
|
+
continue
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// we have one listener which listens on one port so whatever the external
|
|
505
|
+
// NAT port mapping is, it should be for this listener
|
|
506
|
+
const linkLocalAddr = transportListeners[0].getAddrs().filter(ma => {
|
|
507
|
+
return ma.toOptions().host !== '127.0.0.1'
|
|
508
|
+
}).pop()
|
|
509
|
+
|
|
510
|
+
if (linkLocalAddr == null) {
|
|
511
|
+
continue
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const linkLocalOptions = linkLocalAddr.toOptions()
|
|
515
|
+
|
|
516
|
+
// upgrade observed address to IP mapping
|
|
517
|
+
this.observed.remove(ma)
|
|
518
|
+
this.ipMappings.add(
|
|
519
|
+
linkLocalOptions.host,
|
|
520
|
+
linkLocalOptions.port,
|
|
521
|
+
maOptions.host,
|
|
522
|
+
maOptions.port,
|
|
523
|
+
maOptions.transport
|
|
524
|
+
)
|
|
525
|
+
|
|
526
|
+
return true
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
return false
|
|
530
|
+
}
|
|
413
531
|
}
|
package/src/index.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface Libp2pInit<T extends ServiceMap = ServiceMap> {
|
|
|
50
50
|
/**
|
|
51
51
|
* Metadata about the node - implementation name, version number, etc
|
|
52
52
|
*/
|
|
53
|
-
nodeInfo?: NodeInfo
|
|
53
|
+
nodeInfo?: Partial<NodeInfo>
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Addresses for transport listening and to advertise to the network
|
package/src/libp2p.ts
CHANGED
|
@@ -16,14 +16,14 @@ import { ConnectionMonitor } from './connection-monitor.js'
|
|
|
16
16
|
import { CompoundContentRouting } from './content-routing.js'
|
|
17
17
|
import { DefaultPeerRouting } from './peer-routing.js'
|
|
18
18
|
import { RandomWalk } from './random-walk.js'
|
|
19
|
-
import {
|
|
19
|
+
import { Registrar } from './registrar.js'
|
|
20
20
|
import { DefaultTransportManager } from './transport-manager.js'
|
|
21
21
|
import { DefaultUpgrader } from './upgrader.js'
|
|
22
|
+
import { userAgent } from './user-agent.js'
|
|
22
23
|
import * as pkg from './version.js'
|
|
23
24
|
import type { Components } from './components.js'
|
|
24
25
|
import type { Libp2p as Libp2pInterface, Libp2pInit } from './index.js'
|
|
25
|
-
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 } from '@libp2p/interface'
|
|
26
|
-
import type { StreamHandler, StreamHandlerOptions } from '@libp2p/interface-internal'
|
|
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
27
|
|
|
28
28
|
export class Libp2p<T extends ServiceMap = ServiceMap> extends TypedEventEmitter<Libp2pEvents> implements Libp2pInterface<T> {
|
|
29
29
|
public peerId: PeerId
|
|
@@ -64,13 +64,18 @@ export class Libp2p<T extends ServiceMap = ServiceMap> extends TypedEventEmitter
|
|
|
64
64
|
this.log = this.logger.forComponent('libp2p')
|
|
65
65
|
// @ts-expect-error {} may not be of type T
|
|
66
66
|
this.services = {}
|
|
67
|
+
|
|
68
|
+
const nodeInfoName = init.nodeInfo?.name ?? pkg.name
|
|
69
|
+
const nodeInfoVersion = init.nodeInfo?.version ?? pkg.name
|
|
70
|
+
|
|
67
71
|
// @ts-expect-error defaultComponents is missing component types added later
|
|
68
72
|
const components = this.components = defaultComponents({
|
|
69
73
|
peerId: init.peerId,
|
|
70
74
|
privateKey: init.privateKey,
|
|
71
|
-
nodeInfo:
|
|
72
|
-
name:
|
|
73
|
-
version:
|
|
75
|
+
nodeInfo: {
|
|
76
|
+
name: nodeInfoName,
|
|
77
|
+
version: nodeInfoVersion,
|
|
78
|
+
userAgent: init.nodeInfo?.userAgent ?? userAgent(nodeInfoName, nodeInfoVersion)
|
|
74
79
|
},
|
|
75
80
|
logger: this.logger,
|
|
76
81
|
events,
|
|
@@ -126,7 +131,7 @@ export class Libp2p<T extends ServiceMap = ServiceMap> extends TypedEventEmitter
|
|
|
126
131
|
}
|
|
127
132
|
|
|
128
133
|
// Create the Registrar
|
|
129
|
-
this.configureComponent('registrar', new
|
|
134
|
+
this.configureComponent('registrar', new Registrar(this.components))
|
|
130
135
|
|
|
131
136
|
// Addresses {listen, announce, noAnnounce}
|
|
132
137
|
this.configureComponent('addressManager', new AddressManager(this.components, init.addresses))
|
package/src/registrar.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InvalidParametersError } from '@libp2p/interface'
|
|
2
2
|
import merge from 'merge-options'
|
|
3
3
|
import * as errorsJs from './errors.js'
|
|
4
|
-
import type { IdentifyResult, Libp2pEvents, Logger, PeerUpdate, TypedEventTarget, PeerId, PeerStore, Topology } from '@libp2p/interface'
|
|
5
|
-
import type {
|
|
4
|
+
import type { IdentifyResult, Libp2pEvents, Logger, PeerUpdate, TypedEventTarget, PeerId, PeerStore, Topology, StreamHandlerRecord, StreamHandlerOptions } from '@libp2p/interface'
|
|
5
|
+
import type { Registrar as RegistrarInterface, StreamHandler } from '@libp2p/interface-internal'
|
|
6
6
|
import type { ComponentLogger } from '@libp2p/logger'
|
|
7
7
|
|
|
8
8
|
export const DEFAULT_MAX_INBOUND_STREAMS = 32
|
|
@@ -18,7 +18,7 @@ export interface RegistrarComponents {
|
|
|
18
18
|
/**
|
|
19
19
|
* Responsible for notifying registered protocols of events in the network.
|
|
20
20
|
*/
|
|
21
|
-
export class
|
|
21
|
+
export class Registrar implements RegistrarInterface {
|
|
22
22
|
private readonly log: Logger
|
|
23
23
|
private readonly topologies: Map<string, Map<string, Topology>>
|
|
24
24
|
private readonly handlers: Map<string, StreamHandlerRecord>
|
|
@@ -73,7 +73,7 @@ export class DefaultRegistrar implements Registrar {
|
|
|
73
73
|
* Registers the `handler` for each protocol
|
|
74
74
|
*/
|
|
75
75
|
async handle (protocol: string, handler: StreamHandler, opts?: StreamHandlerOptions): Promise<void> {
|
|
76
|
-
if (this.handlers.has(protocol)) {
|
|
76
|
+
if (this.handlers.has(protocol) && opts?.force !== true) {
|
|
77
77
|
throw new errorsJs.DuplicateProtocolHandlerError(`Handler already registered for protocol ${protocol}`)
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Platform } from 'react-native'
|
|
2
|
+
import * as pkg from './version.js'
|
|
3
|
+
|
|
4
|
+
export function userAgent (name?: string, version?: string): string {
|
|
5
|
+
return `${name ?? pkg.name}/${version ?? pkg.version} react-native/${Platform.OS}-${`${Platform.Version}`.replaceAll('v', '')}`
|
|
6
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import * as pkg from './version.js'
|
|
3
|
+
|
|
4
|
+
export function userAgent (name?: string, version?: string): string {
|
|
5
|
+
let platform = 'node'
|
|
6
|
+
let platformVersion = process.versions.node
|
|
7
|
+
|
|
8
|
+
if (process.versions.deno != null) {
|
|
9
|
+
platform = 'deno'
|
|
10
|
+
platformVersion = process.versions.deno
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (process.versions.bun != null) {
|
|
14
|
+
platform = 'bun'
|
|
15
|
+
platformVersion = process.versions.bun
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (process.versions.electron != null) {
|
|
19
|
+
platform = 'electron'
|
|
20
|
+
platformVersion = process.versions.electron
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return `${name ?? pkg.name}/${version ?? pkg.version} ${platform}/${platformVersion.replaceAll('v', '')}`
|
|
24
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.6.0-d8f003e6e'
|
|
2
2
|
export const name = 'js-libp2p'
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,19 +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
|
-
"name": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.name.html",
|
|
16
|
-
"./version:name": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.name.html",
|
|
17
|
-
"version": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.version.html",
|
|
18
|
-
"./version:version": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.version.html"
|
|
19
|
-
}
|