libp2p 2.8.7 → 2.8.8-5b004c0c4
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 +10 -10
- package/dist/index.min.js.map +4 -4
- package/dist/src/content-routing.js +1 -1
- package/dist/src/content-routing.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 +6 -6
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.js +2 -2
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/registrar.d.ts +2 -2
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +7 -4
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +12 -6
- 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 +12 -12
- package/src/content-routing.ts +1 -1
- package/src/libp2p.ts +6 -6
- package/src/peer-routing.ts +2 -2
- package/src/registrar.ts +8 -5
- package/src/upgrader.ts +13 -6
- package/src/version.ts +1 -1
- package/dist/typedoc-urls.json +0 -21
package/src/peer-routing.ts
CHANGED
|
@@ -92,7 +92,7 @@ export class DefaultPeerRouting implements PeerRouting {
|
|
|
92
92
|
if (peer.multiaddrs.length > 0) {
|
|
93
93
|
await this.peerStore.merge(peer.id, {
|
|
94
94
|
multiaddrs: peer.multiaddrs
|
|
95
|
-
})
|
|
95
|
+
}, options)
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
return peer
|
|
@@ -148,7 +148,7 @@ export class DefaultPeerRouting implements PeerRouting {
|
|
|
148
148
|
if (peer.multiaddrs.length > 0) {
|
|
149
149
|
await this.peerStore.merge(peer.id, {
|
|
150
150
|
multiaddrs: peer.multiaddrs
|
|
151
|
-
})
|
|
151
|
+
}, options)
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
// deduplicate peers
|
package/src/registrar.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InvalidParametersError } from '@libp2p/interface'
|
|
2
2
|
import { mergeOptions } from '@libp2p/utils/merge-options'
|
|
3
3
|
import * as errorsJs from './errors.js'
|
|
4
|
-
import type { IdentifyResult, Libp2pEvents, Logger, PeerUpdate, TypedEventTarget, PeerId, PeerStore, Topology, StreamHandler, StreamHandlerRecord, StreamHandlerOptions } from '@libp2p/interface'
|
|
4
|
+
import type { IdentifyResult, Libp2pEvents, Logger, PeerUpdate, TypedEventTarget, PeerId, PeerStore, Topology, StreamHandler, StreamHandlerRecord, StreamHandlerOptions, AbortOptions } from '@libp2p/interface'
|
|
5
5
|
import type { Registrar as RegistrarInterface } from '@libp2p/interface-internal'
|
|
6
6
|
import type { ComponentLogger } from '@libp2p/logger'
|
|
7
7
|
|
|
@@ -90,14 +90,14 @@ export class Registrar implements RegistrarInterface {
|
|
|
90
90
|
// Add new protocol to self protocols in the peer store
|
|
91
91
|
await this.components.peerStore.merge(this.components.peerId, {
|
|
92
92
|
protocols: [protocol]
|
|
93
|
-
})
|
|
93
|
+
}, opts)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* Removes the handler for each protocol. The protocol
|
|
98
98
|
* will no longer be supported on streams.
|
|
99
99
|
*/
|
|
100
|
-
async unhandle (protocols: string | string[]): Promise<void> {
|
|
100
|
+
async unhandle (protocols: string | string[], options?: AbortOptions): Promise<void> {
|
|
101
101
|
const protocolList = Array.isArray(protocols) ? protocols : [protocols]
|
|
102
102
|
|
|
103
103
|
protocolList.forEach(protocol => {
|
|
@@ -107,7 +107,7 @@ export class Registrar implements RegistrarInterface {
|
|
|
107
107
|
// Update self protocols in the peer store
|
|
108
108
|
await this.components.peerStore.patch(this.components.peerId, {
|
|
109
109
|
protocols: this.getProtocols()
|
|
110
|
-
})
|
|
110
|
+
}, options)
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
@@ -153,8 +153,11 @@ export class Registrar implements RegistrarInterface {
|
|
|
153
153
|
*/
|
|
154
154
|
_onDisconnect (evt: CustomEvent<PeerId>): void {
|
|
155
155
|
const remotePeer = evt.detail
|
|
156
|
+
const options = {
|
|
157
|
+
signal: AbortSignal.timeout(5_000)
|
|
158
|
+
}
|
|
156
159
|
|
|
157
|
-
void this.components.peerStore.get(remotePeer)
|
|
160
|
+
void this.components.peerStore.get(remotePeer, options)
|
|
158
161
|
.then(peer => {
|
|
159
162
|
for (const protocol of peer.protocols) {
|
|
160
163
|
const topologies = this.topologies.get(protocol)
|
package/src/upgrader.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as mss from '@libp2p/multistream-select'
|
|
|
3
3
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
4
4
|
import { anySignal } from 'any-signal'
|
|
5
5
|
import { CustomProgressEvent } from 'progress-events'
|
|
6
|
+
import { raceSignal } from 'race-signal'
|
|
6
7
|
import { createConnection } from './connection/index.js'
|
|
7
8
|
import { PROTOCOL_NEGOTIATION_TIMEOUT, INBOUND_UPGRADE_TIMEOUT } from './connection-manager/constants.js'
|
|
8
9
|
import { ConnectionDeniedError, ConnectionInterceptedError, EncryptionFailedError, MuxerUnavailableError } from './errors.js'
|
|
@@ -193,13 +194,13 @@ export class Upgrader implements UpgraderInterface {
|
|
|
193
194
|
inbound: true
|
|
194
195
|
})
|
|
195
196
|
|
|
196
|
-
accepted = await this.components.connectionManager.acceptIncomingConnection(maConn)
|
|
197
|
+
accepted = await raceSignal(this.components.connectionManager.acceptIncomingConnection(maConn), signal)
|
|
197
198
|
|
|
198
199
|
if (!accepted) {
|
|
199
200
|
throw new ConnectionDeniedError('Connection denied')
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
await this.shouldBlockConnection('denyInboundConnection', maConn)
|
|
203
|
+
await raceSignal(this.shouldBlockConnection('denyInboundConnection', maConn), signal)
|
|
203
204
|
|
|
204
205
|
await this._performUpgrade(maConn, 'inbound', {
|
|
205
206
|
...opts,
|
|
@@ -234,7 +235,7 @@ export class Upgrader implements UpgraderInterface {
|
|
|
234
235
|
|
|
235
236
|
if (idStr != null) {
|
|
236
237
|
remotePeerId = peerIdFromString(idStr)
|
|
237
|
-
await this.shouldBlockConnection('denyOutboundConnection', remotePeerId, maConn)
|
|
238
|
+
await raceSignal(this.shouldBlockConnection('denyOutboundConnection', remotePeerId, maConn), opts.signal)
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
let direction: 'inbound' | 'outbound' = 'outbound'
|
|
@@ -387,11 +388,12 @@ export class Upgrader implements UpgraderInterface {
|
|
|
387
388
|
return
|
|
388
389
|
}
|
|
389
390
|
|
|
391
|
+
const signal = AbortSignal.timeout(this.inboundStreamProtocolNegotiationTimeout)
|
|
392
|
+
setMaxListeners(Infinity, signal)
|
|
393
|
+
|
|
390
394
|
void Promise.resolve()
|
|
391
395
|
.then(async () => {
|
|
392
396
|
const protocols = this.components.registrar.getProtocols()
|
|
393
|
-
const signal = AbortSignal.timeout(this.inboundStreamProtocolNegotiationTimeout)
|
|
394
|
-
setMaxListeners(Infinity, signal)
|
|
395
397
|
|
|
396
398
|
const { stream, protocol } = await mss.handle(muxedStream, protocols, {
|
|
397
399
|
signal,
|
|
@@ -440,6 +442,8 @@ export class Upgrader implements UpgraderInterface {
|
|
|
440
442
|
// the peer store should ensure that the peer is registered with that protocol
|
|
441
443
|
await this.components.peerStore.merge(remotePeer, {
|
|
442
444
|
protocols: [protocol]
|
|
445
|
+
}, {
|
|
446
|
+
signal
|
|
443
447
|
})
|
|
444
448
|
|
|
445
449
|
this.components.metrics?.trackProtocolStream(muxedStream, connection)
|
|
@@ -450,7 +454,10 @@ export class Upgrader implements UpgraderInterface {
|
|
|
450
454
|
connection.log.error('error handling incoming stream id %s - %e', muxedStream.id, err)
|
|
451
455
|
|
|
452
456
|
if (muxedStream.timeline.close == null) {
|
|
453
|
-
await muxedStream.close(
|
|
457
|
+
await muxedStream.close({
|
|
458
|
+
signal
|
|
459
|
+
})
|
|
460
|
+
.catch(err => muxedStream.abort(err))
|
|
454
461
|
}
|
|
455
462
|
})
|
|
456
463
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '2.8.
|
|
1
|
+
export const version = '2.8.8-5b004c0c4'
|
|
2
2
|
export const name = 'js-libp2p'
|
package/dist/typedoc-urls.json
DELETED
|
@@ -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
|
-
}
|