@libp2p/interface 0.1.2 → 0.1.3
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/src/connection/index.d.ts +13 -13
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection-encrypter/index.d.ts +2 -2
- package/dist/src/connection-encrypter/index.d.ts.map +1 -1
- package/dist/src/connection-gater/index.d.ts +12 -12
- package/dist/src/connection-gater/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.d.ts +4 -4
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/index.d.ts +13 -13
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/keychain/index.d.ts +11 -11
- package/dist/src/keychain/index.d.ts.map +1 -1
- package/dist/src/keys/index.d.ts +10 -10
- package/dist/src/keys/index.d.ts.map +1 -1
- package/dist/src/metrics/index.d.ts +16 -16
- package/dist/src/metrics/index.d.ts.map +1 -1
- package/dist/src/peer-id/index.d.ts +4 -4
- package/dist/src/peer-id/index.d.ts.map +1 -1
- package/dist/src/peer-routing/index.d.ts +2 -2
- package/dist/src/peer-routing/index.d.ts.map +1 -1
- package/dist/src/peer-store/index.d.ts +9 -9
- package/dist/src/peer-store/index.d.ts.map +1 -1
- package/dist/src/pubsub/index.d.ts +10 -10
- package/dist/src/pubsub/index.d.ts.map +1 -1
- package/dist/src/record/index.d.ts +5 -5
- package/dist/src/record/index.d.ts.map +1 -1
- package/dist/src/startable.d.ts +7 -7
- package/dist/src/startable.d.ts.map +1 -1
- package/dist/src/stream-muxer/index.d.ts +6 -6
- package/dist/src/stream-muxer/index.d.ts.map +1 -1
- package/dist/src/stream-muxer/stream.d.ts +13 -7
- package/dist/src/stream-muxer/stream.d.ts.map +1 -1
- package/dist/src/stream-muxer/stream.js +31 -19
- package/dist/src/stream-muxer/stream.js.map +1 -1
- package/dist/src/topology/index.d.ts +2 -2
- package/dist/src/topology/index.d.ts.map +1 -1
- package/dist/src/transport/index.d.ts +7 -7
- package/dist/src/transport/index.d.ts.map +1 -1
- package/dist/typedoc-urls.json +133 -8
- package/package.json +8 -3
- package/src/connection/index.ts +13 -13
- package/src/connection-encrypter/index.ts +2 -2
- package/src/connection-gater/index.ts +12 -12
- package/src/content-routing/index.ts +4 -4
- package/src/index.ts +13 -13
- package/src/keychain/index.ts +11 -11
- package/src/keys/index.ts +10 -10
- package/src/metrics/index.ts +16 -16
- package/src/peer-id/index.ts +4 -4
- package/src/peer-routing/index.ts +2 -2
- package/src/peer-store/index.ts +9 -9
- package/src/pubsub/index.ts +10 -10
- package/src/record/index.ts +5 -5
- package/src/startable.ts +7 -7
- package/src/stream-muxer/index.ts +6 -6
- package/src/stream-muxer/stream.ts +52 -30
- package/src/topology/index.ts +2 -2
- package/src/transport/index.ts +7 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/interface",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "The interface implemented by a libp2p node",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/interface#readme",
|
|
@@ -140,6 +140,7 @@
|
|
|
140
140
|
"eslintConfig": {
|
|
141
141
|
"extends": "ipfs",
|
|
142
142
|
"parserOptions": {
|
|
143
|
+
"project": true,
|
|
143
144
|
"sourceType": "module"
|
|
144
145
|
}
|
|
145
146
|
},
|
|
@@ -163,12 +164,16 @@
|
|
|
163
164
|
"it-stream-types": "^2.0.1",
|
|
164
165
|
"multiformats": "^12.0.1",
|
|
165
166
|
"p-defer": "^4.0.0",
|
|
167
|
+
"race-signal": "^1.0.0",
|
|
166
168
|
"uint8arraylist": "^2.4.3"
|
|
167
169
|
},
|
|
168
170
|
"devDependencies": {
|
|
169
171
|
"@types/sinon": "^10.0.15",
|
|
170
|
-
"aegir": "^
|
|
171
|
-
"
|
|
172
|
+
"aegir": "^41.0.2",
|
|
173
|
+
"delay": "^6.0.0",
|
|
174
|
+
"it-all": "^3.0.3",
|
|
175
|
+
"it-drain": "^3.0.3",
|
|
176
|
+
"sinon": "^16.0.0",
|
|
172
177
|
"sinon-ts": "^1.0.0"
|
|
173
178
|
}
|
|
174
179
|
}
|
package/src/connection/index.ts
CHANGED
|
@@ -101,7 +101,7 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
101
101
|
*
|
|
102
102
|
* The sink and the source will return normally.
|
|
103
103
|
*/
|
|
104
|
-
close
|
|
104
|
+
close(options?: AbortOptions): Promise<void>
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Closes the stream for **reading**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed.
|
|
@@ -110,14 +110,14 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
110
110
|
*
|
|
111
111
|
* The source will return normally, the sink will continue to consume.
|
|
112
112
|
*/
|
|
113
|
-
closeRead
|
|
113
|
+
closeRead(options?: AbortOptions): Promise<void>
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* Closes the stream for **writing**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed.
|
|
117
117
|
*
|
|
118
118
|
* The source will return normally, the sink will continue to consume.
|
|
119
119
|
*/
|
|
120
|
-
closeWrite
|
|
120
|
+
closeWrite(options?: AbortOptions): Promise<void>
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* Closes the stream for **reading** *and* **writing**. This should be called when a *local error* has occurred.
|
|
@@ -128,7 +128,7 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
128
128
|
*
|
|
129
129
|
* The sink will return and the source will throw if an error is passed or return normally if not.
|
|
130
130
|
*/
|
|
131
|
-
abort
|
|
131
|
+
abort(err: Error): void
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
134
|
* Unique identifier for a stream. Identifiers are not unique across muxers.
|
|
@@ -146,7 +146,7 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
146
146
|
timeline: StreamTimeline
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
149
|
+
* The protocol negotiated for this stream
|
|
150
150
|
*/
|
|
151
151
|
protocol?: string
|
|
152
152
|
|
|
@@ -231,12 +231,12 @@ export interface Connection {
|
|
|
231
231
|
timeline: ConnectionTimeline
|
|
232
232
|
|
|
233
233
|
/**
|
|
234
|
-
*
|
|
234
|
+
* The multiplexer negotiated for this connection
|
|
235
235
|
*/
|
|
236
236
|
multiplexer?: string
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
|
-
*
|
|
239
|
+
* The encryption protocol negotiated for this connection
|
|
240
240
|
*/
|
|
241
241
|
encryption?: string
|
|
242
242
|
|
|
@@ -256,18 +256,18 @@ export interface Connection {
|
|
|
256
256
|
/**
|
|
257
257
|
* Create a new stream on this connection and negotiate one of the passed protocols
|
|
258
258
|
*/
|
|
259
|
-
newStream
|
|
259
|
+
newStream(protocols: string | string[], options?: NewStreamOptions): Promise<Stream>
|
|
260
260
|
|
|
261
261
|
/**
|
|
262
262
|
* Gracefully close the connection. All queued data will be written to the
|
|
263
263
|
* underlying transport.
|
|
264
264
|
*/
|
|
265
|
-
close
|
|
265
|
+
close(options?: AbortOptions): Promise<void>
|
|
266
266
|
|
|
267
267
|
/**
|
|
268
268
|
* Immediately close the connection, any queued data will be discarded
|
|
269
269
|
*/
|
|
270
|
-
abort
|
|
270
|
+
abort(err: Error): void
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
export const symbol = Symbol.for('@libp2p/connection')
|
|
@@ -282,7 +282,7 @@ export interface ConnectionProtector {
|
|
|
282
282
|
* between its two peers from the PSK the Protector instance was
|
|
283
283
|
* created with.
|
|
284
284
|
*/
|
|
285
|
-
protect
|
|
285
|
+
protect(connection: MultiaddrConnection): Promise<MultiaddrConnection>
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
export interface MultiaddrConnectionTimeline {
|
|
@@ -313,12 +313,12 @@ export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array>,
|
|
|
313
313
|
* Gracefully close the connection. All queued data will be written to the
|
|
314
314
|
* underlying transport.
|
|
315
315
|
*/
|
|
316
|
-
close
|
|
316
|
+
close(options?: AbortOptions): Promise<void>
|
|
317
317
|
|
|
318
318
|
/**
|
|
319
319
|
* Immediately close the connection, any queued data will be discarded
|
|
320
320
|
*/
|
|
321
|
-
abort
|
|
321
|
+
abort(err: Error): void
|
|
322
322
|
|
|
323
323
|
/**
|
|
324
324
|
* The address of the remote end of the connection
|
|
@@ -13,14 +13,14 @@ export interface ConnectionEncrypter<Extension = unknown> {
|
|
|
13
13
|
* pass it for extra verification, otherwise it will be determined during
|
|
14
14
|
* the handshake.
|
|
15
15
|
*/
|
|
16
|
-
secureOutbound
|
|
16
|
+
secureOutbound(localPeer: PeerId, connection: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>, remotePeer?: PeerId): Promise<SecuredConnection<Extension>>
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Decrypt incoming data. If the remote PeerId is known,
|
|
20
20
|
* pass it for extra verification, otherwise it will be determined during
|
|
21
21
|
* the handshake
|
|
22
22
|
*/
|
|
23
|
-
secureInbound
|
|
23
|
+
secureInbound(localPeer: PeerId, connection: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>, remotePeer?: PeerId): Promise<SecuredConnection<Extension>>
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface SecuredConnection<Extension = unknown> {
|
|
@@ -12,7 +12,7 @@ export interface ConnectionGater {
|
|
|
12
12
|
*
|
|
13
13
|
* Return true to prevent dialing the passed peer.
|
|
14
14
|
*/
|
|
15
|
-
denyDialPeer
|
|
15
|
+
denyDialPeer?(peerId: PeerId): Promise<boolean>
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* denyDialMultiaddr tests whether we're permitted to dial the specified
|
|
@@ -23,7 +23,7 @@ export interface ConnectionGater {
|
|
|
23
23
|
*
|
|
24
24
|
* Return true to prevent dialing the passed peer on the passed multiaddr.
|
|
25
25
|
*/
|
|
26
|
-
denyDialMultiaddr
|
|
26
|
+
denyDialMultiaddr?(multiaddr: Multiaddr): Promise<boolean>
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* denyInboundConnection tests whether an incipient inbound connection is allowed.
|
|
@@ -33,7 +33,7 @@ export interface ConnectionGater {
|
|
|
33
33
|
*
|
|
34
34
|
* Return true to deny the incoming passed connection.
|
|
35
35
|
*/
|
|
36
|
-
denyInboundConnection
|
|
36
|
+
denyInboundConnection?(maConn: MultiaddrConnection): Promise<boolean>
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* denyOutboundConnection tests whether an incipient outbound connection is allowed.
|
|
@@ -43,7 +43,7 @@ export interface ConnectionGater {
|
|
|
43
43
|
*
|
|
44
44
|
* Return true to deny the incoming passed connection.
|
|
45
45
|
*/
|
|
46
|
-
denyOutboundConnection
|
|
46
|
+
denyOutboundConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* denyInboundEncryptedConnection tests whether a given connection, now encrypted,
|
|
@@ -55,7 +55,7 @@ export interface ConnectionGater {
|
|
|
55
55
|
*
|
|
56
56
|
* Return true to deny the passed secured connection.
|
|
57
57
|
*/
|
|
58
|
-
denyInboundEncryptedConnection
|
|
58
|
+
denyInboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* denyOutboundEncryptedConnection tests whether a given connection, now encrypted,
|
|
@@ -67,7 +67,7 @@ export interface ConnectionGater {
|
|
|
67
67
|
*
|
|
68
68
|
* Return true to deny the passed secured connection.
|
|
69
69
|
*/
|
|
70
|
-
denyOutboundEncryptedConnection
|
|
70
|
+
denyOutboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* denyInboundUpgradedConnection tests whether a fully capable connection is allowed.
|
|
@@ -77,7 +77,7 @@ export interface ConnectionGater {
|
|
|
77
77
|
*
|
|
78
78
|
* Return true to deny the passed upgraded connection.
|
|
79
79
|
*/
|
|
80
|
-
denyInboundUpgradedConnection
|
|
80
|
+
denyInboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* denyOutboundUpgradedConnection tests whether a fully capable connection is allowed.
|
|
@@ -87,7 +87,7 @@ export interface ConnectionGater {
|
|
|
87
87
|
*
|
|
88
88
|
* Return true to deny the passed upgraded connection.
|
|
89
89
|
*/
|
|
90
|
-
denyOutboundUpgradedConnection
|
|
90
|
+
denyOutboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* denyInboundRelayReservation tests whether a remote peer is allowed make a
|
|
@@ -95,7 +95,7 @@ export interface ConnectionGater {
|
|
|
95
95
|
*
|
|
96
96
|
* Return true to deny the relay reservation.
|
|
97
97
|
*/
|
|
98
|
-
denyInboundRelayReservation
|
|
98
|
+
denyInboundRelayReservation?(source: PeerId): Promise<boolean>
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* denyOutboundRelayedConnection tests whether a remote peer is allowed to open a relayed
|
|
@@ -106,7 +106,7 @@ export interface ConnectionGater {
|
|
|
106
106
|
*
|
|
107
107
|
* Return true to deny the relayed connection.
|
|
108
108
|
*/
|
|
109
|
-
denyOutboundRelayedConnection
|
|
109
|
+
denyOutboundRelayedConnection?(source: PeerId, destination: PeerId): Promise<boolean>
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* denyInboundRelayedConnection tests whether a remote peer is allowed to open a relayed
|
|
@@ -117,12 +117,12 @@ export interface ConnectionGater {
|
|
|
117
117
|
*
|
|
118
118
|
* Return true to deny the relayed connection.
|
|
119
119
|
*/
|
|
120
|
-
denyInboundRelayedConnection
|
|
120
|
+
denyInboundRelayedConnection?(relay: PeerId, remotePeer: PeerId): Promise<boolean>
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* Used by the address book to filter passed addresses.
|
|
124
124
|
*
|
|
125
125
|
* Return true to allow storing the passed multiaddr for the passed peer.
|
|
126
126
|
*/
|
|
127
|
-
filterMultiaddrForPeer
|
|
127
|
+
filterMultiaddrForPeer?(peer: PeerId, multiaddr: Multiaddr): Promise<boolean>
|
|
128
128
|
}
|
|
@@ -35,7 +35,7 @@ export interface ContentRouting {
|
|
|
35
35
|
* await contentRouting.provide(cid)
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
provide
|
|
38
|
+
provide(cid: CID, options?: AbortOptions): Promise<void>
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Find the providers of the passed CID.
|
|
@@ -49,7 +49,7 @@ export interface ContentRouting {
|
|
|
49
49
|
* }
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
|
-
findProviders
|
|
52
|
+
findProviders(cid: CID, options?: AbortOptions): AsyncIterable<PeerInfo>
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Puts a value corresponding to the passed key in a way that can later be
|
|
@@ -65,7 +65,7 @@ export interface ContentRouting {
|
|
|
65
65
|
* await contentRouting.put(key, value)
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
|
-
put
|
|
68
|
+
put(key: Uint8Array, value: Uint8Array, options?: AbortOptions): Promise<void>
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Retrieves a value from the network corresponding to the passed key.
|
|
@@ -79,5 +79,5 @@ export interface ContentRouting {
|
|
|
79
79
|
* const value = await contentRouting.get(key)
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
|
-
get
|
|
82
|
+
get(key: Uint8Array, options?: AbortOptions): Promise<Uint8Array>
|
|
83
83
|
}
|
package/src/index.ts
CHANGED
|
@@ -418,7 +418,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
418
418
|
* // [ <Multiaddr 047f00000106f9ba - /ip4/127.0.0.1/tcp/63930> ]
|
|
419
419
|
* ```
|
|
420
420
|
*/
|
|
421
|
-
getMultiaddrs
|
|
421
|
+
getMultiaddrs(): Multiaddr[]
|
|
422
422
|
|
|
423
423
|
/**
|
|
424
424
|
* Returns a list of supported protocols
|
|
@@ -430,7 +430,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
430
430
|
* // [ '/ipfs/ping/1.0.0', '/ipfs/id/1.0.0' ]
|
|
431
431
|
* ```
|
|
432
432
|
*/
|
|
433
|
-
getProtocols
|
|
433
|
+
getProtocols(): string[]
|
|
434
434
|
|
|
435
435
|
/**
|
|
436
436
|
* Return a list of all connections this node has open, optionally filtering
|
|
@@ -445,7 +445,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
445
445
|
* }
|
|
446
446
|
* ```
|
|
447
447
|
*/
|
|
448
|
-
getConnections
|
|
448
|
+
getConnections(peerId?: PeerId): Connection[]
|
|
449
449
|
|
|
450
450
|
/**
|
|
451
451
|
* Return the list of dials currently in progress or queued to start
|
|
@@ -458,12 +458,12 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
458
458
|
* }
|
|
459
459
|
* ```
|
|
460
460
|
*/
|
|
461
|
-
getDialQueue
|
|
461
|
+
getDialQueue(): PendingDial[]
|
|
462
462
|
|
|
463
463
|
/**
|
|
464
464
|
* Return a list of all peers we currently have a connection open to
|
|
465
465
|
*/
|
|
466
|
-
getPeers
|
|
466
|
+
getPeers(): PeerId[]
|
|
467
467
|
|
|
468
468
|
/**
|
|
469
469
|
* Dials to the provided peer. If successful, the known metadata of the
|
|
@@ -485,7 +485,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
485
485
|
* await conn.close()
|
|
486
486
|
* ```
|
|
487
487
|
*/
|
|
488
|
-
dial
|
|
488
|
+
dial(peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<Connection>
|
|
489
489
|
|
|
490
490
|
/**
|
|
491
491
|
* Dials to the provided peer and tries to handshake with the given protocols in order.
|
|
@@ -503,7 +503,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
503
503
|
* pipe([1, 2, 3], stream, consume)
|
|
504
504
|
* ```
|
|
505
505
|
*/
|
|
506
|
-
dialProtocol
|
|
506
|
+
dialProtocol(peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?: NewStreamOptions): Promise<Stream>
|
|
507
507
|
|
|
508
508
|
/**
|
|
509
509
|
* Attempts to gracefully close an open connection to the given peer. If the
|
|
@@ -518,7 +518,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
518
518
|
* await libp2p.hangUp(remotePeerId)
|
|
519
519
|
* ```
|
|
520
520
|
*/
|
|
521
|
-
hangUp
|
|
521
|
+
hangUp(peer: PeerId | Multiaddr, options?: AbortOptions): Promise<void>
|
|
522
522
|
|
|
523
523
|
/**
|
|
524
524
|
* Sets up [multistream-select routing](https://github.com/multiformats/multistream-select) of protocols to their application handlers. Whenever a stream is opened on one of the provided protocols, the handler will be called. `handle` must be called in order to register a handler and support for a given protocol. This also informs other peers of the protocols you support.
|
|
@@ -540,7 +540,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
540
540
|
* })
|
|
541
541
|
* ```
|
|
542
542
|
*/
|
|
543
|
-
handle
|
|
543
|
+
handle(protocol: string | string[], handler: StreamHandler, options?: StreamHandlerOptions): Promise<void>
|
|
544
544
|
|
|
545
545
|
/**
|
|
546
546
|
* Removes the handler for each protocol. The protocol
|
|
@@ -552,7 +552,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
552
552
|
* libp2p.unhandle(['/echo/1.0.0'])
|
|
553
553
|
* ```
|
|
554
554
|
*/
|
|
555
|
-
unhandle
|
|
555
|
+
unhandle(protocols: string[] | string): Promise<void>
|
|
556
556
|
|
|
557
557
|
/**
|
|
558
558
|
* Register a topology to be informed when peers are encountered that
|
|
@@ -571,7 +571,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
571
571
|
* })
|
|
572
572
|
* ```
|
|
573
573
|
*/
|
|
574
|
-
register
|
|
574
|
+
register(protocol: string, topology: Topology): Promise<string>
|
|
575
575
|
|
|
576
576
|
/**
|
|
577
577
|
* Unregister topology to no longer be informed when peers connect or
|
|
@@ -585,14 +585,14 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
585
585
|
* libp2p.unregister(id)
|
|
586
586
|
* ```
|
|
587
587
|
*/
|
|
588
|
-
unregister
|
|
588
|
+
unregister(id: string): void
|
|
589
589
|
|
|
590
590
|
/**
|
|
591
591
|
* Returns the public key for the passed PeerId. If the PeerId is of the 'RSA' type
|
|
592
592
|
* this may mean searching the DHT if the key is not present in the KeyStore.
|
|
593
593
|
* A set of user defined services
|
|
594
594
|
*/
|
|
595
|
-
getPublicKey
|
|
595
|
+
getPublicKey(peer: PeerId, options?: AbortOptions): Promise<Uint8Array>
|
|
596
596
|
|
|
597
597
|
/**
|
|
598
598
|
* A set of user defined services
|
package/src/keychain/index.ts
CHANGED
|
@@ -47,7 +47,7 @@ export interface KeyChain {
|
|
|
47
47
|
* const pemKey = await libp2p.keychain.exportKey('keyTest', 'password123')
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
exportKey
|
|
50
|
+
exportKey(name: string, password: string): Promise<Multibase<'m'>>
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Import a new key from a PEM encoded PKCS #8 string.
|
|
@@ -60,7 +60,7 @@ export interface KeyChain {
|
|
|
60
60
|
* const keyInfo = await libp2p.keychain.importKey('keyTestImport', pemKey, 'password123')
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
|
-
importKey
|
|
63
|
+
importKey(name: string, pem: string, password: string): Promise<KeyInfo>
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Import a new key from a PeerId with a private key component
|
|
@@ -71,7 +71,7 @@ export interface KeyChain {
|
|
|
71
71
|
* const keyInfo = await libp2p.keychain.importPeer('keyTestImport', peerIdFromString('12D3Foo...'))
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
|
-
importPeer
|
|
74
|
+
importPeer(name: string, peerId: PeerId): Promise<KeyInfo>
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Export an existing key as a PeerId
|
|
@@ -82,7 +82,7 @@ export interface KeyChain {
|
|
|
82
82
|
* const peerId = await libp2p.keychain.exportPeerId('key-name')
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
|
-
exportPeerId
|
|
85
|
+
exportPeerId(name: string): Promise<PeerId>
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* Create a key in the keychain.
|
|
@@ -93,7 +93,7 @@ export interface KeyChain {
|
|
|
93
93
|
* const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
|
|
94
94
|
* ```
|
|
95
95
|
*/
|
|
96
|
-
createKey
|
|
96
|
+
createKey(name: string, type: KeyType, size?: number): Promise<KeyInfo>
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* List all the keys.
|
|
@@ -104,7 +104,7 @@ export interface KeyChain {
|
|
|
104
104
|
* const keyInfos = await libp2p.keychain.listKeys()
|
|
105
105
|
* ```
|
|
106
106
|
*/
|
|
107
|
-
listKeys
|
|
107
|
+
listKeys(): Promise<KeyInfo[]>
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Removes a key from the keychain.
|
|
@@ -116,7 +116,7 @@ export interface KeyChain {
|
|
|
116
116
|
* const keyInfo = await libp2p.keychain.removeKey('keyTest')
|
|
117
117
|
* ```
|
|
118
118
|
*/
|
|
119
|
-
removeKey
|
|
119
|
+
removeKey(name: string): Promise<KeyInfo>
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* Rename a key in the keychain.
|
|
@@ -128,7 +128,7 @@ export interface KeyChain {
|
|
|
128
128
|
* const keyInfo = await libp2p.keychain.renameKey('keyTest', 'keyNewNtest')
|
|
129
129
|
* ```
|
|
130
130
|
*/
|
|
131
|
-
renameKey
|
|
131
|
+
renameKey(oldName: string, newName: string): Promise<KeyInfo>
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
134
|
* Find a key by it's id.
|
|
@@ -140,7 +140,7 @@ export interface KeyChain {
|
|
|
140
140
|
* const keyInfo2 = await libp2p.keychain.findKeyById(keyInfo.id)
|
|
141
141
|
* ```
|
|
142
142
|
*/
|
|
143
|
-
findKeyById
|
|
143
|
+
findKeyById(id: string): Promise<KeyInfo>
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* Find a key by it's name.
|
|
@@ -152,7 +152,7 @@ export interface KeyChain {
|
|
|
152
152
|
* const keyInfo2 = await libp2p.keychain.findKeyByName('keyTest')
|
|
153
153
|
* ```
|
|
154
154
|
*/
|
|
155
|
-
findKeyByName
|
|
155
|
+
findKeyByName(name: string): Promise<KeyInfo>
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* Rotate keychain password and re-encrypt all associated keys
|
|
@@ -163,5 +163,5 @@ export interface KeyChain {
|
|
|
163
163
|
* await libp2p.keychain.rotateKeychainPass('oldPassword', 'newPassword')
|
|
164
164
|
* ```
|
|
165
165
|
*/
|
|
166
|
-
rotateKeychainPass
|
|
166
|
+
rotateKeychainPass(oldPass: string, newPass: string): Promise<void>
|
|
167
167
|
}
|
package/src/keys/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface PublicKey {
|
|
2
2
|
readonly bytes: Uint8Array
|
|
3
|
-
verify
|
|
4
|
-
marshal
|
|
5
|
-
equals
|
|
6
|
-
hash
|
|
3
|
+
verify(data: Uint8Array, sig: Uint8Array): Promise<boolean>
|
|
4
|
+
marshal(): Uint8Array
|
|
5
|
+
equals(key: PublicKey): boolean
|
|
6
|
+
hash(): Promise<Uint8Array>
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -12,10 +12,10 @@ export interface PublicKey {
|
|
|
12
12
|
export interface PrivateKey {
|
|
13
13
|
readonly public: PublicKey
|
|
14
14
|
readonly bytes: Uint8Array
|
|
15
|
-
sign
|
|
16
|
-
marshal
|
|
17
|
-
equals
|
|
18
|
-
hash
|
|
15
|
+
sign(data: Uint8Array): Promise<Uint8Array>
|
|
16
|
+
marshal(): Uint8Array
|
|
17
|
+
equals(key: PrivateKey): boolean
|
|
18
|
+
hash(): Promise<Uint8Array>
|
|
19
19
|
/**
|
|
20
20
|
* Gets the ID of the key.
|
|
21
21
|
*
|
|
@@ -23,11 +23,11 @@ export interface PrivateKey {
|
|
|
23
23
|
* The public key is a protobuf encoding containing a type and the DER encoding
|
|
24
24
|
* of the PKCS SubjectPublicKeyInfo.
|
|
25
25
|
*/
|
|
26
|
-
id
|
|
26
|
+
id(): Promise<string>
|
|
27
27
|
/**
|
|
28
28
|
* Exports the password protected key in the format specified.
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export(password: string, format?: 'pkcs-8' | string): Promise<string>
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export const Ed25519 = 'Ed25519'
|
package/src/metrics/index.ts
CHANGED
|
@@ -48,28 +48,28 @@ export interface Metric {
|
|
|
48
48
|
/**
|
|
49
49
|
* Update the stored metric to the passed value
|
|
50
50
|
*/
|
|
51
|
-
update
|
|
51
|
+
update(value: number): void
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Increment the metric by the passed value or 1
|
|
55
55
|
*/
|
|
56
|
-
increment
|
|
56
|
+
increment(value?: number): void
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* Decrement the metric by the passed value or 1
|
|
60
60
|
*/
|
|
61
|
-
decrement
|
|
61
|
+
decrement(value?: number): void
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Reset this metric to its default value
|
|
65
65
|
*/
|
|
66
|
-
reset
|
|
66
|
+
reset(): void
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Start a timed metric, call the returned function to
|
|
70
70
|
* stop the timer
|
|
71
71
|
*/
|
|
72
|
-
timer
|
|
72
|
+
timer(): StopTimer
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
@@ -80,31 +80,31 @@ export interface MetricGroup {
|
|
|
80
80
|
/**
|
|
81
81
|
* Update the stored metric group to the passed value
|
|
82
82
|
*/
|
|
83
|
-
update
|
|
83
|
+
update(values: Record<string, number>): void
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* Increment the metric group keys by the passed number or
|
|
87
87
|
* any non-numeric value to increment by 1
|
|
88
88
|
*/
|
|
89
|
-
increment
|
|
89
|
+
increment(values: Record<string, number | unknown>): void
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Decrement the metric group keys by the passed number or
|
|
93
93
|
* any non-numeric value to decrement by 1
|
|
94
94
|
*/
|
|
95
|
-
decrement
|
|
95
|
+
decrement(values: Record<string, number | unknown>): void
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* Reset the passed key in this metric group to its default value
|
|
99
99
|
* or all keys if no key is passed
|
|
100
100
|
*/
|
|
101
|
-
reset
|
|
101
|
+
reset(): void
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Start a timed metric for the named key in the group, call
|
|
105
105
|
* the returned function to stop the timer
|
|
106
106
|
*/
|
|
107
|
-
timer
|
|
107
|
+
timer(key: string): StopTimer
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/**
|
|
@@ -115,12 +115,12 @@ export interface Counter {
|
|
|
115
115
|
/**
|
|
116
116
|
* Increment the metric by the passed value or 1
|
|
117
117
|
*/
|
|
118
|
-
increment
|
|
118
|
+
increment(value?: number): void
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* Reset this metric to its default value
|
|
122
122
|
*/
|
|
123
|
-
reset
|
|
123
|
+
reset(): void
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
@@ -133,13 +133,13 @@ export interface CounterGroup {
|
|
|
133
133
|
* Increment the metric group keys by the passed number or
|
|
134
134
|
* any non-numeric value to increment by 1
|
|
135
135
|
*/
|
|
136
|
-
increment
|
|
136
|
+
increment(values: Record<string, number | unknown>): void
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
139
|
* Reset the passed key in this metric group to its default value
|
|
140
140
|
* or all keys if no key is passed
|
|
141
141
|
*/
|
|
142
|
-
reset
|
|
142
|
+
reset(): void
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
/**
|
|
@@ -151,12 +151,12 @@ export interface Metrics {
|
|
|
151
151
|
/**
|
|
152
152
|
* Track a newly opened multiaddr connection
|
|
153
153
|
*/
|
|
154
|
-
trackMultiaddrConnection
|
|
154
|
+
trackMultiaddrConnection(maConn: MultiaddrConnection): void
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* Track a newly opened protocol stream
|
|
158
158
|
*/
|
|
159
|
-
trackProtocolStream
|
|
159
|
+
trackProtocolStream(stream: Stream, connection: Connection): void
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
* Register an arbitrary metric. Call this to set help/labels for metrics
|
package/src/peer-id/index.ts
CHANGED
|
@@ -9,10 +9,10 @@ interface BasePeerId {
|
|
|
9
9
|
readonly privateKey?: Uint8Array
|
|
10
10
|
readonly publicKey?: Uint8Array
|
|
11
11
|
|
|
12
|
-
toString
|
|
13
|
-
toCID
|
|
14
|
-
toBytes
|
|
15
|
-
equals
|
|
12
|
+
toString(): string
|
|
13
|
+
toCID(): CID
|
|
14
|
+
toBytes(): Uint8Array
|
|
15
|
+
equals(other: PeerId | Uint8Array | string): boolean
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface RSAPeerId extends BasePeerId {
|