corestore 6.12.0 → 6.13.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 +6 -24
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -169,7 +169,6 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
169
169
|
if (opts._discoveryKey) {
|
|
170
170
|
return {
|
|
171
171
|
keyPair: null,
|
|
172
|
-
auth: null,
|
|
173
172
|
discoveryKey: opts._discoveryKey
|
|
174
173
|
}
|
|
175
174
|
}
|
|
@@ -179,18 +178,16 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
179
178
|
publicKey: opts.publicKey,
|
|
180
179
|
secretKey: opts.secretKey
|
|
181
180
|
},
|
|
182
|
-
sign: opts.sign,
|
|
183
|
-
auth: opts.auth,
|
|
184
181
|
discoveryKey: crypto.discoveryKey(opts.publicKey)
|
|
185
182
|
}
|
|
186
183
|
}
|
|
187
|
-
const { publicKey,
|
|
184
|
+
const { publicKey, secretKey } = await this.createKeyPair(opts.name)
|
|
185
|
+
|
|
188
186
|
return {
|
|
189
187
|
keyPair: {
|
|
190
188
|
publicKey,
|
|
191
|
-
secretKey
|
|
189
|
+
secretKey
|
|
192
190
|
},
|
|
193
|
-
auth,
|
|
194
191
|
discoveryKey: crypto.discoveryKey(publicKey)
|
|
195
192
|
}
|
|
196
193
|
}
|
|
@@ -208,13 +205,9 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
208
205
|
if (!name) return
|
|
209
206
|
|
|
210
207
|
const namespace = this._getPrereadyUserData(core, USERDATA_NAMESPACE_KEY)
|
|
211
|
-
const
|
|
212
|
-
if (!b4a.equals(publicKey, core.key)) throw new Error('Stored core key does not match the provided name')
|
|
208
|
+
const keyPair = await this.createKeyPair(b4a.toString(name), namespace)
|
|
213
209
|
|
|
214
|
-
|
|
215
|
-
core.auth = auth
|
|
216
|
-
core.key = publicKey
|
|
217
|
-
core.writable = true
|
|
210
|
+
core.setKeyPair(keyPair)
|
|
218
211
|
}
|
|
219
212
|
|
|
220
213
|
_getLock (id) {
|
|
@@ -293,13 +286,7 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
293
286
|
|
|
294
287
|
const keyPair = {
|
|
295
288
|
publicKey: b4a.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES),
|
|
296
|
-
secretKey: b4a.alloc(sodium.crypto_sign_SECRETKEYBYTES)
|
|
297
|
-
auth: {
|
|
298
|
-
sign: (msg) => sign(keyPair, msg),
|
|
299
|
-
verify: (signable, signature) => {
|
|
300
|
-
return crypto.verify(signable, signature, keyPair.publicKey)
|
|
301
|
-
}
|
|
302
|
-
}
|
|
289
|
+
secretKey: b4a.alloc(sodium.crypto_sign_SECRETKEYBYTES)
|
|
303
290
|
}
|
|
304
291
|
|
|
305
292
|
const seed = deriveSeed(this.primaryKey, namespace, name)
|
|
@@ -454,11 +441,6 @@ module.exports = class Corestore extends ReadyResource {
|
|
|
454
441
|
}
|
|
455
442
|
}
|
|
456
443
|
|
|
457
|
-
function sign (keyPair, message) {
|
|
458
|
-
if (!keyPair.secretKey) throw new Error('Invalid key pair')
|
|
459
|
-
return crypto.sign(message, keyPair.secretKey)
|
|
460
|
-
}
|
|
461
|
-
|
|
462
444
|
function validateGetOptions (opts) {
|
|
463
445
|
const key = (b4a.isBuffer(opts) || typeof opts === 'string') ? hypercoreId.decode(opts) : null
|
|
464
446
|
if (key) return { key, publicKey: key }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corestore",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.13.0",
|
|
4
4
|
"description": "A Hypercore factory that simplifies managing collections of cores.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"b4a": "^1.6.4",
|
|
34
|
-
"hypercore": "^10.
|
|
34
|
+
"hypercore": "^10.21.0",
|
|
35
35
|
"hypercore-crypto": "^3.4.0",
|
|
36
36
|
"hypercore-id-encoding": "^1.2.0",
|
|
37
37
|
"read-write-mutexify": "^2.1.0",
|