libp2p 0.44.0 → 0.45.0

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 (188) hide show
  1. package/dist/index.min.js +30 -30
  2. package/dist/src/address-manager/index.d.ts +8 -4
  3. package/dist/src/address-manager/index.d.ts.map +1 -1
  4. package/dist/src/address-manager/index.js +37 -6
  5. package/dist/src/address-manager/index.js.map +1 -1
  6. package/dist/src/address-manager/utils.d.ts +2 -0
  7. package/dist/src/address-manager/utils.d.ts.map +1 -0
  8. package/dist/src/address-manager/utils.js +12 -0
  9. package/dist/src/address-manager/utils.js.map +1 -0
  10. package/dist/src/autonat/constants.d.ts +16 -2
  11. package/dist/src/autonat/constants.d.ts.map +1 -1
  12. package/dist/src/autonat/constants.js +16 -2
  13. package/dist/src/autonat/constants.js.map +1 -1
  14. package/dist/src/autonat/index.d.ts +12 -33
  15. package/dist/src/autonat/index.d.ts.map +1 -1
  16. package/dist/src/autonat/index.js +36 -30
  17. package/dist/src/autonat/index.js.map +1 -1
  18. package/dist/src/circuit-relay/server/advert-service.d.ts.map +1 -1
  19. package/dist/src/circuit-relay/server/advert-service.js +2 -2
  20. package/dist/src/circuit-relay/server/advert-service.js.map +1 -1
  21. package/dist/src/circuit-relay/server/index.d.ts.map +1 -1
  22. package/dist/src/circuit-relay/server/index.js +10 -3
  23. package/dist/src/circuit-relay/server/index.js.map +1 -1
  24. package/dist/src/circuit-relay/transport/discovery.d.ts.map +1 -1
  25. package/dist/src/circuit-relay/transport/discovery.js +4 -2
  26. package/dist/src/circuit-relay/transport/discovery.js.map +1 -1
  27. package/dist/src/circuit-relay/transport/index.d.ts +3 -0
  28. package/dist/src/circuit-relay/transport/index.d.ts.map +1 -1
  29. package/dist/src/circuit-relay/transport/index.js +6 -4
  30. package/dist/src/circuit-relay/transport/index.js.map +1 -1
  31. package/dist/src/circuit-relay/transport/listener.d.ts.map +1 -1
  32. package/dist/src/circuit-relay/transport/listener.js +30 -26
  33. package/dist/src/circuit-relay/transport/listener.js.map +1 -1
  34. package/dist/src/circuit-relay/transport/reservation-store.d.ts +5 -4
  35. package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +1 -1
  36. package/dist/src/circuit-relay/transport/reservation-store.js +37 -30
  37. package/dist/src/circuit-relay/transport/reservation-store.js.map +1 -1
  38. package/dist/src/components.d.ts +6 -63
  39. package/dist/src/components.d.ts.map +1 -1
  40. package/dist/src/components.js +60 -164
  41. package/dist/src/components.js.map +1 -1
  42. package/dist/src/config/connection-gater.browser.d.ts +8 -0
  43. package/dist/src/config/connection-gater.browser.d.ts.map +1 -0
  44. package/dist/src/config/connection-gater.browser.js +27 -0
  45. package/dist/src/config/connection-gater.browser.js.map +1 -0
  46. package/dist/src/config/connection-gater.d.ts +6 -0
  47. package/dist/src/config/connection-gater.d.ts.map +1 -0
  48. package/dist/src/config/connection-gater.js +18 -0
  49. package/dist/src/config/connection-gater.js.map +1 -0
  50. package/dist/src/config.d.ts +2 -1
  51. package/dist/src/config.d.ts.map +1 -1
  52. package/dist/src/config.js +0 -62
  53. package/dist/src/config.js.map +1 -1
  54. package/dist/src/connection-manager/auto-dial.d.ts +3 -0
  55. package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
  56. package/dist/src/connection-manager/auto-dial.js +36 -13
  57. package/dist/src/connection-manager/auto-dial.js.map +1 -1
  58. package/dist/src/connection-manager/connection-pruner.d.ts +4 -0
  59. package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -1
  60. package/dist/src/connection-manager/connection-pruner.js +23 -8
  61. package/dist/src/connection-manager/connection-pruner.js.map +1 -1
  62. package/dist/src/connection-manager/dial-queue.d.ts +2 -1
  63. package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
  64. package/dist/src/connection-manager/dial-queue.js +36 -14
  65. package/dist/src/connection-manager/dial-queue.js.map +1 -1
  66. package/dist/src/connection-manager/index.d.ts +8 -7
  67. package/dist/src/connection-manager/index.d.ts.map +1 -1
  68. package/dist/src/connection-manager/index.js +23 -34
  69. package/dist/src/connection-manager/index.js.map +1 -1
  70. package/dist/src/content-routing/index.d.ts +0 -10
  71. package/dist/src/content-routing/index.d.ts.map +1 -1
  72. package/dist/src/content-routing/index.js +7 -42
  73. package/dist/src/content-routing/index.js.map +1 -1
  74. package/dist/src/content-routing/utils.d.ts.map +1 -1
  75. package/dist/src/content-routing/utils.js +3 -1
  76. package/dist/src/content-routing/utils.js.map +1 -1
  77. package/dist/src/fetch/index.d.ts +13 -35
  78. package/dist/src/fetch/index.d.ts.map +1 -1
  79. package/dist/src/fetch/index.js +7 -9
  80. package/dist/src/fetch/index.js.map +1 -1
  81. package/dist/src/identify/identify.d.ts +53 -0
  82. package/dist/src/identify/identify.d.ts.map +1 -0
  83. package/dist/src/identify/identify.js +405 -0
  84. package/dist/src/identify/identify.js.map +1 -0
  85. package/dist/src/identify/index.d.ts +12 -58
  86. package/dist/src/identify/index.d.ts.map +1 -1
  87. package/dist/src/identify/index.js +5 -388
  88. package/dist/src/identify/index.js.map +1 -1
  89. package/dist/src/index.d.ts +13 -68
  90. package/dist/src/index.d.ts.map +1 -1
  91. package/dist/src/index.js +2 -1
  92. package/dist/src/index.js.map +1 -1
  93. package/dist/src/insecure/index.js.map +1 -1
  94. package/dist/src/libp2p.d.ts +11 -42
  95. package/dist/src/libp2p.d.ts.map +1 -1
  96. package/dist/src/libp2p.js +137 -196
  97. package/dist/src/libp2p.js.map +1 -1
  98. package/dist/src/peer-routing.d.ts +1 -38
  99. package/dist/src/peer-routing.d.ts.map +1 -1
  100. package/dist/src/peer-routing.js +0 -59
  101. package/dist/src/peer-routing.js.map +1 -1
  102. package/dist/src/ping/constants.d.ts +4 -0
  103. package/dist/src/ping/constants.d.ts.map +1 -1
  104. package/dist/src/ping/constants.js +10 -0
  105. package/dist/src/ping/constants.js.map +1 -1
  106. package/dist/src/ping/index.d.ts +10 -27
  107. package/dist/src/ping/index.d.ts.map +1 -1
  108. package/dist/src/ping/index.js +18 -21
  109. package/dist/src/ping/index.js.map +1 -1
  110. package/dist/src/registrar.d.ts +5 -2
  111. package/dist/src/registrar.d.ts.map +1 -1
  112. package/dist/src/registrar.js +27 -25
  113. package/dist/src/registrar.js.map +1 -1
  114. package/dist/src/transport-manager.d.ts +11 -4
  115. package/dist/src/transport-manager.d.ts.map +1 -1
  116. package/dist/src/transport-manager.js +19 -10
  117. package/dist/src/transport-manager.js.map +1 -1
  118. package/dist/src/upgrader.d.ts +15 -10
  119. package/dist/src/upgrader.d.ts.map +1 -1
  120. package/dist/src/upgrader.js +39 -48
  121. package/dist/src/upgrader.js.map +1 -1
  122. package/dist/src/upnp-nat/index.d.ts +42 -0
  123. package/dist/src/upnp-nat/index.d.ts.map +1 -0
  124. package/dist/src/{nat-manager.js → upnp-nat/index.js} +11 -7
  125. package/dist/src/upnp-nat/index.js.map +1 -0
  126. package/dist/src/version.d.ts +1 -1
  127. package/dist/src/version.d.ts.map +1 -1
  128. package/dist/src/version.js +1 -1
  129. package/dist/src/version.js.map +1 -1
  130. package/dist/typedoc-urls.json +25 -10
  131. package/package.json +61 -45
  132. package/src/address-manager/index.ts +50 -8
  133. package/src/address-manager/utils.ts +14 -0
  134. package/src/autonat/constants.ts +17 -2
  135. package/src/autonat/index.ts +53 -45
  136. package/src/circuit-relay/server/advert-service.ts +2 -2
  137. package/src/circuit-relay/server/index.ts +11 -3
  138. package/src/circuit-relay/transport/discovery.ts +5 -3
  139. package/src/circuit-relay/transport/index.ts +9 -4
  140. package/src/circuit-relay/transport/listener.ts +38 -28
  141. package/src/circuit-relay/transport/reservation-store.ts +34 -20
  142. package/src/components.ts +71 -234
  143. package/src/config/connection-gater.browser.ts +31 -0
  144. package/src/config/connection-gater.ts +19 -0
  145. package/src/config.ts +3 -64
  146. package/src/connection-manager/auto-dial.ts +44 -15
  147. package/src/connection-manager/connection-pruner.ts +28 -8
  148. package/src/connection-manager/dial-queue.ts +41 -21
  149. package/src/connection-manager/index.ts +31 -43
  150. package/src/content-routing/index.ts +7 -55
  151. package/src/content-routing/utils.ts +3 -1
  152. package/src/fetch/index.ts +51 -14
  153. package/src/identify/identify.ts +518 -0
  154. package/src/identify/index.ts +17 -507
  155. package/src/index.ts +14 -77
  156. package/src/insecure/index.ts +4 -4
  157. package/src/libp2p.ts +139 -260
  158. package/src/peer-routing.ts +1 -101
  159. package/src/ping/constants.ts +11 -0
  160. package/src/ping/index.ts +32 -28
  161. package/src/registrar.ts +31 -27
  162. package/src/transport-manager.ts +27 -13
  163. package/src/upgrader.ts +62 -58
  164. package/src/{nat-manager.ts → upnp-nat/index.ts} +16 -17
  165. package/src/version.ts +1 -1
  166. package/dist/src/dht/dht-content-routing.d.ts +0 -17
  167. package/dist/src/dht/dht-content-routing.d.ts.map +0 -1
  168. package/dist/src/dht/dht-content-routing.js +0 -32
  169. package/dist/src/dht/dht-content-routing.js.map +0 -1
  170. package/dist/src/dht/dht-peer-routing.d.ts +0 -15
  171. package/dist/src/dht/dht-peer-routing.d.ts.map +0 -1
  172. package/dist/src/dht/dht-peer-routing.js +0 -26
  173. package/dist/src/dht/dht-peer-routing.js.map +0 -1
  174. package/dist/src/dht/dummy-dht.d.ts +0 -20
  175. package/dist/src/dht/dummy-dht.d.ts.map +0 -1
  176. package/dist/src/dht/dummy-dht.js +0 -46
  177. package/dist/src/dht/dummy-dht.js.map +0 -1
  178. package/dist/src/nat-manager.d.ts +0 -74
  179. package/dist/src/nat-manager.d.ts.map +0 -1
  180. package/dist/src/nat-manager.js.map +0 -1
  181. package/dist/src/peer-record-updater.d.ts +0 -24
  182. package/dist/src/peer-record-updater.d.ts.map +0 -1
  183. package/dist/src/peer-record-updater.js +0 -44
  184. package/dist/src/peer-record-updater.js.map +0 -1
  185. package/src/dht/dht-content-routing.ts +0 -44
  186. package/src/dht/dht-peer-routing.ts +0 -36
  187. package/src/dht/dummy-dht.ts +0 -60
  188. package/src/peer-record-updater.ts +0 -65
