hypercore 10.0.0-alpha.7 → 10.0.0-alpha.8

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.
Files changed (2) hide show
  1. package/index.js +5 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -48,9 +48,9 @@ module.exports = class Hypercore extends EventEmitter {
48
48
  this.crypto = opts.crypto || hypercoreCrypto
49
49
  this.core = null
50
50
  this.replicator = null
51
+ this.encryption = null
51
52
  this.extensions = opts.extensions || new Extensions()
52
53
  this.cache = opts.cache === true ? new Xache({ maxSize: 65536, maxAge: 0 }) : (opts.cache || null)
53
- this.encryption = opts.encryption || null
54
54
 
55
55
  this.valueEncoding = null
56
56
  this.key = key || null
@@ -67,7 +67,7 @@ module.exports = class Hypercore extends EventEmitter {
67
67
  this.opening = opts._opening || this._open(key, storage, opts)
68
68
  this.opening.catch(noop)
69
69
 
70
- this._preappend = this.encryption && preappend.bind(this)
70
+ this._preappend = preappend.bind(this)
71
71
  }
72
72
 
73
73
  [inspect] (depth, opts) {
@@ -123,7 +123,6 @@ module.exports = class Hypercore extends EventEmitter {
123
123
  ...opts,
124
124
  sign: opts.sign || (keyPair && keyPair.secretKey && Core.createSigner(this.crypto, keyPair)) || this.sign,
125
125
  valueEncoding: this.valueEncoding,
126
- encryption: this.encryption,
127
126
  extensions: this.extensions,
128
127
  _opening: this.opening,
129
128
  _sessions: this.sessions
@@ -143,6 +142,7 @@ module.exports = class Hypercore extends EventEmitter {
143
142
  this.discoveryKey = o.discoveryKey
144
143
  this.core = o.core
145
144
  this.replicator = o.replicator
145
+ this.encryption = o.encryption
146
146
  this.writable = !!this.sign
147
147
  this.autoClose = o.autoClose
148
148
  }
@@ -286,7 +286,6 @@ module.exports = class Hypercore extends EventEmitter {
286
286
 
287
287
  if (!this.encryption && opts.encryptionKey) {
288
288
  this.encryption = new BlockEncryption(opts.encryptionKey, this.key)
289
- this._preappend = preappend.bind(this)
290
289
  }
291
290
 
292
291
  this.extensions.attach(this.replicator)
@@ -460,15 +459,14 @@ module.exports = class Hypercore extends EventEmitter {
460
459
 
461
460
  blocks = Array.isArray(blocks) ? blocks : [blocks]
462
461
 
462
+ const preappend = this.encryption && this._preappend
463
463
  const buffers = new Array(blocks.length)
464
464
 
465
465
  for (let i = 0; i < blocks.length; i++) {
466
466
  buffers[i] = this._encode(this.valueEncoding, blocks[i])
467
467
  }
468
468
 
469
- return await this.core.append(buffers, this.sign, {
470
- preappend: this._preappend
471
- })
469
+ return await this.core.append(buffers, this.sign, { preappend })
472
470
  }
473
471
 
474
472
  registerExtension (name, handlers) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.0.0-alpha.7",
3
+ "version": "10.0.0-alpha.8",
4
4
  "description": "Hypercore 10",
5
5
  "main": "index.js",
6
6
  "scripts": {