autobee 1.0.7 → 1.0.9

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 CHANGED
@@ -492,7 +492,7 @@ module.exports = class Autobee extends ReadyResource {
492
492
  const oldLocal = this.local
493
493
 
494
494
  this.local = newLocal
495
- this.writers.rotateLocalWriter(this.local)
495
+ await this.writers.rotateLocalWriter(this.local)
496
496
 
497
497
  this._updateLocalCore = null
498
498
 
package/lib/encoding.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const b4a = require('b4a')
2
2
  const c = require('compact-encoding')
3
3
  const crypto = require('hypercore-crypto')
4
- const { AutobeeEncryption } = require('autobee-encryption')
4
+ const { AutobeeEncryption, WriterEncryption } = require('autobee-encryption')
5
5
 
6
6
  const { getEncoding } = require('../encoding/spec/autobee')
7
7
  const { LEGACY_OPLOG_VERSION, OPLOG_VERSION } = require('./constants')
@@ -155,6 +155,13 @@ function encodeValue(value, opts = {}) {
155
155
  return b4a.concat([padding.subarray(0, AutobeeEncryption.PADDING), state.buffer])
156
156
  }
157
157
 
158
- function decodeValue(buf, opts = {}) {
158
+ async function decodeValue(buf, { encryptionKey, autobeeKey, key, manifest, index = 0 } = {}) {
159
+ if (encryptionKey) {
160
+ const w = new WriterEncryption({ encryptionKey, key: autobeeKey })
161
+
162
+ await w.decrypt(index, buf, { key, manifest })
163
+ buf = buf.subarray(AutobeeEncryption.PADDING)
164
+ }
165
+
159
166
  return decodeOplog(buf).value
160
167
  }
package/lib/writers.js CHANGED
@@ -67,6 +67,8 @@ class ActiveWriters {
67
67
  this.localWriter = new Writer(this, this.auto.system, true, core, b4a.toString(core.key, 'hex'))
68
68
  this.localWriter.addPending()
69
69
  this.auto.emit('writer', this.localWriter)
70
+
71
+ await this.updateLocalState()
70
72
  }
71
73
 
72
74
  clearLocal() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autobee",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Bee based autobase",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Holepunch Inc.",
@@ -23,7 +23,7 @@
23
23
  "test:generate": "brittle -r test/all.js test/*.js"
24
24
  },
25
25
  "dependencies": {
26
- "autobee-encryption": "^0.0.5",
26
+ "autobee-encryption": "^0.1.2",
27
27
  "autobee-wakeup": "^1.0.5",
28
28
  "b4a": "^1.8.0",
29
29
  "compact-encoding": "^2.18.0",