@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.
- package/README.md +1 -24
- package/dist/index.min.js +3 -3
- package/dist/src/consts.d.ts +0 -2
- package/dist/src/consts.d.ts.map +1 -1
- package/dist/src/consts.js +0 -4
- package/dist/src/consts.js.map +1 -1
- package/dist/src/identify.d.ts +40 -3
- package/dist/src/identify.d.ts.map +1 -1
- package/dist/src/identify.js +334 -14
- package/dist/src/identify.js.map +1 -1
- package/dist/src/index.d.ts +17 -75
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -28
- package/dist/src/index.js.map +1 -1
- package/dist/typedoc-urls.json +12 -0
- package/package.json +9 -10
- package/src/consts.ts +0 -6
- package/src/identify.ts +404 -16
- package/src/index.ts +20 -81
- package/dist/src/identify-push.d.ts +0 -18
- package/dist/src/identify-push.d.ts.map +0 -1
- package/dist/src/identify-push.js +0 -120
- package/dist/src/identify-push.js.map +0 -1
- package/dist/src/utils.d.ts +0 -53
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -217
- package/dist/src/utils.js.map +0 -1
- package/src/identify-push.ts +0 -146
- package/src/utils.ts +0 -273
package/dist/src/index.d.ts
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
|
-
*
|
|
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
|
-
|
|
84
|
-
*/
|
|
41
|
+
maxPushIncomingStreams?: number;
|
|
42
|
+
maxPushOutgoingStreams?: number;
|
|
85
43
|
maxObservedAddresses?: number;
|
|
86
44
|
/**
|
|
87
|
-
* Whether to
|
|
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
|
|
102
|
-
*
|
|
103
|
-
* @default true
|
|
49
|
+
* Whether to run on connections with data or duration limits (default: true)
|
|
104
50
|
*/
|
|
105
|
-
|
|
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
|
-
|
|
123
|
-
|
|
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
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC/J,OAAO,KAAK,EAAE,cAAc,EAAE,iB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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
|
-
*
|
|
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 {
|
|
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
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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
|
|
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
|
|
56
|
-
"@libp2p/interface-internal": "1.2.0
|
|
57
|
-
"@libp2p/peer-id": "4.1.1
|
|
58
|
-
"@libp2p/peer-record": "7.0.16
|
|
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
|
|
71
|
-
"@libp2p/logger": "4.0.12
|
|
72
|
-
"@libp2p/peer-id-factory": "4.1.1
|
|
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
|