@libp2p/identify 0.0.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.
@@ -0,0 +1,9 @@
1
+ export declare const PROTOCOL_VERSION = "ipfs/0.1.0";
2
+ export declare const MULTICODEC_IDENTIFY = "/ipfs/id/1.0.0";
3
+ export declare const MULTICODEC_IDENTIFY_PUSH = "/ipfs/id/push/1.0.0";
4
+ export declare const IDENTIFY_PROTOCOL_VERSION = "0.1.0";
5
+ export declare const MULTICODEC_IDENTIFY_PROTOCOL_NAME = "id";
6
+ export declare const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME = "id/push";
7
+ export declare const MULTICODEC_IDENTIFY_PROTOCOL_VERSION = "1.0.0";
8
+ export declare const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION = "1.0.0";
9
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../src/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAC5C,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AACnD,eAAO,MAAM,wBAAwB,wBAAwB,CAAA;AAE7D,eAAO,MAAM,yBAAyB,UAAU,CAAA;AAChD,eAAO,MAAM,iCAAiC,OAAO,CAAA;AACrD,eAAO,MAAM,sCAAsC,YAAY,CAAA;AAC/D,eAAO,MAAM,oCAAoC,UAAU,CAAA;AAC3D,eAAO,MAAM,yCAAyC,UAAU,CAAA"}
@@ -0,0 +1,9 @@
1
+ export const PROTOCOL_VERSION = 'ipfs/0.1.0'; // deprecated
2
+ export const MULTICODEC_IDENTIFY = '/ipfs/id/1.0.0'; // deprecated
3
+ export const MULTICODEC_IDENTIFY_PUSH = '/ipfs/id/push/1.0.0'; // deprecated
4
+ export const IDENTIFY_PROTOCOL_VERSION = '0.1.0';
5
+ export const MULTICODEC_IDENTIFY_PROTOCOL_NAME = 'id';
6
+ export const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME = 'id/push';
7
+ export const MULTICODEC_IDENTIFY_PROTOCOL_VERSION = '1.0.0';
8
+ export const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION = '1.0.0';
9
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/consts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAA,CAAC,aAAa;AAC1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAA,CAAC,aAAa;AACjE,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAA,CAAC,aAAa;AAE3E,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAO,CAAA;AAChD,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,CAAA;AACrD,MAAM,CAAC,MAAM,sCAAsC,GAAG,SAAS,CAAA;AAC/D,MAAM,CAAC,MAAM,oCAAoC,GAAG,OAAO,CAAA;AAC3D,MAAM,CAAC,MAAM,yCAAyC,GAAG,OAAO,CAAA"}
@@ -0,0 +1,54 @@
1
+ import { Identify as IdentifyMessage } from './pb/message.js';
2
+ import type { Identify as IdentifyInterface, IdentifyComponents, IdentifyInit } from './index.js';
3
+ import type { IdentifyResult, AbortOptions } from '@libp2p/interface';
4
+ import type { Connection } from '@libp2p/interface/connection';
5
+ import type { Startable } from '@libp2p/interface/startable';
6
+ import type { IncomingStreamData } from '@libp2p/interface-internal/registrar';
7
+ export declare class Identify implements Startable, IdentifyInterface {
8
+ #private;
9
+ private readonly identifyProtocolStr;
10
+ private readonly identifyPushProtocolStr;
11
+ readonly host: {
12
+ protocolVersion: string;
13
+ agentVersion: string;
14
+ };
15
+ private started;
16
+ private readonly timeout;
17
+ private readonly peerId;
18
+ private readonly peerStore;
19
+ private readonly registrar;
20
+ private readonly connectionManager;
21
+ private readonly addressManager;
22
+ private readonly maxInboundStreams;
23
+ private readonly maxOutboundStreams;
24
+ private readonly maxPushIncomingStreams;
25
+ private readonly maxPushOutgoingStreams;
26
+ private readonly maxIdentifyMessageSize;
27
+ private readonly maxObservedAddresses;
28
+ private readonly events;
29
+ private readonly runOnTransientConnection;
30
+ constructor(components: IdentifyComponents, init?: IdentifyInit);
31
+ isStarted(): boolean;
32
+ start(): Promise<void>;
33
+ stop(): Promise<void>;
34
+ /**
35
+ * Send an Identify Push update to the list of connections
36
+ */
37
+ pushToConnections(connections: Connection[]): Promise<void>;
38
+ /**
39
+ * Calls `push` on all peer connections
40
+ */
41
+ push(): Promise<void>;
42
+ _identify(connection: Connection, options?: AbortOptions): Promise<IdentifyMessage>;
43
+ identify(connection: Connection, options?: AbortOptions): Promise<IdentifyResult>;
44
+ /**
45
+ * Sends the `Identify` response with the Signed Peer Record
46
+ * to the requesting peer over the given `connection`
47
+ */
48
+ _handleIdentify(data: IncomingStreamData): Promise<void>;
49
+ /**
50
+ * Reads the Identify Push message from the given `connection`
51
+ */
52
+ _handlePush(data: IncomingStreamData): Promise<void>;
53
+ }
54
+ //# sourceMappingURL=identify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identify.d.ts","sourceRoot":"","sources":["../../src/identify.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,IAAI,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACjG,OAAO,KAAK,EAAgB,cAAc,EAAoB,YAAY,EAAU,MAAM,mBAAmB,CAAA;AAC7G,OAAO,KAAK,EAAE,UAAU,EAAU,MAAM,8BAA8B,CAAA;AAItE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAG5D,OAAO,KAAK,EAAE,kBAAkB,EAAa,MAAM,sCAAsC,CAAA;AAmBzF,qBAAa,Q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AE,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IAmCxF,QAAQ,CAAE,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,cAAc,CAAC;IAqC5F;;;OAGG;IACG,eAAe,CAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoD/D;;OAEG;IACG,WAAW,CAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAgK5D"}
@@ -0,0 +1,446 @@
1
+ /* eslint-disable complexity */
2
+ import { CodeError, ERR_NOT_FOUND } from '@libp2p/interface/errors';
3
+ import { setMaxListeners } from '@libp2p/interface/events';
4
+ import { peerIdFromKeys } from '@libp2p/peer-id';
5
+ import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record';
6
+ import { multiaddr, protocols } from '@multiformats/multiaddr';
7
+ import { IP_OR_DOMAIN } from '@multiformats/multiaddr-matcher';
8
+ import { pbStream } from 'it-protobuf-stream';
9
+ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
10
+ import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
11
+ import { isNode, isBrowser, isWebWorker, isElectronMain, isElectronRenderer, isReactNative } from 'wherearewe';
12
+ import { IDENTIFY_PROTOCOL_VERSION, MULTICODEC_IDENTIFY_PROTOCOL_NAME, MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME, MULTICODEC_IDENTIFY_PROTOCOL_VERSION, MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION } from './consts.js';
13
+ import { Identify as IdentifyMessage } from './pb/message.js';
14
+ // https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L52
15
+ const MAX_IDENTIFY_MESSAGE_SIZE = 1024 * 8;
16
+ const defaultValues = {
17
+ protocolPrefix: 'ipfs',
18
+ // https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L48
19
+ timeout: 60000,
20
+ maxInboundStreams: 1,
21
+ maxOutboundStreams: 1,
22
+ maxPushIncomingStreams: 1,
23
+ maxPushOutgoingStreams: 1,
24
+ maxObservedAddresses: 10,
25
+ maxIdentifyMessageSize: 8192,
26
+ runOnConnectionOpen: true,
27
+ runOnTransientConnection: true
28
+ };
29
+ export class Identify {
30
+ identifyProtocolStr;
31
+ identifyPushProtocolStr;
32
+ host;
33
+ started;
34
+ timeout;
35
+ peerId;
36
+ peerStore;
37
+ registrar;
38
+ connectionManager;
39
+ addressManager;
40
+ maxInboundStreams;
41
+ maxOutboundStreams;
42
+ maxPushIncomingStreams;
43
+ maxPushOutgoingStreams;
44
+ maxIdentifyMessageSize;
45
+ maxObservedAddresses;
46
+ events;
47
+ runOnTransientConnection;
48
+ #log;
49
+ constructor(components, init = {}) {
50
+ this.started = false;
51
+ this.peerId = components.peerId;
52
+ this.peerStore = components.peerStore;
53
+ this.registrar = components.registrar;
54
+ this.addressManager = components.addressManager;
55
+ this.connectionManager = components.connectionManager;
56
+ this.events = components.events;
57
+ this.#log = components.logger.forComponent('libp2p:identify');
58
+ this.identifyProtocolStr = `/${init.protocolPrefix ?? defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`;
59
+ this.identifyPushProtocolStr = `/${init.protocolPrefix ?? defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`;
60
+ this.timeout = init.timeout ?? defaultValues.timeout;
61
+ this.maxInboundStreams = init.maxInboundStreams ?? defaultValues.maxInboundStreams;
62
+ this.maxOutboundStreams = init.maxOutboundStreams ?? defaultValues.maxOutboundStreams;
63
+ this.maxPushIncomingStreams = init.maxPushIncomingStreams ?? defaultValues.maxPushIncomingStreams;
64
+ this.maxPushOutgoingStreams = init.maxPushOutgoingStreams ?? defaultValues.maxPushOutgoingStreams;
65
+ this.maxIdentifyMessageSize = init.maxIdentifyMessageSize ?? defaultValues.maxIdentifyMessageSize;
66
+ this.maxObservedAddresses = init.maxObservedAddresses ?? defaultValues.maxObservedAddresses;
67
+ this.runOnTransientConnection = init.runOnTransientConnection ?? defaultValues.runOnTransientConnection;
68
+ // Store self host metadata
69
+ this.host = {
70
+ protocolVersion: `${init.protocolPrefix ?? defaultValues.protocolPrefix}/${IDENTIFY_PROTOCOL_VERSION}`,
71
+ agentVersion: init.agentVersion ?? `${components.nodeInfo.name}/${components.nodeInfo.version}`
72
+ };
73
+ if (init.runOnConnectionOpen ?? defaultValues.runOnConnectionOpen) {
74
+ // When a new connection happens, trigger identify
75
+ components.events.addEventListener('connection:open', (evt) => {
76
+ const connection = evt.detail;
77
+ this.identify(connection).catch(err => { this.#log.error('error during identify trigged by connection:open', err); });
78
+ });
79
+ }
80
+ // When self peer record changes, trigger identify-push
81
+ components.events.addEventListener('self:peer:update', (evt) => {
82
+ void this.push().catch(err => { this.#log.error(err); });
83
+ });
84
+ // Append user agent version to default AGENT_VERSION depending on the environment
85
+ if (this.host.agentVersion === `${components.nodeInfo.name}/${components.nodeInfo.version}`) {
86
+ if (isNode || isElectronMain) {
87
+ this.host.agentVersion += ` UserAgent=${globalThis.process.version}`;
88
+ }
89
+ else if (isBrowser || isWebWorker || isElectronRenderer || isReactNative) {
90
+ this.host.agentVersion += ` UserAgent=${globalThis.navigator.userAgent}`;
91
+ }
92
+ }
93
+ }
94
+ isStarted() {
95
+ return this.started;
96
+ }
97
+ async start() {
98
+ if (this.started) {
99
+ return;
100
+ }
101
+ await this.peerStore.merge(this.peerId, {
102
+ metadata: {
103
+ AgentVersion: uint8ArrayFromString(this.host.agentVersion),
104
+ ProtocolVersion: uint8ArrayFromString(this.host.protocolVersion)
105
+ }
106
+ });
107
+ await this.registrar.handle(this.identifyProtocolStr, (data) => {
108
+ void this._handleIdentify(data).catch(err => {
109
+ this.#log.error(err);
110
+ });
111
+ }, {
112
+ maxInboundStreams: this.maxInboundStreams,
113
+ maxOutboundStreams: this.maxOutboundStreams,
114
+ runOnTransientConnection: this.runOnTransientConnection
115
+ });
116
+ await this.registrar.handle(this.identifyPushProtocolStr, (data) => {
117
+ void this._handlePush(data).catch(err => {
118
+ this.#log.error(err);
119
+ });
120
+ }, {
121
+ maxInboundStreams: this.maxPushIncomingStreams,
122
+ maxOutboundStreams: this.maxPushOutgoingStreams,
123
+ runOnTransientConnection: this.runOnTransientConnection
124
+ });
125
+ this.started = true;
126
+ }
127
+ async stop() {
128
+ await this.registrar.unhandle(this.identifyProtocolStr);
129
+ await this.registrar.unhandle(this.identifyPushProtocolStr);
130
+ this.started = false;
131
+ }
132
+ /**
133
+ * Send an Identify Push update to the list of connections
134
+ */
135
+ async pushToConnections(connections) {
136
+ const listenAddresses = this.addressManager.getAddresses().map(ma => ma.decapsulateCode(protocols('p2p').code));
137
+ const peerRecord = new PeerRecord({
138
+ peerId: this.peerId,
139
+ multiaddrs: listenAddresses
140
+ });
141
+ const signedPeerRecord = await RecordEnvelope.seal(peerRecord, this.peerId);
142
+ const supportedProtocols = this.registrar.getProtocols();
143
+ const peer = await this.peerStore.get(this.peerId);
144
+ const agentVersion = uint8ArrayToString(peer.metadata.get('AgentVersion') ?? uint8ArrayFromString(this.host.agentVersion));
145
+ const protocolVersion = uint8ArrayToString(peer.metadata.get('ProtocolVersion') ?? uint8ArrayFromString(this.host.protocolVersion));
146
+ const pushes = connections.map(async (connection) => {
147
+ let stream;
148
+ const signal = AbortSignal.timeout(this.timeout);
149
+ setMaxListeners(Infinity, signal);
150
+ try {
151
+ stream = await connection.newStream(this.identifyPushProtocolStr, {
152
+ signal,
153
+ runOnTransientConnection: this.runOnTransientConnection
154
+ });
155
+ const pb = pbStream(stream, {
156
+ maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE
157
+ }).pb(IdentifyMessage);
158
+ await pb.write({
159
+ listenAddrs: listenAddresses.map(ma => ma.bytes),
160
+ signedPeerRecord: signedPeerRecord.marshal(),
161
+ protocols: supportedProtocols,
162
+ agentVersion,
163
+ protocolVersion
164
+ }, {
165
+ signal
166
+ });
167
+ await stream.close({
168
+ signal
169
+ });
170
+ }
171
+ catch (err) {
172
+ // Just log errors
173
+ this.#log.error('could not push identify update to peer', err);
174
+ stream?.abort(err);
175
+ }
176
+ });
177
+ await Promise.all(pushes);
178
+ }
179
+ /**
180
+ * Calls `push` on all peer connections
181
+ */
182
+ async push() {
183
+ // Do not try to push if we are not running
184
+ if (!this.isStarted()) {
185
+ return;
186
+ }
187
+ const connections = [];
188
+ await Promise.all(this.connectionManager.getConnections().map(async (conn) => {
189
+ try {
190
+ const peer = await this.peerStore.get(conn.remotePeer);
191
+ if (!peer.protocols.includes(this.identifyPushProtocolStr)) {
192
+ return;
193
+ }
194
+ connections.push(conn);
195
+ }
196
+ catch (err) {
197
+ if (err.code !== ERR_NOT_FOUND) {
198
+ throw err;
199
+ }
200
+ }
201
+ }));
202
+ await this.pushToConnections(connections);
203
+ }
204
+ async _identify(connection, options = {}) {
205
+ let stream;
206
+ if (options.signal == null) {
207
+ const signal = AbortSignal.timeout(this.timeout);
208
+ setMaxListeners(Infinity, signal);
209
+ options = {
210
+ ...options,
211
+ signal
212
+ };
213
+ }
214
+ try {
215
+ stream = await connection.newStream(this.identifyProtocolStr, {
216
+ ...options,
217
+ runOnTransientConnection: this.runOnTransientConnection
218
+ });
219
+ const pb = pbStream(stream, {
220
+ maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE
221
+ }).pb(IdentifyMessage);
222
+ const message = await pb.read(options);
223
+ await stream.close(options);
224
+ return message;
225
+ }
226
+ catch (err) {
227
+ this.#log.error('error while reading identify message', err);
228
+ stream?.abort(err);
229
+ throw err;
230
+ }
231
+ }
232
+ async identify(connection, options = {}) {
233
+ const message = await this._identify(connection, options);
234
+ const { publicKey, protocols, observedAddr } = message;
235
+ if (publicKey == null) {
236
+ throw new CodeError('public key was missing from identify message', 'ERR_MISSING_PUBLIC_KEY');
237
+ }
238
+ const id = await peerIdFromKeys(publicKey);
239
+ if (!connection.remotePeer.equals(id)) {
240
+ throw new CodeError('identified peer does not match the expected peer', 'ERR_INVALID_PEER');
241
+ }
242
+ if (this.peerId.equals(id)) {
243
+ throw new CodeError('identified peer is our own peer id?', 'ERR_INVALID_PEER');
244
+ }
245
+ // Get the observedAddr if there is one
246
+ const cleanObservedAddr = getCleanMultiaddr(observedAddr);
247
+ this.#log('identify completed for peer %p and protocols %o', id, protocols);
248
+ this.#log('our observed address is %a', cleanObservedAddr);
249
+ if (cleanObservedAddr != null &&
250
+ this.addressManager.getObservedAddrs().length < (this.maxObservedAddresses ?? Infinity)) {
251
+ this.#log('storing our observed address %a', cleanObservedAddr);
252
+ this.addressManager.addObservedAddr(cleanObservedAddr);
253
+ }
254
+ return this.#consumeIdentifyMessage(connection, message);
255
+ }
256
+ /**
257
+ * Sends the `Identify` response with the Signed Peer Record
258
+ * to the requesting peer over the given `connection`
259
+ */
260
+ async _handleIdentify(data) {
261
+ const { connection, stream } = data;
262
+ const signal = AbortSignal.timeout(this.timeout);
263
+ setMaxListeners(Infinity, signal);
264
+ try {
265
+ const publicKey = this.peerId.publicKey ?? new Uint8Array(0);
266
+ const peerData = await this.peerStore.get(this.peerId);
267
+ const multiaddrs = this.addressManager.getAddresses().map(ma => ma.decapsulateCode(protocols('p2p').code));
268
+ let signedPeerRecord = peerData.peerRecordEnvelope;
269
+ if (multiaddrs.length > 0 && signedPeerRecord == null) {
270
+ const peerRecord = new PeerRecord({
271
+ peerId: this.peerId,
272
+ multiaddrs
273
+ });
274
+ const envelope = await RecordEnvelope.seal(peerRecord, this.peerId);
275
+ signedPeerRecord = envelope.marshal().subarray();
276
+ }
277
+ let observedAddr = connection.remoteAddr.bytes;
278
+ if (!IP_OR_DOMAIN.matches(connection.remoteAddr)) {
279
+ observedAddr = undefined;
280
+ }
281
+ const pb = pbStream(stream).pb(IdentifyMessage);
282
+ await pb.write({
283
+ protocolVersion: this.host.protocolVersion,
284
+ agentVersion: this.host.agentVersion,
285
+ publicKey,
286
+ listenAddrs: multiaddrs.map(addr => addr.bytes),
287
+ signedPeerRecord,
288
+ observedAddr,
289
+ protocols: peerData.protocols
290
+ }, {
291
+ signal
292
+ });
293
+ await stream.close({
294
+ signal
295
+ });
296
+ }
297
+ catch (err) {
298
+ this.#log.error('could not respond to identify request', err);
299
+ stream.abort(err);
300
+ }
301
+ }
302
+ /**
303
+ * Reads the Identify Push message from the given `connection`
304
+ */
305
+ async _handlePush(data) {
306
+ const { connection, stream } = data;
307
+ try {
308
+ if (this.peerId.equals(connection.remotePeer)) {
309
+ throw new Error('received push from ourselves?');
310
+ }
311
+ const options = {
312
+ signal: AbortSignal.timeout(this.timeout)
313
+ };
314
+ const pb = pbStream(stream, {
315
+ maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE
316
+ }).pb(IdentifyMessage);
317
+ const message = await pb.read(options);
318
+ await stream.close(options);
319
+ await this.#consumeIdentifyMessage(connection, message);
320
+ }
321
+ catch (err) {
322
+ this.#log.error('received invalid message', err);
323
+ stream.abort(err);
324
+ return;
325
+ }
326
+ this.#log('handled push from %p', connection.remotePeer);
327
+ }
328
+ async #consumeIdentifyMessage(connection, message) {
329
+ this.#log('received identify from %p', connection.remotePeer);
330
+ if (message == null) {
331
+ throw new CodeError('message was null or undefined', 'ERR_INVALID_MESSAGE');
332
+ }
333
+ const peer = {};
334
+ if (message.listenAddrs.length > 0) {
335
+ peer.addresses = message.listenAddrs.map(buf => ({
336
+ isCertified: false,
337
+ multiaddr: multiaddr(buf)
338
+ }));
339
+ }
340
+ if (message.protocols.length > 0) {
341
+ peer.protocols = message.protocols;
342
+ }
343
+ if (message.publicKey != null) {
344
+ peer.publicKey = message.publicKey;
345
+ const peerId = await peerIdFromKeys(message.publicKey);
346
+ if (!peerId.equals(connection.remotePeer)) {
347
+ throw new CodeError('public key did not match remote PeerId', 'ERR_INVALID_PUBLIC_KEY');
348
+ }
349
+ }
350
+ let output;
351
+ // if the peer record has been sent, prefer the addresses in the record as they are signed by the remote peer
352
+ if (message.signedPeerRecord != null) {
353
+ this.#log('received signedPeerRecord from %p', connection.remotePeer);
354
+ let peerRecordEnvelope = message.signedPeerRecord;
355
+ const envelope = await RecordEnvelope.openAndCertify(peerRecordEnvelope, PeerRecord.DOMAIN);
356
+ let peerRecord = PeerRecord.createFromProtobuf(envelope.payload);
357
+ // Verify peerId
358
+ if (!peerRecord.peerId.equals(envelope.peerId)) {
359
+ throw new CodeError('signing key does not match PeerId in the PeerRecord', 'ERR_INVALID_SIGNING_KEY');
360
+ }
361
+ // Make sure remote peer is the one sending the record
362
+ if (!connection.remotePeer.equals(peerRecord.peerId)) {
363
+ throw new CodeError('signing key does not match remote PeerId', 'ERR_INVALID_PEER_RECORD_KEY');
364
+ }
365
+ let existingPeer;
366
+ try {
367
+ existingPeer = await this.peerStore.get(peerRecord.peerId);
368
+ }
369
+ catch (err) {
370
+ if (err.code !== 'ERR_NOT_FOUND') {
371
+ throw err;
372
+ }
373
+ }
374
+ if (existingPeer != null) {
375
+ // don't lose any existing metadata
376
+ peer.metadata = existingPeer.metadata;
377
+ // if we have previously received a signed record for this peer, compare it to the incoming one
378
+ if (existingPeer.peerRecordEnvelope != null) {
379
+ const storedEnvelope = await RecordEnvelope.createFromProtobuf(existingPeer.peerRecordEnvelope);
380
+ const storedRecord = PeerRecord.createFromProtobuf(storedEnvelope.payload);
381
+ // ensure seq is greater than, or equal to, the last received
382
+ if (storedRecord.seqNumber >= peerRecord.seqNumber) {
383
+ this.#log('sequence number was lower or equal to existing sequence number - stored: %d received: %d', storedRecord.seqNumber, peerRecord.seqNumber);
384
+ peerRecord = storedRecord;
385
+ peerRecordEnvelope = existingPeer.peerRecordEnvelope;
386
+ }
387
+ }
388
+ }
389
+ // store the signed record for next time
390
+ peer.peerRecordEnvelope = peerRecordEnvelope;
391
+ // override the stored addresses with the signed multiaddrs
392
+ peer.addresses = peerRecord.multiaddrs.map(multiaddr => ({
393
+ isCertified: true,
394
+ multiaddr
395
+ }));
396
+ output = {
397
+ seq: peerRecord.seqNumber,
398
+ addresses: peerRecord.multiaddrs
399
+ };
400
+ }
401
+ else {
402
+ this.#log('%p did not send a signed peer record', connection.remotePeer);
403
+ }
404
+ this.#log('patching %p with', connection.remotePeer, peer);
405
+ await this.peerStore.patch(connection.remotePeer, peer);
406
+ if (message.agentVersion != null || message.protocolVersion != null) {
407
+ const metadata = {};
408
+ if (message.agentVersion != null) {
409
+ metadata.AgentVersion = uint8ArrayFromString(message.agentVersion);
410
+ }
411
+ if (message.protocolVersion != null) {
412
+ metadata.ProtocolVersion = uint8ArrayFromString(message.protocolVersion);
413
+ }
414
+ this.#log('merging %p metadata', connection.remotePeer, metadata);
415
+ await this.peerStore.merge(connection.remotePeer, {
416
+ metadata
417
+ });
418
+ }
419
+ const result = {
420
+ peerId: connection.remotePeer,
421
+ protocolVersion: message.protocolVersion,
422
+ agentVersion: message.agentVersion,
423
+ publicKey: message.publicKey,
424
+ listenAddrs: message.listenAddrs.map(buf => multiaddr(buf)),
425
+ observedAddr: message.observedAddr == null ? undefined : multiaddr(message.observedAddr),
426
+ protocols: message.protocols,
427
+ signedPeerRecord: output,
428
+ connection
429
+ };
430
+ this.events.safeDispatchEvent('peer:identify', { detail: result });
431
+ return result;
432
+ }
433
+ }
434
+ /**
435
+ * Takes the `addr` and converts it to a Multiaddr if possible
436
+ */
437
+ function getCleanMultiaddr(addr) {
438
+ if (addr != null && addr.length > 0) {
439
+ try {
440
+ return multiaddr(addr);
441
+ }
442
+ catch {
443
+ }
444
+ }
445
+ }
446
+ //# sourceMappingURL=identify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identify.js","sourceRoot":"","sources":["../../src/identify.ts"],"names":[],"mappings":"AAAA,+B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,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;SACvB;QAAC,MAAM;SAEP;KACF;AACH,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Use the `identify` function to add support for the [Identify protocol](https://github.com/libp2p/specs/blob/master/identify/README.md) to libp2p.
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import { createLibp2p } from 'libp2p'
10
+ * import { identify } from '@libp2p/identify'
11
+ *
12
+ * const node = await createLibp2p({
13
+ * // ...other options
14
+ * services: {
15
+ * identify: identify()
16
+ * }
17
+ * })
18
+ * ```
19
+ */
20
+ import type { AbortOptions, IdentifyResult, Libp2pEvents, ComponentLogger, NodeInfo } from '@libp2p/interface';
21
+ import type { TypedEventTarget } from '@libp2p/interface/events';
22
+ import type { PeerId } from '@libp2p/interface/peer-id';
23
+ import type { PeerStore } from '@libp2p/interface/peer-store';
24
+ import type { Connection } from '@libp2p/interface/src/connection/index.js';
25
+ import type { AddressManager } from '@libp2p/interface-internal/address-manager';
26
+ import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager';
27
+ import type { Registrar } from '@libp2p/interface-internal/registrar';
28
+ export interface IdentifyInit {
29
+ /**
30
+ * The prefix to use for the protocol (default: 'ipfs')
31
+ */
32
+ protocolPrefix?: string;
33
+ /**
34
+ * What details we should send as part of an identify message
35
+ */
36
+ agentVersion?: string;
37
+ /**
38
+ * How long we should wait for a remote peer to send their identify response
39
+ */
40
+ timeout?: number;
41
+ /**
42
+ * Identify responses larger than this in bytes will be rejected (default: 8192)
43
+ */
44
+ maxIdentifyMessageSize?: number;
45
+ maxInboundStreams?: number;
46
+ maxOutboundStreams?: number;
47
+ maxPushIncomingStreams?: number;
48
+ maxPushOutgoingStreams?: number;
49
+ maxObservedAddresses?: number;
50
+ /**
51
+ * Whether to automatically dial identify on newly opened connections (default: true)
52
+ */
53
+ runOnConnectionOpen?: boolean;
54
+ /**
55
+ * Whether to run on connections with data or duration limits (default: true)
56
+ */
57
+ runOnTransientConnection?: boolean;
58
+ }
59
+ export interface IdentifyComponents {
60
+ peerId: PeerId;
61
+ peerStore: PeerStore;
62
+ connectionManager: ConnectionManager;
63
+ registrar: Registrar;
64
+ addressManager: AddressManager;
65
+ events: TypedEventTarget<Libp2pEvents>;
66
+ logger: ComponentLogger;
67
+ nodeInfo: NodeInfo;
68
+ }
69
+ /**
70
+ * The protocols the IdentifyService supports
71
+ */
72
+ export declare const multicodecs: {
73
+ IDENTIFY: string;
74
+ IDENTIFY_PUSH: string;
75
+ };
76
+ export interface Identify {
77
+ /**
78
+ * due to the default limits on inbound/outbound streams for this protocol,
79
+ * invoking this method when runOnConnectionOpen is true can lead to unpredictable results
80
+ * as streams may be closed by the local or the remote node.
81
+ * Please use with caution. If you find yourself needing to call this method to discover other peers that support your protocol,
82
+ * you may be better off configuring a topology to be notified instead.
83
+ */
84
+ identify(connection: Connection, options?: AbortOptions): Promise<IdentifyResult>;
85
+ push(): Promise<void>;
86
+ }
87
+ export declare function identify(init?: IdentifyInit): (components: IdentifyComponents) => Identify;
88
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC9G,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAA;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAChF,OAAO,KAAK,EAA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