@libp2p/peer-record 7.0.9 → 7.0.10-1fc929c1c

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.
@@ -9,55 +9,38 @@
9
9
  *
10
10
  * This envelope stores a marshaled record implementing the [interface-record](https://github.com/libp2p/js-libp2p/blob/main/packages/interface/src/record/index.ts). These Records are designed to be serialized to bytes and placed inside of the envelopes before being shared with other peers.
11
11
  *
12
- * You can read further about the envelope in [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
12
+ * You can read further about the envelope in [RFC 0002 - Signed Envelopes](https://github.com/libp2p/specs/blob/master/RFC/0002-signed-envelopes.md). For the original discussion about it you can look at the PR that was used to create it: [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
13
13
  *
14
14
  * @example Creating a peer record
15
15
  *
16
16
  * Create an envelope with an instance of an [interface-record](https://github.com/libp2p/js-libp2p/blob/main/packages/interface/src/record/index.ts) implementation and prepare it for being exchanged:
17
17
  *
18
- * ```js
19
- * // interface-record implementation example with the "libp2p-example" namespace
20
- * import { PeerRecord } from '@libp2p/peer-record'
21
- * import { fromString } from 'uint8arrays/from-string'
22
- *
23
- * class ExampleRecord extends PeerRecord {
24
- * constructor () {
25
- * super ('libp2p-example', fromString('0302', 'hex'))
26
- * }
27
- *
28
- * marshal () {}
29
- *
30
- * equals (other) {}
31
- * }
18
+ * ```TypeScript
19
+ * import { PeerRecord, RecordEnvelope } from '@libp2p/peer-record'
20
+ * import { createEd25519PeerId } from '@libp2p/peer-id-factory'
32
21
  *
33
- * ExampleRecord.createFromProtobuf = () => {}
34
- * ```
22
+ * const peerId = await createEd25519PeerId()
35
23
  *
36
- * ```js
37
- * import { PeerEnvelope } from '@libp2p/peer-record'
38
- * import { ExampleRecord } from './example-record.js'
24
+ * const record = new PeerRecord({
25
+ * peerId,
26
+ * // ...other data
27
+ * })
39
28
  *
40
- * const rec = new ExampleRecord()
41
- * const e = await PeerEnvelope.seal(rec, peerId)
42
- * const wireData = e.marshal()
29
+ * const envelope = await RecordEnvelope.seal(record, peerId)
30
+ * const wireData = envelope.marshal()
43
31
  * ```
44
32
  *
45
33
  * @example Consuming a peer record
46
34
  *
47
- * Consume a received envelope (`wireData`) and transform it back to a record:
35
+ * Consume a received envelope `wireData` and transform it back to a record:
48
36
  *
49
- * ```js
50
- * import { PeerEnvelope } from '@libp2p/peer-record'
51
- * import { ExampleRecord } from './example-record.js'
37
+ * ```TypeScript
38
+ * import { PeerRecord, RecordEnvelope } from '@libp2p/peer-record'
52
39
  *
53
- * const domain = 'libp2p-example'
54
- * let e
40
+ * const wireData = Uint8Array.from([0, 1, 2, 3, 4])
41
+ * const envelope = await RecordEnvelope.openAndCertify(wireData, PeerRecord.DOMAIN)
55
42
  *
56
- * try {
57
- * e = await PeerEnvelope.openAndCertify(wireData, domain)
58
- * } catch (err) {}
59
- *
60
- * const rec = ExampleRecord.createFromProtobuf(e.payload)
43
+ * const record = PeerRecord.createFromProtobuf(envelope.payload)
61
44
  * ```
62
45
  *
63
46
  * ## Peer Record
@@ -68,18 +51,25 @@
68
51
  *
69
52
  * A peer record contains the peers' publicly reachable listen addresses, and may be extended in the future to contain additional metadata relevant to routing. It also contains a `seqNumber` field, a timestamp per the spec, so that we can verify the most recent record.
70
53
  *
71
- * You can read further about the Peer Record in [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
54
+ * You can read further about the Peer Record in [RFC 0003 - Peer Routing Records](https://github.com/libp2p/specs/blob/master/RFC/0003-routing-records.md). For the original discussion about it you can view the PR that created the RFC: [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
72
55
  *
73
56
  * @example
74
57
  *
75
58
  * Create a new Peer Record
76
59
  *
77
- * ```js
60
+ * ```TypeScript
78
61
  * import { PeerRecord } from '@libp2p/peer-record'
62
+ * import { createEd25519PeerId } from '@libp2p/peer-id-factory'
63
+ * import { multiaddr } from '@multiformats/multiaddr'
64
+ *
65
+ * const peerId = await createEd25519PeerId()
79
66
  *
80
- * const pr = new PeerRecord({
81
- * peerId: node.peerId,
82
- * multiaddrs: node.multiaddrs
67
+ * const record = new PeerRecord({
68
+ * peerId: peerId,
69
+ * multiaddrs: [
70
+ * multiaddr('/ip4/...'),
71
+ * multiaddr('/ip4/...')
72
+ * ]
83
73
  * })
84
74
  * ```
85
75
  *
@@ -87,10 +77,11 @@
87
77
  *
88
78
  * Create a Peer Record from a protobuf
89
79
  *
90
- * ```js
80
+ * ```TypeScript
91
81
  * import { PeerRecord } from '@libp2p/peer-record'
92
82
  *
93
- * const pr = PeerRecord.createFromProtobuf(data)
83
+ * const data = Uint8Array.from([0, 1, 2, 3, 4])
84
+ * const record = PeerRecord.createFromProtobuf(data)
94
85
  * ```
95
86
  *
96
87
  * ## Libp2p Flows
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4HG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA"}
package/dist/src/index.js CHANGED
@@ -9,55 +9,38 @@
9
9
  *
10
10
  * This envelope stores a marshaled record implementing the [interface-record](https://github.com/libp2p/js-libp2p/blob/main/packages/interface/src/record/index.ts). These Records are designed to be serialized to bytes and placed inside of the envelopes before being shared with other peers.
11
11
  *
12
- * You can read further about the envelope in [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
12
+ * You can read further about the envelope in [RFC 0002 - Signed Envelopes](https://github.com/libp2p/specs/blob/master/RFC/0002-signed-envelopes.md). For the original discussion about it you can look at the PR that was used to create it: [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
13
13
  *
14
14
  * @example Creating a peer record
15
15
  *
16
16
  * Create an envelope with an instance of an [interface-record](https://github.com/libp2p/js-libp2p/blob/main/packages/interface/src/record/index.ts) implementation and prepare it for being exchanged:
17
17
  *
18
- * ```js
19
- * // interface-record implementation example with the "libp2p-example" namespace
20
- * import { PeerRecord } from '@libp2p/peer-record'
21
- * import { fromString } from 'uint8arrays/from-string'
22
- *
23
- * class ExampleRecord extends PeerRecord {
24
- * constructor () {
25
- * super ('libp2p-example', fromString('0302', 'hex'))
26
- * }
27
- *
28
- * marshal () {}
29
- *
30
- * equals (other) {}
31
- * }
18
+ * ```TypeScript
19
+ * import { PeerRecord, RecordEnvelope } from '@libp2p/peer-record'
20
+ * import { createEd25519PeerId } from '@libp2p/peer-id-factory'
32
21
  *
33
- * ExampleRecord.createFromProtobuf = () => {}
34
- * ```
22
+ * const peerId = await createEd25519PeerId()
35
23
  *
36
- * ```js
37
- * import { PeerEnvelope } from '@libp2p/peer-record'
38
- * import { ExampleRecord } from './example-record.js'
24
+ * const record = new PeerRecord({
25
+ * peerId,
26
+ * // ...other data
27
+ * })
39
28
  *
40
- * const rec = new ExampleRecord()
41
- * const e = await PeerEnvelope.seal(rec, peerId)
42
- * const wireData = e.marshal()
29
+ * const envelope = await RecordEnvelope.seal(record, peerId)
30
+ * const wireData = envelope.marshal()
43
31
  * ```
44
32
  *
45
33
  * @example Consuming a peer record
46
34
  *
47
- * Consume a received envelope (`wireData`) and transform it back to a record:
35
+ * Consume a received envelope `wireData` and transform it back to a record:
48
36
  *
49
- * ```js
50
- * import { PeerEnvelope } from '@libp2p/peer-record'
51
- * import { ExampleRecord } from './example-record.js'
37
+ * ```TypeScript
38
+ * import { PeerRecord, RecordEnvelope } from '@libp2p/peer-record'
52
39
  *
53
- * const domain = 'libp2p-example'
54
- * let e
40
+ * const wireData = Uint8Array.from([0, 1, 2, 3, 4])
41
+ * const envelope = await RecordEnvelope.openAndCertify(wireData, PeerRecord.DOMAIN)
55
42
  *
56
- * try {
57
- * e = await PeerEnvelope.openAndCertify(wireData, domain)
58
- * } catch (err) {}
59
- *
60
- * const rec = ExampleRecord.createFromProtobuf(e.payload)
43
+ * const record = PeerRecord.createFromProtobuf(envelope.payload)
61
44
  * ```
62
45
  *
63
46
  * ## Peer Record
@@ -68,18 +51,25 @@
68
51
  *
69
52
  * A peer record contains the peers' publicly reachable listen addresses, and may be extended in the future to contain additional metadata relevant to routing. It also contains a `seqNumber` field, a timestamp per the spec, so that we can verify the most recent record.
70
53
  *
71
- * You can read further about the Peer Record in [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
54
+ * You can read further about the Peer Record in [RFC 0003 - Peer Routing Records](https://github.com/libp2p/specs/blob/master/RFC/0003-routing-records.md). For the original discussion about it you can view the PR that created the RFC: [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
72
55
  *
73
56
  * @example
74
57
  *
75
58
  * Create a new Peer Record
76
59
  *
77
- * ```js
60
+ * ```TypeScript
78
61
  * import { PeerRecord } from '@libp2p/peer-record'
62
+ * import { createEd25519PeerId } from '@libp2p/peer-id-factory'
63
+ * import { multiaddr } from '@multiformats/multiaddr'
64
+ *
65
+ * const peerId = await createEd25519PeerId()
79
66
  *
80
- * const pr = new PeerRecord({
81
- * peerId: node.peerId,
82
- * multiaddrs: node.multiaddrs
67
+ * const record = new PeerRecord({
68
+ * peerId: peerId,
69
+ * multiaddrs: [
70
+ * multiaddr('/ip4/...'),
71
+ * multiaddr('/ip4/...')
72
+ * ]
83
73
  * })
84
74
  * ```
85
75
  *
@@ -87,10 +77,11 @@
87
77
  *
88
78
  * Create a Peer Record from a protobuf
89
79
  *
90
- * ```js
80
+ * ```TypeScript
91
81
  * import { PeerRecord } from '@libp2p/peer-record'
92
82
  *
93
- * const pr = PeerRecord.createFromProtobuf(data)
83
+ * const data = Uint8Array.from([0, 1, 2, 3, 4])
84
+ * const record = PeerRecord.createFromProtobuf(data)
94
85
  * ```
95
86
  *
96
87
  * ## Libp2p Flows
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4HG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/peer-record",
3
- "version": "7.0.9",
3
+ "version": "7.0.10-1fc929c1c",
4
4
  "description": "Used to transfer signed peer data across the network",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-record#readme",
@@ -49,6 +49,7 @@
49
49
  "clean": "aegir clean",
50
50
  "lint": "aegir lint",
51
51
  "dep-check": "aegir dep-check",
52
+ "doc-check": "aegir doc-check",
52
53
  "generate": "protons src/envelope/envelope.proto src/peer-record/peer-record.proto",
53
54
  "build": "aegir build",
54
55
  "test": "aegir test",
@@ -60,19 +61,19 @@
60
61
  "test:electron-main": "aegir test -t electron-main"
61
62
  },
62
63
  "dependencies": {
63
- "@libp2p/crypto": "^4.0.2",
64
- "@libp2p/interface": "^1.1.3",
65
- "@libp2p/peer-id": "^4.0.6",
66
- "@libp2p/utils": "^5.2.5",
64
+ "@libp2p/crypto": "4.0.3-1fc929c1c",
65
+ "@libp2p/interface": "1.1.4-1fc929c1c",
66
+ "@libp2p/peer-id": "4.0.7-1fc929c1c",
67
+ "@libp2p/utils": "5.2.6-1fc929c1c",
67
68
  "@multiformats/multiaddr": "^12.1.14",
68
69
  "protons-runtime": "^5.4.0",
69
70
  "uint8-varint": "^2.0.4",
70
71
  "uint8arraylist": "^2.4.8",
71
- "uint8arrays": "^5.0.1"
72
+ "uint8arrays": "^5.0.2"
72
73
  },
73
74
  "devDependencies": {
74
- "@libp2p/peer-id-factory": "^4.0.6",
75
- "aegir": "^42.2.3",
75
+ "@libp2p/peer-id-factory": "4.0.7-1fc929c1c",
76
+ "aegir": "^42.2.4",
76
77
  "protons": "^7.5.0"
77
78
  },
78
79
  "sideEffects": false
package/src/index.ts CHANGED
@@ -9,55 +9,38 @@
9
9
  *
10
10
  * This envelope stores a marshaled record implementing the [interface-record](https://github.com/libp2p/js-libp2p/blob/main/packages/interface/src/record/index.ts). These Records are designed to be serialized to bytes and placed inside of the envelopes before being shared with other peers.
11
11
  *
12
- * You can read further about the envelope in [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
12
+ * You can read further about the envelope in [RFC 0002 - Signed Envelopes](https://github.com/libp2p/specs/blob/master/RFC/0002-signed-envelopes.md). For the original discussion about it you can look at the PR that was used to create it: [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
13
13
  *
14
14
  * @example Creating a peer record
15
15
  *
16
16
  * Create an envelope with an instance of an [interface-record](https://github.com/libp2p/js-libp2p/blob/main/packages/interface/src/record/index.ts) implementation and prepare it for being exchanged:
17
17
  *
18
- * ```js
19
- * // interface-record implementation example with the "libp2p-example" namespace
20
- * import { PeerRecord } from '@libp2p/peer-record'
21
- * import { fromString } from 'uint8arrays/from-string'
22
- *
23
- * class ExampleRecord extends PeerRecord {
24
- * constructor () {
25
- * super ('libp2p-example', fromString('0302', 'hex'))
26
- * }
27
- *
28
- * marshal () {}
29
- *
30
- * equals (other) {}
31
- * }
18
+ * ```TypeScript
19
+ * import { PeerRecord, RecordEnvelope } from '@libp2p/peer-record'
20
+ * import { createEd25519PeerId } from '@libp2p/peer-id-factory'
32
21
  *
33
- * ExampleRecord.createFromProtobuf = () => {}
34
- * ```
22
+ * const peerId = await createEd25519PeerId()
35
23
  *
36
- * ```js
37
- * import { PeerEnvelope } from '@libp2p/peer-record'
38
- * import { ExampleRecord } from './example-record.js'
24
+ * const record = new PeerRecord({
25
+ * peerId,
26
+ * // ...other data
27
+ * })
39
28
  *
40
- * const rec = new ExampleRecord()
41
- * const e = await PeerEnvelope.seal(rec, peerId)
42
- * const wireData = e.marshal()
29
+ * const envelope = await RecordEnvelope.seal(record, peerId)
30
+ * const wireData = envelope.marshal()
43
31
  * ```
44
32
  *
45
33
  * @example Consuming a peer record
46
34
  *
47
- * Consume a received envelope (`wireData`) and transform it back to a record:
35
+ * Consume a received envelope `wireData` and transform it back to a record:
48
36
  *
49
- * ```js
50
- * import { PeerEnvelope } from '@libp2p/peer-record'
51
- * import { ExampleRecord } from './example-record.js'
37
+ * ```TypeScript
38
+ * import { PeerRecord, RecordEnvelope } from '@libp2p/peer-record'
52
39
  *
53
- * const domain = 'libp2p-example'
54
- * let e
40
+ * const wireData = Uint8Array.from([0, 1, 2, 3, 4])
41
+ * const envelope = await RecordEnvelope.openAndCertify(wireData, PeerRecord.DOMAIN)
55
42
  *
56
- * try {
57
- * e = await PeerEnvelope.openAndCertify(wireData, domain)
58
- * } catch (err) {}
59
- *
60
- * const rec = ExampleRecord.createFromProtobuf(e.payload)
43
+ * const record = PeerRecord.createFromProtobuf(envelope.payload)
61
44
  * ```
62
45
  *
63
46
  * ## Peer Record
@@ -68,18 +51,25 @@
68
51
  *
69
52
  * A peer record contains the peers' publicly reachable listen addresses, and may be extended in the future to contain additional metadata relevant to routing. It also contains a `seqNumber` field, a timestamp per the spec, so that we can verify the most recent record.
70
53
  *
71
- * You can read further about the Peer Record in [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
54
+ * You can read further about the Peer Record in [RFC 0003 - Peer Routing Records](https://github.com/libp2p/specs/blob/master/RFC/0003-routing-records.md). For the original discussion about it you can view the PR that created the RFC: [libp2p/specs#217](https://github.com/libp2p/specs/pull/217).
72
55
  *
73
56
  * @example
74
57
  *
75
58
  * Create a new Peer Record
76
59
  *
77
- * ```js
60
+ * ```TypeScript
78
61
  * import { PeerRecord } from '@libp2p/peer-record'
62
+ * import { createEd25519PeerId } from '@libp2p/peer-id-factory'
63
+ * import { multiaddr } from '@multiformats/multiaddr'
64
+ *
65
+ * const peerId = await createEd25519PeerId()
79
66
  *
80
- * const pr = new PeerRecord({
81
- * peerId: node.peerId,
82
- * multiaddrs: node.multiaddrs
67
+ * const record = new PeerRecord({
68
+ * peerId: peerId,
69
+ * multiaddrs: [
70
+ * multiaddr('/ip4/...'),
71
+ * multiaddr('/ip4/...')
72
+ * ]
83
73
  * })
84
74
  * ```
85
75
  *
@@ -87,10 +77,11 @@
87
77
  *
88
78
  * Create a Peer Record from a protobuf
89
79
  *
90
- * ```js
80
+ * ```TypeScript
91
81
  * import { PeerRecord } from '@libp2p/peer-record'
92
82
  *
93
- * const pr = PeerRecord.createFromProtobuf(data)
83
+ * const data = Uint8Array.from([0, 1, 2, 3, 4])
84
+ * const record = PeerRecord.createFromProtobuf(data)
94
85
  * ```
95
86
  *
96
87
  * ## Libp2p Flows
@@ -1,6 +0,0 @@
1
- {
2
- "PeerRecord": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_record.PeerRecord.html",
3
- "RecordEnvelope": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_record.RecordEnvelope.html",
4
- "PeerRecordInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_peer_record.PeerRecordInit.html",
5
- "RecordEnvelopeInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_peer_record.RecordEnvelopeInit.html"
6
- }