@@ -1,392 +1,6 @@
1
- import { logger } from '@libp2p/logger';
2
- import { CodeError } from '@libp2p/interfaces/errors';
3
- import * as lp from 'it-length-prefixed';
4
- import { pipe } from 'it-pipe';
5
- import first from 'it-first';
6
- import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
7
- import { multiaddr, protocols } from '@multiformats/multiaddr';
8
1
  import { Identify } from './pb/message.js';
9
- import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record';
10
- import { MULTICODEC_IDENTIFY, MULTICODEC_IDENTIFY_PUSH, IDENTIFY_PROTOCOL_VERSION, MULTICODEC_IDENTIFY_PROTOCOL_NAME, MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME, MULTICODEC_IDENTIFY_PROTOCOL_VERSION, MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION } from './consts.js';
11
- import { codes } from '../errors.js';
12
- import { peerIdFromKeys } from '@libp2p/peer-id';
13
- import { TimeoutController } from 'timeout-abort-controller';
14
- import { abortableDuplex } from 'abortable-iterator';
15
- import { setMaxListeners } from 'events';
16
- const log = logger('libp2p:identify');
17
- // https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L52
18
- const MAX_IDENTIFY_MESSAGE_SIZE = 1024 * 8;
19
- export class IdentifyService {
20
- constructor(components, init) {
21
- this.components = components;
22
- this.started = false;
23
- this.init = init;
24
- this.identifyProtocolStr = `/${init.protocolPrefix}/${MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`;
25
- this.identifyPushProtocolStr = `/${init.protocolPrefix}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`;
26
- // Store self host metadata
27
- this.host = {
28
- protocolVersion: `${init.protocolPrefix}/${IDENTIFY_PROTOCOL_VERSION}`,
29
- ...init.host
30
- };
31
- // When a new connection happens, trigger identify
32
- this.components.connectionManager.addEventListener('peer:connect', (evt) => {
33
- const connection = evt.detail;
34
- this.identify(connection).catch(log.error);
35
- });
36
- // When self multiaddrs change, trigger identify-push
37
- this.components.peerStore.addEventListener('change:multiaddrs', (evt) => {
38
- const { peerId } = evt.detail;
39
- if (this.components.peerId.equals(peerId)) {
40
- void this.pushToPeerStore().catch(err => { log.error(err); });
41
- }
42
- });
43
- // When self protocols change, trigger identify-push
44
- this.components.peerStore.addEventListener('change:protocols', (evt) => {
45
- const { peerId } = evt.detail;
46
- if (this.components.peerId.equals(peerId)) {
47
- void this.pushToPeerStore().catch(err => { log.error(err); });
48
- }
49
- });
50
- }
51
- isStarted() {
52
- return this.started;
53
- }
54
- async start() {
55
- if (this.started) {
56
- return;
57
- }
58
- await this.components.peerStore.metadataBook.setValue(this.components.peerId, 'AgentVersion', uint8ArrayFromString(this.host.agentVersion));
59
- await this.components.peerStore.metadataBook.setValue(this.components.peerId, 'ProtocolVersion', uint8ArrayFromString(this.host.protocolVersion));
60
- await this.components.registrar.handle(this.identifyProtocolStr, (data) => {
61
- void this._handleIdentify(data).catch(err => {
62
- log.error(err);
63
- });
64
- }, {
65
- maxInboundStreams: this.init.maxInboundStreams,
66
- maxOutboundStreams: this.init.maxOutboundStreams
67
- });
68
- await this.components.registrar.handle(this.identifyPushProtocolStr, (data) => {
69
- void this._handlePush(data).catch(err => {
70
- log.error(err);
71
- });
72
- }, {
73
- maxInboundStreams: this.init.maxPushIncomingStreams,
74
- maxOutboundStreams: this.init.maxPushOutgoingStreams
75
- });
76
- this.started = true;
77
- }
78
- async stop() {
79
- await this.components.registrar.unhandle(this.identifyProtocolStr);
80
- await this.components.registrar.unhandle(this.identifyPushProtocolStr);
81
- this.started = false;
82
- }
83
- /**
84
- * Send an Identify Push update to the list of connections
85
- */
86
- async push(connections) {
87
- const signedPeerRecord = await this.components.peerStore.addressBook.getRawEnvelope(this.components.peerId);
88
- const listenAddrs = this.components.addressManager.getAddresses().map((ma) => ma.bytes);
89
- const protocols = await this.components.peerStore.protoBook.get(this.components.peerId);
90
- const pushes = connections.map(async (connection) => {
91
- let stream;
92
- const timeoutController = new TimeoutController(this.init.timeout);
93
- try {
94
- // fails on node < 15.4
95
- setMaxListeners?.(Infinity, timeoutController.signal);
96
- }
97
- catch { }
98
- try {
99
- stream = await connection.newStream([this.identifyPushProtocolStr], {
100
- signal: timeoutController.signal
101
- });
102
- // make stream abortable
103
- const source = abortableDuplex(stream, timeoutController.signal);
104
- await source.sink(pipe([Identify.encode({
105
- listenAddrs,
106
- signedPeerRecord,
107
- protocols
108
- })], (source) => lp.encode(source)));
109
- }
110
- catch (err) {
111
- // Just log errors
112
- log.error('could not push identify update to peer', err);
113
- }
114
- finally {
115
- if (stream != null) {
116
- stream.close();
117
- }
118
- timeoutController.clear();
119
- }
120
- });
121
- await Promise.all(pushes);
122
- }
123
- /**
124
- * Calls `push` on all peer connections
125
- */
126
- async pushToPeerStore() {
127
- // Do not try to push if we are not running
128
- if (!this.isStarted()) {
129
- return;
130
- }
131
- const connections = [];
132
- for (const conn of this.components.connectionManager.getConnections()) {
133
- const peerId = conn.remotePeer;
134
- const peer = await this.components.peerStore.get(peerId);
135
- if (!peer.protocols.includes(this.identifyPushProtocolStr)) {
136
- continue;
137
- }
138
- connections.push(conn);
139
- }
140
- await this.push(connections);
141
- }
142
- async _identify(connection, options = {}) {
143
- let timeoutController;
144
- let signal = options.signal;
145
- let stream;
146
- // create a timeout if no abort signal passed
147
- if (signal == null) {
148
- timeoutController = new TimeoutController(this.init.timeout);
149
- signal = timeoutController.signal;
150
- try {
151
- // fails on node < 15.4
152
- setMaxListeners?.(Infinity, timeoutController.signal);
153
- }
154
- catch { }
155
- }
156
- try {
157
- stream = await connection.newStream([this.identifyProtocolStr], {
158
- signal
159
- });
160
- // make stream abortable
161
- const source = abortableDuplex(stream, signal);
162
- const data = await pipe([], source, (source) => lp.decode(source, {
163
- maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE
164
- }), async (source) => await first(source));
165
- if (data == null) {
166
- throw new CodeError('No data could be retrieved', codes.ERR_CONNECTION_ENDED);
167
- }
168
- try {
169
- return Identify.decode(data);
170
- }
171
- catch (err) {
172
- throw new CodeError(String(err), codes.ERR_INVALID_MESSAGE);
173
- }
174
- }
175
- finally {
176
- if (timeoutController != null) {
177
- timeoutController.clear();
178
- }
179
- if (stream != null) {
180
- stream.close();
181
- }
182
- }
183
- }
184
- /**
185
- * Requests the `Identify` message from peer associated with the given `connection`.
186
- * If the identified peer does not match the `PeerId` associated with the connection,
187
- * an error will be thrown.
188
- */
189
- async identify(connection, options = {}) {
190
- const message = await this._identify(connection, options);
191
- const { publicKey, listenAddrs, protocols, observedAddr, signedPeerRecord, agentVersion, protocolVersion } = message;
192
- if (publicKey == null) {
193
- throw new CodeError('public key was missing from identify message', codes.ERR_MISSING_PUBLIC_KEY);
194
- }
195
- const id = await peerIdFromKeys(publicKey);
196
- if (!connection.remotePeer.equals(id)) {
197
- throw new CodeError('identified peer does not match the expected peer', codes.ERR_INVALID_PEER);
198
- }
199
- if (this.components.peerId.equals(id)) {
200
- throw new CodeError('identified peer is our own peer id?', codes.ERR_INVALID_PEER);
201
- }
202
- // Get the observedAddr if there is one
203
- const cleanObservedAddr = IdentifyService.getCleanMultiaddr(observedAddr);
204
- if (signedPeerRecord != null) {
205
- log('received signed peer record from %p', id);
206
- try {
207
- const envelope = await RecordEnvelope.openAndCertify(signedPeerRecord, PeerRecord.DOMAIN);
208
- if (!envelope.peerId.equals(id)) {
209
- throw new CodeError('identified peer does not match the expected peer', codes.ERR_INVALID_PEER);
210
- }
211
- if (await this.components.peerStore.addressBook.consumePeerRecord(envelope)) {
212
- await this.components.peerStore.protoBook.set(id, protocols);
213
- if (agentVersion != null) {
214
- await this.components.peerStore.metadataBook.setValue(id, 'AgentVersion', uint8ArrayFromString(agentVersion));
215
- }
216
- if (protocolVersion != null) {
217
- await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', uint8ArrayFromString(protocolVersion));
218
- }
219
- log('identify completed for peer %p with protocols %o', id, protocols);
220
- return;
221
- }
222
- }
223
- catch (err) {
224
- log('received invalid envelope, discard it and fallback to listenAddrs is available', err);
225
- }
226
- }
227
- else {
228
- log('no signed peer record received from %p', id);
229
- }
230
- log('falling back to legacy addresses from %p', id);
231
- // LEGACY: Update peers data in PeerStore
232
- try {
233
- await this.components.peerStore.addressBook.set(id, listenAddrs.map((addr) => multiaddr(addr)));
234
- }
235
- catch (err) {
236
- log.error('received invalid addrs', err);
237
- }
238
- await this.components.peerStore.protoBook.set(id, protocols);
239
- if (agentVersion != null) {
240
- await this.components.peerStore.metadataBook.setValue(id, 'AgentVersion', uint8ArrayFromString(agentVersion));
241
- }
242
- if (protocolVersion != null) {
243
- await this.components.peerStore.metadataBook.setValue(id, 'ProtocolVersion', uint8ArrayFromString(protocolVersion));
244
- }
245
- log('identify completed for peer %p and protocols %o', id, protocols);
246
- log('our observed address is %s', cleanObservedAddr);
247
- if (cleanObservedAddr != null &&
248
- this.components.addressManager.getObservedAddrs().length < (this.init.maxObservedAddresses ?? Infinity)) {
249
- log('storing our observed address %s', cleanObservedAddr?.toString());
250
- this.components.addressManager.addObservedAddr(cleanObservedAddr);
251
- }
252
- }
253
- /**
254
- * Sends the `Identify` response with the Signed Peer Record
255
- * to the requesting peer over the given `connection`
256
- */
257
- async _handleIdentify(data) {
258
- const { connection, stream } = data;
259
- const timeoutController = new TimeoutController(this.init.timeout);
260
- try {
261
- // fails on node < 15.4
262
- setMaxListeners?.(Infinity, timeoutController.signal);
263
- }
264
- catch { }
265
- try {
266
- const publicKey = this.components.peerId.publicKey ?? new Uint8Array(0);
267
- const peerData = await this.components.peerStore.get(this.components.peerId);
268
- const multiaddrs = this.components.addressManager.getAddresses().map(ma => ma.decapsulateCode(protocols('p2p').code));
269
- let signedPeerRecord = peerData.peerRecordEnvelope;
270
- if (multiaddrs.length > 0 && signedPeerRecord == null) {
271
- const peerRecord = new PeerRecord({
272
- peerId: this.components.peerId,
273
- multiaddrs
274
- });
275
- const envelope = await RecordEnvelope.seal(peerRecord, this.components.peerId);
276
- await this.components.peerStore.addressBook.consumePeerRecord(envelope);
277
- signedPeerRecord = envelope.marshal().subarray();
278
- }
279
- const message = Identify.encode({
280
- protocolVersion: this.host.protocolVersion,
281
- agentVersion: this.host.agentVersion,
282
- publicKey,
283
- listenAddrs: multiaddrs.map(addr => addr.bytes),
284
- signedPeerRecord,
285
- observedAddr: connection.remoteAddr.bytes,
286
- protocols: peerData.protocols
287
- });
288
- // make stream abortable
289
- const source = abortableDuplex(stream, timeoutController.signal);
290
- const msgWithLenPrefix = pipe([message], (source) => lp.encode(source));
291
- await source.sink(msgWithLenPrefix);
292
- }
293
- catch (err) {
294
- log.error('could not respond to identify request', err);
295
- }
296
- finally {
297
- stream.close();
298
- timeoutController.clear();
299
- }
300
- }
301
- /**
302
- * Reads the Identify Push message from the given `connection`
303
- */
304
- async _handlePush(data) {
305
- const { connection, stream } = data;
306
- const timeoutController = new TimeoutController(this.init.timeout);
307
- try {
308
- // fails on node < 15.4
309
- setMaxListeners?.(Infinity, timeoutController.signal);
310
- }
311
- catch { }
312
- let message;
313
- try {
314
- // make stream abortable
315
- const source = abortableDuplex(stream, timeoutController.signal);
316
- const data = await pipe([], source, (source) => lp.decode(source, {
317
- maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE
318
- }), async (source) => await first(source));
319
- if (data != null) {
320
- message = Identify.decode(data);
321
- }
322
- }
323
- catch (err) {
324
- log.error('received invalid message', err);
325
- return;
326
- }
327
- finally {
328
- stream.close();
329
- timeoutController.clear();
330
- }
331
- if (message == null) {
332
- log.error('received invalid message');
333
- return;
334
- }
335
- const id = connection.remotePeer;
336
- if (this.components.peerId.equals(id)) {
337
- log('received push from ourselves?');
338
- return;
339
- }
340
- log('received push from %p', id);
341
- if (message.signedPeerRecord != null) {
342
- log('received signedPeerRecord in push');
343
- try {
344
- const envelope = await RecordEnvelope.openAndCertify(message.signedPeerRecord, PeerRecord.DOMAIN);
345
- if (await this.components.peerStore.addressBook.consumePeerRecord(envelope)) {
346
- log('consumed signedPeerRecord sent in push');
347
- await this.components.peerStore.protoBook.set(id, message.protocols);
348
- return;
349
- }
350
- else {
351
- log('failed to consume signedPeerRecord sent in push');
352
- }
353
- }
354
- catch (err) {
355
- log('received invalid envelope, discard it and fallback to listenAddrs is available', err);
356
- }
357
- }
358
- else {
359
- log('did not receive signedPeerRecord in push');
360
- }
361
- // LEGACY: Update peers data in PeerStore
362
- try {
363
- await this.components.peerStore.addressBook.set(id, message.listenAddrs.map((addr) => multiaddr(addr)));
364
- }
365
- catch (err) {
366
- log.error('received invalid addrs', err);
367
- }
368
- // Update the protocols
369
- try {
370
- await this.components.peerStore.protoBook.set(id, message.protocols);
371
- }
372
- catch (err) {
373
- log.error('received invalid protocols', err);
374
- }
375
- log('handled push from %p', id);
376
- }
377
- /**
378
- * Takes the `addr` and converts it to a Multiaddr if possible
379
- */
380
- static getCleanMultiaddr(addr) {
381
- if (addr != null && addr.length > 0) {
382
- try {
383
- return multiaddr(addr);
384
- }
385
- catch {
386
- }
387
- }
388
- }
389
- }
2
+ import { MULTICODEC_IDENTIFY, MULTICODEC_IDENTIFY_PUSH } from './consts.js';
3
+ import { DefaultIdentifyService } from './identify.js';
390
4
  /**
391
5
  * The protocols the IdentifyService supports
392
6
  */
