@libp2p/plaintext 2.0.28-cfe2be4c9 → 2.0.29
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 +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -3
- package/dist/src/index.js.map +1 -1
- package/dist/typedoc-urls.json +6 -0
- package/package.json +6 -7
- package/src/index.ts +8 -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;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH,OAAO,KAAK,EAAE,eAAe,EAA+B,mBAAmB,EAAqB,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH,OAAO,KAAK,EAAE,eAAe,EAA+B,mBAAmB,EAAqB,UAAU,EAA4C,MAAM,mBAAmB,CAAA;AAInL,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,eAAe,CAAA;CACxB;AA0FD,wBAAgB,SAAS,IAAK,CAAC,UAAU,EAAE,mBAAmB,KAAK,mBAAmB,CAErF"}
|
package/dist/src/index.js
CHANGED
|
@@ -49,8 +49,9 @@ class Plaintext {
|
|
|
49
49
|
* Encrypt connection
|
|
50
50
|
*/
|
|
51
51
|
async _encrypt(conn, options) {
|
|
52
|
+
const log = conn.log?.newScope('plaintext') ?? this.log;
|
|
52
53
|
const pb = pbStream(conn).pb(Exchange);
|
|
53
|
-
|
|
54
|
+
log('write pubkey exchange to peer %p', options?.remotePeer);
|
|
54
55
|
const publicKey = this.privateKey.publicKey;
|
|
55
56
|
const [, response] = await Promise.all([
|
|
56
57
|
// Encode the public key and write it to the remote peer
|
|
@@ -82,13 +83,13 @@ class Plaintext {
|
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
catch (err) {
|
|
85
|
-
|
|
86
|
+
log.error(err);
|
|
86
87
|
throw new InvalidCryptoExchangeError('Invalid public key - ' + err.message);
|
|
87
88
|
}
|
|
88
89
|
if (options?.remotePeer != null && !peerId.equals(options?.remotePeer)) {
|
|
89
90
|
throw new UnexpectedPeerError();
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
log('plaintext key exchange completed successfully with peer %p', peerId);
|
|
92
93
|
return {
|
|
93
94
|
conn: pb.unwrap().unwrap(),
|
|
94
95
|
remotePeer: peerId
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACvH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACvH,OAAO,EAAE,mBAAmB,EAAE,MA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AC,CAAA;YACd,MAAM,IAAI,0BAA0B,CAAC,uBAAuB,GAAG,GAAG,CAAC,OAAO,CAAC,CAAA;QAC7E,CAAC;QAED,IAAI,OAAO,EAAE,UAAU,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;YACvE,MAAM,IAAI,mBAAmB,EAAE,CAAA;QACjC,CAAC;QAED,GAAG,CAAC,4DAA4D,EAAE,MAAM,CAAC,CAAA;QAEzE,OAAO;YACL,IAAI,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE;YAC1B,UAAU,EAAE,MAAM;SACnB,CAAA;IACH,CAAC;CACF;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"PlaintextComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_plaintext.PlaintextComponents.html",
|
|
3
|
+
".:PlaintextComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_plaintext.PlaintextComponents.html",
|
|
4
|
+
"plaintext": "https://libp2p.github.io/js-libp2p/functions/_libp2p_plaintext.plaintext.html",
|
|
5
|
+
".:plaintext": "https://libp2p.github.io/js-libp2p/functions/_libp2p_plaintext.plaintext.html"
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/plaintext",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.29",
|
|
4
4
|
"description": "An insecure connection encrypter",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext#readme",
|
|
@@ -45,18 +45,17 @@
|
|
|
45
45
|
"doc-check": "aegir doc-check"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@libp2p/crypto": "5.1.
|
|
49
|
-
"@libp2p/interface": "2.
|
|
50
|
-
"@libp2p/peer-id": "5.1.
|
|
48
|
+
"@libp2p/crypto": "^5.1.8",
|
|
49
|
+
"@libp2p/interface": "^2.11.0",
|
|
50
|
+
"@libp2p/peer-id": "^5.1.9",
|
|
51
51
|
"it-protobuf-stream": "^2.0.2",
|
|
52
|
-
"it-stream-types": "^2.0.2",
|
|
53
52
|
"protons-runtime": "^5.5.0",
|
|
54
53
|
"uint8arraylist": "^2.4.8",
|
|
55
54
|
"uint8arrays": "^5.1.0"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
|
-
"@libp2p/crypto": "5.1.
|
|
59
|
-
"@libp2p/logger": "5.
|
|
57
|
+
"@libp2p/crypto": "^5.1.8",
|
|
58
|
+
"@libp2p/logger": "^5.2.0",
|
|
60
59
|
"aegir": "^47.0.14",
|
|
61
60
|
"it-pair": "^2.0.6",
|
|
62
61
|
"protons": "^7.6.1",
|
package/src/index.ts
CHANGED
|
@@ -27,9 +27,7 @@ import { peerIdFromPublicKey } from '@libp2p/peer-id'
|
|
|
27
27
|
import { pbStream } from 'it-protobuf-stream'
|
|
28
28
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
29
29
|
import { Exchange, KeyType } from './pb/proto.js'
|
|
30
|
-
import type { ComponentLogger, Logger, MultiaddrConnection, ConnectionEncrypter, SecuredConnection, PrivateKey, SecureConnectionOptions } from '@libp2p/interface'
|
|
31
|
-
import type { Duplex } from 'it-stream-types'
|
|
32
|
-
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
30
|
+
import type { ComponentLogger, Logger, MultiaddrConnection, ConnectionEncrypter, SecuredConnection, PrivateKey, SecureConnectionOptions, SecurableStream } from '@libp2p/interface'
|
|
33
31
|
|
|
34
32
|
const PROTOCOL = '/plaintext/2.0.0'
|
|
35
33
|
|
|
@@ -54,21 +52,22 @@ class Plaintext implements ConnectionEncrypter {
|
|
|
54
52
|
'@libp2p/connection-encryption'
|
|
55
53
|
]
|
|
56
54
|
|
|
57
|
-
async secureInbound<Stream extends
|
|
55
|
+
async secureInbound<Stream extends SecurableStream = MultiaddrConnection>(conn: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream>> {
|
|
58
56
|
return this._encrypt(conn, options)
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
async secureOutbound<Stream extends
|
|
59
|
+
async secureOutbound<Stream extends SecurableStream = MultiaddrConnection>(conn: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream>> {
|
|
62
60
|
return this._encrypt(conn, options)
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
/**
|
|
66
64
|
* Encrypt connection
|
|
67
65
|
*/
|
|
68
|
-
async _encrypt<Stream extends
|
|
66
|
+
async _encrypt<Stream extends SecurableStream = MultiaddrConnection>(conn: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream>> {
|
|
67
|
+
const log = conn.log?.newScope('plaintext') ?? this.log
|
|
69
68
|
const pb = pbStream(conn).pb(Exchange)
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
log('write pubkey exchange to peer %p', options?.remotePeer)
|
|
72
71
|
|
|
73
72
|
const publicKey = this.privateKey.publicKey
|
|
74
73
|
|
|
@@ -108,7 +107,7 @@ class Plaintext implements ConnectionEncrypter {
|
|
|
108
107
|
throw new InvalidCryptoExchangeError('Public key did not match id')
|
|
109
108
|
}
|
|
110
109
|
} catch (err: any) {
|
|
111
|
-
|
|
110
|
+
log.error(err)
|
|
112
111
|
throw new InvalidCryptoExchangeError('Invalid public key - ' + err.message)
|
|
113
112
|
}
|
|
114
113
|
|
|
@@ -116,7 +115,7 @@ class Plaintext implements ConnectionEncrypter {
|
|
|
116
115
|
throw new UnexpectedPeerError()
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
|
|
118
|
+
log('plaintext key exchange completed successfully with peer %p', peerId)
|
|
120
119
|
|
|
121
120
|
return {
|
|
122
121
|
conn: pb.unwrap().unwrap(),
|