@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.
@@ -3,16 +3,7 @@
3
3
  *
4
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
5
  *
6
- * This protocol allows network peers to discover the multiaddrs the current node listens on, and the protocols it supports.
7
- *
8
- * A second function, `identifyPush` is also exported to add support for [identify/push](https://github.com/libp2p/specs/blob/master/identify/README.md#identifypush).
9
- *
10
- * This protocol will send updates to all connected peers when the multiaddrs or protocols of the current node change.
11
- *
12
- * > [!TIP]
13
- * > For maximum network compatibility you should configure both protocols
14
- *
15
- * @example Enabling identify
6
+ * @example
16
7
  *
17
8
  * ```typescript
18
9
  * import { createLibp2p } from 'libp2p'
@@ -25,28 +16,12 @@
25
16
  * }
26
17
  * })
27
18
  * ```
28
- *
29
- * @example Enabling identify push
30
- *
31
- * ```typescript
32
- * import { createLibp2p } from 'libp2p'
33
- * import { identifyPush } from '@libp2p/identify'
34
- *
35
- * const node = await createLibp2p({
36
- * // ...other options
37
- * services: {
38
- * identifyPush: identifyPush()
39
- * }
40
- * })
41
- * ```
42
19
  */
43
20
  import type { AbortOptions, IdentifyResult, Libp2pEvents, ComponentLogger, NodeInfo, TypedEventTarget, PeerId, PeerStore, Connection } from '@libp2p/interface';
44
21
  import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal';
45
22
  export interface IdentifyInit {
46
23
  /**
47
- * The prefix to use for the protocol
48
- *
49
- * @default 'ipfs'
24
+ * The prefix to use for the protocol (default: 'ipfs')
50
25
  */
51
26
  protocolPrefix?: string;
52
27
  /**
@@ -55,73 +30,43 @@ export interface IdentifyInit {
55
30
  agentVersion?: string;
56
31
  /**
57
32
  * How long we should wait for a remote peer to send their identify response
58
- *
59
- * @default 5000
60
33
  */
61
34
  timeout?: number;
62
35
  /**
63
- * Identify responses larger than this in bytes will be rejected
64
- *
65
- * @default 8192
66
- */
67
- maxMessageSize?: number;
68
- /**
69
- * The maximum number of inbound streams that may be open on a single
70
- * connection for this protocol
71
- *
72
- * @default 1
36
+ * Identify responses larger than this in bytes will be rejected (default: 8192)
73
37
  */
38
+ maxIdentifyMessageSize?: number;
74
39
  maxInboundStreams?: number;
75
- /**
76
- * The maximum number of outbound streams that may be open on a single
77
- * connection for this protocol
78
- *
79
- * @default 1
80
- */
81
40
  maxOutboundStreams?: number;
82
- /**
83
- * The maximum number of observed addresses to send in an Identify message
84
- */
41
+ maxPushIncomingStreams?: number;
42
+ maxPushOutgoingStreams?: number;
85
43
  maxObservedAddresses?: number;
86
44
  /**
87
- * Whether to run on connections with data or duration limits
88
- *
89
- * @default true
90
- */
91
- runOnTransientConnection?: boolean;
92
- /**
93
- * Whether to automatically run identify on newly opened connections
94
- *
95
- * @default true
45
+ * Whether to automatically dial identify on newly opened connections (default: true)
96
46
  */
97
47
  runOnConnectionOpen?: boolean;
98
- }
99
- export interface IdentifyPushInit extends Omit<IdentifyInit, 'runOnConnectionOpen'> {
100
48
  /**
101
- * Whether to automatically dial identify-push on self updates
102
- *
103
- * @default true
49
+ * Whether to run on connections with data or duration limits (default: true)
104
50
  */
105
- runOnSelfUpdate?: boolean;
106
- /**
107
- * Push to this many connections in parallel
108
- *
109
- * @default 32
110
- */
111
- concurrency?: number;
51
+ runOnTransientConnection?: boolean;
112
52
  }
113
53
  export interface IdentifyComponents {
114
54
  peerId: PeerId;
115
55
  peerStore: PeerStore;
56
+ connectionManager: ConnectionManager;
116
57
  registrar: Registrar;
117
58
  addressManager: AddressManager;
118
59
  events: TypedEventTarget<Libp2pEvents>;
119
60
  logger: ComponentLogger;
120
61
  nodeInfo: NodeInfo;
121
62
  }
122
- export interface IdentifyPushComponents extends IdentifyComponents {
123
- connectionManager: ConnectionManager;
124
- }
63
+ /**
64
+ * The protocols the Identify service supports
65
+ */
66
+ export declare const multicodecs: {
67
+ IDENTIFY: string;
68
+ IDENTIFY_PUSH: string;
69
+ };
125
70
  export interface Identify {
126
71
  /**
127
72
  * due to the default limits on inbound/outbound streams for this protocol,
@@ -131,10 +76,7 @@ export interface Identify {
131
76
  * you may be better off configuring a topology to be notified instead.
132
77
  */
133
78
  identify(connection: Connection, options?: AbortOptions): Promise<IdentifyResult>;
134
- }
135
- export interface IdentifyPush {
136
79
  push(): Promise<void>;
137
80
  }
138
81
  export declare function identify(init?: IdentifyInit): (components: IdentifyComponents) => Identify;
139
- export declare function identifyPush(init?: IdentifyPushInit): (components: IdentifyPushComponents) => IdentifyPush;
140
82
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC/J,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE9F,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAE7B;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAElC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AAE,YAAiB,GAAG,CAAC,UAAU,EAAE,kBAAkB,KAAK,QAAQ,CAE/F"}
package/dist/src/index.js CHANGED
@@ -3,16 +3,7 @@
3
3
  *
4
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
5
  *
6
- * This protocol allows network peers to discover the multiaddrs the current node listens on, and the protocols it supports.
7
- *
8
- * A second function, `identifyPush` is also exported to add support for [identify/push](https://github.com/libp2p/specs/blob/master/identify/README.md#identifypush).
9
- *
10
- * This protocol will send updates to all connected peers when the multiaddrs or protocols of the current node change.
11
- *
12
- * > [!TIP]
13
- * > For maximum network compatibility you should configure both protocols
14
- *
15
- * @example Enabling identify
6
+ * @example
16
7
  *
17
8
  * ```typescript
18
9
  * import { createLibp2p } from 'libp2p'
@@ -25,27 +16,17 @@
25
16
  * }
26
17
  * })
27
18
  * ```
28
- *
29
- * @example Enabling identify push
30
- *
31
- * ```typescript
32
- * import { createLibp2p } from 'libp2p'
33
- * import { identifyPush } from '@libp2p/identify'
34
- *
35
- * const node = await createLibp2p({
36
- * // ...other options
37
- * services: {
38
- * identifyPush: identifyPush()
39
- * }
40
- * })
41
- * ```
42
19
  */
43
- import { IdentifyPush as IdentifyPushClass } from './identify-push.js';
20
+ import { MULTICODEC_IDENTIFY, MULTICODEC_IDENTIFY_PUSH } from './consts.js';
44
21
  import { Identify as IdentifyClass } from './identify.js';
22
+ /**
23
+ * The protocols the Identify service supports
24
+ */
25
+ export const multicodecs = {
26
+ IDENTIFY: MULTICODEC_IDENTIFY,
27
+ IDENTIFY_PUSH: MULTICODEC_IDENTIFY_PUSH
28
+ };
45
29
  export function identify(init = {}) {
46
30
  return (components) => new IdentifyClass(components, init);
47
31
  }
48
- export function identifyPush(init = {}) {
49
- return (components) => new IdentifyPushClass(components, init);
50
- }
51
32
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AAgHzD,MAAM,UAAU,QAAQ,CAAE,OAAqB,EAAE;IAC/C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,YAAY,CAAE,OAAyB,EAAE;IACvD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAChE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AAsDzD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,mBAAmB;IAC7B,aAAa,EAAE,wBAAwB;CACxC,CAAA;AAeD,MAAM,UAAU,QAAQ,CAAE,OAAqB,EAAE;IAC/C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAC5D,CAAC"}
@@ -0,0 +1,12 @@
1
+ {
2
+ "Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
3
+ ".:Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
4
+ "IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
5
+ ".:IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
6
+ "IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
7
+ ".:IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
8
+ "multicodecs": "https://libp2p.github.io/js-libp2p/variables/_libp2p_identify.multicodecs.html",
9
+ ".:multicodecs": "https://libp2p.github.io/js-libp2p/variables/_libp2p_identify.multicodecs.html",
10
+ "identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify-1.html",
11
+ ".:identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify-1.html"
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/identify",
3
- "version": "1.0.21-9d13a2f6a",
3
+ "version": "1.0.21",
4
4
  "description": "Implementation of the Identify Protocol",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-identify#readme",
@@ -52,14 +52,12 @@
52
52
  "doc-check": "aegir doc-check"
53
53
  },
54
54
  "dependencies": {
55
- "@libp2p/interface": "1.3.1-9d13a2f6a",
56
- "@libp2p/interface-internal": "1.2.0-9d13a2f6a",
57
- "@libp2p/peer-id": "4.1.1-9d13a2f6a",
58
- "@libp2p/peer-record": "7.0.16-9d13a2f6a",
55
+ "@libp2p/interface": "^1.3.1",
56
+ "@libp2p/interface-internal": "^1.2.0",
57
+ "@libp2p/peer-id": "^4.1.1",
58
+ "@libp2p/peer-record": "^7.0.16",
59
59
  "@multiformats/multiaddr": "^12.2.1",
60
60
  "@multiformats/multiaddr-matcher": "^1.2.0",
61
- "it-drain": "^3.0.7",
62
- "it-parallel": "^3.0.7",
63
61
  "it-protobuf-stream": "^1.1.2",
64
62
  "protons-runtime": "^5.4.0",
65
63
  "uint8arraylist": "^2.4.8",
@@ -67,11 +65,12 @@
67
65
  "wherearewe": "^2.0.1"
68
66
  },
69
67
  "devDependencies": {
70
- "@libp2p/interface-compliance-tests": "5.4.3-9d13a2f6a",
71
- "@libp2p/logger": "4.0.12-9d13a2f6a",
72
- "@libp2p/peer-id-factory": "4.1.1-9d13a2f6a",
68
+ "@libp2p/interface-compliance-tests": "^5.4.3",
69
+ "@libp2p/logger": "^4.0.12",
70
+ "@libp2p/peer-id-factory": "^4.1.1",
73
71
  "aegir": "^42.2.5",
74
72
  "delay": "^6.0.0",
73
+ "it-drain": "^3.0.5",
75
74
  "it-length-prefixed": "^9.0.4",
76
75
  "it-pair": "^2.0.6",
77
76
  "it-pushable": "^3.2.3",
package/src/consts.ts CHANGED
@@ -7,9 +7,3 @@ export const MULTICODEC_IDENTIFY_PROTOCOL_NAME = 'id'
7
7
  export const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME = 'id/push'
8
8
  export const MULTICODEC_IDENTIFY_PROTOCOL_VERSION = '1.0.0'
9
9
  export const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION = '1.0.0'
10
-
11
- // https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L52
12
- export const MAX_IDENTIFY_MESSAGE_SIZE = 1024 * 8
13
-
14
- // https://github.com/libp2p/go-libp2p/blob/0385ec924bad172f74a74db09939e97c079b1420/p2p/protocol/identify/id.go#L47C7-L47C25
15
- export const MAX_PUSH_CONCURRENCY = 32