@libp2p/noise 12.0.1 → 16.1.4-6059227cb

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 (127) hide show
  1. package/README.md +95 -0
  2. package/dist/index.min.js +16 -20
  3. package/dist/index.min.js.map +7 -0
  4. package/dist/src/constants.d.ts +1 -0
  5. package/dist/src/constants.d.ts.map +1 -1
  6. package/dist/src/constants.js +1 -0
  7. package/dist/src/constants.js.map +1 -1
  8. package/dist/src/crypto/index.browser.d.ts +2 -0
  9. package/dist/src/crypto/index.browser.d.ts.map +1 -0
  10. package/dist/src/crypto/index.browser.js +3 -0
  11. package/dist/src/crypto/index.browser.js.map +1 -0
  12. package/dist/src/crypto/index.d.ts +3 -0
  13. package/dist/src/crypto/index.d.ts.map +1 -0
  14. package/dist/src/crypto/index.js +188 -0
  15. package/dist/src/crypto/index.js.map +1 -0
  16. package/dist/src/crypto/js.d.ts.map +1 -1
  17. package/dist/src/crypto/js.js +18 -17
  18. package/dist/src/crypto/js.js.map +1 -1
  19. package/dist/src/crypto.d.ts +11 -10
  20. package/dist/src/crypto.d.ts.map +1 -1
  21. package/dist/src/crypto.js +10 -1
  22. package/dist/src/crypto.js.map +1 -1
  23. package/dist/src/encoder.d.ts +5 -10
  24. package/dist/src/encoder.d.ts.map +1 -1
  25. package/dist/src/encoder.js +10 -51
  26. package/dist/src/encoder.js.map +1 -1
  27. package/dist/src/errors.d.ts +6 -0
  28. package/dist/src/errors.d.ts.map +1 -0
  29. package/dist/src/errors.js +9 -0
  30. package/dist/src/errors.js.map +1 -0
  31. package/dist/src/index.d.ts +50 -5
  32. package/dist/src/index.d.ts.map +1 -1
  33. package/dist/src/index.js +38 -1
  34. package/dist/src/index.js.map +1 -1
  35. package/dist/src/logger.d.ts +9 -10
  36. package/dist/src/logger.d.ts.map +1 -1
  37. package/dist/src/logger.js +39 -28
  38. package/dist/src/logger.js.map +1 -1
  39. package/dist/src/metrics.d.ts +1 -1
  40. package/dist/src/metrics.d.ts.map +1 -1
  41. package/dist/src/noise.d.ts +33 -30
  42. package/dist/src/noise.d.ts.map +1 -1
  43. package/dist/src/noise.js +122 -78
  44. package/dist/src/noise.js.map +1 -1
  45. package/dist/src/nonce.d.ts +2 -3
  46. package/dist/src/nonce.d.ts.map +1 -1
  47. package/dist/src/nonce.js +3 -2
  48. package/dist/src/nonce.js.map +1 -1
  49. package/dist/src/performHandshake.d.ts +5 -0
  50. package/dist/src/performHandshake.d.ts.map +1 -0
  51. package/dist/src/performHandshake.js +69 -0
  52. package/dist/src/performHandshake.js.map +1 -0
  53. package/dist/src/proto/payload.d.ts +4 -3
  54. package/dist/src/proto/payload.d.ts.map +1 -1
  55. package/dist/src/proto/payload.js +48 -29
  56. package/dist/src/proto/payload.js.map +1 -1
  57. package/dist/src/protocol.d.ts +71 -0
  58. package/dist/src/protocol.d.ts.map +1 -0
  59. package/dist/src/protocol.js +257 -0
  60. package/dist/src/protocol.js.map +1 -0
  61. package/dist/src/types.d.ts +98 -0
  62. package/dist/src/types.d.ts.map +1 -0
  63. package/dist/src/types.js +2 -0
  64. package/dist/src/types.js.map +1 -0
  65. package/dist/src/utils.d.ts +10 -19
  66. package/dist/src/utils.d.ts.map +1 -1
  67. package/dist/src/utils.js +159 -57
  68. package/dist/src/utils.js.map +1 -1
  69. package/package.json +43 -48
  70. package/src/constants.ts +1 -0
  71. package/src/crypto/index.browser.ts +3 -0
  72. package/src/crypto/index.ts +219 -0
  73. package/src/crypto/js.ts +25 -27
  74. package/src/crypto.ts +21 -10
  75. package/src/encoder.ts +10 -67
  76. package/src/errors.ts +10 -0
  77. package/src/index.ts +54 -6
  78. package/src/logger.ts +46 -32
  79. package/src/metrics.ts +1 -1
  80. package/src/noise.ts +176 -131
  81. package/src/nonce.ts +7 -7
  82. package/src/performHandshake.ts +91 -0
  83. package/src/proto/payload.proto +2 -1
  84. package/src/proto/payload.ts +53 -31
  85. package/src/protocol.ts +313 -0
  86. package/src/types.ts +105 -0
  87. package/src/utils.ts +189 -79
  88. package/dist/src/@types/basic.d.ts +0 -5
  89. package/dist/src/@types/basic.d.ts.map +0 -1
  90. package/dist/src/@types/basic.js +0 -2
  91. package/dist/src/@types/basic.js.map +0 -1
  92. package/dist/src/@types/handshake-interface.d.ts +0 -15
  93. package/dist/src/@types/handshake-interface.d.ts.map +0 -1
  94. package/dist/src/@types/handshake-interface.js +0 -2
  95. package/dist/src/@types/handshake-interface.js.map +0 -1
  96. package/dist/src/@types/handshake.d.ts +0 -40
  97. package/dist/src/@types/handshake.d.ts.map +0 -1
  98. package/dist/src/@types/handshake.js +0 -2
  99. package/dist/src/@types/handshake.js.map +0 -1
  100. package/dist/src/@types/libp2p.d.ts +0 -10
  101. package/dist/src/@types/libp2p.d.ts.map +0 -1
  102. package/dist/src/@types/libp2p.js +0 -2
  103. package/dist/src/@types/libp2p.js.map +0 -1
  104. package/dist/src/crypto/streaming.d.ts +0 -7
  105. package/dist/src/crypto/streaming.d.ts.map +0 -1
  106. package/dist/src/crypto/streaming.js +0 -50
  107. package/dist/src/crypto/streaming.js.map +0 -1
  108. package/dist/src/handshake-xx.d.ts +0 -33
  109. package/dist/src/handshake-xx.d.ts.map +0 -1
  110. package/dist/src/handshake-xx.js +0 -139
  111. package/dist/src/handshake-xx.js.map +0 -1
  112. package/dist/src/handshakes/abstract-handshake.d.ts +0 -36
  113. package/dist/src/handshakes/abstract-handshake.d.ts.map +0 -1
  114. package/dist/src/handshakes/abstract-handshake.js +0 -140
  115. package/dist/src/handshakes/abstract-handshake.js.map +0 -1
  116. package/dist/src/handshakes/xx.d.ts +0 -18
  117. package/dist/src/handshakes/xx.d.ts.map +0 -1
  118. package/dist/src/handshakes/xx.js +0 -161
  119. package/dist/src/handshakes/xx.js.map +0 -1
  120. package/src/@types/basic.ts +0 -5
  121. package/src/@types/handshake-interface.ts +0 -12
  122. package/src/@types/handshake.ts +0 -48
  123. package/src/@types/libp2p.ts +0 -10
  124. package/src/crypto/streaming.ts +0 -58
  125. package/src/handshake-xx.ts +0 -177
  126. package/src/handshakes/abstract-handshake.ts +0 -180
  127. package/src/handshakes/xx.ts +0 -184
