@dotrino/vaultd 0.94.0 → 0.94.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/src/ctl.js +6 -4
- package/src/vault.js +10 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/vaultd",
|
|
3
|
-
"version": "0.94.
|
|
3
|
+
"version": "0.94.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Certificador personal de Dotrino: daemon headless que custodia la clave maestra y delega capacidades a tus dispositivos por el proxy. Tu CA propia.",
|
|
6
6
|
"bin": {
|
package/src/ctl.js
CHANGED
|
@@ -963,12 +963,14 @@ function verifyActivity (lines) {
|
|
|
963
963
|
let prev = null; let seq = null; let checked = 0; let unchained = 0
|
|
964
964
|
for (const text of lines) {
|
|
965
965
|
let e; try { e = JSON.parse(text) } catch { continue }
|
|
966
|
-
|
|
966
|
+
// Sin `logSeq` es de antes de que la cadena existiera: no se puede verificar, y se
|
|
967
|
+
// dice cuántas hay en vez de callarlo.
|
|
968
|
+
if (typeof e.logSeq !== 'number') { unchained++; continue }
|
|
967
969
|
if (seq !== null) {
|
|
968
|
-
if (e.
|
|
969
|
-
if (e.
|
|
970
|
+
if (e.logSeq !== seq + 1) return { ok: false, at: e.logSeq, why: `salta del #${seq} al #${e.logSeq}` }
|
|
971
|
+
if (e.logPrev !== prev) return { ok: false, at: e.logSeq, why: `el #${e.logSeq} no encadena con el #${seq}` }
|
|
970
972
|
}
|
|
971
|
-
seq = e.
|
|
973
|
+
seq = e.logSeq; prev = sha256(text); checked++
|
|
972
974
|
}
|
|
973
975
|
return { ok: true, checked, unchained, last: seq }
|
|
974
976
|
}
|
package/src/vault.js
CHANGED
|
@@ -400,7 +400,7 @@ export async function startVault ({ dir = dataDir(), proxyUrl, log = console.log
|
|
|
400
400
|
try {
|
|
401
401
|
const text = activityAtRest.decrypt(lines[i])
|
|
402
402
|
const e = JSON.parse(text)
|
|
403
|
-
if (typeof e.
|
|
403
|
+
if (typeof e.logSeq === 'number') { auditSeq = e.logSeq; auditPrev = sha256(text); break }
|
|
404
404
|
} catch (_) { /* una línea vieja o ilegible: se sigue hacia atrás */ }
|
|
405
405
|
}
|
|
406
406
|
} catch (_) { /* no hay bitácora todavía */ }
|
|
@@ -424,7 +424,15 @@ export async function startVault ({ dir = dataDir(), proxyUrl, log = console.log
|
|
|
424
424
|
|
|
425
425
|
const audit = (op, info = {}) => {
|
|
426
426
|
try {
|
|
427
|
-
|
|
427
|
+
// LOS CAMPOS DE LA CADENA VAN AL FINAL Y CON NOMBRE PROPIO, y las dos cosas por el
|
|
428
|
+
// mismo motivo: que quien llama no pueda pisarlos.
|
|
429
|
+
//
|
|
430
|
+
// Estaban delante y se llamaban `seq`/`prev`, así que `...info` los sobrescribía. Y
|
|
431
|
+
// no era hipotético: `renew` ya mandaba un `seq` —el del ACTA, que no tiene nada que
|
|
432
|
+
// ver— y dejaba dos entradas seguidas numeradas igual. Lo cazó el propio verificador
|
|
433
|
+
// contra la bitácora de producción a los diez minutos de desplegarlo, que es
|
|
434
|
+
// exactamente para lo que sirve.
|
|
435
|
+
const entry = { ...info, ts: Date.now(), op, logSeq: ++auditSeq, logPrev: auditPrev }
|
|
428
436
|
const text = JSON.stringify(entry)
|
|
429
437
|
fs.appendFileSync(activityFile, activityAtRest.encrypt(text) + '\n', { mode: 0o600 })
|
|
430
438
|
auditPrev = sha256(text)
|