@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.
- package/README.md +31 -35
- package/dist/index.min.js +2 -4
- package/dist/index.min.js.map +4 -4
- package/dist/src/crypto/index.browser.js +1 -1
- package/dist/src/crypto/index.d.ts +5 -1
- package/dist/src/crypto/index.d.ts.map +1 -1
- package/dist/src/crypto/index.js +4 -3
- package/dist/src/crypto/index.js.map +1 -1
- package/dist/src/crypto/js.d.ts +1 -1
- package/dist/src/crypto.d.ts +1 -1
- package/dist/src/index.d.ts +25 -14
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -12
- package/dist/src/index.js.map +1 -1
- package/dist/src/logger.d.ts +2 -2
- package/dist/src/logger.js +1 -1
- package/dist/src/noise.d.ts +3 -3
- package/dist/src/noise.js +6 -6
- package/dist/src/nonce.js +1 -1
- package/dist/src/nonce.js.map +1 -1
- package/dist/src/performHandshake.d.ts +1 -1
- package/dist/src/performHandshake.js +3 -3
- package/dist/src/proto/payload.d.ts +34 -4
- package/dist/src/proto/payload.d.ts.map +1 -1
- package/dist/src/proto/payload.js +95 -13
- package/dist/src/proto/payload.js.map +1 -1
- package/dist/src/protocol.d.ts +3 -3
- package/dist/src/protocol.d.ts.map +1 -1
- package/dist/src/protocol.js +2 -2
- package/dist/src/types.d.ts +2 -2
- package/dist/src/utils.d.ts +2 -2
- package/dist/src/utils.js +1 -1
- package/package.json +61 -35
- package/src/crypto/index.browser.ts +1 -1
- package/src/crypto/index.ts +8 -5
- package/src/crypto/js.ts +2 -2
- package/src/crypto.ts +1 -1
- package/src/index.ts +26 -15
- package/src/logger.ts +3 -3
- package/src/noise.ts +10 -10
- package/src/nonce.ts +1 -1
- package/src/performHandshake.ts +4 -4
- package/src/proto/payload.ts +133 -9
- package/src/protocol.ts +3 -3
- package/src/types.ts +2 -2
- package/src/utils.ts +2 -2
package/README.md
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
# @
|
|
2
|
-
|
|
3
|
-
](https://opensource.org/licenses/Apache-2.0)
|
|
8
|
-
[](https://opensource.org/licenses/MIT)
|
|
9
|
-

|
|
10
|
-

|
|
11
|
-

|
|
12
|
-
[](https://twitter.com/ChainSafeth)
|
|
13
|
-
[](https://discord.gg/Q6A3YA2)
|
|
1
|
+
# @libp2p/noise
|
|
2
|
+
|
|
3
|
+
[](http://libp2p.io/)
|
|
4
|
+
[](https://discuss.libp2p.io)
|
|
5
|
+
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
6
|
+
[](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 `
|
|
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
|
|
44
|
-
import {noise} from
|
|
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
|
-
|
|
43
|
+
// ... other options
|
|
53
44
|
})
|
|
54
45
|
```
|
|
55
46
|
|
|
56
|
-
See the [NoiseInit](https://github.com/
|
|
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/
|
|
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 @
|
|
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://
|
|
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/
|
|
91
|
-
- MIT ([LICENSE-MIT](https://github.com/
|
|
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
|
|