@libp2p/interface 0.1.2 → 0.1.3-68504939

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 (58) hide show
  1. package/dist/src/connection/index.d.ts +13 -13
  2. package/dist/src/connection/index.d.ts.map +1 -1
  3. package/dist/src/connection-encrypter/index.d.ts +2 -2
  4. package/dist/src/connection-encrypter/index.d.ts.map +1 -1
  5. package/dist/src/connection-gater/index.d.ts +12 -12
  6. package/dist/src/connection-gater/index.d.ts.map +1 -1
  7. package/dist/src/content-routing/index.d.ts +4 -4
  8. package/dist/src/content-routing/index.d.ts.map +1 -1
  9. package/dist/src/index.d.ts +13 -13
  10. package/dist/src/index.d.ts.map +1 -1
  11. package/dist/src/keychain/index.d.ts +11 -11
  12. package/dist/src/keychain/index.d.ts.map +1 -1
  13. package/dist/src/keys/index.d.ts +10 -10
  14. package/dist/src/keys/index.d.ts.map +1 -1
  15. package/dist/src/metrics/index.d.ts +16 -16
  16. package/dist/src/metrics/index.d.ts.map +1 -1
  17. package/dist/src/peer-id/index.d.ts +4 -4
  18. package/dist/src/peer-id/index.d.ts.map +1 -1
  19. package/dist/src/peer-routing/index.d.ts +2 -2
  20. package/dist/src/peer-routing/index.d.ts.map +1 -1
  21. package/dist/src/peer-store/index.d.ts +9 -9
  22. package/dist/src/peer-store/index.d.ts.map +1 -1
  23. package/dist/src/pubsub/index.d.ts +10 -10
  24. package/dist/src/pubsub/index.d.ts.map +1 -1
  25. package/dist/src/record/index.d.ts +5 -5
  26. package/dist/src/record/index.d.ts.map +1 -1
  27. package/dist/src/startable.d.ts +7 -7
  28. package/dist/src/startable.d.ts.map +1 -1
  29. package/dist/src/stream-muxer/index.d.ts +6 -6
  30. package/dist/src/stream-muxer/index.d.ts.map +1 -1
  31. package/dist/src/stream-muxer/stream.d.ts +13 -7
  32. package/dist/src/stream-muxer/stream.d.ts.map +1 -1
  33. package/dist/src/stream-muxer/stream.js +31 -19
  34. package/dist/src/stream-muxer/stream.js.map +1 -1
  35. package/dist/src/topology/index.d.ts +2 -2
  36. package/dist/src/topology/index.d.ts.map +1 -1
  37. package/dist/src/transport/index.d.ts +7 -7
  38. package/dist/src/transport/index.d.ts.map +1 -1
  39. package/package.json +8 -3
  40. package/src/connection/index.ts +13 -13
  41. package/src/connection-encrypter/index.ts +2 -2
  42. package/src/connection-gater/index.ts +12 -12
  43. package/src/content-routing/index.ts +4 -4
  44. package/src/index.ts +13 -13
  45. package/src/keychain/index.ts +11 -11
  46. package/src/keys/index.ts +10 -10
  47. package/src/metrics/index.ts +16 -16
  48. package/src/peer-id/index.ts +4 -4
  49. package/src/peer-routing/index.ts +2 -2
  50. package/src/peer-store/index.ts +9 -9
  51. package/src/pubsub/index.ts +10 -10
  52. package/src/record/index.ts +5 -5
  53. package/src/startable.ts +7 -7
  54. package/src/stream-muxer/index.ts +6 -6
  55. package/src/stream-muxer/stream.ts +52 -30
  56. package/src/topology/index.ts +2 -2
  57. package/src/transport/index.ts +7 -7
  58. package/dist/typedoc-urls.json +0 -133
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: () => Multiaddr[]
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: () => string[]
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: (peerId?: PeerId) => Connection[]
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: () => PendingDial[]
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: () => PeerId[]
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: (peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions) => Promise<Connection>
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: (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?: NewStreamOptions) => Promise<Stream>
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: (peer: PeerId | Multiaddr, options?: AbortOptions) => Promise<void>
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: (protocol: string | string[], handler: StreamHandler, options?: StreamHandlerOptions) => Promise<void>
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: (protocols: string[] | string) => Promise<void>
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: (protocol: string, topology: Topology) => Promise<string>
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: (id: string) => void
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: (peer: PeerId, options?: AbortOptions) => Promise<Uint8Array>
595
+ getPublicKey(peer: PeerId, options?: AbortOptions): Promise<Uint8Array>
596
596
 
