@libp2p/pnet 3.0.21 → 3.0.22-5e07d5963
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/dist/index.min.js +2 -2
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/key-generator.d.ts.map +1 -1
- package/dist/src/key-generator.js +1 -2
- package/dist/src/key-generator.js.map +1 -1
- package/package.json +6 -7
- package/src/index.ts +1 -2
- package/src/key-generator.ts +1 -2
- package/dist/typedoc-urls.json +0 -9
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAqC,MAAM,mBAAmB,CAAA;AAEhH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,GAAG,EAAE,UAAU,CAAA;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,eAAe,CAAA;CACxB;AAqED,wBAAgB,YAAY,CAAE,IAAI,EAAE,aAAa,GAAG,MAAM,mBAAmB,CAE5E"}
|
package/dist/src/index.js
CHANGED
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
* fs.writeFileSync('swarm.key', swarmKey)
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
|
-
import { randomBytes } from '@libp2p/crypto';
|
|
59
58
|
import { InvalidParametersError } from '@libp2p/interface';
|
|
60
59
|
import { byteStream } from '@libp2p/utils';
|
|
61
60
|
import { BoxMessageStream, decodeV1PSK } from "./crypto.js";
|
|
@@ -88,7 +87,7 @@ class PreSharedKeyConnectionProtector {
|
|
|
88
87
|
// Exchange nonces
|
|
89
88
|
const log = connection.log.newScope('pnet');
|
|
90
89
|
log('protecting the connection');
|
|
91
|
-
const localNonce =
|
|
90
|
+
const localNonce = crypto.getRandomValues(new Uint8Array(NONCE_LENGTH));
|
|
92
91
|
if (options == null) {
|
|
93
92
|
options = {
|
|
94
93
|
signal: AbortSignal.timeout(this.timeout)
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAoBhD,MAAM,+BAA+B;IAC5B,GAAG,CAAQ;IACD,GAAG,CAAY;IACf,OAAO,CAAQ;IAEhC;;;OAGG;IACH,YAAa,IAAmB;QAC9B,IAAI,CAAC,OAAO,GAA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OAAO,IAAI,gBAAgB,CAAC;YAC1B,UAAU;YACV,WAAW;YACX,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;YACtB,GAAG;SACJ,CAAC,CAAA;IACJ,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAE,IAAmB;IAC/C,OAAO,GAAG,EAAE,CAAC,IAAI,+BAA+B,CAAC,IAAI,CAAC,CAAA;AACxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-generator.d.ts","sourceRoot":"","sources":["../../src/key-generator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"key-generator.d.ts","sourceRoot":"","sources":["../../src/key-generator.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC,WAAW,GAAG,IAAI,CASzE;AAED,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,eAAO,MAAM,UAAU,KAAK,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { randomBytes } from '@libp2p/crypto';
|
|
2
1
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
3
2
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
4
3
|
/**
|
|
@@ -8,7 +7,7 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
|
8
7
|
* @returns {void}
|
|
9
8
|
*/
|
|
10
9
|
export function generateKey(bytes) {
|
|
11
|
-
const psk = uint8ArrayToString(
|
|
10
|
+
const psk = uint8ArrayToString(crypto.getRandomValues(new Uint8Array(KEY_LENGTH)), 'base16');
|
|
12
11
|
const key = uint8ArrayFromString('/key/swarm/psk/1.0.0/\n/base16/\n' + psk);
|
|
13
12
|
if (bytes instanceof Uint8Array) {
|
|
14
13
|
bytes.set(key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-generator.js","sourceRoot":"","sources":["../../src/key-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"key-generator.js","sourceRoot":"","sources":["../../src/key-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAEtE;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAE,KAAsC;IACjE,MAAM,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;IAC5F,MAAM,GAAG,GAAG,oBAAoB,CAAC,mCAAmC,GAAG,GAAG,CAAC,CAAA;IAE3E,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAChB,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAA;AAC9B,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/pnet",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.22-5e07d5963",
|
|
4
4
|
"description": "Implementation of Connection protection management via a shared secret",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/pnet#readme",
|
|
@@ -44,16 +44,15 @@
|
|
|
44
44
|
"doc-check": "aegir doc-check"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@libp2p/
|
|
48
|
-
"@libp2p/
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"uint8arrays": "^5.1.0",
|
|
47
|
+
"@libp2p/interface": "3.2.3-5e07d5963",
|
|
48
|
+
"@libp2p/utils": "7.2.2-5e07d5963",
|
|
49
|
+
"uint8arraylist": "^3.0.2",
|
|
50
|
+
"uint8arrays": "^6.1.1",
|
|
52
51
|
"xsalsa20": "^1.2.0"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
55
54
|
"@types/xsalsa20": "^1.1.3",
|
|
56
|
-
"aegir": "^
|
|
55
|
+
"aegir": "^48.0.11",
|
|
57
56
|
"p-event": "^7.0.0"
|
|
58
57
|
},
|
|
59
58
|
"sideEffects": false
|
package/src/index.ts
CHANGED
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
|
-
import { randomBytes } from '@libp2p/crypto'
|
|
60
59
|
import { InvalidParametersError } from '@libp2p/interface'
|
|
61
60
|
import { byteStream } from '@libp2p/utils'
|
|
62
61
|
import { BoxMessageStream, decodeV1PSK } from './crypto.ts'
|
|
@@ -115,7 +114,7 @@ class PreSharedKeyConnectionProtector implements ConnectionProtector {
|
|
|
115
114
|
// Exchange nonces
|
|
116
115
|
const log = connection.log.newScope('pnet')
|
|
117
116
|
log('protecting the connection')
|
|
118
|
-
const localNonce =
|
|
117
|
+
const localNonce = crypto.getRandomValues(new Uint8Array(NONCE_LENGTH))
|
|
119
118
|
|
|
120
119
|
if (options == null) {
|
|
121
120
|
options = {
|
package/src/key-generator.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { randomBytes } from '@libp2p/crypto'
|
|
2
1
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
3
2
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
4
3
|
|
|
@@ -9,7 +8,7 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
|
9
8
|
* @returns {void}
|
|
10
9
|
*/
|
|
11
10
|
export function generateKey (bytes: Uint8Array | NodeJS.WriteStream): void {
|
|
12
|
-
const psk = uint8ArrayToString(
|
|
11
|
+
const psk = uint8ArrayToString(crypto.getRandomValues(new Uint8Array(KEY_LENGTH)), 'base16')
|
|
13
12
|
const key = uint8ArrayFromString('/key/swarm/psk/1.0.0/\n/base16/\n' + psk)
|
|
14
13
|
|
|
15
14
|
if (bytes instanceof Uint8Array) {
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"ProtectorComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_pnet.ProtectorComponents.html",
|
|
3
|
-
".:ProtectorComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_pnet.ProtectorComponents.html",
|
|
4
|
-
"ProtectorInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_pnet.ProtectorInit.html",
|
|
5
|
-
".:ProtectorInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_pnet.ProtectorInit.html",
|
|
6
|
-
"generateKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_pnet.generateKey.html",
|
|
7
|
-
"preSharedKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_pnet.preSharedKey.html",
|
|
8
|
-
".:preSharedKey": "https://libp2p.github.io/js-libp2p/functions/_libp2p_pnet.preSharedKey.html"
|
|
9
|
-
}
|