hypercore 10.31.4 → 10.31.5

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 (3) hide show
  1. package/index.js +1 -2
  2. package/lib/core.js +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -985,8 +985,7 @@ module.exports = class Hypercore extends EventEmitter {
985
985
  } = typeof opts === 'number' ? { fork: opts } : opts
986
986
 
987
987
  const writable = !this._readonly && !!(signature || (keyPair && keyPair.secretKey))
988
-
989
- if (writable === false) throw SESSION_NOT_WRITABLE()
988
+ if (writable === false && (newLength > 0 || fork !== this.core.tree.fork)) throw SESSION_NOT_WRITABLE()
990
989
 
991
990
  await this.core.truncate(newLength, fork, { keyPair, signature })
992
991
 
package/lib/core.js CHANGED
@@ -375,7 +375,7 @@ module.exports = class Core {
375
375
 
376
376
  try {
377
377
  const batch = await this.tree.truncate(length, fork)
378
- batch.signature = signature || this.verifier.sign(batch, keyPair)
378
+ if (length > 0) batch.signature = signature || this.verifier.sign(batch, keyPair)
379
379
  await this._truncate(batch, null)
380
380
  } finally {
381
381
  this.truncating--
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.31.4",
3
+ "version": "10.31.5",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {