hypercore 10.23.0 → 10.24.0
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 +4 -12
- package/lib/manifest.js +1 -1
- package/lib/multisig.js +5 -5
- package/package.json +2 -1
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const Xache = require('xache')
|
|
|
8
8
|
const NoiseSecretStream = require('@hyperswarm/secret-stream')
|
|
9
9
|
const Protomux = require('protomux')
|
|
10
10
|
const z32 = require('z32')
|
|
11
|
+
const id = require('hypercore-id-encoding')
|
|
11
12
|
|
|
12
13
|
const Replicator = require('./lib/replicator')
|
|
13
14
|
const Core = require('./lib/core')
|
|
@@ -42,16 +43,9 @@ module.exports = class Hypercore extends EventEmitter {
|
|
|
42
43
|
key = opts.key || null
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
if (key && typeof key === 'string')
|
|
46
|
-
key = b4a.from(key, 'hex')
|
|
47
|
-
}
|
|
48
|
-
|
|
46
|
+
if (key && typeof key === 'string') key = id.decode(key)
|
|
49
47
|
if (!opts) opts = {}
|
|
50
48
|
|
|
51
|
-
if (!opts.crypto && key && key.byteLength !== 32) {
|
|
52
|
-
throw BAD_ARGUMENT('Hypercore key should be 32 bytes')
|
|
53
|
-
}
|
|
54
|
-
|
|
55
49
|
if (!storage) storage = opts.storage
|
|
56
50
|
|
|
57
51
|
this[promises] = true
|
|
@@ -85,7 +79,6 @@ module.exports = class Hypercore extends EventEmitter {
|
|
|
85
79
|
this.closing = null
|
|
86
80
|
this.opening = null
|
|
87
81
|
|
|
88
|
-
this._manifest = opts.manifest || null
|
|
89
82
|
this._clone = opts.clone || null
|
|
90
83
|
this._readonly = opts.writable === false
|
|
91
84
|
this._preappend = preappend.bind(this)
|
|
@@ -546,7 +539,7 @@ module.exports = class Hypercore extends EventEmitter {
|
|
|
546
539
|
}
|
|
547
540
|
|
|
548
541
|
get manifest () {
|
|
549
|
-
return this.
|
|
542
|
+
return this.core === null ? null : this.core.header.manifest
|
|
550
543
|
}
|
|
551
544
|
|
|
552
545
|
get length () {
|
|
@@ -642,8 +635,7 @@ module.exports = class Hypercore extends EventEmitter {
|
|
|
642
635
|
|
|
643
636
|
if (status & 0b10000) {
|
|
644
637
|
for (let i = 0; i < this.sessions.length; i++) {
|
|
645
|
-
|
|
646
|
-
if (!s._manifest) s.emit('manifest')
|
|
638
|
+
this.sessions[i].emit('manifest')
|
|
647
639
|
}
|
|
648
640
|
}
|
|
649
641
|
|
package/lib/manifest.js
CHANGED
|
@@ -188,7 +188,7 @@ function parseSigner (signer) {
|
|
|
188
188
|
|
|
189
189
|
function validateSigner (signer) {
|
|
190
190
|
if (!signer || !signer.publicKey) throw BAD_ARGUMENT('Signer missing public key')
|
|
191
|
-
if (signer.signature !== 'ed25519') throw BAD_ARGUMENT('Only Ed25519 signatures are supported')
|
|
191
|
+
if (signer.signature && signer.signature !== 'ed25519') throw BAD_ARGUMENT('Only Ed25519 signatures are supported')
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
function defaultSignerManifest (publicKey) {
|
package/lib/multisig.js
CHANGED
|
@@ -24,9 +24,9 @@ function inflate (data) {
|
|
|
24
24
|
return inputs
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
async function partialSignature (
|
|
28
|
-
if (from >
|
|
29
|
-
const patch = to <= from ? null : await upgrade(
|
|
27
|
+
async function partialSignature (tree, signer, from, to = tree.length, signature = tree.signature) {
|
|
28
|
+
if (from > tree.length) return null
|
|
29
|
+
const patch = to <= from ? null : await upgrade(tree, from, to)
|
|
30
30
|
|
|
31
31
|
return {
|
|
32
32
|
signer,
|
|
@@ -35,8 +35,8 @@ async function partialSignature (core, signer, from, to = core.core.tree.length,
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
async function upgrade (
|
|
39
|
-
const p = await
|
|
38
|
+
async function upgrade (tree, from, to) {
|
|
39
|
+
const p = await tree.proof({ upgrade: { start: from, length: to - from } })
|
|
40
40
|
p.upgrade.additionalNodes = []
|
|
41
41
|
p.upgrade.signature = null
|
|
42
42
|
return p.upgrade
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypercore",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.24.0",
|
|
4
4
|
"description": "Hypercore is a secure, distributed append-only log",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"flat-tree": "^1.9.0",
|
|
46
46
|
"hypercore-crypto": "^3.2.1",
|
|
47
47
|
"hypercore-errors": "^1.1.0",
|
|
48
|
+
"hypercore-id-encoding": "^1.2.0",
|
|
48
49
|
"is-options": "^1.0.1",
|
|
49
50
|
"protomux": "^3.5.0",
|
|
50
51
|
"quickbit-universal": "^2.1.1",
|