@dotrino/vaultd 0.192.0 → 0.192.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/lib/src/admin.js CHANGED
@@ -241,7 +241,10 @@ export function createAdminDesk ({
241
241
  // VER UNA PRIVADA (`varsDesk.reveal`). Antes que las demás de variables porque aquí no
242
242
  // viaja ningún destino en claro: va dentro del sobre, y la política es de la bóveda.
243
243
  if (data.op === 'var.reveal.begin' || data.op === 'var.reveal') {
244
- if (!vars || typeof vars.reveal !== 'function') return { ok: false, error: 'admin: this vault cannot show a private variable (update it)' }
244
+ // Se comprueba el método que se va a llamar. Antes se miraba siempre `reveal`, y una
245
+ // bóveda sin `revealBegin` reventaba con un TypeError en vez de decirlo.
246
+ const method = data.op === 'var.reveal.begin' ? 'revealBegin' : 'reveal'
247
+ if (!vars || typeof vars[method] !== 'function') return { ok: false, error: 'admin: this vault cannot show a private variable (update it)' }
245
248
  try {
246
249
  const result = data.op === 'var.reveal.begin'
247
250
  ? await vars.revealBegin({ caller: chk.device, by })
@@ -5,4 +5,4 @@
5
5
  * si no coincide con la del paquete: una versión anunciada que no es la que corre es peor
6
6
  * que no anunciar ninguna.
7
7
  */
8
- export const LIB_VERSION = '0.120.0'
8
+ export const LIB_VERSION = '0.120.1'
@@ -1448,7 +1448,10 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1448
1448
  dev: {},
1449
1449
  recovery: { pub: pair.pub, priv: await sealer.sealMaster(pair.priv, keyOr(adminKey)) },
1450
1450
  // El histórico empieza aquí: de lo de antes no se guardó ninguna versión previa.
1451
- history: []
1451
+ history: [],
1452
+ // Las lápidas se conservan. Faltaba el campo, y el primer `delete` tras convertir
1453
+ // reventaba en `_drop` (`data.deleted[owner]` sobre `undefined`) hasta reiniciar.
1454
+ deleted: data.deleted
1452
1455
  }
1453
1456
  const antes = {}
1454
1457
  const noKey = {}
@@ -2943,6 +2943,16 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2943
2943
  })
2944
2944
  }
2945
2945
  function scheduleDeviceNotice (pub) { schedule('dev:' + pub, () => notifyDeviceChange(pub)) }
2946
+ /**
2947
+ * El aviso del cajón que se tocó: el de un namespace o el de un aparato. `varsDesk` escribe en
2948
+ * los dos, y avisaba siempre al namespace —con `ns` null cuando el cajón era de un aparato—,
2949
+ * así que el aparato no se enteraba de que su configuración había cambiado.
2950
+ */
2951
+ function noticeFor (ns, pub) {
2952
+ if (ns) return scheduleNotice(ns)
2953
+ if (!pub) throw new Error('vars: a drawer needs its ns or its device pub')
2954
+ scheduleDeviceNotice(pub)
2955
+ }
2946
2956
 
2947
2957
  function schedule (key, fn) {
2948
2958
  clearTimeout(pendingNotices.get(key))
@@ -3450,7 +3460,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
3450
3460
  await checkAuthor(owner, key, sealed, caller, { allowOverwrite: ask })
3451
3461
  await checkRecipients(owner, sealed.wraps, !!isPublic)
3452
3462
  await secrets.putSealed(owner, key, sealed, { by: who, public: isPublic })
3453
- audit('secret.set', { ns: ns || null, key, sealed: true }); scheduleNotice(ns)
3463
+ audit('secret.set', { ns: ns || null, key, sealed: true }); noticeFor(ns, pub)
3454
3464
  await settleDebts(owner)
3455
3465
  }
3456
3466
  // Comprobado ANTES de dejarlo en espera: un sobre malo falla al guardarlo, no cinco
@@ -3522,7 +3532,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
3522
3532
  await secrets.putSealed(owner, it.key, it.sealed, { by: who, public: !!it.public })
3523
3533
  keys.push(it.key)
3524
3534
  }
3525
- audit('secret.setMany', { ns: ns || null, keys }); scheduleNotice(ns)
3535
+ audit('secret.setMany', { ns: ns || null, keys }); noticeFor(ns, pub)
3526
3536
  await settleDebts(owner)
