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