@libp2p/identify 1.0.21-9d13a2f6a → 1.0.21

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.
@@ -6,6 +6,4 @@ export declare const MULTICODEC_IDENTIFY_PROTOCOL_NAME = "id";
6
6
  export declare const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME = "id/push";
7
7
  export declare const MULTICODEC_IDENTIFY_PROTOCOL_VERSION = "1.0.0";
8
8
  export declare const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION = "1.0.0";
9
- export declare const MAX_IDENTIFY_MESSAGE_SIZE: number;
10
- export declare const MAX_PUSH_CONCURRENCY = 32;
11
9
  //# sourceMappingURL=consts.d.ts.map
@@ -1 +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;AAGhE,eAAO,MAAM,yBAAyB,QAAW,CAAA;AAGjD,eAAO,MAAM,oBAAoB,KAAK,CAAA"}
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"}
@@ -6,8 +6,4 @@ export const MULTICODEC_IDENTIFY_PROTOCOL_NAME = 'id';
6
6
  export const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME = 'id/push';
7
7
  export const MULTICODEC_IDENTIFY_PROTOCOL_VERSION = '1.0.0';
8
8
  export const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION = '1.0.0';
9
- // https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L52
10
- export const MAX_IDENTIFY_MESSAGE_SIZE = 1024 * 8;
11
- // https://github.com/libp2p/go-libp2p/blob/0385ec924bad172f74a74db09939e97c079b1420/p2p/protocol/identify/id.go#L47C7-L47C25
12
- export const MAX_PUSH_CONCURRENCY = 32;
13
9
  //# sourceMappingURL=consts.js.map
@@ -1 +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;AAEhE,oHAAoH;AACpH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAA;AAEjD,6HAA6H;AAC7H,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAA"}
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"}
@@ -1,16 +1,53 @@
1
1
  import { Identify as IdentifyMessage } from './pb/message.js';
2
- import { AbstractIdentify } from './utils.js';
3
2
  import type { Identify as IdentifyInterface, IdentifyComponents, IdentifyInit } from './index.js';
4
3
  import type { IdentifyResult, AbortOptions, Connection, Startable } from '@libp2p/interface';
5
4
  import type { IncomingStreamData } from '@libp2p/interface-internal';
