@dotrino/identity 0.54.0 → 0.54.1
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/package.json +1 -1
- package/vault/acta.js +5 -2
- package/vault/core.js +11 -0
package/package.json
CHANGED
package/vault/acta.js
CHANGED
|
@@ -253,8 +253,11 @@ export async function applyChanges (acta, changes, { by, now = Date.now(), sealP
|
|
|
253
253
|
if (!by) throw new Error('applyChanges: missing `by` (who seals)')
|
|
254
254
|
if (by !== acta.sealer) throw new Error('only the master can change the record; this device is not the master')
|
|
255
255
|
|
|
256
|
-
const list = Array.isArray(changes) ? changes : [changes]
|
|
257
|
-
|
|
256
|
+
const list = (Array.isArray(changes) ? changes : [changes]).filter(Boolean)
|
|
257
|
+
// Estrenar la llave de sellado ES un cambio del acta, aunque no toque a ningún miembro:
|
|
258
|
+
// rota con el acta (§8.9) y el acta es lo que le da autoridad. Por eso una lista vacía
|
|
259
|
+
// se acepta si viene con llave nueva, y solo entonces.
|
|
260
|
+
if (list.length === 0 && !sealPub) throw new Error('applyChanges: no hay cambios')
|
|
258
261
|
|
|
259
262
|
const next = {
|
|
260
263
|
...acta,
|
package/vault/core.js
CHANGED
|
@@ -1474,6 +1474,17 @@ export async function createIdentityCore ({ kv: rawKv, peers, makeSync = null, k
|
|
|
1474
1474
|
sealKeyProvider = typeof fn === 'function' ? fn : null
|
|
1475
1475
|
},
|
|
1476
1476
|
|
|
1477
|
+
/**
|
|
1478
|
+
* Estrena la llave de sellado sin tocar a nadie más: pide una al proveedor y la nombra
|
|
1479
|
+
* en un acta nueva. Es lo que hace la bóveda al arrancar si el acta no tiene llave, o
|
|
1480
|
+
* si la que nombra no es suya (el disco se restauró, otro master la puso…).
|
|
1481
|
+
*/
|
|
1482
|
+
async rotateSealKey () {
|
|
1483
|
+
if (!sealKeyProvider) throw new Error('this identity does not seal envelopes')
|
|
1484
|
+
const acta = await sealChanges([])
|
|
1485
|
+
return { ok: true, seq: acta.seq, sealPub: acta.sealPub }
|
|
1486
|
+
},
|
|
1487
|
+
|
|
1477
1488
|
/** La llave con la que se firmaron los sobres de un acta dada. Para VERIFICARLOS. */
|
|
1478
1489
|
sealKeyAt (seq) {
|
|
1479
1490
|
return Acta.sealKeyAt(loadActa(), seq)
|