@@ -395,4 +9,7 @@ export const multicodecs = {
395
9
  IDENTIFY_PUSH: MULTICODEC_IDENTIFY_PUSH
396
10
  };
397
11
  export const Message = { Identify };
12
+ export function identifyService(init = {}) {
13
+ return (components) => new DefaultIdentifyService(components, init);
14
+ }
398
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,KAAK,EAAE,MA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C;IAED;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAE,IAA4C;QACpE,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnC,IAAI;gBACF,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;aACvB;YAAC,MAAM;aAEP;SACF;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,mBAAmB;IAC7B,aAAa,EAAE,wBAAwB;CACxC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,aAAa,CAAA;AAQpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAwCtD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,mBAAmB;IAC7B,aAAa,EAAE,wBAAwB;CACxC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,CAAA;AAEnC,MAAM,UAAU,eAAe,CAAE,OAA4B,EAAE;IAC7D,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACrE,CAAC"}
@@ -15,10 +15,7 @@
15
15
  */
16
16
  import type { RecursivePartial } from '@libp2p/interfaces';
17
17
  import type { TransportManagerInit } from './transport-manager.js';
18
- import type { IdentifyServiceInit } from './identify/index.js';
19
- import type { DualDHT } from '@libp2p/interface-dht';
20
18
  import type { Datastore } from 'interface-datastore';