597
597
  /**
598
598
  * A set of user defined services
@@ -47,7 +47,7 @@ export interface KeyChain {
47
47
  * const pemKey = await libp2p.keychain.exportKey('keyTest', 'password123')
48
48
  * ```
49
49
  */
50
- exportKey: (name: string, password: string) => Promise<Multibase<'m'>>
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: (name: string, pem: string, password: string) => Promise<KeyInfo>
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: (name: string, peerId: PeerId) => Promise<KeyInfo>
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: (name: string) => Promise<PeerId>
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: (name: string, type: KeyType, size?: number) => Promise<KeyInfo>
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: () => Promise<KeyInfo[]>
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: (name: string) => Promise<KeyInfo>
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: (oldName: string, newName: string) => Promise<KeyInfo>
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: (id: string) => Promise<KeyInfo>
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: (name: string) => Promise<KeyInfo>
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: (oldPass: string, newPass: string) => Promise<void>
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: (data: Uint8Array, sig: Uint8Array) => Promise<boolean>
4
- marshal: () => Uint8Array
5
- equals: (key: PublicKey) => boolean
6
- hash: () => Promise<Uint8Array>
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: (data: Uint8Array) => Promise<Uint8Array>
16
- marshal: () => Uint8Array
17
- equals: (key: PrivateKey) => boolean
18
- hash: () => Promise<Uint8Array>
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: () => Promise<string>
26
+ id(): Promise<string>
27
27
  /**
28
28
  * Exports the password protected key in the format specified.
29
29
  */
30
- export: (password: string, format?: 'pkcs-8' | string) => Promise<string>
30
+ export(password: string, format?: 'pkcs-8' | string): Promise<string>
31
31
  }
32
32
 
33
33
  export const Ed25519 = 'Ed25519'
