@libp2p/peer-record 1.0.12 → 2.0.0

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 CHANGED
@@ -1,9 +1,16 @@
1
- # libp2p-peer-record <!-- omit in toc -->
1
+ # @libp2p/peer-record <!-- omit in toc -->
2
2
 
3
- > Peer records are signed records that contain the address information of network peers
3
+ [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4
+ [![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
5
+ [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
6
+ [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-peer-record.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-peer-record)
7
+ [![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-peer-record/actions/workflows/js-test-and-release.yml)
4
8
 
5
- ## Table of Contents <!-- omit in toc -->
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
- - [Contribution](#contribution)
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
- const Record = require('libp2p-interfaces/src/record')
42
- const { fromString } = require('uint8arrays/from-string')
53
+ import { PeerRecord } from '@libp2p/peer-record'
54
+ import { fromString } from 'uint8arrays/from-string'
43
55
 
44
- class ExampleRecord extends Record {
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
- const Envelope = require('libp2p/src/record/envelop')
59
- const ExampleRecord = require('./example-record')
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 Envelope.seal(rec, peerId)
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
- const Envelope = require('libp2p/src/record/envelop')
70
- const ExampleRecord = require('./example-record')
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 Envelope.openAndCertify(wireData, domain)
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
- const PeerRecord = require('libp2p/src/record/peer-record')
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
- const PeerRecord = require('libp2p/src/record/peer-record')
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
- **_NOT_YET_IMPLEMENTED_**
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
- * Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0)
175
- * MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT)
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
- ### Contribution
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/interfaces/peer-id';
2
- import type { Record, Envelope } from '@libp2p/interfaces/record';
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,E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AAgB,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,5 +1,5 @@
1
1
  import { Multiaddr } from '@multiformats/multiaddr';
2
- import type { PeerId } from '@libp2p/interfaces/peer-id';
2
+ import type { PeerId } from '@libp2p/interface-peer-id';
3
3
  export interface PeerRecordInit {
4
4
  peerId: PeerId;
5
5
  /**
@@ -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,4BAA4B,CAAA;AASxD,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"}
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": "1.0.12",
3
+ "version": "2.0.0",
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-interfaces/tree/master/packages/libp2p-peer-record#readme",
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-interfaces.git"
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-interfaces/issues"
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,10 +141,11 @@
140
141
  "release": "aegir release"
141
142
  },
142
143
  "dependencies": {
143
- "@libp2p/crypto": "^0.22.8",
144
- "@libp2p/interfaces": "^2.0.0",
144
+ "@libp2p/crypto": "^1.0.0",
145
+ "@libp2p/interface-peer-id": "^1.0.2",
146
+ "@libp2p/interface-record": "^1.0.1",
145
147
  "@libp2p/logger": "^1.1.0",
146
- "@libp2p/peer-id": "^1.1.0",
148
+ "@libp2p/peer-id": "^1.1.13",
147
149
  "@libp2p/utils": "^1.0.9",
148
150
  "@multiformats/multiaddr": "^10.1.5",
149
151
  "err-code": "^3.0.1",
@@ -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/interfaces/peer-id'
11
- import type { Record, Envelope } from '@libp2p/interfaces/record'
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
@@ -1,5 +1,5 @@
1
1
  import { Multiaddr } from '@multiformats/multiaddr'
2
- import type { PeerId } from '@libp2p/interfaces/peer-id'
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'