hypercore 10.37.16 → 10.37.17
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/lib/core.js +12 -1
- package/package.json +1 -1
package/lib/core.js
CHANGED
|
@@ -107,7 +107,7 @@ module.exports = class Core {
|
|
|
107
107
|
external: null,
|
|
108
108
|
key: opts.key || (compat ? manifest.signers[0].publicKey : Verifier.manifestHash(manifest)),
|
|
109
109
|
manifest,
|
|
110
|
-
keyPair,
|
|
110
|
+
keyPair: keyPair ? { publicKey: keyPair.publicKey, secretKey: keyPair.secretKey || null } : null,
|
|
111
111
|
userData: [],
|
|
112
112
|
tree: {
|
|
113
113
|
fork: 0,
|
|
@@ -131,6 +131,11 @@ module.exports = class Core {
|
|
|
131
131
|
header.tree.rootHash = unslab(header.tree.rootHash)
|
|
132
132
|
header.tree.signature = unslab(header.tree.signature)
|
|
133
133
|
|
|
134
|
+
if (header.keyPair) {
|
|
135
|
+
header.keyPair.publicKey = unslab(header.keyPair.publicKey)
|
|
136
|
+
header.keyPair.secretKey = unslab(header.keyPair.secretKey)
|
|
137
|
+
}
|
|
138
|
+
|
|
134
139
|
if (opts.manifest) {
|
|
135
140
|
// if we provide a manifest and no key, verify that the stored key is the same
|
|
136
141
|
if (!opts.key && !Verifier.isValidManifest(header.key, Verifier.createManifest(opts.manifest))) {
|
|
@@ -204,6 +209,10 @@ module.exports = class Core {
|
|
|
204
209
|
}
|
|
205
210
|
}
|
|
206
211
|
|
|
212
|
+
for (const entry of header.userData) {
|
|
213
|
+
entry.value = unslab(entry.value)
|
|
214
|
+
}
|
|
215
|
+
|
|
207
216
|
return new this(header, compat, crypto, oplog, bigHeader, tree, blocks, bitfield, verifier, opts.sessions || [], legacy, opts.globalCache || null, opts.onupdate || noop, opts.onconflict || noop)
|
|
208
217
|
}
|
|
209
218
|
|
|
@@ -1022,6 +1031,8 @@ function addReorgHint (list, tree, batch) {
|
|
|
1022
1031
|
}
|
|
1023
1032
|
|
|
1024
1033
|
function updateUserData (list, key, value) {
|
|
1034
|
+
value = unslab(value)
|
|
1035
|
+
|
|
1025
1036
|
for (let i = 0; i < list.length; i++) {
|
|
1026
1037
|
if (list[i].key === key) {
|
|
1027
1038
|
if (value) list[i].value = value
|