@libp2p/noise 17.0.1-71e8ee163 → 17.0.2-d91797b55

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.
Files changed (46) hide show
  1. package/README.md +31 -35
  2. package/dist/index.min.js +2 -4
  3. package/dist/index.min.js.map +4 -4
  4. package/dist/src/crypto/index.browser.js +1 -1
  5. package/dist/src/crypto/index.d.ts +5 -1
  6. package/dist/src/crypto/index.d.ts.map +1 -1
  7. package/dist/src/crypto/index.js +4 -3
  8. package/dist/src/crypto/index.js.map +1 -1
  9. package/dist/src/crypto/js.d.ts +1 -1
  10. package/dist/src/crypto.d.ts +1 -1
  11. package/dist/src/index.d.ts +25 -14
  12. package/dist/src/index.d.ts.map +1 -1
  13. package/dist/src/index.js +23 -12
  14. package/dist/src/index.js.map +1 -1
  15. package/dist/src/logger.d.ts +2 -2
  16. package/dist/src/logger.js +1 -1
  17. package/dist/src/noise.d.ts +3 -3
  18. package/dist/src/noise.js +6 -6
  19. package/dist/src/nonce.js +1 -1
  20. package/dist/src/nonce.js.map +1 -1
  21. package/dist/src/performHandshake.d.ts +1 -1
  22. package/dist/src/performHandshake.js +3 -3
  23. package/dist/src/proto/payload.d.ts +34 -4
  24. package/dist/src/proto/payload.d.ts.map +1 -1
  25. package/dist/src/proto/payload.js +95 -13
  26. package/dist/src/proto/payload.js.map +1 -1
  27. package/dist/src/protocol.d.ts +3 -3
  28. package/dist/src/protocol.d.ts.map +1 -1
  29. package/dist/src/protocol.js +2 -2
  30. package/dist/src/types.d.ts +2 -2
  31. package/dist/src/utils.d.ts +2 -2
  32. package/dist/src/utils.js +1 -1
  33. package/package.json +61 -35
  34. package/src/crypto/index.browser.ts +1 -1
  35. package/src/crypto/index.ts +8 -5
  36. package/src/crypto/js.ts +2 -2
  37. package/src/crypto.ts +1 -1
  38. package/src/index.ts +26 -15
  39. package/src/logger.ts +3 -3
  40. package/src/noise.ts +10 -10
  41. package/src/nonce.ts +1 -1
  42. package/src/performHandshake.ts +4 -4
  43. package/src/proto/payload.ts +133 -9
  44. package/src/protocol.ts +3 -3
  45. package/src/types.ts +2 -2
  46. package/src/utils.ts +2 -2
