@dotrino/vault 0.44.0 → 0.45.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/service.js +8 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/vault",
3
- "version": "0.44.0",
3
+ "version": "0.45.0",
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.