3527
3537
  }
3528
3538
  const pending = await holdWrite({ caller, ns, pub, keys: items.map((it) => it.key), apply, ask })
@@ -5128,7 +5138,8 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
5128
5138
  // La bóveda de contraseñas (`passwords.js`). Aquí SÍ se lista: es donde está la
5129
5139
  // llave. Lo que no puede es listarla un aparato.
5130
5140
  passwordDevices,
5131
- passwordsVault: () => passwords?.vault || null,
5141
+ // (Aquí estaba `passwordsVault`, que siempre daba null: el mostrador sellado ya no tiene
5142
+ // `vault` —no hay llave que guardar— y nadie lo llamaba. Quitado, no arreglado.)
5132
5143
  // La política de las contraseñas, para quien atiende su propio almacén (la extensión).
5133
5144
  passwordsNeedApproval,
5134
5145
  approvePasswordRequest,
@@ -66,3 +66,20 @@ export function formatDeviceInfo (info) {
66
66
  const w = Math.max(...rows.map(([k]) => k.length))
67
67
  return rows.map(([k, v]) => `${(k + ':').padEnd(w + 2)}${v}`).join('\n')
68
68
  }
69
+
70
+ /**
71
+ * Cómo se describe el papel (cert) de un servicio: por el ACTA a la que se ató, o, si es del
72
+ * modelo viejo, con la fecha en que vence — lo único que todavía caduca. Sin ninguna de las
73
+ * dos se dice `?`. Antes `dotrino-env enroll` hacía `new Date(undefined).toISOString()` en la
74
+ * rama vieja, que lanza RangeError justo al terminar de enrolar.
75
+ *
76
+ * @param {{ seq?: unknown, exp?: unknown } | null | undefined} cert
77
+ * @param {{ old?: string }} [words] cómo se llama el modelo viejo en la salida
78
+ * @returns {string}
79
+ */
80
+ export function describePaper (cert, { old = 'modelo viejo' } = {}) {
81
+ if (typeof cert?.seq === 'number') return `acta #${cert.seq}`
82
+ if (typeof cert?.exp === 'number' && Number.isFinite(cert.exp)) return `${old} · vence ${new Date(cert.exp).toISOString().slice(0, 10)}`
83
+ return '?'
84
+ }
85
+
package/lib/src/env.js CHANGED
@@ -114,11 +114,13 @@ export function resolveNs (ns) {
114
114
  return ns
115
115
  }
116
116
  const found = listEnrolled()
117
- if (found.length === 1) return found[0]
117
+ // `listEnrolled` da `{ vault, ns }`: lo que se devuelve es el ns. Devolvía el objeto entero,
118
+ // y `serviceDir` lo rechazaba como «invalid ns» justo en el caso «el único enrolado».
119
+ if (found.length === 1) return found[0].ns
118
120
  if (found.length === 0) {
119
121
  throw new Error('no service enrolled on this machine: run `npx dotrino-env enroll --ns <your-app>`')
120
122
  }
121
- throw new Error(`several services are enrolled (${found.join(', ')}): pick one with DOTRINO_NS=<ns> or loadEnv({ ns })`)
123
+ throw new Error(`several services are enrolled (${found.map((e) => e.vault ? `${e.vault}/${e.ns}` : e.ns).join(', ')}): pick one with DOTRINO_NS=<ns> or loadEnv({ ns })`)
122
124
  }
123
125
 
124
126
  /**
@@ -501,10 +501,12 @@ export function createLoginDesk ({ load, save, now = () => Date.now(), opaque =
501
501
  export async function createPasswordLogin ({ user, password, label, caps, begin, finish, opaque = opaqueClientePorDefecto } = {}) {
502
502
  if (!isValidUser(user)) throw Object.assign(new Error('invalid user name'), { code: 'bad-user' })
503
503
  if (typeof password !== 'string' || !password) throw Object.assign(new Error('a password is required'), { code: 'no-password' })
504
- const start = opaque.registrationStart({ password })
504
+ // `opaque` se inyecta, y el resto de este archivo ya lo espera con `await`: una
505
+ // implementación asíncrona devolvía aquí una promesa y `start.request` salía `undefined`.
506
+ const start = await opaque.registrationStart({ password })
505
507
  const begun = await begin({ user, request: start.request })
506
508
  // La bóveda contesta con su mitad; el registro se termina AQUÍ, con la contraseña.
507
- const fin = opaque.registrationFinish({ state: start.state, response: begun.response, password })
509
+ const fin = await opaque.registrationFinish({ state: start.state, response: begun.response, password })
508
510
  const device = await makeDeviceKey({ label })
509
511
  const enc = await makeDeviceEncKey()
510
512
  const blob = await sealDeviceKeys(fin.exportKey, { sign: device.privateJwk, enc: enc.encPrivateJwk })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/vaultd",
3
- "version": "0.192.0",
3
+ "version": "0.192.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/tui/app.js CHANGED
@@ -1153,7 +1153,7 @@ async function refreshMembers (term, st) {
1153
1153
  * que nadie está mirando.
1154
1154
  */
