@libp2p/dcutr 1.0.12 → 1.0.13

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,3 +1,5 @@
1
+ # @libp2p/dcutr
2
+
1
3
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
2
4
  [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
3
5
  [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
@@ -7,6 +9,21 @@
7
9
 
8
10
  # About
9
11
 
12
+ <!--
13
+
14
+ !IMPORTANT!
15
+
16
+ Everything in this README between "# About" and "# Install" is automatically
17
+ generated and will be overwritten the next time the doc generator is run.
18
+
19
+ To make changes to this section, please update the @packageDocumentation section
20
+ of src/index.js or src/index.ts
21
+
22
+ To experiment with formatting, please run "npm run docs" from the root of this
23
+ repo and examine the changes made.
24
+
25
+ -->
26
+
10
27
  Direct Connection Upgrade through Relay (DCUtR) is a protocol that allows two
11
28
  nodes to connect to each other who would otherwise be prevented doing so due
12
29
  to being behind NATed connections or firewalls.
@@ -19,10 +36,11 @@ at precisely the same moment.
19
36
 
20
37
  ```TypeScript
21
38
  import { createLibp2p } from 'libp2p'
22
- import { circuitRelayTransport } from 'libp2p/circuit-relay'
39
+ import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
23
40
  import { tcp } from '@libp2p/tcp'
24
41
  import { identify } from '@libp2p/identify'
25
42
  import { dcutr } from '@libp2p/dcutr'
43
+ import { multiaddr } from '@multiformats/multiaddr'
26
44
 
27
45
  const node = await createLibp2p({
28
46
  transports: [
@@ -37,7 +55,8 @@ const node = await createLibp2p({
37
55
 
38
56
  // QmTarget is a peer that is behind a NAT, supports TCP and has a relay
39
57
  // reservation
40
- await node.dial('/ip4/.../p2p/QmRelay/p2p-circuit/p2p/QmTarget')
58
+ const ma = multiaddr('/ip4/.../p2p/QmRelay/p2p-circuit/p2p/QmTarget')
59
+ await node.dial(ma)
41
60
 
42
61
  // after a while the connection should automatically get upgraded to a
43
62
  // direct connection (e.g. non-transient)
@@ -51,7 +70,7 @@ while (true) {
51
70
  console.info('have relayed connection')
52
71
 
53
72
  // wait a few seconds to see if it's succeeded yet
54
- await new Promise((resolve) => {
73
+ await new Promise<void>((resolve) => {
55
74
  setTimeout(() => resolve(), 5000)
56
75
  })
57
76
  }
@@ -13,10 +13,11 @@
13
13
  *
14
14
  * ```TypeScript
15
15
  * import { createLibp2p } from 'libp2p'
16
- * import { circuitRelayTransport } from 'libp2p/circuit-relay'
16
+ * import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
17
17
  * import { tcp } from '@libp2p/tcp'
18
18
  * import { identify } from '@libp2p/identify'
19
19
  * import { dcutr } from '@libp2p/dcutr'
20
+ * import { multiaddr } from '@multiformats/multiaddr'
20
21
  *
21
22
  * const node = await createLibp2p({
22
23
  * transports: [
@@ -31,7 +32,8 @@
31
32
  *
32
33
  * // QmTarget is a peer that is behind a NAT, supports TCP and has a relay
33
34
  * // reservation
34
- * await node.dial('/ip4/.../p2p/QmRelay/p2p-circuit/p2p/QmTarget')
35
+ * const ma = multiaddr('/ip4/.../p2p/QmRelay/p2p-circuit/p2p/QmTarget')
36
+ * await node.dial(ma)
35
37
  *
36
38
  * // after a while the connection should automatically get upgraded to a
37
39
  * // direct connection (e.g. non-transient)
@@ -45,7 +47,7 @@
45
47
  * console.info('have relayed connection')
46
48
  *
47
49
  * // wait a few seconds to see if it's succeeded yet
48
- * await new Promise((resolve) => {
50
+ * await new Promise<void>((resolve) => {
49
51
  * setTimeout(() => resolve(), 5000)
50
52
  * })
51
53
  * }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC,EAAE,MAAM,CAAA;IAEhB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,SAAS,CAAA;IACpB,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,SAAS,EAAE,SAAS,CAAA;IACpB,cAAc,EAAE,cAAc,CAAA;IAC9B,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,MAAM,EAAE,eAAe,CAAA;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,kBAAkB,CAAA;AAEzC,wBAAgB,KAAK,CAAE,IAAI,GAAE,gBAAqB,GAAG,CAAC,UAAU,EAAE,sBAAsB,KAAK,OAAO,CAEnG"}
package/dist/src/index.js CHANGED
@@ -13,10 +13,11 @@
13
13
  *
14
14
  * ```TypeScript
15
15
  * import { createLibp2p } from 'libp2p'
16
- * import { circuitRelayTransport } from 'libp2p/circuit-relay'
16
+ * import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
17
17
  * import { tcp } from '@libp2p/tcp'
18
18
  * import { identify } from '@libp2p/identify'
19
19
  * import { dcutr } from '@libp2p/dcutr'
20
+ * import { multiaddr } from '@multiformats/multiaddr'
20
21
  *
21
22
  * const node = await createLibp2p({
22
23
  * transports: [
@@ -31,7 +32,8 @@
31
32
  *
32
33
  * // QmTarget is a peer that is behind a NAT, supports TCP and has a relay
33
34
  * // reservation
34
- * await node.dial('/ip4/.../p2p/QmRelay/p2p-circuit/p2p/QmTarget')
35
+ * const ma = multiaddr('/ip4/.../p2p/QmRelay/p2p-circuit/p2p/QmTarget')
36
+ * await node.dial(ma)
35
37
  *
36
38
  * // after a while the connection should automatically get upgraded to a
37
39
  * // direct connection (e.g. non-transient)
@@ -45,7 +47,7 @@
45
47
  * console.info('have relayed connection')
46
48
  *
47
49
  * // wait a few seconds to see if it's succeeded yet
48
- * await new Promise((resolve) => {
50
+ * await new Promise<void>((resolve) => {
49
51
  * setTimeout(() => resolve(), 5000)
50
52
  * })
51
53
  * }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAqChD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAA;AAEzC,MAAM,UAAU,KAAK,CAAE,OAAyB,EAAE;IAChD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAClE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAqChD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAA;AAEzC,MAAM,UAAU,KAAK,CAAE,OAAyB,EAAE;IAChD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAClE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/dcutr",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Implementation of the DCUtR Protocol",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-dcutr#readme",
@@ -48,12 +48,13 @@
48
48
  "test:firefox": "aegir test -t browser -- --browser firefox",
49
49
  "test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
50
50
  "test:node": "aegir test -t node --cov",
51
- "dep-check": "aegir dep-check"
51
+ "dep-check": "aegir dep-check",
52
+ "doc-check": "aegir doc-check"
52
53
  },
53
54
  "dependencies": {
54
- "@libp2p/interface": "^1.1.3",
55
- "@libp2p/interface-internal": "^1.0.8",
56
- "@libp2p/utils": "^5.2.5",
55
+ "@libp2p/interface": "^1.1.4",
56
+ "@libp2p/interface-internal": "^1.0.9",
57
+ "@libp2p/utils": "^5.2.6",
57
58
  "@multiformats/multiaddr": "^12.1.14",
58
59
  "@multiformats/multiaddr-matcher": "^1.1.2",
59
60
  "delay": "^6.0.0",
@@ -62,7 +63,7 @@
62
63
  "uint8arraylist": "^2.4.8"
63
64
  },
64
65
  "devDependencies": {
65
- "aegir": "^42.2.3",
66
+ "aegir": "^42.2.4",
66
67
  "protons": "^7.5.0",
67
68
  "sinon": "^17.0.1",
68
69
  "sinon-ts": "^2.0.0"
package/src/index.ts CHANGED
@@ -13,10 +13,11 @@
13
13
  *
14
14
  * ```TypeScript
15
15
  * import { createLibp2p } from 'libp2p'
16
- * import { circuitRelayTransport } from 'libp2p/circuit-relay'
16
+ * import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
17
17
  * import { tcp } from '@libp2p/tcp'
18
18
  * import { identify } from '@libp2p/identify'
19
19
  * import { dcutr } from '@libp2p/dcutr'
20
+ * import { multiaddr } from '@multiformats/multiaddr'
20
21
  *
21
22
  * const node = await createLibp2p({
22
23
  * transports: [
@@ -31,7 +32,8 @@
31
32
  *
32
33
  * // QmTarget is a peer that is behind a NAT, supports TCP and has a relay
33
34
  * // reservation
34
- * await node.dial('/ip4/.../p2p/QmRelay/p2p-circuit/p2p/QmTarget')
35
+ * const ma = multiaddr('/ip4/.../p2p/QmRelay/p2p-circuit/p2p/QmTarget')
36
+ * await node.dial(ma)
35
37
  *
36
38
  * // after a while the connection should automatically get upgraded to a
37
39
  * // direct connection (e.g. non-transient)
@@ -45,7 +47,7 @@
45
47
  * console.info('have relayed connection')
46
48
  *
47
49
  * // wait a few seconds to see if it's succeeded yet
48
- * await new Promise((resolve) => {
50
+ * await new Promise<void>((resolve) => {
49
51
  * setTimeout(() => resolve(), 5000)
50
52
  * })
51
53
  * }