@libp2p/pnet 1.0.0-e2267d437 → 1.0.0-ee7ffe9b9
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 +8 -8
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -7
- package/dist/src/index.js.map +1 -1
- package/package.json +12 -8
- package/src/index.ts +12 -9
package/dist/src/index.d.ts
CHANGED
@@ -55,8 +55,7 @@
|
|
55
55
|
* fs.writeFileSync('swarm.key', swarmKey)
|
56
56
|
* ```
|
57
57
|
*/
|
58
|
-
import type { ComponentLogger } from '@libp2p/interface';
|
59
|
-
import type { ConnectionProtector } from '@libp2p/interface/connection';
|
58
|
+
import type { ComponentLogger, ConnectionProtector } from '@libp2p/interface';
|
60
59
|
export { generateKey } from './key-generator.js';
|
61
60
|
export interface ProtectorInit {
|
62
61
|
/**
|
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;AAeH,OAAO,KAAK,EAAE,eAAe,EAAU,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAeH,OAAO,KAAK,EAAE,eAAe,EAAU,mBAAmB,EAAuB,MAAM,mBAAmB,CAAA;AAG1G,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,GAAG,EAAE,UAAU,CAAA;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,eAAe,CAAA;CACxB;AAyED,wBAAgB,YAAY,CAAE,IAAI,EAAE,aAAa,GAAG,CAAC,UAAU,EAAE,mBAAmB,KAAK,mBAAmB,CAE3G"}
|
package/dist/src/index.js
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
* ```
|
57
57
|
*/
|
58
58
|
import { randomBytes } from '@libp2p/crypto';
|
59
|
-
import { CodeError } from '@libp2p/interface
|
59
|
+
import { CodeError } from '@libp2p/interface';
|
60
60
|
import { byteStream } from 'it-byte-stream';
|
61
61
|
import map from 'it-map';
|
62
62
|
import { duplexPair } from 'it-pair/duplex';
|
@@ -95,12 +95,14 @@ class PreSharedKeyConnectionProtector {
|
|
95
95
|
const localNonce = randomBytes(NONCE_LENGTH);
|
96
96
|
const signal = AbortSignal.timeout(this.timeout);
|
97
97
|
const bytes = byteStream(connection);
|
98
|
-
await
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
const [, result] = await Promise.all([
|
99
|
+
bytes.write(localNonce, {
|
100
|
+
signal
|
101
|
+
}),
|
102
|
+
bytes.read(NONCE_LENGTH, {
|
103
|
+
signal
|
104
|
+
})
|
105
|
+
]);
|
104
106
|
const remoteNonce = result.subarray();
|
105
107
|
// Create the boxing/unboxing pipe
|
106
108
|
this.log('exchanged nonces');
|
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,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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+B,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAC9E,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@libp2p/pnet",
|
3
|
-
"version": "1.0.0-
|
3
|
+
"version": "1.0.0-ee7ffe9b9",
|
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",
|
@@ -11,6 +11,10 @@
|
|
11
11
|
"bugs": {
|
12
12
|
"url": "https://github.com/libp2p/js-libp2p/issues"
|
13
13
|
},
|
14
|
+
"publishConfig": {
|
15
|
+
"access": "public",
|
16
|
+
"provenance": true
|
17
|
+
},
|
14
18
|
"type": "module",
|
15
19
|
"types": "./dist/src/index.d.ts",
|
16
20
|
"files": [
|
@@ -45,24 +49,24 @@
|
|
45
49
|
"dep-check": "aegir dep-check"
|
46
50
|
},
|
47
51
|
"dependencies": {
|
48
|
-
"@libp2p/crypto": "
|
49
|
-
"@libp2p/interface": "
|
52
|
+
"@libp2p/crypto": "3.0.4-ee7ffe9b9",
|
53
|
+
"@libp2p/interface": "1.1.1-ee7ffe9b9",
|
50
54
|
"it-byte-stream": "^1.0.5",
|
51
55
|
"it-map": "^3.0.4",
|
52
56
|
"it-pair": "^2.0.6",
|
53
57
|
"it-pipe": "^3.0.1",
|
54
58
|
"it-stream-types": "^2.0.1",
|
55
59
|
"uint8arraylist": "^2.4.7",
|
56
|
-
"uint8arrays": "^
|
60
|
+
"uint8arrays": "^5.0.0",
|
57
61
|
"xsalsa20": "^1.1.0"
|
58
62
|
},
|
59
63
|
"devDependencies": {
|
60
|
-
"@libp2p/interface-compliance-tests": "
|
61
|
-
"@libp2p/logger": "
|
62
|
-
"@libp2p/peer-id-factory": "
|
64
|
+
"@libp2p/interface-compliance-tests": "5.1.1-ee7ffe9b9",
|
65
|
+
"@libp2p/logger": "4.0.4-ee7ffe9b9",
|
66
|
+
"@libp2p/peer-id-factory": "4.0.3-ee7ffe9b9",
|
63
67
|
"@multiformats/multiaddr": "^12.1.10",
|
64
68
|
"@types/xsalsa20": "^1.1.0",
|
65
|
-
"aegir": "^
|
69
|
+
"aegir": "^42.0.0",
|
66
70
|
"it-all": "^3.0.3"
|
67
71
|
}
|
68
72
|
}
|
package/src/index.ts
CHANGED
@@ -57,7 +57,7 @@
|
|
57
57
|
*/
|
58
58
|
|
59
59
|
import { randomBytes } from '@libp2p/crypto'
|
60
|
-
import { CodeError } from '@libp2p/interface
|
60
|
+
import { CodeError } from '@libp2p/interface'
|
61
61
|
import { byteStream } from 'it-byte-stream'
|
62
62
|
import map from 'it-map'
|
63
63
|
import { duplexPair } from 'it-pair/duplex'
|
@@ -69,8 +69,7 @@ import {
|
|
69
69
|
} from './crypto.js'
|
70
70
|
import * as Errors from './errors.js'
|
71
71
|
import { NONCE_LENGTH } from './key-generator.js'
|
72
|
-
import type { ComponentLogger, Logger } from '@libp2p/interface'
|
73
|
-
import type { ConnectionProtector, MultiaddrConnection } from '@libp2p/interface/connection'
|
72
|
+
import type { ComponentLogger, Logger, ConnectionProtector, MultiaddrConnection } from '@libp2p/interface'
|
74
73
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
75
74
|
|
76
75
|
export { generateKey } from './key-generator.js'
|
@@ -128,13 +127,17 @@ class PreSharedKeyConnectionProtector implements ConnectionProtector {
|
|
128
127
|
const signal = AbortSignal.timeout(this.timeout)
|
129
128
|
|
130
129
|
const bytes = byteStream(connection)
|
131
|
-
await bytes.write(localNonce, {
|
132
|
-
signal
|
133
|
-
})
|
134
130
|
|
135
|
-
const
|
136
|
-
|
137
|
-
|
131
|
+
const [
|
132
|
+
, result
|
133
|
+
] = await Promise.all([
|
134
|
+
bytes.write(localNonce, {
|
135
|
+
signal
|
136
|
+
}),
|
137
|
+
bytes.read(NONCE_LENGTH, {
|
138
|
+
signal
|
139
|
+
})
|
140
|
+
])
|
138
141
|
|
139
142
|
const remoteNonce = result.subarray()
|
140
143
|
|