@dotrino/vaultd 0.89.0 → 0.90.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/package.json +1 -1
- package/src/vault.js +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/vaultd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.90.0",
|
|
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/vault.js
CHANGED
|
@@ -333,6 +333,23 @@ export async function startVault ({ dir = dataDir(), proxyUrl, log = console.log
|
|
|
333
333
|
// rotación no necesita abrir nada.
|
|
334
334
|
const activityFile = path.join(dir, 'activity.log')
|
|
335
335
|
const activityAtRest = atRestFor(dir)
|
|
336
|
+
// MIGRACIÓN de las bitácoras escritas antes de 0.89, que están en claro. Se convierten
|
|
337
|
+
// de una vez al arrancar: es un archivo acotado (rota al MB) y así «nada en claro» es
|
|
338
|
+
// cierto también para lo que ya estaba escrito, no solo para lo que se escriba desde
|
|
339
|
+
// ahora. Se agota sola — cuando no queda ninguna línea en claro, no vuelve a tocar nada.
|
|
340
|
+
try {
|
|
341
|
+
const crudo = fs.readFileSync(activityFile, 'utf8')
|
|
342
|
+
const lineas = crudo.split('\n')
|
|
343
|
+
if (lineas.some((l) => l && !l.startsWith('DOTRINO-ATREST-v1.'))) {
|
|
344
|
+
const convertidas = lineas.map((l) => (l && !l.startsWith('DOTRINO-ATREST-v1.') ? activityAtRest.encrypt(l) : l))
|
|
345
|
+
// Escribir aparte y renombrar: a medio convertir, la bitácora sería ilegible entera.
|
|
346
|
+
fs.writeFileSync(activityFile + '.tmp', convertidas.join('\n'), { mode: 0o600 })
|
|
347
|
+
fs.renameSync(activityFile + '.tmp', activityFile)
|
|
348
|
+
log('[vault] activity log: %d line(s) sealed at rest', convertidas.filter(Boolean).length)
|
|
349
|
+
}
|
|
350
|
+
// Y el modo, que hasta 0.89 se creaba 0664: legible por cualquier usuario.
|
|
351
|
+
if ((fs.statSync(activityFile).mode & 0o077) !== 0) fs.chmodSync(activityFile, 0o600)
|
|
352
|
+
} catch (_) { /* no hay bitácora todavía */ }
|
|
336
353
|
const audit = (op, info = {}) => {
|
|
337
354
|
try {
|
|
338
355
|
const line = activityAtRest.encrypt(JSON.stringify({ ts: Date.now(), op, ...info }))
|