6
- export declare class Identify extends AbstractIdentify implements Startable, IdentifyInterface {
5
+ export declare class Identify implements Startable, IdentifyInterface {
6
+ #private;
7
+ private readonly identifyProtocolStr;
8
+ private readonly identifyPushProtocolStr;
9
+ readonly host: {
10
+ protocolVersion: string;
11
+ agentVersion: string;
12
+ };
13
+ private started;
14
+ private readonly timeout;
15
+ private readonly peerId;
16
+ private readonly peerStore;
17
+ private readonly registrar;
18
+ private readonly connectionManager;
19
+ private readonly addressManager;
20
+ private readonly maxInboundStreams;
21
+ private readonly maxOutboundStreams;
22
+ private readonly maxPushIncomingStreams;
23
+ private readonly maxPushOutgoingStreams;
24
+ private readonly maxIdentifyMessageSize;
25
+ private readonly maxObservedAddresses;
26
+ private readonly events;
27
+ private readonly runOnTransientConnection;
28
+ private readonly log;
7
29
  constructor(components: IdentifyComponents, init?: IdentifyInit);
30
+ isStarted(): boolean;
31
+ start(): Promise<void>;
32
+ stop(): Promise<void>;
33
+ /**
34
+ * Send an Identify Push update to the list of connections
35
+ */
36
+ pushToConnections(connections: Connection[]): Promise<void>;
37
+ /**
38
+ * Calls `push` on all peer connections
39
+ */
40
+ push(): Promise<void>;
8
41
  _identify(connection: Connection, options?: AbortOptions): Promise<IdentifyMessage>;
9
42
  identify(connection: Connection, options?: AbortOptions): Promise<IdentifyResult>;
10
43
  /**
11
44
  * Sends the `Identify` response with the Signed Peer Record
12
45
  * to the requesting peer over the given `connection`
13
46
  */
14
- handleProtocol(data: IncomingStreamData): Promise<void>;
47
+ _handleIdentify(data: IncomingStreamData): Promise<void>;
48
+ /**
49
+ * Reads the Identify Push message from the given `connection`
50
+ */
51
+ _handlePush(data: IncomingStreamData): Promise<void>;
15
52
  }
16
53
  //# sourceMappingURL=identify.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identify.d.ts","sourceRoot":"","sources":["../../src/identify.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAA4D,MAAM,YAAY,CAAA;AACvG,OAAO,KAAK,EAAE,QAAQ,IAAI,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACjG,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAU,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,qBAAa,QAAS,SAAQ,gBAAiB,YAAW,SAAS,EAAE,iBAAiB;gBACvE,UAAU,EAAE,kBAAkB,EAAE,IAAI,GAAE,YAAiB;IAgB9D,SAAS,CAAE,UAAU,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;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAQ;IAC/C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAQ;IAC/C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAQ;IAC/C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAQ;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAS;IAClD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;gBAEf,UAAU,EAAE,kBAAkB,EAAE,IAAI,GAAE,YAAiB;IAkDpE,SAAS,IAAK,OAAO;IAIf,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAkCvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IAO5B;;OAEG;IACG,iBAAiB,CAAE,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmDlE;;OAEG;IACG,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IA6BtB,SAAS,CAAE,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"}
@@ -1,20 +1,74 @@
1
1
  /* eslint-disable complexity */
2
- import { CodeError, setMaxListeners } from '@libp2p/interface';
2
+ import { CodeError, ERR_NOT_FOUND, setMaxListeners } from '@libp2p/interface';
3
3
  import { peerIdFromKeys } from '@libp2p/peer-id';
4
4
  import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record';
5
- import { protocols } from '@multiformats/multiaddr';
5
+ import { multiaddr, protocols } from '@multiformats/multiaddr';
6
6
  import { IP_OR_DOMAIN } from '@multiformats/multiaddr-matcher';
7
7
  import { pbStream } from 'it-protobuf-stream';
8
- import { MULTICODEC_IDENTIFY_PROTOCOL_NAME, MULTICODEC_IDENTIFY_PROTOCOL_VERSION } from './consts.js';
8
+ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
9
+ import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
10
+ import { isNode, isBrowser, isWebWorker, isElectronMain, isElectronRenderer, isReactNative } from 'wherearewe';
11
+ 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';
9
12
  import { Identify as IdentifyMessage } from './pb/message.js';
10
- import { AbstractIdentify, consumeIdentifyMessage, defaultValues, getCleanMultiaddr } from './utils.js';
11
- export class Identify extends AbstractIdentify {
13
+ // https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L52
14
+ const MAX_IDENTIFY_MESSAGE_SIZE = 1024 * 8;
15
+ const defaultValues = {
16
+ protocolPrefix: 'ipfs',
17
+ // https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L48
18
+ timeout: 60000,
19
+ maxInboundStreams: 1,
20
+ maxOutboundStreams: 1,
21
+ maxPushIncomingStreams: 1,
22
+ maxPushOutgoingStreams: 1,
23
+ maxObservedAddresses: 10,
24
+ maxIdentifyMessageSize: 8192,
25
+ runOnConnectionOpen: true,
26
+ runOnTransientConnection: true
27
+ };
28
+ export class Identify {
29
+ identifyProtocolStr;
30
+ identifyPushProtocolStr;
31
+ host;
32
+ started;
33
+ timeout;
34
+ peerId;
35
+ peerStore;
36
+ registrar;
37
+ connectionManager;
38
+ addressManager;
39
+ maxInboundStreams;
40
+ maxOutboundStreams;
41
+ maxPushIncomingStreams;
42
+ maxPushOutgoingStreams;
43
+ maxIdentifyMessageSize;
44
+ maxObservedAddresses;
45
+ events;
46
+ runOnTransientConnection;
47
+ log;
12
48
  constructor(components, init = {}) {
13
- super(components, {
14
- ...init,
15
- protocol: `/${init.protocolPrefix ?? defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`,
16
- log: components.logger.forComponent('libp2p:identify')
17
- });
49
+ this.started = false;
50
+ this.peerId = components.peerId;
51
+ this.peerStore = components.peerStore;
52
+ this.registrar = components.registrar;
53
+ this.addressManager = components.addressManager;
54
+ this.connectionManager = components.connectionManager;
55
+ this.events = components.events;
56
+ this.log = components.logger.forComponent('libp2p:identify');
57
+ this.identifyProtocolStr = `/${init.protocolPrefix ?? defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PROTOCOL_VERSION}`;
58
+ this.identifyPushProtocolStr = `/${init.protocolPrefix ?? defaultValues.protocolPrefix}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME}/${MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION}`;
59
+ this.timeout = init.timeout ?? defaultValues.timeout;
60
+ this.maxInboundStreams = init.maxInboundStreams ?? defaultValues.maxInboundStreams;
61
+ this.maxOutboundStreams = init.maxOutboundStreams ?? defaultValues.maxOutboundStreams;
62
+ this.maxPushIncomingStreams = init.maxPushIncomingStreams ?? defaultValues.maxPushIncomingStreams;
63
+ this.maxPushOutgoingStreams = init.maxPushOutgoingStreams ?? defaultValues.maxPushOutgoingStreams;
64
+ this.maxIdentifyMessageSize = init.maxIdentifyMessageSize ?? defaultValues.maxIdentifyMessageSize;
65
+ this.maxObservedAddresses = init.maxObservedAddresses ?? defaultValues.maxObservedAddresses;
66
+ this.runOnTransientConnection = init.runOnTransientConnection ?? defaultValues.runOnTransientConnection;
67
+ // Store self host metadata
68
+ this.host = {
69
+ protocolVersion: `${init.protocolPrefix ?? defaultValues.protocolPrefix}/${IDENTIFY_PROTOCOL_VERSION}`,
70
+ agentVersion: init.agentVersion ?? `${components.nodeInfo.name}/${components.nodeInfo.version}`
71
+ };
18
72
  if (init.runOnConnectionOpen ?? defaultValues.runOnConnectionOpen) {
19
73
  // When a new connection happens, trigger identify
20
74
  components.events.addEventListener('connection:open', (evt) => {
@@ -22,6 +76,129 @@ export class Identify extends AbstractIdentify {
22
76
  this.identify(connection).catch(err => { this.log.error('error during identify trigged by connection:open', err); });
23
77
  });
24
78
  }
79
+ // When self peer record changes, trigger identify-push
80
+ components.events.addEventListener('self:peer:update', (evt) => {
81
+ void this.push().catch(err => { this.log.error(err); });
82
+ });
83
+ // Append user agent version to default AGENT_VERSION depending on the environment
84
+ if (this.host.agentVersion === `${components.nodeInfo.name}/${components.nodeInfo.version}`) {
85
+ if (isNode || isElectronMain) {
86
+ this.host.agentVersion += ` UserAgent=${globalThis.process.version}`;
87
+ }
88
+ else if (isBrowser || isWebWorker || isElectronRenderer || isReactNative) {
89
+ this.host.agentVersion += ` UserAgent=${globalThis.navigator.userAgent}`;
90
+ }
91
+ }
92
+ }
93
+ isStarted() {
94
+ return this.started;
95
+ }
96
+ async start() {
97
+ if (this.started) {
98
+ return;
99
+ }
100
+ await this.peerStore.merge(this.peerId, {
101
+ metadata: {
102
+ AgentVersion: uint8ArrayFromString(this.host.agentVersion),
103
+ ProtocolVersion: uint8ArrayFromString(this.host.protocolVersion)
104
+ }
105
+ });
106
+ await this.registrar.handle(this.identifyProtocolStr, (data) => {
107
+ void this._handleIdentify(data).catch(err => {
108
+ this.log.error(err);
109
+ });
110
+ }, {
111
+ maxInboundStreams: this.maxInboundStreams,
112
+ maxOutboundStreams: this.maxOutboundStreams,
113
+ runOnTransientConnection: this.runOnTransientConnection
114
+ });
115
+ await this.registrar.handle(this.identifyPushProtocolStr, (data) => {
116
+ void this._handlePush(data).catch(err => {
117
+ this.log.error(err);
118
+ });
119
+ }, {
120
+ maxInboundStreams: this.maxPushIncomingStreams,
121
+ maxOutboundStreams: this.maxPushOutgoingStreams,
122
+ runOnTransientConnection: this.runOnTransientConnection
123
+ });
124
+ this.started = true;
125
+ }
126
+ async stop() {
127
+ await this.registrar.unhandle(this.identifyProtocolStr);
128
+ await this.registrar.unhandle(this.identifyPushProtocolStr);
129
+ this.started = false;
130
+ }
131
+ /**
132
+ * Send an Identify Push update to the list of connections
133
+ */
134
+ async pushToConnections(connections) {
135
+ const listenAddresses = this.addressManager.getAddresses().map(ma => ma.decapsulateCode(protocols('p2p').code));
136
+ const peerRecord = new PeerRecord({
137
+ peerId: this.peerId,
138
+ multiaddrs: listenAddresses
139
+ });
140
+ const signedPeerRecord = await RecordEnvelope.seal(peerRecord, this.peerId);
141
+ const supportedProtocols = this.registrar.getProtocols();
142
+ const peer = await this.peerStore.get(this.peerId);
143
+ const agentVersion = uint8ArrayToString(peer.metadata.get('AgentVersion') ?? uint8ArrayFromString(this.host.agentVersion));
144
+ const protocolVersion = uint8ArrayToString(peer.metadata.get('ProtocolVersion') ?? uint8ArrayFromString(this.host.protocolVersion));
145
+ const pushes = connections.map(async (connection) => {
146
+ let stream;
147
+ const signal = AbortSignal.timeout(this.timeout);
148
+ setMaxListeners(Infinity, signal);
149
+ try {
150
+ stream = await connection.newStream(this.identifyPushProtocolStr, {
151
+ signal,
152
+ runOnTransientConnection: this.runOnTransientConnection
153
+ });
154
+ const pb = pbStream(stream, {
155
+ maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE
156
+ }).pb(IdentifyMessage);
157
+ await pb.write({
158
+ listenAddrs: listenAddresses.map(ma => ma.bytes),
159
+ signedPeerRecord: signedPeerRecord.marshal(),
160
+ protocols: supportedProtocols,
161
+ agentVersion,
162
+ protocolVersion
163
+ }, {
164
+ signal
165
+ });
166
+ await stream.close({
167
+ signal
168
+ });
169
+ }
170
+ catch (err) {
171
+ // Just log errors
172
+ this.log.error('could not push identify update to peer', err);
173
+ stream?.abort(err);
174
+ }
175
+ });
176
+ await Promise.all(pushes);
177
+ }
178
+ /**
179
+ * Calls `push` on all peer connections
180
+ */
181
+ async push() {
182
+ // Do not try to push if we are not running
183
+ if (!this.isStarted()) {
184
+ return;
185
+ }
186
+ const connections = [];
187
+ await Promise.all(this.connectionManager.getConnections().map(async (conn) => {
188
+ try {
189
+ const peer = await this.peerStore.get(conn.remotePeer);
190
+ if (!peer.protocols.includes(this.identifyPushProtocolStr)) {
191
+ return;
192
+ }
193
+ connections.push(conn);
194
+ }
195
+ catch (err) {
196
+ if (err.code !== ERR_NOT_FOUND) {
197
+ throw err;
198
+ }
199
+ }
200
+ }));
201
+ await this.pushToConnections(connections);
25
202
  }
26
203
  async _identify(connection, options = {}) {
27
204
  let stream;
@@ -34,12 +211,12 @@ export class Identify extends AbstractIdentify {
34
211
  };
35
212
  }
36
213
  try {
37
- stream = await connection.newStream(this.protocol, {
214
+ stream = await connection.newStream(this.identifyProtocolStr, {
38
215
  ...options,
39
216
  runOnTransientConnection: this.runOnTransientConnection
40
217
  });
41
218
  const pb = pbStream(stream, {
42
- maxDataLength: this.maxMessageSize
219
+ maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE
43
220
  }).pb(IdentifyMessage);
44
221
  const message = await pb.read(options);
45
222
  await stream.close(options);
@@ -73,13 +250,13 @@ export class Identify extends AbstractIdentify {
73
250
  this.log('storing our observed address %a', cleanObservedAddr);
74
251
  this.addressManager.addObservedAddr(cleanObservedAddr);
75
252
  }
76
- return consumeIdentifyMessage(this.peerStore, this.events, this.log, connection, message);
253
+ return this.#consumeIdentifyMessage(connection, message);
77
254
  }
78
255
  /**
79
256
  * Sends the `Identify` response with the Signed Peer Record
80
257
  * to the requesting peer over the given `connection`
81
258
  */
82
- async handleProtocol(data) {
259
+ async _handleIdentify(data) {
83
260
  const { connection, stream } = data;
84
261
  const signal = AbortSignal.timeout(this.timeout);
85
262
  setMaxListeners(Infinity, signal);
@@ -121,5 +298,148 @@ export class Identify extends AbstractIdentify {
121
298
  stream.abort(err);
122
299
  }
123
300
  }
301
+ /**
302
+ * Reads the Identify Push message from the given `connection`
303
+ */
304
+ async _handlePush(data) {
305
+ const { connection, stream } = data;
306
+ try {
307
+ if (this.peerId.equals(connection.remotePeer)) {
308
+ throw new Error('received push from ourselves?');
309
+ }
310
+ const options = {
311
+ signal: AbortSignal.timeout(this.timeout)
312
+ };
313
+ const pb = pbStream(stream, {
314
+ maxDataLength: this.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE
315
+ }).pb(IdentifyMessage);
316
+ const message = await pb.read(options);
317
+ await stream.close(options);
318
+ await this.#consumeIdentifyMessage(connection, message);
319
+ }
320
+ catch (err) {
321
+ this.log.error('received invalid message', err);
322
+ stream.abort(err);
323
+ return;
324
+ }
325
+ this.log('handled push from %p', connection.remotePeer);
326
+ }
327
+ async #consumeIdentifyMessage(connection, message) {
328
+ this.log('received identify from %p', connection.remotePeer);
329
+ if (message == null) {
330
+ throw new CodeError('message was null or undefined', 'ERR_INVALID_MESSAGE');
331
+ }
332
+ const peer = {};
333
+ if (message.listenAddrs.length > 0) {
334
+ peer.addresses = message.listenAddrs.map(buf => ({
335
+ isCertified: false,
336
+ multiaddr: multiaddr(buf)
337
+ }));
338
+ }
339
+ if (message.protocols.length > 0) {
340
+ peer.protocols = message.protocols;
341
+ }
342
+ if (message.publicKey != null) {
343
+ peer.publicKey = message.publicKey;
344
+ const peerId = await peerIdFromKeys(message.publicKey);
345
+ if (!peerId.equals(connection.remotePeer)) {
346
+ throw new CodeError('public key did not match remote PeerId', 'ERR_INVALID_PUBLIC_KEY');
347
+ }
348
+ }
349
+ let output;
350
+ // if the peer record has been sent, prefer the addresses in the record as they are signed by the remote peer
351
+ if (message.signedPeerRecord != null) {
352
+ this.log('received signedPeerRecord from %p', connection.remotePeer);
353
+ let peerRecordEnvelope = message.signedPeerRecord;
354
+ const envelope = await RecordEnvelope.openAndCertify(peerRecordEnvelope, PeerRecord.DOMAIN);
355
+ let peerRecord = PeerRecord.createFromProtobuf(envelope.payload);
356
+ // Verify peerId
357
+ if (!peerRecord.peerId.equals(envelope.peerId)) {
358
+ throw new CodeError('signing key does not match PeerId in the PeerRecord', 'ERR_INVALID_SIGNING_KEY');
359
+ }
360
+ // Make sure remote peer is the one sending the record
361
+ if (!connection.remotePeer.equals(peerRecord.peerId)) {
362
+ throw new CodeError('signing key does not match remote PeerId', 'ERR_INVALID_PEER_RECORD_KEY');
363
+ }
364
+ let existingPeer;
365
+ try {
366
+ existingPeer = await this.peerStore.get(peerRecord.peerId);
367
+ }
368
+ catch (err) {
369
+ if (err.code !== 'ERR_NOT_FOUND') {
370
+ throw err;
371
+ }
372
+ }
373
+ if (existingPeer != null) {
374
+ // don't lose any existing metadata
375
+ peer.metadata = existingPeer.metadata;
376
+ // if we have previously received a signed record for this peer, compare it to the incoming one
377
+ if (existingPeer.peerRecordEnvelope != null) {
378
+ const storedEnvelope = await RecordEnvelope.createFromProtobuf(existingPeer.peerRecordEnvelope);
379
+ const storedRecord = PeerRecord.createFromProtobuf(storedEnvelope.payload);
380
+ // ensure seq is greater than, or equal to, the last received
381
+ if (storedRecord.seqNumber >= peerRecord.seqNumber) {
382
+ this.log('sequence number was lower or equal to existing sequence number - stored: %d received: %d', storedRecord.seqNumber, peerRecord.seqNumber);
383
+ peerRecord = storedRecord;
384
+ peerRecordEnvelope = existingPeer.peerRecordEnvelope;
385
+ }
386
+ }
387
+ }
388
+ // store the signed record for next time
389
+ peer.peerRecordEnvelope = peerRecordEnvelope;
390
+ // override the stored addresses with the signed multiaddrs
391
+ peer.addresses = peerRecord.multiaddrs.map(multiaddr => ({
392
+ isCertified: true,
393
+ multiaddr
394
+ }));
395
+ output = {
396
+ seq: peerRecord.seqNumber,
397
+ addresses: peerRecord.multiaddrs
398
+ };
399
+ }
400
+ else {
401
+ this.log('%p did not send a signed peer record', connection.remotePeer);
402
+ }
403
+ this.log('patching %p with', connection.remotePeer, peer);
404
+ await this.peerStore.patch(connection.remotePeer, peer);
405
+ if (message.agentVersion != null || message.protocolVersion != null) {
406
+ const metadata = {};
407
+ if (message.agentVersion != null) {
408
+ metadata.AgentVersion = uint8ArrayFromString(message.agentVersion);
409
+ }
410
+ if (message.protocolVersion != null) {
411
+ metadata.ProtocolVersion = uint8ArrayFromString(message.protocolVersion);
412
+ }
413
+ this.log('merging %p metadata', connection.remotePeer, metadata);
414
+ await this.peerStore.merge(connection.remotePeer, {
415
+ metadata
416
+ });
417
+ }
418
+ const result = {
419
+ peerId: connection.remotePeer,
420
+ protocolVersion: message.protocolVersion,
421
+ agentVersion: message.agentVersion,
422
+ publicKey: message.publicKey,
423
+ listenAddrs: message.listenAddrs.map(buf => multiaddr(buf)),
424
+ observedAddr: message.observedAddr == null ? undefined : multiaddr(message.observedAddr),
425
+ protocols: message.protocols,
426
+ signedPeerRecord: output,
427
+ connection
428
+ };
429
+ this.events.safeDispatchEvent('peer:identify', { detail: result });
430
+ return result;
431
+ }
432
+ }
433
+ /**
434
+ * Takes the `addr` and converts it to a Multiaddr if possible
435
+ */
436
+ function getCleanMultiaddr(addr) {
437
+ if (addr != null && addr.length > 0) {
438
+ try {
439
+ return multiaddr(addr);
440
+ }
441
+ catch {
442
+ }
443
+ }
124
444
  }
125
445
  //# sourceMappingURL=identify.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identify.js","sourceRoot":"","sources":["../../src/identify.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,UAA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