21
- import type { PeerStoreInit } from '@libp2p/interface-peer-store';
22
19
  import type { PeerId } from '@libp2p/interface-peer-id';
23
20
  import type { PeerDiscovery } from '@libp2p/interface-peer-discovery';
24
21
  import type { ConnectionProtector } from '@libp2p/interface-connection';
@@ -28,24 +25,20 @@ import type { StreamMuxerFactory } from '@libp2p/interface-stream-muxer';
28
25
  import type { ConnectionEncrypter } from '@libp2p/interface-connection-encrypter';
29
26
  import type { PeerRouting } from '@libp2p/interface-peer-routing';
30
27
  import type { ContentRouting } from '@libp2p/interface-content-routing';
31
- import type { PubSub } from '@libp2p/interface-pubsub';
32
28
  import type { Metrics } from '@libp2p/interface-metrics';
33
- import type { PeerInfo } from '@libp2p/interface-peer-info';
34
- import type { PingServiceInit } from './ping/index.js';
35
- import type { FetchServiceInit } from './fetch/index.js';
36
- import type { AutonatServiceInit } from './autonat/index.js';
37
29
  import type { Components } from './components.js';
38
- import type { Libp2p } from '@libp2p/interface-libp2p';
30
+ import type { Libp2p, ServiceMap } from '@libp2p/interface-libp2p';
39
31
  import type { KeyChainInit } from '@libp2p/keychain';
