corestore 6.0.1-alpha.15 → 6.0.1-alpha.16
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 +2 -2
- package/package.json +1 -1
- package/test/all.js +24 -0
package/index.js
CHANGED
|
@@ -202,7 +202,7 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
202
202
|
return { from: core, keyPair, auth }
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
async createKeyPair (name) {
|
|
205
|
+
async createKeyPair (name, namespace = this._namespace) {
|
|
206
206
|
if (!this.primaryKey) await this._opening
|
|
207
207
|
|
|
208
208
|
const keyPair = {
|
|
@@ -216,7 +216,7 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
const seed = deriveSeed(this.primaryKey,
|
|
219
|
+
const seed = deriveSeed(this.primaryKey, namespace, name)
|
|
220
220
|
sodium.crypto_sign_seed_keypair(keyPair.publicKey, keyPair.secretKey, seed)
|
|
221
221
|
|
|
222
222
|
return keyPair
|
package/package.json
CHANGED
package/test/all.js
CHANGED
|
@@ -168,6 +168,30 @@ test('writable core loaded from name userData', async function (t) {
|
|
|
168
168
|
t.alike(await core.get(1), Buffer.from('world'))
|
|
169
169
|
})
|
|
170
170
|
|
|
171
|
+
test('writable core loaded from name and namespace userData', async function (t) {
|
|
172
|
+
const dir = tmpdir()
|
|
173
|
+
|
|
174
|
+
let store = new Corestore(dir)
|
|
175
|
+
let core = store.namespace('ns1').get({ name: 'main' })
|
|
176
|
+
await core.ready()
|
|
177
|
+
const key = core.key
|
|
178
|
+
|
|
179
|
+
t.ok(core.writable)
|
|
180
|
+
await core.append('hello')
|
|
181
|
+
t.is(core.length, 1)
|
|
182
|
+
|
|
183
|
+
await store.close()
|
|
184
|
+
store = new Corestore(dir)
|
|
185
|
+
core = store.get(key)
|
|
186
|
+
await core.ready()
|
|
187
|
+
|
|
188
|
+
t.ok(core.writable)
|
|
189
|
+
await core.append('world')
|
|
190
|
+
t.is(core.length, 2)
|
|
191
|
+
t.alike(await core.get(0), Buffer.from('hello'))
|
|
192
|
+
t.alike(await core.get(1), Buffer.from('world'))
|
|
193
|
+
})
|
|
194
|
+
|
|
171
195
|
test('storage locking', async function (t) {
|
|
172
196
|
const dir = tmpdir()
|
|
173
197
|
|