@libp2p/identify 0.0.0-97ab31c0c
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/LICENSE +4 -0
- package/README.md +53 -0
- package/dist/index.min.js +45 -0
- package/dist/src/consts.d.ts +9 -0
- package/dist/src/consts.d.ts.map +1 -0
- package/dist/src/consts.js +9 -0
- package/dist/src/consts.js.map +1 -0
- package/dist/src/identify.d.ts +55 -0
- package/dist/src/identify.d.ts.map +1 -0
- package/dist/src/identify.js +446 -0
- package/dist/src/identify.js.map +1 -0
- package/dist/src/index.d.ts +88 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +32 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/pb/message.d.ts +17 -0
- package/dist/src/pb/message.d.ts.map +1 -0
- package/dist/src/pb/message.js +98 -0
- package/dist/src/pb/message.js.map +1 -0
- package/package.json +75 -0
- package/src/consts.ts +9 -0
- package/src/identify.ts +559 -0
- package/src/index.ts +108 -0
- package/src/pb/message.proto +30 -0
- package/src/pb/message.ts +126 -0
|
@@ -0,0 +1,32 @@
|
|
|
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 { MULTICODEC_IDENTIFY, MULTICODEC_IDENTIFY_PUSH } from './consts.js';
|
|
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
|
+
};
|
|
29
|
+
export function identify(init = {}) {
|
|
30
|
+
return (components) => new IdentifyClass(components, init);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AA4DzD;;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,17 @@
|
|
|
1
|
+
import type { Codec } from 'protons-runtime';
|
|
2
|
+
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
3
|
+
export interface Identify {
|
|
4
|
+
protocolVersion?: string;
|
|
5
|
+
agentVersion?: string;
|
|
6
|
+
publicKey?: Uint8Array;
|
|
7
|
+
listenAddrs: Uint8Array[];
|
|
8
|
+
observedAddr?: Uint8Array;
|
|
9
|
+
protocols: string[];
|
|
10
|
+
signedPeerRecord?: Uint8Array;
|
|
11
|
+
}
|
|
12
|
+
export declare namespace Identify {
|
|
13
|
+
const codec: () => Codec<Identify>;
|
|
14
|
+
const encode: (obj: Partial<Identify>) => Uint8Array;
|
|
15
|
+
const decode: (buf: Uint8Array | Uint8ArrayList) => Identify;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,QAAQ;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,YAAY,CAAC,EAAE,UAAU,CAAA;IACzB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,gBAAgB,CAAC,EAAE,UAAU,CAAA;CAC9B;AAED,yBAAiB,QAAQ,CAAC;IAGjB,MAAM,KAAK,QAAO,MAAM,QAAQ,CA6FtC,CAAA;IAEM,MAAM,MAAM,QAAS,QAAQ,QAAQ,CAAC,KAAG,UAE/C,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,GAAG,cAAc,KAAG,QAEzD,CAAA;CACF"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/* eslint-disable import/export */
|
|
2
|
+
/* eslint-disable complexity */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
6
|
+
import { encodeMessage, decodeMessage, message } from 'protons-runtime';
|
|
7
|
+
export var Identify;
|
|
8
|
+
(function (Identify) {
|
|
9
|
+
let _codec;
|
|
10
|
+
Identify.codec = () => {
|
|
11
|
+
if (_codec == null) {
|
|
12
|
+
_codec = message((obj, w, opts = {}) => {
|
|
13
|
+
if (opts.lengthDelimited !== false) {
|
|
14
|
+
w.fork();
|
|
15
|
+
}
|
|
16
|
+
if (obj.protocolVersion != null) {
|
|
17
|
+
w.uint32(42);
|
|
18
|
+
w.string(obj.protocolVersion);
|
|
19
|
+
}
|
|
20
|
+
if (obj.agentVersion != null) {
|
|
21
|
+
w.uint32(50);
|
|
22
|
+
w.string(obj.agentVersion);
|
|
23
|
+
}
|
|
24
|
+
if (obj.publicKey != null) {
|
|
25
|
+
w.uint32(10);
|
|
26
|
+
w.bytes(obj.publicKey);
|
|
27
|
+
}
|
|
28
|
+
if (obj.listenAddrs != null) {
|
|
29
|
+
for (const value of obj.listenAddrs) {
|
|
30
|
+
w.uint32(18);
|
|
31
|
+
w.bytes(value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (obj.observedAddr != null) {
|
|
35
|
+
w.uint32(34);
|
|
36
|
+
w.bytes(obj.observedAddr);
|
|
37
|
+
}
|
|
38
|
+
if (obj.protocols != null) {
|
|
39
|
+
for (const value of obj.protocols) {
|
|
40
|
+
w.uint32(26);
|
|
41
|
+
w.string(value);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (obj.signedPeerRecord != null) {
|
|
45
|
+
w.uint32(66);
|
|
46
|
+
w.bytes(obj.signedPeerRecord);
|
|
47
|
+
}
|
|
48
|
+
if (opts.lengthDelimited !== false) {
|
|
49
|
+
w.ldelim();
|
|
50
|
+
}
|
|
51
|
+
}, (reader, length) => {
|
|
52
|
+
const obj = {
|
|
53
|
+
listenAddrs: [],
|
|
54
|
+
protocols: []
|
|
55
|
+
};
|
|
56
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
57
|
+
while (reader.pos < end) {
|
|
58
|
+
const tag = reader.uint32();
|
|
59
|
+
switch (tag >>> 3) {
|
|
60
|
+
case 5:
|
|
61
|
+
obj.protocolVersion = reader.string();
|
|
62
|
+
break;
|
|
63
|
+
case 6:
|
|
64
|
+
obj.agentVersion = reader.string();
|
|
65
|
+
break;
|
|
66
|
+
case 1:
|
|
67
|
+
obj.publicKey = reader.bytes();
|
|
68
|
+
break;
|
|
69
|
+
case 2:
|
|
70
|
+
obj.listenAddrs.push(reader.bytes());
|
|
71
|
+
break;
|
|
72
|
+
case 4:
|
|
73
|
+
obj.observedAddr = reader.bytes();
|
|
74
|
+
break;
|
|
75
|
+
case 3:
|
|
76
|
+
obj.protocols.push(reader.string());
|
|
77
|
+
break;
|
|
78
|
+
case 8:
|
|
79
|
+
obj.signedPeerRecord = reader.bytes();
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
reader.skipType(tag & 7);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return obj;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return _codec;
|
|
90
|
+
};
|
|
91
|
+
Identify.encode = (obj) => {
|
|
92
|
+
return encodeMessage(obj, Identify.codec());
|
|
93
|
+
};
|
|
94
|
+
Identify.decode = (buf) => {
|
|
95
|
+
return decodeMessage(buf, Identify.codec());
|
|
96
|
+
};
|
|
97
|
+
})(Identify || (Identify = {}));
|
|
98
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+BAA+B;AAC/B,oDAAoD;AACpD,8EAA8E;AAC9E,0DAA0D;AAE1D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAcvE,MAAM,KAAW,QAAQ,CAyGxB;AAzGD,WAAiB,QAAQ;IACvB,IAAI,MAAuB,CAAA;IAEd,cAAK,GAAG,GAAoB,EAAE;QACzC,IAAI,MAAM,IAAI,IAAI,EAAE;YAClB,MAAM,GAAG,OAAO,CAAW,CAAC,GAAG,EAAE,CAAC,EAAE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,MAAM,EAAE,CAAC,CAAA;4BACnC,MAAK;wBACP,KAAK,CAAC;4BACJ,GAAG,CAAC,gBAAgB,GAAG,MAAM,CAAC,KAAK,EAAE,CAAA;4BACrC,MAAK;wBACP;4BACE,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;4BACxB,MAAK;qBACR;iBACF;gBAED,OAAO,GAAG,CAAA;YACZ,CAAC,CAAC,CAAA;SACH;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAEY,eAAM,GAAG,CAAC,GAAsB,EAAc,EAAE;QAC3D,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;IAC7C,CAAC,CAAA;IAEY,eAAM,GAAG,CAAC,GAAgC,EAAY,EAAE;QACnE,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;IAC7C,CAAC,CAAA;AACH,CAAC,EAzGgB,QAAQ,KAAR,QAAQ,QAyGxB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@libp2p/identify",
|
|
3
|
+
"version": "0.0.0-97ab31c0c",
|
|
4
|
+
"description": "Implementation of the Identify Protocol",
|
|
5
|
+
"license": "Apache-2.0 OR MIT",
|
|
6
|
+
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/protocol-identify#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/libp2p/js-libp2p.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/libp2p/js-libp2p/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"types": "./dist/src/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"dist",
|
|
19
|
+
"!dist/test",
|
|
20
|
+
"!**/*.tsbuildinfo"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/src/index.d.ts",
|
|
25
|
+
"import": "./dist/src/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"eslintConfig": {
|
|
29
|
+
"extends": "ipfs",
|
|
30
|
+
"parserOptions": {
|
|
31
|
+
"project": true,
|
|
32
|
+
"sourceType": "module"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"start": "node dist/src/main.js",
|
|
37
|
+
"build": "aegir build",
|
|
38
|
+
"test": "aegir test",
|
|
39
|
+
"clean": "aegir clean",
|
|
40
|
+
"generate": "protons ./src/pb/index.proto",
|
|
41
|
+
"lint": "aegir lint",
|
|
42
|
+
"test:chrome": "aegir test -t browser --cov",
|
|
43
|
+
"test:chrome-webworker": "aegir test -t webworker",
|
|
44
|
+
"test:firefox": "aegir test -t browser -- --browser firefox",
|
|
45
|
+
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
|
|
46
|
+
"test:node": "aegir test -t node --cov",
|
|
47
|
+
"dep-check": "aegir dep-check"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@libp2p/interface": "0.1.6-97ab31c0c",
|
|
51
|
+
"@libp2p/interface-internal": "0.1.9-97ab31c0c",
|
|
52
|
+
"@libp2p/peer-id": "3.0.6-97ab31c0c",
|
|
53
|
+
"@libp2p/peer-record": "6.0.9-97ab31c0c",
|
|
54
|
+
"@multiformats/multiaddr": "^12.1.10",
|
|
55
|
+
"@multiformats/multiaddr-matcher": "^1.1.0",
|
|
56
|
+
"it-length-prefixed": "^9.0.3",
|
|
57
|
+
"it-protobuf-stream": "^1.0.2",
|
|
58
|
+
"protons-runtime": "^5.0.0",
|
|
59
|
+
"uint8arraylist": "^2.4.3",
|
|
60
|
+
"uint8arrays": "^4.0.6",
|
|
61
|
+
"wherearewe": "^2.0.1"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@libp2p/logger": "3.1.0-97ab31c0c",
|
|
65
|
+
"@libp2p/peer-id-factory": "3.0.8-97ab31c0c",
|
|
66
|
+
"aegir": "^41.0.2",
|
|
67
|
+
"delay": "^6.0.0",
|
|
68
|
+
"it-drain": "^3.0.3",
|
|
69
|
+
"it-pair": "^2.0.6",
|
|
70
|
+
"it-pushable": "^3.2.1",
|
|
71
|
+
"protons": "^7.3.0",
|
|
72
|
+
"sinon": "^17.0.0",
|
|
73
|
+
"sinon-ts": "^2.0.0"
|
|
74
|
+
}
|
|
75
|
+
}
|
package/src/consts.ts
ADDED
|
@@ -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
|
+
|
|
5
|
+
export const IDENTIFY_PROTOCOL_VERSION = '0.1.0'
|
|
6
|
+
export const MULTICODEC_IDENTIFY_PROTOCOL_NAME = 'id'
|
|
7
|
+
export const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME = 'id/push'
|
|
8
|
+
export const MULTICODEC_IDENTIFY_PROTOCOL_VERSION = '1.0.0'
|
|
9
|
+
export const MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION = '1.0.0'
|