40
- import type { NatManagerInit } from './nat-manager.js';
41
32
  import type { AddressManagerInit } from './address-manager/index.js';
42
- import type { PeerRoutingInit } from './peer-routing.js';
43
33
  import type { ConnectionManagerInit } from './connection-manager/index.js';
44
- import type { CircuitRelayService } from './circuit-relay/index.js';
34
+ import type { PersistentPeerStoreInit } from '@libp2p/peer-store';
35
+ export type ServiceFactoryMap<T extends Record<string, unknown> = Record<string, unknown>> = {
36
+ [Property in keyof T]: (components: Components) => T[Property];
37
+ };
45
38
  /**
46
39
  * For Libp2p configurations and modules details read the [Configuration Document](./CONFIGURATION.md).
47
40
  */
48
- export interface Libp2pInit {
41
+ export interface Libp2pInit<T extends ServiceMap = {}> {
49
42
  /**
50
43
  * peerId instance (it will be created if not provided)
51
44
  */
@@ -75,40 +68,11 @@ export interface Libp2pInit {
75
68
  /**
76
69
  * libp2p PeerStore configuration
77
70
  */
78
- peerStore: PeerStoreInit;
79
- /**
80
- * libp2p Peer routing service configuration
81
- */
82
- peerRouting: PeerRoutingInit;
71
+ peerStore: PersistentPeerStoreInit;
83
72
  /**
84
73
  * keychain configuration
85
74
  */
86
75
  keychain: KeyChainInit;
87
- /**
88
- * The NAT manager controls uPNP hole punching
89
- */
90
- nat: NatManagerInit;
91
- /**
92
- * If configured as a relay this node will relay certain
93
- * types of traffic for other peers
94
- */
95
- relay: (components: Components) => CircuitRelayService;
96
- /**
97
- * identify protocol options
98
- */
99
- identify: IdentifyServiceInit;
100
- /**
101
- * ping protocol options
102
- */
103
- ping: PingServiceInit;
104
- /**
105
- * fetch protocol options
106
- */
107
- fetch: FetchServiceInit;
108
- /**
109
- * autonat protocol options
110
- */
111
- autonat: AutonatServiceInit;
112
76
  /**
113
77
  * An array that must include at least 1 compliant transport
114
78
  */
@@ -118,41 +82,21 @@ export interface Libp2pInit {
118
82
  peerDiscovery?: Array<(components: Components) => PeerDiscovery>;
119
83
  peerRouters?: Array<(components: Components) => PeerRouting>;
120
84
  contentRouters?: Array<(components: Components) => ContentRouting>;
121
- /**
122
- * Pass a DHT implementation to enable DHT operations
123
- */
124
- dht?: (components: Components) => DualDHT;
125
85
  /**
126
86
  * A Metrics implementation can be supplied to collect metrics on this node
127
87
  */
128
88
  metrics?: (components: Components) => Metrics;
129
- /**
130
- * If a PubSub implmentation is supplied, PubSub operations will become available
131
- */
132
- pubsub?: (components: Components) => PubSub;
133
89
  /**
134
90
  * A ConnectionProtector can be used to create a secure overlay on top of the network using pre-shared keys
135
91
  */
136
92
  connectionProtector?: (components: Components) => ConnectionProtector;
137
- }
138
- /**
139
- * Once you have a libp2p instance, you can listen to several events it emits, so that you can be notified of relevant network events.
140
- */
141
- export interface Libp2pEvents {
142
93
  /**
143
- * @example
144
- *
145
- * ```js
146
- * libp2p.addEventListener('peer:discovery', (event) => {
147
- * const peerInfo = event.detail
148
- * // ...
149
- * })
150
- * ```
94
+ * Arbitrary libp2p modules
151
95
  */
152
- 'peer:discovery': CustomEvent<PeerInfo>;
96
+ services: ServiceFactoryMap<T>;
153
97
  }
154
98
  export type { Libp2p };
155
- export type Libp2pOptions = RecursivePartial<Libp2pInit> & {
99
+ export type Libp2pOptions<T extends ServiceMap = {}> = RecursivePartial<Libp2pInit<T>> & {
156
100
  start?: boolean;
157
101
  };
158
102
  /**
@@ -168,11 +112,12 @@ export type Libp2pOptions = RecursivePartial<Libp2pInit> & {
168
112
  * import { tcp } from '@libp2p/tcp'
169
113
  * import { mplex } from '@libp2p/mplex'
170
114
  * import { noise } from '@chainsafe/libp2p-noise'
115
+ * import { yamux } from '@chainsafe/libp2p-yamux'
171
116
  *
172
117
  * // specify options
173
118
  * const options = {
174
119
  * transports: [tcp()],
175
- * streamMuxers: [mplex()],
120
+ * streamMuxers: [yamux(), mplex()],
176
121
  * connectionEncryption: [noise()]
177
122
  * }
178
123
  *
@@ -180,5 +125,5 @@ export type Libp2pOptions = RecursivePartial<Libp2pInit> & {
180
125
  * const libp2p = await createLibp2p(options)
181
126
  * ```
182
127
  */
183
- export declare function createLibp2p(options: Libp2pOptions): Promise<Libp2p>;
128
+ export declare function createLibp2p<T extends ServiceMap = {}>(options: Libp2pOptions<T>): Promise<Libp2p<T>>;
184
129
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAA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GAAG,EAAE,EAAG,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAQ7G"}
package/dist/src/index.js CHANGED
@@ -27,11 +27,12 @@ import { createLibp2pNode } from './libp2p.js';
27
27
  * import { tcp } from '@libp2p/tcp'
28
28
  * import { mplex } from '@libp2p/mplex'
29
29
  * import { noise } from '@chainsafe/libp2p-noise'
30
+ * import { yamux } from '@chainsafe/libp2p-yamux'
30
31
  *
31
32
  * // specify options
32
33
  * const options = {
33
34
  * transports: [tcp()],
34
- * streamMuxers: [mplex()],
35
+ * streamMuxers: [yamux(), mplex()],
35
36
  * connectionEncryption: [noise()]
36
37
  * }
37
38
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAqK9C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAE,OAAsB;IACxD,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE5C,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK,EAAE;QAC3B,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;KACnB;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAqG9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAA8B,OAAyB;IACvF,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE5C,IAAI,OAAO,CAAC,KAAK,KAAK,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