1155
1155
  async function refreshLogins (term, st, api = vc) {
1156
- const r = await guard(term, st, L(st).refreshing, () => api.listLogins(activeId(st)))
1156
+ const r = await guard(term, st, L(st).loadingLogins, () => api.listLogins(activeId(st)))
1157
1157
  if (r.ok) st.logins = r.v
1158
1158
  else st.logins = []
1159
1159
  }
@@ -2217,7 +2217,7 @@ async function onKeySecrets (term, st, key) {
2217
2217
  function promptRenameVariable (term, st, cur) {
2218
2218
  const i = L(st)
2219
2219
  setInput(st, {
2220
- label: i.renameLabel(cur.key),
2220
+ label: i.renameVarLabel(cur.key),
2221
2221
  hint: i.renameHint,
2222
2222
  value: cur.key,
2223
2223
  onSubmit: async (newer) => {
package/src/tui/i18n.js CHANGED
@@ -262,6 +262,7 @@ const es = {
262
262
  loadingDevices: 'Cargando dispositivos…',
263
263
  loadingSecrets: 'Cargando secretos…',
264
264
  loadingVaults: 'Cargando bóvedas…',
265
+ loadingLogins: 'Cargando los inicios de sesión…',
265
266
  switchingVault: 'Cambiando de bóveda…',
266
267
  vaultNowActive: (name) => `Bóveda activa: ${name}`,
267
268
  newVaultLabel: 'Nombre de la nueva bóveda',
@@ -388,9 +389,8 @@ const es = {
388
389
  newVarPrivateAsk: '¿Es privada?',
389
390
  makePublicConfirm: '¿Hacerla pública?',
390
391
  changingVisibility: 'Cambiando…',
391
- renameLabel: (k) => `Nuevo nombre para ${k}`,
392
+ renameVarLabel: (k) => `Nuevo nombre para ${k}`,
392
393
  renameHint: 'MAYUSCULAS_CON_GUION_BAJO · el valor no se toca · Esc cancela',
393
- renaming: 'Renombrando…',
394
394
  renamed: (a, b) => `${a} ahora se llama ${b} — el servicio que la lee se reinicia; si busca el nombre viejo, ya no lo encuentra`,
395
395
  nowPublic: 'Pública: se entrega sin pedirte permiso',
396
396
  nowPrivate: 'Privada: para entregarla te pide permiso',
@@ -813,6 +813,7 @@ const en = {
813
813
  loadingDevices: 'Loading devices…',
814
814
  loadingSecrets: 'Loading secrets…',
815
815
  loadingVaults: 'Loading vaults…',
816
+ loadingLogins: 'Loading the sign-ins…',
816
817
  switchingVault: 'Switching vault…',
817
818
  vaultNowActive: (name) => `Active vault: ${name}`,
818
819
  newVaultLabel: 'Name of the new vault',
@@ -926,9 +927,8 @@ const en = {
926
927
  newVarPrivateAsk: 'Is it private?',
927
928
  makePublicConfirm: 'Make it public?',
928
929
  changingVisibility: 'Changing…',
929
- renameLabel: (k) => `New name for ${k}`,
930
+ renameVarLabel: (k) => `New name for ${k}`,
930
931
  renameHint: 'UPPERCASE_WITH_UNDERSCORES · the value is not touched · Esc cancels',
931
- renaming: 'Renaming…',
932
932
  renamed: (a, b) => `${a} is now ${b} — the service that reads it restarts; if it looks for the old name, it will not find it`,
933
933
  nowPublic: 'Public: handed over without asking you',
934
934
  nowPrivate: 'Private: handing it over asks you first',