@@ -48,28 +48,28 @@ export interface Metric {
48
48
  /**
49
49
  * Update the stored metric to the passed value
50
50
  */
51
- update: (value: number) => void
51
+ update(value: number): void
52
52
 
53
53
  /**
54
54
  * Increment the metric by the passed value or 1
55
55
  */
56
- increment: (value?: number) => void
56
+ increment(value?: number): void
57
57
 
58
58
  /**
59
59
  * Decrement the metric by the passed value or 1
60
60
  */
61
- decrement: (value?: number) => void
61
+ decrement(value?: number): void
62
62
 
63
63
  /**
64
64
  * Reset this metric to its default value
65
65
  */
66
- reset: () => void
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: () => StopTimer
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: (values: Record<string, number>) => void
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: (values: Record<string, number | unknown>) => void
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: (values: Record<string, number | unknown>) => void
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: () => void
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: (key: string) => StopTimer
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: (value?: number) => void
118
+ increment(value?: number): void
119
119
 
120
120
  /**
121
121
  * Reset this metric to its default value
122
122
  */
123
- reset: () => void
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: (values: Record<string, number | unknown>) => void
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: () => void
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: (maConn: MultiaddrConnection) => void
154
+ trackMultiaddrConnection(maConn: MultiaddrConnection): void
155
155
 
156
156
  /**
157
157
  * Track a newly opened protocol stream
158
158
  */
159
- trackProtocolStream: (stream: Stream, connection: Connection) => void
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
@@ -9,10 +9,10 @@ interface BasePeerId {
9
9
  readonly privateKey?: Uint8Array
10
10
  readonly publicKey?: Uint8Array
11
11
 
12
- toString: () => string
13
- toCID: () => CID
14
- toBytes: () => Uint8Array
15
- equals: (other: PeerId | Uint8Array | string) => boolean
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 {
@@ -34,7 +34,7 @@ export interface PeerRouting {
34
34
  * const peer = await peerRouting.findPeer(peerId, options)
35
35
  * ```
36
36
  */
37
- findPeer: (peerId: PeerId, options?: AbortOptions) => Promise<PeerInfo>
37
+ findPeer(peerId: PeerId, options?: AbortOptions): Promise<PeerInfo>
38
38
 
39
39
  /**
40
40
  * Search the network for peers that are closer to the passed key. Peer
@@ -49,5 +49,5 @@ export interface PeerRouting {
49
49
  * }
50
50
  * ```
51
51
  */
52
- getClosestPeers: (key: Uint8Array, options?: AbortOptions) => AsyncIterable<PeerInfo>
52
+ getClosestPeers(key: Uint8Array, options?: AbortOptions): AsyncIterable<PeerInfo>
53
53
  }
@@ -156,7 +156,7 @@ export interface PeerStore {
156
156
  * })
157
157
  * ```
158
158
  */
159
- forEach: (fn: (peer: Peer) => void, query?: PeerQuery) => Promise<void>
159
+ forEach(fn: (peer: Peer) => void, query?: PeerQuery): Promise<void>
160
160
 
161
161
  /**
162
162
  * Returns all peers in the peer store.
@@ -169,7 +169,7 @@ export interface PeerStore {
169
169
  * }
170
170
  * ```
171
171
  */
172
- all: (query?: PeerQuery) => Promise<Peer[]>
172
+ all(query?: PeerQuery): Promise<Peer[]>
173
173
 
174
174
  /**
175
175
  * Delete all data stored for the passed peer
@@ -187,7 +187,7 @@ export interface PeerStore {
187
187
  * // []
188
188
  * ```
189
189
  */
190
- delete: (peerId: PeerId) => Promise<void>
190
+ delete(peerId: PeerId): Promise<void>
191
191
 
192
192
  /**
193
193
  * Returns true if the passed PeerId is in the peer store
@@ -202,7 +202,7 @@ export interface PeerStore {
202
202
  * // true
203
203
  * ```
204
204
  */
205
- has: (peerId: PeerId) => Promise<boolean>
205
+ has(peerId: PeerId): Promise<boolean>
206
206
 
207
207
  /**
208
208
  * Returns all data stored for the passed PeerId
@@ -214,7 +214,7 @@ export interface PeerStore {
214
214
  * // { .. }
215
215
  * ```
216
216
  */
217
- get: (peerId: PeerId) => Promise<Peer>
217
+ get(peerId: PeerId): Promise<Peer>
218
218
 
219
219
  /**
220
220
  * Adds a peer to the peer store, overwriting any existing data
@@ -227,7 +227,7 @@ export interface PeerStore {
227
227
  * })
228
228
  * ```
229
229
  */
230
- save: (id: PeerId, data: PeerData) => Promise<Peer>
230
+ save(id: PeerId, data: PeerData): Promise<Peer>
231
231
 
232
232
  /**
233
233
  * Adds a peer to the peer store, overwriting only the passed fields
@@ -240,7 +240,7 @@ export interface PeerStore {
240
240
  * })
241
241
  * ```
242
242
  */
243
- patch: (id: PeerId, data: PeerData) => Promise<Peer>
243
+ patch(id: PeerId, data: PeerData): Promise<Peer>
244
244
 
245
245
  /**
246
246
  * Adds a peer to the peer store, deeply merging any existing data.
@@ -253,7 +253,7 @@ export interface PeerStore {
253
253
  * })
254
254
  * ```
255
255
  */
256
- merge: (id: PeerId, data: PeerData) => Promise<Peer>
256
+ merge(id: PeerId, data: PeerData): Promise<Peer>
257
257
 
258
258
  /**
259
259
  * Unmarshal and verify a signed peer record, extract the multiaddrs and
@@ -268,5 +268,5 @@ export interface PeerStore {
268
268
  * await peerStore.consumePeerRecord(buf, expectedPeer)
269
269
  * ```
270
270
  */
271
- consumePeerRecord: (buf: Uint8Array, expectedPeer?: PeerId) => Promise<boolean>
271
+ consumePeerRecord(buf: Uint8Array, expectedPeer?: PeerId): Promise<boolean>
272
272
  }
@@ -72,10 +72,10 @@ export interface PeerStreams extends EventEmitter<PeerStreamEvents> {
72
72
  inboundStream?: AsyncIterable<Uint8ArrayList>
73
73
  isWritable: boolean
74
74
 
75
- close: () => void
76
- write: (buf: Uint8Array | Uint8ArrayList) => void
77
- attachInboundStream: (stream: Stream) => AsyncIterable<Uint8ArrayList>
78
- attachOutboundStream: (stream: Stream) => Promise<Pushable<Uint8ArrayList>>
75
+ close(): void
76
+ write(buf: Uint8Array | Uint8ArrayList): void
77
+ attachInboundStream(stream: Stream): AsyncIterable<Uint8ArrayList>
78
+ attachOutboundStream(stream: Stream): Promise<Pushable<Uint8ArrayList>>
79
79
  }
80
80
 
81
81
  export interface PubSubInit {
@@ -189,7 +189,7 @@ export interface PubSub<Events extends Record<string, any> = PubSubEvents> exten
189
189
  */
190
190
  topicValidators: Map<string, TopicValidatorFn>
191
191
 
192
- getPeers: () => PeerId[]
192
+ getPeers(): PeerId[]
193
193
 
194
194
  /**
195
195
  * Gets a list of topics the node is subscribed to.
@@ -198,7 +198,7 @@ export interface PubSub<Events extends Record<string, any> = PubSubEvents> exten
198
198
  * const topics = libp2p.pubsub.getTopics()
199
199
  * ```
200
200
  */
201
- getTopics: () => string[]
201
+ getTopics(): string[]
202
202
 
203
203
  /**
204
204
  * Subscribes to a pubsub topic.
@@ -217,7 +217,7 @@ export interface PubSub<Events extends Record<string, any> = PubSubEvents> exten
217
217
  * libp2p.pubsub.subscribe(topic)
218
218
  * ```
219
219
  */
220
- subscribe: (topic: string) => void
220
+ subscribe(topic: string): void
221
221
 
222
222
  /**
223
223
  * Unsubscribes from a pubsub topic.
@@ -234,7 +234,7 @@ export interface PubSub<Events extends Record<string, any> = PubSubEvents> exten
234
234
  * libp2p.pubsub.unsubscribe(topic)
235
235
  * ```
236
236
  */
237
- unsubscribe: (topic: string) => void
237
+ unsubscribe(topic: string): void
238
238
 
239
239
  /**
240
240
  * Gets a list of the PeerIds that are subscribed to one topic.
@@ -245,7 +245,7 @@ export interface PubSub<Events extends Record<string, any> = PubSubEvents> exten
245
245
  * const peerIds = libp2p.pubsub.getSubscribers(topic)
246
246
  * ```
247
247
  */
248
- getSubscribers: (topic: string) => PeerId[]
248
+ getSubscribers(topic: string): PeerId[]
249
249
 
250
250
  /**
251
251
  * Publishes messages to the given topic.
@@ -259,7 +259,7 @@ export interface PubSub<Events extends Record<string, any> = PubSubEvents> exten
259
259
  * await libp2p.pubsub.publish(topic, data)
260
260
  * ```
261
261
  */
262
- publish: (topic: string, data: Uint8Array) => Promise<PublishResult>
262
+ publish(topic: string, data: Uint8Array): Promise<PublishResult>
263
263
  }
264
264
 
265
265
  export interface PeerStreamEvents {
@@ -16,11 +16,11 @@ export interface Record {
16
16
  /**
17
17
  * Marshal a record to be used in an envelope.
18
18
  */
19
- marshal: () => Uint8Array
19
+ marshal(): Uint8Array
20
20
  /**
21
21
  * Verifies if the other provided Record is identical to this one.
22
22
  */
23
- equals: (other: Record) => boolean
23
+ equals(other: Record): boolean
24
24
  }
25
25
 
26
26
  export interface Envelope {
@@ -29,7 +29,7 @@ export interface Envelope {
29
29
  payload: Uint8Array
30
30
  signature: Uint8Array | Uint8ArrayList
31
31
 
32
- marshal: () => Uint8Array
33
- validate: (domain: string) => Promise<boolean>
34
- equals: (other: Envelope) => boolean
32
+ marshal(): Uint8Array
33
+ validate(domain: string): Promise<boolean>
34
+ equals(other: Envelope): boolean
35
35
  }
package/src/startable.ts CHANGED
@@ -2,49 +2,49 @@
2
2
  * Implemented by components that have a lifecycle
3
3
  */
4
4
  export interface Startable {
5
- isStarted: () => boolean
5
+ isStarted(): boolean
6
6
 
7
7
  /**
8
8
  * If implemented, this method will be invoked before the start method.
9
9
  *
10
10
  * It should not assume any other components have been started.
11
11
  */
12
- beforeStart?: () => void | Promise<void>
12
+ beforeStart?(): void | Promise<void>
13
13
 
14
14
  /**
15
15
  * This method will be invoked to start the component.
16
16
  *
17
17
  * It should not assume that any other components have been started.
18
18
  */
19
- start: () => void | Promise<void>
19
+ start(): void | Promise<void>
20
20
 
21
21
  /**
22
22
  * If implemented, this method will be invoked after the start method.
23
23
  *
24
24
  * All other components will have had their start method invoked before this method is called.
25
25
  */
26
- afterStart?: () => void | Promise<void>
26
+ afterStart?(): void | Promise<void>
27
27
 
28
28
  /**
29
29
  * If implemented, this method will be invoked before the stop method.
30
30
  *
31
31
  * Any other components will still be running when this method is called.
32
32
  */
33
- beforeStop?: () => void | Promise<void>
33
+ beforeStop?(): void | Promise<void>
34
34
 
35
35
  /**
36
36
  * This method will be invoked to stop the component.
37
37
  *
38
38
  * It should not assume any other components are running when it is called.
39
39
  */
40
- stop: () => void | Promise<void>
40
+ stop(): void | Promise<void>
41
41
 
42
42
  /**
43
43
  * If implemented, this method will be invoked after the stop method.
44
44
  *
45
45
  * All other components will have had their stop method invoked before this method is called.
46
46
  */
47
- afterStop?: () => void | Promise<void>
47
+ afterStop?(): void | Promise<void>
48
48
  }
49
49
 
50
50
  export function isStartable (obj: any): obj is Startable {
@@ -12,7 +12,7 @@ export interface StreamMuxerFactory {
12
12
  /**
13
13
  * Creates a new stream muxer to be used with a new connection
14
14
  */
15
- createStreamMuxer: (init?: StreamMuxerInit) => StreamMuxer
15
+ createStreamMuxer(init?: StreamMuxerInit): StreamMuxer
16
16
  }
17
17
 
18
18
  /**
@@ -32,29 +32,29 @@ export interface StreamMuxer extends Duplex<AsyncGenerator<Uint8Array>, Source<U
32
32
  * Initiate a new stream with the given name. If no name is
33
33
  * provided, the id of the stream will be used.
34
34
  */
35
- newStream: (name?: string) => Stream | Promise<Stream>
35
+ newStream(name?: string): Stream | Promise<Stream>
36
36
 
37
37
  /**
38
38
  * Close or abort all tracked streams and stop the muxer
39
39
  */
40
- close: (options?: AbortOptions) => Promise<void>
40
+ close(options?: AbortOptions): Promise<void>
41
41
 
42
42
  /**
43
43
  * Close or abort all tracked streams and stop the muxer
44
44
  */
45
- abort: (err: Error) => void
45
+ abort(err: Error): void
46
46
  }
47
47
 
48
48
  export interface StreamMuxerInit {
49
49
  /**
50
50
  * A callback function invoked every time an incoming stream is opened
51
51
  */
52
- onIncomingStream?: (stream: Stream) => void
52
+ onIncomingStream?(stream: Stream): void
53
53
 
54
54
  /**
55
55
  * A callback function invoke every time a stream ends
56
56
  */
57
- onStreamEnd?: (stream: Stream) => void
57
+ onStreamEnd?(stream: Stream): void
58
58
 
59
59
  /**
60
60
  * Outbound stream muxers are opened by the local node, inbound stream muxers are opened by the remote