hypercore 11.5.0 → 11.6.1
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/index.js +9 -17
- package/lib/core.js +0 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -235,8 +235,8 @@ class Hypercore extends EventEmitter {
|
|
|
235
235
|
return s
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
setEncryptionKey (
|
|
239
|
-
const encryption = this._getEncryptionProvider(
|
|
238
|
+
setEncryptionKey (key, opts) {
|
|
239
|
+
const encryption = this._getEncryptionProvider({ key, block: !!(opts && opts.block) })
|
|
240
240
|
return this.setEncryption(encryption, opts)
|
|
241
241
|
}
|
|
242
242
|
|
|
@@ -253,7 +253,6 @@ class Hypercore extends EventEmitter {
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
this.encryption = encryption
|
|
256
|
-
if (!this.core.encryption) this.core.encryption = this.encryption
|
|
257
256
|
}
|
|
258
257
|
|
|
259
258
|
setKeyPair (keyPair) {
|
|
@@ -329,19 +328,11 @@ class Hypercore extends EventEmitter {
|
|
|
329
328
|
|
|
330
329
|
if (this.keyPair === null) this.keyPair = opts.keyPair || this.core.header.keyPair
|
|
331
330
|
|
|
332
|
-
const e = getEncryptionOption(opts)
|
|
333
|
-
if (!this.core.encryption && e) {
|
|
334
|
-
if (isEncryptionProvider(e)) {
|
|
335
|
-
this.core.encryption = e
|
|
336
|
-
} else {
|
|
337
|
-
this.core.encryption = this._getEncryptionProvider(e.key, e.block)
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
331
|
const parent = opts.parent || null
|
|
332
|
+
if (parent && parent.encryption) this.encryption = parent.encryption
|
|
342
333
|
|
|
343
|
-
|
|
344
|
-
|
|
334
|
+
const e = getEncryptionOption(opts)
|
|
335
|
+
if (!this.encryption) this.encryption = this._getEncryptionProvider(e)
|
|
345
336
|
|
|
346
337
|
this.writable = this._isWritable()
|
|
347
338
|
|
|
@@ -1064,9 +1055,10 @@ class Hypercore extends EventEmitter {
|
|
|
1064
1055
|
return block
|
|
1065
1056
|
}
|
|
1066
1057
|
|
|
1067
|
-
_getEncryptionProvider (
|
|
1068
|
-
if (
|
|
1069
|
-
|
|
1058
|
+
_getEncryptionProvider (e) {
|
|
1059
|
+
if (isEncryptionProvider(e)) return e
|
|
1060
|
+
if (!e || !e.key) return null
|
|
1061
|
+
return new DefaultEncryption(e.key, this.key, { block: e.block, compat: this.core.compat })
|
|
1070
1062
|
}
|
|
1071
1063
|
}
|
|
1072
1064
|
|
package/lib/core.js
CHANGED