@libp2p/peer-record 1.0.11 → 2.0.1
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 +32 -26
- package/dist/src/envelope/index.d.ts +2 -2
- package/dist/src/envelope/index.d.ts.map +1 -1
- package/dist/src/peer-record/index.d.ts +1 -1
- package/dist/src/peer-record/index.d.ts.map +1 -1
- package/package.json +12 -10
- package/src/envelope/index.ts +2 -2
- package/src/peer-record/index.ts +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
# libp2p
|
|
1
|
+
# @libp2p/peer-record <!-- omit in toc -->
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](http://libp2p.io/)
|
|
4
|
+
[](http://webchat.freenode.net/?channels=%23libp2p)
|
|
5
|
+
[](https://discuss.libp2p.io)
|
|
6
|
+
[](https://codecov.io/gh/libp2p/js-libp2p-peer-record)
|
|
7
|
+
[](https://github.com/libp2p/js-libp2p-peer-record/actions/workflows/js-test-and-release.yml)
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
> Used to transfer signed peer data across the network
|
|
6
10
|
|
|
11
|
+
## Table of contents <!-- omit in toc -->
|
|
12
|
+
|
|
13
|
+
- [Install](#install)
|
|
7
14
|
- [Description](#description)
|
|
8
15
|
- [Envelope](#envelope)
|
|
9
16
|
- [Usage](#usage)
|
|
@@ -16,9 +23,14 @@
|
|
|
16
23
|
- [Subsystem providing a record](#subsystem-providing-a-record)
|
|
17
24
|
- [Future Work](#future-work)
|
|
18
25
|
- [Example](#example)
|
|
19
|
-
- [Installation](#installation)
|
|
20
26
|
- [License](#license)
|
|
21
|
-
|
|
27
|
+
- [Contribution](#contribution)
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```console
|
|
32
|
+
$ npm i @libp2p/peer-record
|
|
33
|
+
```
|
|
22
34
|
|
|
23
35
|
## Description
|
|
24
36
|
|
|
@@ -38,10 +50,10 @@ You can read further about the envelope in [libp2p/specs#217](https://github.com
|
|
|
38
50
|
|
|
39
51
|
```js
|
|
40
52
|
// interface-record implementation example with the "libp2p-example" namespace
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
import { PeerRecord } from '@libp2p/peer-record'
|
|
54
|
+
import { fromString } from 'uint8arrays/from-string'
|
|
43
55
|
|
|
44
|
-
class ExampleRecord extends
|
|
56
|
+
class ExampleRecord extends PeerRecord {
|
|
45
57
|
constructor () {
|
|
46
58
|
super ('libp2p-example', fromString('0302', 'hex'))
|
|
47
59
|
}
|
|
@@ -55,25 +67,25 @@ ExampleRecord.createFromProtobuf = () => {}
|
|
|
55
67
|
```
|
|
56
68
|
|
|
57
69
|
```js
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
import { PeerEnvelope } from '@libp2p/peer-record'
|
|
71
|
+
import { ExampleRecord } from './example-record.js'
|
|
60
72
|
|
|
61
73
|
const rec = new ExampleRecord()
|
|
62
|
-
const e = await
|
|
74
|
+
const e = await PeerEnvelope.seal(rec, peerId)
|
|
63
75
|
const wireData = e.marshal()
|
|
64
76
|
```
|
|
65
77
|
|
|
66
78
|
- consume a received envelope (`wireData`) and transform it back to a record:
|
|
67
79
|
|
|
68
80
|
```js
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
import { PeerEnvelope } from '@libp2p/peer-record'
|
|
82
|
+
import { ExampleRecord } from './example-record.js'
|
|
71
83
|
|
|
72
84
|
const domain = 'libp2p-example'
|
|
73
85
|
let e
|
|
74
86
|
|
|
75
87
|
try {
|
|
76
|
-
e = await
|
|
88
|
+
e = await PeerEnvelope.openAndCertify(wireData, domain)
|
|
77
89
|
} catch (err) {}
|
|
78
90
|
|
|
79
91
|
const rec = ExampleRecord.createFromProtobuf(e.payload)
|
|
@@ -94,7 +106,7 @@ You can read further about the Peer Record in [libp2p/specs#217](https://github.
|
|
|
94
106
|
- create a new Peer Record
|
|
95
107
|
|
|
96
108
|
```js
|
|
97
|
-
|
|
109
|
+
import { PeerRecord } from '@libp2p/peer-record'
|
|
98
110
|
|
|
99
111
|
const pr = new PeerRecord({
|
|
100
112
|
peerId: node.peerId,
|
|
@@ -105,7 +117,7 @@ const pr = new PeerRecord({
|
|
|
105
117
|
- create a Peer Record from a protobuf
|
|
106
118
|
|
|
107
119
|
```js
|
|
108
|
-
|
|
120
|
+
import { PeerRecord } from '@libp2p/peer-record'
|
|
109
121
|
|
|
110
122
|
const pr = PeerRecord.createFromProtobuf(data)
|
|
111
123
|
```
|
|
@@ -120,7 +132,7 @@ The identify service is responsible for creating the self record when the identi
|
|
|
120
132
|
|
|
121
133
|
#### Self record Updates
|
|
122
134
|
|
|
123
|
-
|
|
135
|
+
***NOT\_YET\_IMPLEMENTED***
|
|
124
136
|
|
|
125
137
|
While creating peer records is fairly trivial, addresses are not static and might be modified at arbitrary times. This can happen via an Address Manager API, or even through AutoRelay/AutoNAT.
|
|
126
138
|
|
|
@@ -161,19 +173,13 @@ const map = trackedMap<string, string>({ metrics })
|
|
|
161
173
|
map.set('key', 'value')
|
|
162
174
|
```
|
|
163
175
|
|
|
164
|
-
## Installation
|
|
165
|
-
|
|
166
|
-
```console
|
|
167
|
-
$ npm i @libp2p/peer-record
|
|
168
|
-
```
|
|
169
|
-
|
|
170
176
|
## License
|
|
171
177
|
|
|
172
178
|
Licensed under either of
|
|
173
179
|
|
|
174
|
-
|
|
175
|
-
|
|
180
|
+
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
181
|
+
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
176
182
|
|
|
177
|
-
|
|
183
|
+
## Contribution
|
|
178
184
|
|
|
179
185
|
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PeerId } from '@libp2p/
|
|
2
|
-
import type { Record, Envelope } from '@libp2p/
|
|
1
|
+
import type { PeerId } from '@libp2p/interface-peer-id';
|
|
2
|
+
import type { Record, Envelope } from '@libp2p/interface-record';
|
|
3
3
|
export interface EnvelopeInit {
|
|
4
4
|
peerId: PeerId;
|
|
5
5
|
payloadType: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/envelope/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/envelope/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEhE,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,UAAU,CAAA;IACvB,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,UAAU,CAAA;CACtB;AAED,qBAAa,cAAe,YAAW,QAAQ;IAC7C;;OAEG;IACH,MAAM,CAAC,kBAAkB,SAAgB,UAAU,6BAUlD;IAED;;;OAGG;IACH,MAAM,CAAC,IAAI,WAAkB,MAAM,UAAU,MAAM,6BAoBlD;IAED;;;OAGG;IACH,MAAM,CAAC,cAAc,SAAgB,UAAU,UAAU,MAAM,6BAS9D;IAEM,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,UAAU,CAAA;IACvB,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,UAAU,CAAA;IACrB,SAAS,CAAC,EAAE,UAAU,CAAA;IAE7B;;;OAGG;gBACU,IAAI,EAAE,YAAY;IAS/B;;OAEG;IACH,OAAO;IAiBP;;OAEG;IACH,MAAM,CAAE,KAAK,EAAE,QAAQ;IAIvB;;OAEG;IACG,QAAQ,CAAE,MAAM,EAAE,MAAM;CAW/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-record/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-record/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AASvD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,EAAE,CAAA;IAExB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB;;OAEG;IACH,MAAM,CAAC,kBAAkB,QAAS,UAAU,KAAG,UAAU,CAOxD;IAED,MAAM,CAAC,MAAM,SAA8B;IAC3C,MAAM,CAAC,KAAK,aAAoC;IAEzC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,SAAS,EAAE,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,SAAoB;IAC1B,KAAK,aAAmB;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAY;gBAEjB,IAAI,EAAE,cAAc;IAQjC;;OAEG;IACH,OAAO;IAcP;;OAEG;IACH,MAAM,CAAE,KAAK,EAAE,OAAO;CAsBvB"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/peer-record",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Used to transfer signed peer data across the network",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
|
-
"homepage": "https://github.com/libp2p/js-libp2p-
|
|
6
|
+
"homepage": "https://github.com/libp2p/js-libp2p-peer-record#readme",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/libp2p/js-libp2p-
|
|
9
|
+
"url": "git+https://github.com/libp2p/js-libp2p-peer-record.git"
|
|
10
10
|
},
|
|
11
11
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/libp2p/js-libp2p-
|
|
12
|
+
"url": "https://github.com/libp2p/js-libp2p-peer-record/issues"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"IPFS"
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
|
+
"types": "./src/index.d.ts",
|
|
31
32
|
"import": "./dist/src/index.js"
|
|
32
33
|
}
|
|
33
34
|
},
|
|
@@ -140,11 +141,12 @@
|
|
|
140
141
|
"release": "aegir release"
|
|
141
142
|
},
|
|
142
143
|
"dependencies": {
|
|
143
|
-
"@libp2p/crypto": "^0.
|
|
144
|
-
"@libp2p/
|
|
145
|
-
"@libp2p/
|
|
146
|
-
"@libp2p/
|
|
147
|
-
"@libp2p/
|
|
144
|
+
"@libp2p/crypto": "^1.0.0",
|
|
145
|
+
"@libp2p/interface-peer-id": "^1.0.2",
|
|
146
|
+
"@libp2p/interface-record": "^1.0.1",
|
|
147
|
+
"@libp2p/logger": "^2.0.0",
|
|
148
|
+
"@libp2p/peer-id": "^1.1.13",
|
|
149
|
+
"@libp2p/utils": "^2.0.0",
|
|
148
150
|
"@multiformats/multiaddr": "^10.1.5",
|
|
149
151
|
"err-code": "^3.0.1",
|
|
150
152
|
"interface-datastore": "^6.1.0",
|
|
@@ -159,7 +161,7 @@
|
|
|
159
161
|
"varint": "^6.0.0"
|
|
160
162
|
},
|
|
161
163
|
"devDependencies": {
|
|
162
|
-
"@libp2p/interface-compliance-tests": "^
|
|
164
|
+
"@libp2p/interface-compliance-tests": "^2.0.0",
|
|
163
165
|
"@libp2p/peer-id-factory": "^1.0.0",
|
|
164
166
|
"@types/varint": "^6.0.0",
|
|
165
167
|
"aegir": "^37.0.7",
|
package/src/envelope/index.ts
CHANGED
|
@@ -7,8 +7,8 @@ import { equals as uint8arraysEquals } from 'uint8arrays/equals'
|
|
|
7
7
|
import { codes } from '../errors.js'
|
|
8
8
|
import { Envelope as Protobuf } from './envelope.js'
|
|
9
9
|
import { peerIdFromKeys } from '@libp2p/peer-id'
|
|
10
|
-
import type { PeerId } from '@libp2p/
|
|
11
|
-
import type { Record, Envelope } from '@libp2p/
|
|
10
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
11
|
+
import type { Record, Envelope } from '@libp2p/interface-record'
|
|
12
12
|
|
|
13
13
|
export interface EnvelopeInit {
|
|
14
14
|
peerId: PeerId
|
package/src/peer-record/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Multiaddr } from '@multiformats/multiaddr'
|
|
2
|
-
import type { PeerId } from '@libp2p/
|
|
2
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
3
3
|
import { arrayEquals } from '@libp2p/utils/array-equals'
|
|
4
4
|
import { peerIdFromBytes } from '@libp2p/peer-id'
|
|
5
5
|
import { PeerRecord as Protobuf } from './peer-record.js'
|