package/README.md ADDED
@@ -0,0 +1,95 @@
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)
14
+
15
+ > Noise libp2p handshake for js-libp2p
16
+
17
+ # About
18
+
19
+ <!--
20
+
21
+ !IMPORTANT!
22
+
23
+ Everything in this README between "# About" and "# Install" is automatically
24
+ generated and will be overwritten the next time the doc generator is run.
25
+
26
+ To make changes to this section, please update the @packageDocumentation section
27
+ of src/index.js or src/index.ts
28
+
29
+ To experiment with formatting, please run "npm run docs" from the root of this
30
+ repo and examine the changes made.
31
+
32
+ -->
33
+
34
+ This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.
35
+
36
+ ## Usage
37
+
38
+ Install with `yarn add @chainsafe/libp2p-noise` or `npm i @chainsafe/libp2p-noise`.
39
+
40
+ Example of using default noise configuration and passing it to the libp2p config:
41
+
42
+ ```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 });
49
+
50
+ const libp2p = await createLibp2p({
51
+ connectionEncrypters: [noise()],
52
+ //... other options
53
+ })
54
+ ```
55
+
56
+ See the [NoiseInit](https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/noise.ts#L22-L30) interface for noise configuration options.
57
+
58
+ ## API
59
+
60
+ This module exposes an implementation of the [ConnectionEncrypter](https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.ConnectionEncrypter.html) interface.
61
+
62
+ ## Bring your own crypto
63
+
64
+ 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
+
66
+ The implementation must conform to the `ICryptoInterface`, defined in <https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/crypto.ts>
67
+
68
+ # Install
69
+
70
+ ```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>
80
+ ```
81
+
82
+ # API Docs
83
+
84
+ - <https://ChainSafe.github.io/js-libp2p-noise>
85
+
86
+ # License
87
+
88
+ Licensed under either of
89
+
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>)
92
+
93
+ # Contribution
94
+
95
+ 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.