corestore 6.8.4 → 6.9.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/README.md +1 -1
- package/index.js +5 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Create a new Corestore instance.
|
|
|
30
30
|
`storage` can be either a random-access-storage module, a string, or a function that takes a path and returns an random-access-storage instance.
|
|
31
31
|
|
|
32
32
|
#### `const core = store.get(key | { name: 'a-name', exclusive, ...hypercoreOpts})`
|
|
33
|
-
Loads a Hypercore, either by name (if the `name` option is provided), or from the provided key (if the first argument is a Buffer, or if the `key` options is set).
|
|
33
|
+
Loads a Hypercore, either by name (if the `name` option is provided), or from the provided key (if the first argument is a Buffer or String with hex/z32 key, or if the `key` options is set).
|
|
34
34
|
|
|
35
35
|
If that Hypercore has previously been loaded, subsequent calls to `get` will return a new Hypercore session on the existing core.
|
|
36
36
|
|
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ const safetyCatch = require('safety-catch')
|
|
|
2
2
|
const crypto = require('hypercore-crypto')
|
|
3
3
|
const sodium = require('sodium-universal')
|
|
4
4
|
const Hypercore = require('hypercore')
|
|
5
|
+
const hypercoreId = require('hypercore-id-encoding')
|
|
5
6
|
const Xache = require('xache')
|
|
6
7
|
const b4a = require('b4a')
|
|
7
8
|
const ReadyResource = require('ready-resource')
|
|
@@ -434,9 +435,11 @@ function sign (keyPair, message) {
|
|
|
434
435
|
}
|
|
435
436
|
|
|
436
437
|
function validateGetOptions (opts) {
|
|
437
|
-
|
|
438
|
+
const key = (b4a.isBuffer(opts) || typeof opts === 'string') ? hypercoreId.decode(opts) : null
|
|
439
|
+
if (key) return { key, publicKey: key }
|
|
440
|
+
|
|
438
441
|
if (opts.key) {
|
|
439
|
-
opts.publicKey = opts.key
|
|
442
|
+
opts.key = opts.publicKey = hypercoreId.decode(opts.key)
|
|
440
443
|
}
|
|
441
444
|
if (opts.keyPair) {
|
|
442
445
|
opts.publicKey = opts.keyPair.publicKey
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corestore",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.9.0",
|
|
4
4
|
"description": "A Hypercore factory that simplifies managing collections of cores.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"b4a": "^1.3.1",
|
|
33
33
|
"hypercore": "^10.12.0",
|
|
34
34
|
"hypercore-crypto": "^3.2.1",
|
|
35
|
+
"hypercore-id-encoding": "^1.1.0",
|
|
35
36
|
"read-write-mutexify": "^2.1.0",
|
|
36
37
|
"ready-resource": "^1.0.0",
|
|
37
38
|
"safety-catch": "^1.0.1",
|