@dotrino/vault 0.44.0 → 0.45.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/bin/dotrino-env.js +14 -5
- package/package.json +1 -1
- package/src/service.js +8 -3
package/bin/dotrino-env.js
CHANGED
|
@@ -104,7 +104,11 @@ async function cmdEnroll () {
|
|
|
104
104
|
}
|
|
105
105
|
})
|
|
106
106
|
console.log('\nListo. Identidad del servicio en: %s', path.join(dir, 'service-identity.json'))
|
|
107
|
-
|
|
107
|
+
// El papel ya no vence: vale mientras el acta lo diga. Decir «vence» era describir un
|
|
108
|
+
// reloj que ya no existe, y encima REVENTABA —`new Date(undefined).toISOString()` lanza
|
|
109
|
+
// RangeError—, o sea que el comando de diagnóstico se caía justo cuando lo necesitas.
|
|
110
|
+
console.log('Certificado con scope: %s (%s)', (cert.scope || []).join(', '),
|
|
111
|
+
typeof cert.seq === 'number' ? `acta #${cert.seq}` : `del modelo viejo, vence ${new Date(cert.exp).toISOString().slice(0, 10)}`)
|
|
108
112
|
console.log('\nEn tu app: import \'@dotrino/vault/config\' (con DOTRINO_NS=%s)', ns)
|
|
109
113
|
}
|
|
110
114
|
|
|
@@ -116,10 +120,15 @@ function cmdStatus () {
|
|
|
116
120
|
}
|
|
117
121
|
for (const ns of found) {
|
|
118
122
|
const id = readServiceIdentity(serviceDir(ns))
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
const c = id?.cert
|
|
124
|
+
// El papel se describe por el ACTA a la que se ató. Uno del modelo viejo se dice tal
|
|
125
|
+
// cual, con su fecha, porque ESO sí importa: es lo único que todavía caduca, y sabrá
|
|
126
|
+
// el operador que le queda una migración por hacer.
|
|
127
|
+
const papel = typeof c?.seq === 'number'
|
|
128
|
+
? `acta #${c.seq}`
|
|
129
|
+
: (typeof c?.exp === 'number' ? `modelo viejo · vence ${new Date(c.exp).toISOString().slice(0, 10)}` : '?')
|
|
130
|
+
console.log('%s\n dir: %s\n vault: %s…\n scope: %s\n cert: %s',
|
|
131
|
+
ns, serviceDir(ns), String(id.iss).slice(0, 24), (c?.scope || []).join(', '), papel)
|
|
123
132
|
}
|
|
124
133
|
}
|
|
125
134
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/vault",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.1",
|
|
4
4
|
"description": "Usa ESTE dispositivo (navegador) como bóveda/CA del ecosistema Dotrino: atiende enrolamientos por el proxy y firma certificados de delegación a tus máquinas. Incluye el cliente de SERVICIO (Node): un proyecto se enrola una vez y jala sus credenciales del vault en vez del .env (`import '@dotrino/vault/config'`).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/service.js
CHANGED
|
@@ -421,7 +421,7 @@ export async function registerEncKey ({ dir, ns, proxyUrl, masterPubkey, device,
|
|
|
421
421
|
* Renueva el cert automáticamente si está por vencer (best-effort).
|
|
422
422
|
* @returns {Promise<Record<string,string>>} secretos KEY→valor
|
|
423
423
|
*/
|
|
424
|
-
export async function fetchSecrets ({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, timeoutMs = 30000, onPending, approvalTimeoutMs = APPROVAL_TIMEOUT_MS } = {}) {
|
|
424
|
+
export async function fetchSecrets ({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, timeoutMs = 30000, onPending, onCert, approvalTimeoutMs = APPROVAL_TIMEOUT_MS } = {}) {
|
|
425
425
|
let saved = null
|
|
426
426
|
if (dir) saved = readServiceIdentity(dir)
|
|
427
427
|
// Sin `dir`: la identidad viene entera por parámetros — es el caso de un agente
|
|
@@ -489,6 +489,11 @@ export async function fetchSecrets ({ dir, ns, proxyUrl, masterPubkey, device, c
|
|
|
489
489
|
if (res.type === MSG.RENEWED && res.cert?.sub === device.publickey) {
|
|
490
490
|
cert = res.cert
|
|
491
491
|
recordar({ cert })
|
|
492
|
+
// QUIEN NO PASA `dir` GUARDA ÉL. Un servicio que lleva su identidad en su propio
|
|
493
|
+
// archivo (`link.json`) y nos pasa el enlace a mano no tiene `saved`, así que
|
|
494
|
+
// `recordar` no escribe nada: sin esto renovaba en cada arranque y volvía a
|
|
495
|
+
// empezar, y su papel del modelo viejo no se cambiaba NUNCA.
|
|
496
|
+
try { onCert?.(cert) } catch (_) {}
|
|
492
497
|
}
|
|
493
498
|
} catch (_) { /* la renovación no bloquea el fetch */ }
|
|
494
499
|
}
|
|
@@ -986,11 +991,11 @@ function fingerprintOf (secrets) {
|
|
|
986
991
|
* servicio no opera hasta que esto resuelva — esa es la regla.
|
|
987
992
|
* @returns {Promise<Record<string,string>>}
|
|
988
993
|
*/
|
|
989
|
-
export async function waitForSecrets ({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, retryMs = 5000, maxRetryMs = 60000, onRetry, onPending } = {}) {
|
|
994
|
+
export async function waitForSecrets ({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, retryMs = 5000, maxRetryMs = 60000, onRetry, onPending, onCert } = {}) {
|
|
990
995
|
let delay = retryMs
|
|
991
996
|
for (;;) {
|
|
992
997
|
try {
|
|
993
|
-
return await fetchSecrets({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, onPending })
|
|
998
|
+
return await fetchSecrets({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, onPending, onCert })
|
|
994
999
|
} catch (e) {
|
|
995
1000
|
// Lo NO transitorio no se arregla reintentando: falta de enrolamiento,
|
|
996
1001
|
// cert revocado/vencido o scope equivocado exigen re-emparejar → se corta.
|