package/README.md CHANGED
@@ -1,16 +1,9 @@
1
- # @chainsafe/libp2p-noise
2
-
3
- ![npm](https://img.shields.io/npm/v/@chainsafe/libp2p-noise)
4
- [![](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-noise/js-test-and-release.yml?branch=master)](https://github.com/ChainSafe/js-libp2p-noise/actions)
5
- [![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](https://libp2p.io/)
6
- ![](https://img.shields.io/github/issues-raw/ChainSafe/js-libp2p-noise)
7
- [![License Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
8
- [![License MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
- ![](https://img.shields.io/badge/npm-%3E%3D7.0.0-orange.svg?style=flat-square)
10
- ![](https://img.shields.io/badge/Node.js-%3E%3D16.0.0-orange.svg?style=flat-square)
11
- ![](https://img.shields.io/badge/browsers-last%202%20versions%2C%20not%20ie%20%3C%3D11-orange)
12
- [![Twitter](https://img.shields.io/twitter/follow/ChainSafeth.svg?label=Twitter)](https://twitter.com/ChainSafeth)
13
- [![Discord](https://img.shields.io/discord/593655374469660673.svg?label=Discord\&logo=discord)](https://discord.gg/Q6A3YA2)
1
+ # @libp2p/noise
2
+
3
+ [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4
+ [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
5
+ [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
6
+ [![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=main\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amain)
14
7
 
15
8
  > Noise libp2p handshake for js-libp2p
16
9
 
@@ -33,27 +26,38 @@ repo and examine the changes made.
33
26
 
34
27
  This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.
35
28
 
29
+ Formerly published as [`@chainsafe/libp2p-noise`](https://www.npmjs.com/package/@chainsafe/libp2p-noise).
30
+
36
31
  ## Usage
37
32
 
38
- Install with `yarn add @chainsafe/libp2p-noise` or `npm i @chainsafe/libp2p-noise`.
33
+ Install with `npm i @libp2p/noise`.
39
34
 
40
35
  Example of using default noise configuration and passing it to the libp2p config:
41
36
 
42
37
  ```ts
43
- import {createLibp2p} from "libp2p"
44
- import {noise} from "@libp2p/noise"
45
-
46
- //custom noise configuration, pass it instead of `noise()`
47
- //x25519 private key
48
- const n = noise({ staticNoiseKey });
38
+ import { createLibp2p } from 'libp2p'
39
+ import { noise } from '@libp2p/noise'
49
40
 
50
41
  const libp2p = await createLibp2p({
51
42
  connectionEncrypters: [noise()],
52
- //... other options
43
+ // ... other options
53
44
  })
54
45
  ```
55
46
 
56
- See the [NoiseInit](https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/noise.ts#L22-L30) interface for noise configuration options.
47
+ See the [NoiseInit](https://github.com/libp2p/js-libp2p/blob/main/packages/connection-encrypter-noise/src/noise.ts) interface for noise configuration options.
48
+
49
+ To use a fixed x25519 static key instead of generating one per session, pass it as `staticNoiseKey`:
50
+
51
+ ```ts
52
+ import { createLibp2p } from 'libp2p'
53
+ import { noise, pureJsCrypto } from '@libp2p/noise'
54
+
55
+ const staticNoiseKey = pureJsCrypto.generateX25519KeyPair().privateKey
56
+
57
+ const node = await createLibp2p({
58
+ connectionEncrypters: [noise({ staticNoiseKey })]
59
+ })
60
+ ```
57
61
 
58
62
  ## API
59
63
 
@@ -63,32 +67,24 @@ This module exposes an implementation of the [ConnectionEncrypter](https://libp2
63
67
 
64
68
  You can provide a custom crypto implementation (instead of the default, based on [@noble](https://paulmillr.com/noble/)) by adding a `crypto` field to the init argument passed to the `Noise` factory.
65
69
 
66
- The implementation must conform to the `ICryptoInterface`, defined in <https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/crypto.ts>
70
+ The implementation must conform to the `ICryptoInterface`, defined in <https://github.com/libp2p/js-libp2p/blob/main/packages/connection-encrypter-noise/src/crypto.ts>
67
71
 
68
72
  # Install
69
73
 
70
74
  ```console
71
- $ npm i @chainsafe/libp2p-noise
72
- ```
73
-
74
- ## Browser `<script>` tag
75
-
76
- Loading this module through a script tag will make its exports available as `ChainsafeLibp2pNoise` in the global namespace.
77
-
78
- ```html
79
- <script src="https://unpkg.com/@chainsafe/libp2p-noise/dist/index.min.js"></script>
75
+ $ npm i @libp2p/noise
80
76
  ```
81
77
 
82
78
  # API Docs
83
79
 
84
- - <https://ChainSafe.github.io/js-libp2p-noise>
80
+ - <https://libp2p.github.io/js-libp2p/modules/_libp2p_noise.html>
85
81
 
86
82
  # License
87
83
 
88
84
  Licensed under either of
89
85
 
90
- - Apache 2.0, ([LICENSE-APACHE](https://github.com/ChainSafe/js-libp2p-noise/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
91
- - MIT ([LICENSE-MIT](https://github.com/ChainSafe/js-libp2p-noise/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
86
+ - Apache 2.0, ([LICENSE-APACHE](https://github.com/libp2p/js-libp2p/blob/main/packages/connection-encrypter-noise/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
87
+ - MIT ([LICENSE-MIT](https://github.com/libp2p/js-libp2p/blob/main/packages/connection-encrypter-noise/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
92
88
 
93
89
  # Contribution
94
90