@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.
- package/README.md +95 -0
- package/dist/index.min.js +16 -20
- package/dist/index.min.js.map +7 -0
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +1 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/crypto/index.browser.d.ts +2 -0
- package/dist/src/crypto/index.browser.d.ts.map +1 -0
- package/dist/src/crypto/index.browser.js +3 -0
- package/dist/src/crypto/index.browser.js.map +1 -0
- package/dist/src/crypto/index.d.ts +3 -0
- package/dist/src/crypto/index.d.ts.map +1 -0
- package/dist/src/crypto/index.js +188 -0
- package/dist/src/crypto/index.js.map +1 -0
- package/dist/src/crypto/js.d.ts.map +1 -1
- package/dist/src/crypto/js.js +18 -17
- package/dist/src/crypto/js.js.map +1 -1
- package/dist/src/crypto.d.ts +11 -10
- package/dist/src/crypto.d.ts.map +1 -1
- package/dist/src/crypto.js +10 -1
- package/dist/src/crypto.js.map +1 -1
- package/dist/src/encoder.d.ts +5 -10
- package/dist/src/encoder.d.ts.map +1 -1
- package/dist/src/encoder.js +10 -51
- package/dist/src/encoder.js.map +1 -1
- package/dist/src/errors.d.ts +6 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +9 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +50 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +38 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/logger.d.ts +9 -10
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/logger.js +39 -28
- package/dist/src/logger.js.map +1 -1
- package/dist/src/metrics.d.ts +1 -1
- package/dist/src/metrics.d.ts.map +1 -1
- package/dist/src/noise.d.ts +33 -30
- package/dist/src/noise.d.ts.map +1 -1
- package/dist/src/noise.js +122 -78
- package/dist/src/noise.js.map +1 -1
- package/dist/src/nonce.d.ts +2 -3
- package/dist/src/nonce.d.ts.map +1 -1
- package/dist/src/nonce.js +3 -2
- package/dist/src/nonce.js.map +1 -1
- package/dist/src/performHandshake.d.ts +5 -0
- package/dist/src/performHandshake.d.ts.map +1 -0
- package/dist/src/performHandshake.js +69 -0
- package/dist/src/performHandshake.js.map +1 -0
- package/dist/src/proto/payload.d.ts +4 -3
- package/dist/src/proto/payload.d.ts.map +1 -1
- package/dist/src/proto/payload.js +48 -29
- package/dist/src/proto/payload.js.map +1 -1
- package/dist/src/protocol.d.ts +71 -0
- package/dist/src/protocol.d.ts.map +1 -0
- package/dist/src/protocol.js +257 -0
- package/dist/src/protocol.js.map +1 -0
- package/dist/src/types.d.ts +98 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +10 -19
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +159 -57
- package/dist/src/utils.js.map +1 -1
- package/package.json +43 -48
- package/src/constants.ts +1 -0
- package/src/crypto/index.browser.ts +3 -0
- package/src/crypto/index.ts +219 -0
- package/src/crypto/js.ts +25 -27
- package/src/crypto.ts +21 -10
- package/src/encoder.ts +10 -67
- package/src/errors.ts +10 -0
- package/src/index.ts +54 -6
- package/src/logger.ts +46 -32
- package/src/metrics.ts +1 -1
- package/src/noise.ts +176 -131
- package/src/nonce.ts +7 -7
- package/src/performHandshake.ts +91 -0
- package/src/proto/payload.proto +2 -1
- package/src/proto/payload.ts +53 -31
- package/src/protocol.ts +313 -0
- package/src/types.ts +105 -0
- package/src/utils.ts +189 -79
- package/dist/src/@types/basic.d.ts +0 -5
- package/dist/src/@types/basic.d.ts.map +0 -1
- package/dist/src/@types/basic.js +0 -2
- package/dist/src/@types/basic.js.map +0 -1
- package/dist/src/@types/handshake-interface.d.ts +0 -15
- package/dist/src/@types/handshake-interface.d.ts.map +0 -1
- package/dist/src/@types/handshake-interface.js +0 -2
- package/dist/src/@types/handshake-interface.js.map +0 -1
- package/dist/src/@types/handshake.d.ts +0 -40
- package/dist/src/@types/handshake.d.ts.map +0 -1
- package/dist/src/@types/handshake.js +0 -2
- package/dist/src/@types/handshake.js.map +0 -1
- package/dist/src/@types/libp2p.d.ts +0 -10
- package/dist/src/@types/libp2p.d.ts.map +0 -1
- package/dist/src/@types/libp2p.js +0 -2
- package/dist/src/@types/libp2p.js.map +0 -1
- package/dist/src/crypto/streaming.d.ts +0 -7
- package/dist/src/crypto/streaming.d.ts.map +0 -1
- package/dist/src/crypto/streaming.js +0 -50
- package/dist/src/crypto/streaming.js.map +0 -1
- package/dist/src/handshake-xx.d.ts +0 -33
- package/dist/src/handshake-xx.d.ts.map +0 -1
- package/dist/src/handshake-xx.js +0 -139
- package/dist/src/handshake-xx.js.map +0 -1
- package/dist/src/handshakes/abstract-handshake.d.ts +0 -36
- package/dist/src/handshakes/abstract-handshake.d.ts.map +0 -1
- package/dist/src/handshakes/abstract-handshake.js +0 -140
- package/dist/src/handshakes/abstract-handshake.js.map +0 -1
- package/dist/src/handshakes/xx.d.ts +0 -18
- package/dist/src/handshakes/xx.d.ts.map +0 -1
- package/dist/src/handshakes/xx.js +0 -161
- package/dist/src/handshakes/xx.js.map +0 -1
- package/src/@types/basic.ts +0 -5
- package/src/@types/handshake-interface.ts +0 -12
- package/src/@types/handshake.ts +0 -48
- package/src/@types/libp2p.ts +0 -10
- package/src/crypto/streaming.ts +0 -58
- package/src/handshake-xx.ts +0 -177
- package/src/handshakes/abstract-handshake.ts +0 -180
- package/src/handshakes/xx.ts +0 -184
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.
|
|
5
|
+
*
|
|
6
|
+
* ## Usage
|
|
7
|
+
*
|
|
8
|
+
* Install with `yarn add @libp2p/noise` or `npm i @libp2p/noise`.
|
|
9
|
+
*
|
|
10
|
+
* Example of using default noise configuration and passing it to the libp2p config:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import {createLibp2p} from "libp2p"
|
|
14
|
+
* import {noise} from "@libp2p/noise"
|
|
15
|
+
*
|
|
16
|
+
* //custom noise configuration, pass it instead of `noise()`
|
|
17
|
+
* //x25519 private key
|
|
18
|
+
* const n = noise({ staticNoiseKey });
|
|
19
|
+
*
|
|
20
|
+
* const libp2p = await createLibp2p({
|
|
21
|
+
* connectionEncrypters: [noise()],
|
|
22
|
+
* //... other options
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* See the [NoiseInit](https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/noise.ts#L22-L30) interface for noise configuration options.
|
|
27
|
+
*
|
|
28
|
+
* ## API
|
|
29
|
+
*
|
|
30
|
+
* This module exposes an implementation of the [ConnectionEncrypter](https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.ConnectionEncrypter.html) interface.
|
|
31
|
+
*
|
|
32
|
+
* ## Bring your own crypto
|
|
33
|
+
*
|
|
34
|
+
* 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.
|
|
35
|
+
*
|
|
36
|
+
* The implementation must conform to the `ICryptoInterface`, defined in <https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/crypto.ts>
|
|
37
|
+
*/
|
|
1
38
|
import { Noise } from './noise.js';
|
|
2
39
|
export { pureJsCrypto } from './crypto/js.js';
|
|
3
40
|
export function noise(init = {}) {
|
|
4
|
-
return () => new Noise(init);
|
|
41
|
+
return (components) => new Noise(components, init);
|
|
5
42
|
}
|
|
6
43
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKlC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKlC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAY7C,MAAM,UAAU,KAAK,CAAE,OAAkB,EAAE;IACzC,OAAO,CAAC,UAA2B,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACrE,CAAC"}
|
package/dist/src/logger.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function logCipherState(session: NoiseSession): void;
|
|
1
|
+
import type { CipherState } from './protocol.js';
|
|
2
|
+
import type { KeyPair } from './types.js';
|
|
3
|
+
import type { Logger } from '@libp2p/interface';
|
|
4
|
+
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
5
|
+
export declare function logLocalStaticKeys(s: KeyPair | undefined, keyLogger: Logger): void;
|
|
6
|
+
export declare function logLocalEphemeralKeys(e: KeyPair | undefined, keyLogger: Logger): void;
|
|
7
|
+
export declare function logRemoteStaticKey(rs: Uint8Array | Uint8ArrayList | undefined, keyLogger: Logger): void;
|
|
8
|
+
export declare function logRemoteEphemeralKey(re: Uint8Array | Uint8ArrayList | undefined, keyLogger: Logger): void;
|
|
9
|
+
export declare function logCipherState(cs1: CipherState, cs2: CipherState, keyLogger: Logger): void;
|
|
11
10
|
//# sourceMappingURL=logger.d.ts.map
|
package/dist/src/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,wBAAgB,kBAAkB,CAAE,CAAC,EAAE,OAAO,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAWnF;AAED,wBAAgB,qBAAqB,CAAE,CAAC,EAAE,OAAO,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAWtF;AAED,wBAAgB,kBAAkB,CAAE,EAAE,EAAE,UAAU,GAAG,cAAc,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAUxG;AAED,wBAAgB,qBAAqB,CAAE,EAAE,EAAE,UAAU,GAAG,cAAc,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAU3G;AAED,wBAAgB,cAAc,CAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAO3F"}
|
package/dist/src/logger.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import { logger } from '@libp2p/logger';
|
|
2
1
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
3
2
|
import { DUMP_SESSION_KEYS } from './constants.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
export function logLocalStaticKeys(s) {
|
|
18
|
-
keyLogger(`LOCAL_STATIC_PUBLIC_KEY ${uint8ArrayToString(s.publicKey, 'hex')}`);
|
|
19
|
-
keyLogger(`LOCAL_STATIC_PRIVATE_KEY ${uint8ArrayToString(s.privateKey, 'hex')}`);
|
|
3
|
+
export function logLocalStaticKeys(s, keyLogger) {
|
|
4
|
+
if (!keyLogger.enabled || !DUMP_SESSION_KEYS) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
if (s) {
|
|
8
|
+
keyLogger(`LOCAL_STATIC_PUBLIC_KEY ${uint8ArrayToString(s.publicKey, 'hex')}`);
|
|
9
|
+
keyLogger(`LOCAL_STATIC_PRIVATE_KEY ${uint8ArrayToString(s.privateKey, 'hex')}`);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
keyLogger('Missing local static keys.');
|
|
13
|
+
}
|
|
20
14
|
}
|
|
21
|
-
export function logLocalEphemeralKeys(e) {
|
|
15
|
+
export function logLocalEphemeralKeys(e, keyLogger) {
|
|
16
|
+
if (!keyLogger.enabled || !DUMP_SESSION_KEYS) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
22
19
|
if (e) {
|
|
23
20
|
keyLogger(`LOCAL_PUBLIC_EPHEMERAL_KEY ${uint8ArrayToString(e.publicKey, 'hex')}`);
|
|
24
21
|
keyLogger(`LOCAL_PRIVATE_EPHEMERAL_KEY ${uint8ArrayToString(e.privateKey, 'hex')}`);
|
|
@@ -27,19 +24,33 @@ export function logLocalEphemeralKeys(e) {
|
|
|
27
24
|
keyLogger('Missing local ephemeral keys.');
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
export function logRemoteStaticKey(rs) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
export function logRemoteStaticKey(rs, keyLogger) {
|
|
28
|
+
if (!keyLogger.enabled || !DUMP_SESSION_KEYS) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (rs) {
|
|
32
|
+
keyLogger(`REMOTE_STATIC_PUBLIC_KEY ${uint8ArrayToString(rs.subarray(), 'hex')}`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
keyLogger('Missing remote static public key.');
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
|
-
export function
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
export function logRemoteEphemeralKey(re, keyLogger) {
|
|
39
|
+
if (!keyLogger.enabled || !DUMP_SESSION_KEYS) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (re) {
|
|
43
|
+
keyLogger(`REMOTE_EPHEMERAL_PUBLIC_KEY ${uint8ArrayToString(re.subarray(), 'hex')}`);
|
|
40
44
|
}
|
|
41
45
|
else {
|
|
42
|
-
keyLogger('Missing
|
|
46
|
+
keyLogger('Missing remote ephemeral keys.');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function logCipherState(cs1, cs2, keyLogger) {
|
|
50
|
+
if (!keyLogger.enabled || !DUMP_SESSION_KEYS) {
|
|
51
|
+
return;
|
|
43
52
|
}
|
|
53
|
+
keyLogger(`CIPHER_STATE_1 ${cs1.n.getUint64()} ${cs1.k && uint8ArrayToString(cs1.k, 'hex')}`);
|
|
54
|
+
keyLogger(`CIPHER_STATE_2 ${cs2.n.getUint64()} ${cs2.k && uint8ArrayToString(cs2.k, 'hex')}`);
|
|
44
55
|
}
|
|
45
56
|
//# sourceMappingURL=logger.js.map
|
package/dist/src/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"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AAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;IACnF,CAAC;SAAM,CAAC;QACN,SAAS,CAAC,mCAAmC,CAAC,CAAA;IAChD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAE,EAA2C,EAAE,SAAiB;IACnG,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC7C,OAAM;IACR,CAAC;IAED,IAAI,EAAE,EAAE,CAAC;QACP,SAAS,CAAC,+BAA+B,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;IACtF,CAAC;SAAM,CAAC;QACN,SAAS,CAAC,gCAAgC,CAAC,CAAA;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAE,GAAgB,EAAE,GAAgB,EAAE,SAAiB;IACnF,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC7C,OAAM;IACR,CAAC;IAED,SAAS,CAAC,kBAAkB,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;IAC7F,SAAS,CAAC,kBAAkB,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;AAC/F,CAAC"}
|
package/dist/src/metrics.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Counter, Metrics } from '@libp2p/interface
|
|
1
|
+
import type { Counter, Metrics } from '@libp2p/interface';
|
|
2
2
|
export type MetricsRegistry = Record<string, Counter>;
|
|
3
3
|
export declare function registerMetrics(metrics: Metrics): MetricsRegistry;
|
|
4
4
|
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEzD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAErD,wBAAgB,eAAe,CAAE,OAAO,EAAE,OAAO,GAAG,eAAe,CA2BlE"}
|
package/dist/src/noise.d.ts
CHANGED
|
@@ -1,55 +1,58 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { INoiseConnection } from './@types/libp2p.js';
|
|
1
|
+
import { serviceCapabilities } from '@libp2p/interface';
|
|
3
2
|
import type { ICryptoInterface } from './crypto.js';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import type { NoiseComponents } from './index.js';
|
|
4
|
+
import type { ICrypto, INoiseConnection, INoiseExtensions } from './types.js';
|
|
5
|
+
import type { SecuredConnection, SecureConnectionOptions, MessageStream } from '@libp2p/interface';
|
|
6
|
+
export interface NoiseExtensions {
|
|
7
|
+
webtransportCerthashes: Uint8Array[];
|
|
8
|
+
}
|
|
9
9
|
export interface NoiseInit {
|
|
10
10
|
/**
|
|
11
11
|
* x25519 private key, reuse for faster handshakes
|
|
12
12
|
*/
|
|
13
|
-
staticNoiseKey?:
|
|
14
|
-
extensions?: NoiseExtensions
|
|
13
|
+
staticNoiseKey?: Uint8Array;
|
|
14
|
+
extensions?: Partial<NoiseExtensions>;
|
|
15
15
|
crypto?: ICryptoInterface;
|
|
16
16
|
prologueBytes?: Uint8Array;
|
|
17
|
-
metrics?: Metrics;
|
|
18
17
|
}
|
|
19
18
|
export declare class Noise implements INoiseConnection {
|
|
20
19
|
protocol: string;
|
|
21
|
-
crypto:
|
|
20
|
+
crypto: ICrypto;
|
|
22
21
|
private readonly prologue;
|
|
23
|
-
private readonly
|
|
22
|
+
private readonly staticKey;
|
|
24
23
|
private readonly extensions?;
|
|
25
24
|
private readonly metrics?;
|
|
26
|
-
|
|
25
|
+
private readonly components;
|
|
26
|
+
private readonly log;
|
|
27
|
+
constructor(components: NoiseComponents, init?: NoiseInit);
|
|
28
|
+
readonly [Symbol.toStringTag] = "@libp2p/noise";
|
|
29
|
+
readonly [serviceCapabilities]: string[];
|
|
27
30
|
/**
|
|
28
31
|
* Encrypt outgoing data to the remote party (handshake as initiator)
|
|
29
32
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @
|
|
33
|
+
* @param connection - streaming iterable duplex that will be encrypted
|
|
34
|
+
* @param options
|
|
35
|
+
* @param options.remotePeer - PeerId of the remote peer. Used to validate the integrity of the remote peer
|
|
36
|
+
* @param options.signal - Used to abort the operation
|
|
34
37
|
*/
|
|
35
|
-
secureOutbound(
|
|
38
|
+
secureOutbound(connection: MessageStream, options?: SecureConnectionOptions): Promise<SecuredConnection<INoiseExtensions>>;
|
|
39
|
+
private getStreamMuxer;
|
|
36
40
|
/**
|
|
37
41
|
* Decrypt incoming data (handshake as responder).
|
|
38
42
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @
|
|
43
|
+
* @param connection - streaming iterable duplex that will be encrypted
|
|
44
|
+
* @param options
|
|
45
|
+
* @param options.remotePeer - PeerId of the remote peer. Used to validate the integrity of the remote peer
|
|
46
|
+
* @param options.signal - Used to abort the operation
|
|
43
47
|
*/
|
|
44
|
-
secureInbound(
|
|
48
|
+
secureInbound(connection: MessageStream, options?: SecureConnectionOptions): Promise<SecuredConnection<INoiseExtensions>>;
|
|
45
49
|
/**
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
* Perform XX handshake as initiator.
|
|
51
|
+
*/
|
|
52
|
+
private performHandshakeInitiator;
|
|
53
|
+
/**
|
|
54
|
+
* Perform XX handshake as responder.
|
|
50
55
|
*/
|
|
51
|
-
private
|
|
52
|
-
private performXXHandshake;
|
|
53
|
-
private createSecureConnection;
|
|
56
|
+
private performHandshakeResponder;
|
|
54
57
|
}
|
|
55
58
|
//# sourceMappingURL=noise.d.ts.map
|
package/dist/src/noise.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../src/noise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../src/noise.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAWnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,KAAK,EAAmB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAW,MAAM,YAAY,CAAA;AACvG,OAAO,KAAK,EAAE,iBAAiB,EAA6C,uBAAuB,EAAU,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGrJ,MAAM,WAAW,eAAe;IAC9B,sBAAsB,EAAE,UAAU,EAAE,CAAA;CACrC;AAED,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,cAAc,CAAC,EAAE,UAAU,CAAA;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IACrC,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,aAAa,CAAC,EAAE,UAAU,CAAA;CAC3B;AAED,qBAAa,KAAM,YAAW,gBAAgB;IACrC,QAAQ,SAAW;IACnB,MAAM,EAAE,OAAO,CAAA;IAEtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAY;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAiB;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAiB;IAC1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAC5C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;gBAEf,UAAU,EAAE,eAAe,EAAE,IAAI,GAAE,SAAc;IAuB9D,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAkB;IAE/C,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAGvC;IAED;;;;;;;OAOG;IACG,cAAc,CAAE,UAAU,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAyBjI,OAAO,CAAC,cAAc;IAsBtB;;;;;;;OAOG;IACG,aAAa,CAAE,UAAU,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAyBhI;;OAEG;YACW,yBAAyB;IAmCvC;;OAEG;YACW,yBAAyB;CAiCxC"}
|
package/dist/src/noise.js
CHANGED
|
@@ -1,130 +1,174 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { publicKeyFromProtobuf } from '@libp2p/crypto/keys';
|
|
2
|
+
import { InvalidCryptoExchangeError, serviceCapabilities } from '@libp2p/interface';
|
|
3
|
+
import { peerIdFromPublicKey } from '@libp2p/peer-id';
|
|
4
|
+
import { lpStream } from '@libp2p/utils';
|
|
5
|
+
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc';
|
|
5
6
|
import { NOISE_MSG_MAX_LENGTH_BYTES } from './constants.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { defaultCrypto } from './crypto/index.js';
|
|
8
|
+
import { wrapCrypto } from './crypto.js';
|
|
8
9
|
import { uint16BEDecode, uint16BEEncode } from './encoder.js';
|
|
9
|
-
import { XXHandshake } from './handshake-xx.js';
|
|
10
10
|
import { registerMetrics } from './metrics.js';
|
|
11
|
-
import {
|
|
11
|
+
import { performHandshakeInitiator, performHandshakeResponder } from './performHandshake.js';
|
|
12
|
+
import { toMessageStream } from "./utils.js";
|
|
12
13
|
export class Noise {
|
|
13
14
|
protocol = '/noise';
|
|
14
15
|
crypto;
|
|
15
16
|
prologue;
|
|
16
|
-
|
|
17
|
+
staticKey;
|
|
17
18
|
extensions;
|
|
18
19
|
metrics;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
components;
|
|
21
|
+
log;
|
|
22
|
+
constructor(components, init = {}) {
|
|
23
|
+
const { staticNoiseKey, extensions, crypto, prologueBytes } = init;
|
|
24
|
+
const { metrics } = components;
|
|
25
|
+
this.components = components;
|
|
26
|
+
this.log = components.logger.forComponent('libp2p:noise');
|
|
27
|
+
const _crypto = crypto ?? defaultCrypto;
|
|
28
|
+
this.crypto = wrapCrypto(_crypto);
|
|
29
|
+
this.extensions = {
|
|
30
|
+
webtransportCerthashes: [],
|
|
31
|
+
...extensions
|
|
32
|
+
};
|
|
23
33
|
this.metrics = metrics ? registerMetrics(metrics) : undefined;
|
|
24
34
|
if (staticNoiseKey) {
|
|
25
35
|
// accepts x25519 private key of length 32
|
|
26
|
-
this.
|
|
36
|
+
this.staticKey = _crypto.generateX25519KeyPairFromSeed(staticNoiseKey);
|
|
27
37
|
}
|
|
28
38
|
else {
|
|
29
|
-
this.
|
|
39
|
+
this.staticKey = _crypto.generateX25519KeyPair();
|
|
30
40
|
}
|
|
31
|
-
this.prologue = prologueBytes ??
|
|
41
|
+
this.prologue = prologueBytes ?? uint8ArrayAlloc(0);
|
|
32
42
|
}
|
|
43
|
+
[Symbol.toStringTag] = '@libp2p/noise';
|
|
44
|
+
[serviceCapabilities] = [
|
|
45
|
+
'@libp2p/connection-encryption',
|
|
46
|
+
'@libp2p/noise'
|
|
47
|
+
];
|
|
33
48
|
/**
|
|
34
49
|
* Encrypt outgoing data to the remote party (handshake as initiator)
|
|
35
50
|
*
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @
|
|
51
|
+
* @param connection - streaming iterable duplex that will be encrypted
|
|
52
|
+
* @param options
|
|
53
|
+
* @param options.remotePeer - PeerId of the remote peer. Used to validate the integrity of the remote peer
|
|
54
|
+
* @param options.signal - Used to abort the operation
|
|
40
55
|
*/
|
|
41
|
-
async secureOutbound(
|
|
56
|
+
async secureOutbound(connection, options) {
|
|
57
|
+
const log = connection.log?.newScope('noise') ?? this.log;
|
|
42
58
|
const wrappedConnection = lpStream(connection, {
|
|
43
59
|
lengthEncoder: uint16BEEncode,
|
|
44
60
|
lengthDecoder: uint16BEDecode,
|
|
45
61
|
maxDataLength: NOISE_MSG_MAX_LENGTH_BYTES
|
|
46
62
|
});
|
|
47
|
-
const handshake = await this.
|
|
48
|
-
|
|
49
|
-
isInitiator: true,
|
|
50
|
-
localPeer,
|
|
51
|
-
remotePeer
|
|
52
|
-
});
|
|
53
|
-
const conn = await this.createSecureConnection(wrappedConnection, handshake);
|
|
63
|
+
const handshake = await this.performHandshakeInitiator(wrappedConnection, this.components.privateKey, log, options?.remotePeer?.publicKey, options);
|
|
64
|
+
const publicKey = publicKeyFromProtobuf(handshake.payload.identityKey);
|
|
54
65
|
return {
|
|
55
|
-
|
|
56
|
-
remoteExtensions: handshake.
|
|
57
|
-
remotePeer:
|
|
66
|
+
connection: toMessageStream(wrappedConnection.unwrap(), handshake, this.metrics),
|
|
67
|
+
remoteExtensions: handshake.payload.extensions,
|
|
68
|
+
remotePeer: peerIdFromPublicKey(publicKey),
|
|
69
|
+
streamMuxer: options?.skipStreamMuxerNegotiation === true ? undefined : this.getStreamMuxer(handshake.payload.extensions?.streamMuxers)
|
|
58
70
|
};
|
|
59
71
|
}
|
|
72
|
+
getStreamMuxer(protocols) {
|
|
73
|
+
if (protocols == null || protocols.length === 0) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const streamMuxers = this.components.upgrader.getStreamMuxers();
|
|
77
|
+
if (streamMuxers != null) {
|
|
78
|
+
for (const protocol of protocols) {
|
|
79
|
+
const streamMuxer = streamMuxers.get(protocol);
|
|
80
|
+
if (streamMuxer != null) {
|
|
81
|
+
return streamMuxer;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (protocols.length) {
|
|
86
|
+
throw new InvalidCryptoExchangeError('Early muxer negotiation was requested but the initiator and responder had no common muxers');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
60
89
|
/**
|
|
61
90
|
* Decrypt incoming data (handshake as responder).
|
|
62
91
|
*
|
|
63
|
-
* @param
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @
|
|
92
|
+
* @param connection - streaming iterable duplex that will be encrypted
|
|
93
|
+
* @param options
|
|
94
|
+
* @param options.remotePeer - PeerId of the remote peer. Used to validate the integrity of the remote peer
|
|
95
|
+
* @param options.signal - Used to abort the operation
|
|
67
96
|
*/
|
|
68
|
-
async secureInbound(
|
|
97
|
+
async secureInbound(connection, options) {
|
|
98
|
+
const log = connection.log?.newScope('noise') ?? this.log;
|
|
69
99
|
const wrappedConnection = lpStream(connection, {
|
|
70
100
|
lengthEncoder: uint16BEEncode,
|
|
71
101
|
lengthDecoder: uint16BEDecode,
|
|
72
102
|
maxDataLength: NOISE_MSG_MAX_LENGTH_BYTES
|
|
73
103
|
});
|
|
74
|
-
const handshake = await this.
|
|
75
|
-
|
|
76
|
-
isInitiator: false,
|
|
77
|
-
localPeer,
|
|
78
|
-
remotePeer
|
|
79
|
-
});
|
|
80
|
-
const conn = await this.createSecureConnection(wrappedConnection, handshake);
|
|
104
|
+
const handshake = await this.performHandshakeResponder(wrappedConnection, this.components.privateKey, log, options?.remotePeer?.publicKey, options);
|
|
105
|
+
const publicKey = publicKeyFromProtobuf(handshake.payload.identityKey);
|
|
81
106
|
return {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
107
|
+
connection: toMessageStream(wrappedConnection.unwrap(), handshake, this.metrics),
|
|
108
|
+
remoteExtensions: handshake.payload.extensions,
|
|
109
|
+
remotePeer: peerIdFromPublicKey(publicKey),
|
|
110
|
+
streamMuxer: options?.skipStreamMuxerNegotiation === true ? undefined : this.getStreamMuxer(handshake.payload.extensions?.streamMuxers)
|
|
85
111
|
};
|
|
86
112
|
}
|
|
87
113
|
/**
|
|
88
|
-
*
|
|
89
|
-
* If noise pipes disabled or remote peer static key is unknown, use XX.
|
|
90
|
-
*
|
|
91
|
-
* @param {HandshakeParams} params
|
|
114
|
+
* Perform XX handshake as initiator.
|
|
92
115
|
*/
|
|
93
|
-
async
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
async performXXHandshake(params, payload) {
|
|
99
|
-
const { isInitiator, remotePeer, connection } = params;
|
|
100
|
-
const handshake = new XXHandshake(isInitiator, payload, this.prologue, this.crypto, this.staticKeys, connection, remotePeer);
|
|
116
|
+
async performHandshakeInitiator(connection,
|
|
117
|
+
// TODO: pass private key in noise constructor via Components
|
|
118
|
+
privateKey, log, remoteIdentityKey, options) {
|
|
119
|
+
let result;
|
|
120
|
+
const streamMuxers = options?.skipStreamMuxerNegotiation === true ? [] : [...this.components.upgrader.getStreamMuxers().keys()];
|
|
101
121
|
try {
|
|
102
|
-
await
|
|
103
|
-
|
|
104
|
-
|
|
122
|
+
result = await performHandshakeInitiator({
|
|
123
|
+
connection,
|
|
124
|
+
privateKey,
|
|
125
|
+
remoteIdentityKey,
|
|
126
|
+
log: log.newScope('xxhandshake'),
|
|
127
|
+
crypto: this.crypto,
|
|
128
|
+
prologue: this.prologue,
|
|
129
|
+
s: this.staticKey,
|
|
130
|
+
extensions: {
|
|
131
|
+
streamMuxers,
|
|
132
|
+
webtransportCerthashes: [],
|
|
133
|
+
...this.extensions
|
|
134
|
+
}
|
|
135
|
+
}, options);
|
|
105
136
|
this.metrics?.xxHandshakeSuccesses.increment();
|
|
106
137
|
}
|
|
107
138
|
catch (e) {
|
|
108
139
|
this.metrics?.xxHandshakeErrors.increment();
|
|
109
|
-
|
|
110
|
-
e.message = `Error occurred during XX handshake: ${e.message}`;
|
|
111
|
-
throw e;
|
|
112
|
-
}
|
|
140
|
+
throw e;
|
|
113
141
|
}
|
|
114
|
-
return
|
|
142
|
+
return result;
|
|
115
143
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Perform XX handshake as responder.
|
|
146
|
+
*/
|
|
147
|
+
async performHandshakeResponder(connection, privateKey, log, remoteIdentityKey, options) {
|
|
148
|
+
let result;
|
|
149
|
+
const streamMuxers = options?.skipStreamMuxerNegotiation === true ? [] : [...this.components.upgrader.getStreamMuxers().keys()];
|
|
150
|
+
try {
|
|
151
|
+
result = await performHandshakeResponder({
|
|
152
|
+
connection,
|
|
153
|
+
privateKey,
|
|
154
|
+
remoteIdentityKey,
|
|
155
|
+
log: log.newScope('xxhandshake'),
|
|
156
|
+
crypto: this.crypto,
|
|
157
|
+
prologue: this.prologue,
|
|
158
|
+
s: this.staticKey,
|
|
159
|
+
extensions: {
|
|
160
|
+
streamMuxers,
|
|
161
|
+
webtransportCerthashes: [],
|
|
162
|
+
...this.extensions
|
|
163
|
+
}
|
|
164
|
+
}, options);
|
|
165
|
+
this.metrics?.xxHandshakeSuccesses.increment();
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
this.metrics?.xxHandshakeErrors.increment();
|
|
169
|
+
throw e;
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
128
172
|
}
|
|
129
173
|
}
|
|
130
174
|
//# sourceMappingURL=noise.js.map
|
package/dist/src/noise.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noise.js","sourceRoot":"","sources":["../../src/noise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"noise.js","sourceRoot":"","sources":["../../src/noise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAsB5C,MAAM,OAAO,KAAK;IACT,QAAQ,GAAG,QAAQ,CAAA;IACnB,MAAM,CAAS;IAEL,QAAQ,CAAY;IACpB,SAAS,CAAS;IAClB,UAAU,CAAkB;IAC5B,OAAO,CAAkB;IACzB,UAAU,CAAiB;IAC3B,GAAG,CAAQ;IA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U;gBACV,iBAAiB;gBACjB,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC;gBAChC,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,CAAC,EAAE,IAAI,CAAC,SAAS;gBACjB,UAAU,EAAE;oBACV,YAAY;oBACZ,sBAAsB,EAAE,EAAE;oBAC1B,GAAG,IAAI,CAAC,UAAU;iBACnB;aACF,EAAE,OAAO,CAAC,CAAA;YACX,IAAI,CAAC,OAAO,EAAE,oBAAoB,CAAC,SAAS,EAAE,CAAA;QAChD,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,SAAS,EAAE,CAAA;YAC3C,MAAM,CAAC,CAAA;QACT,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
package/dist/src/nonce.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { bytes, uint64 } from './@types/basic.js';
|
|
2
1
|
export declare const MIN_NONCE = 0;
|
|
3
2
|
export declare const MAX_NONCE = 4294967295;
|
|
4
3
|
/**
|
|
@@ -11,8 +10,8 @@ export declare class Nonce {
|
|
|
11
10
|
private readonly view;
|
|
12
11
|
constructor(n?: number);
|
|
13
12
|
increment(): void;
|
|
14
|
-
getBytes():
|
|
15
|
-
getUint64():
|
|
13
|
+
getBytes(): Uint8Array;
|
|
14
|
+
getUint64(): number;
|
|
16
15
|
assertValue(): void;
|
|
17
16
|
}
|
|
18
17
|
//# sourceMappingURL=nonce.d.ts.map
|
package/dist/src/nonce.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nonce.d.ts","sourceRoot":"","sources":["../../src/nonce.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nonce.d.ts","sourceRoot":"","sources":["../../src/nonce.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,IAAI,CAAA;AAO1B,eAAO,MAAM,SAAS,aAAa,CAAA;AAInC;;;GAGG;AACH,qBAAa,KAAK;IAChB,OAAO,CAAC,CAAC,CAAQ;IACjB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;gBAElB,CAAC,SAAY;IAO1B,SAAS,IAAK,IAAI;IAMlB,QAAQ,IAAK,UAAU;IAIvB,SAAS,IAAK,MAAM;IAIpB,WAAW,IAAK,IAAI;CAKrB"}
|