@dotrino/vaultd 0.165.0 → 0.165.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/README.md CHANGED
@@ -684,7 +684,7 @@ aislamiento entre perfiles, el freno de borrado del acta, los secretos de punta
684
684
  punta y la precedencia del vault sobre el `.env`; también el render y el bilingüe de
685
685
  la TUI. **Tres son de extremo a extremo contra el proxy de verdad** y esperan el repo
686
686
  hermano en `../dotrino-proxy` (`secrets.e2e`, `multiprofile.e2e`,
687
- `pairing-cita.e2e`): no se saltan solos, así que sin ese repo al lado `npm test`
687
+ `pairing-rendezvous.e2e`): no se saltan solos, así que sin ese repo al lado `npm test`
688
688
  falla.
689
689
 
690
690
  Etiquetar `vaultd-v<ver>` publica la imagen de Docker en GHCR. Etiquetar `v<ver>` lanza
package/lib/src/admin.js CHANGED
@@ -157,7 +157,7 @@ export function createAdminDesk ({
157
157
  now = () => Date.now()
158
158
  }) {
159
159
  const ops = new Set(ADMIN_OPS)
160
- const mientrasCerrada = new Set(ADMIN_OPS_WHILE_LOCKED)
160
+ const whileLocked = new Set(ADMIN_OPS_WHILE_LOCKED)
161
161
 
162
162
  // NONCE de un solo uso. `sign`/`get` son idempotentes y les basta la ventana de ±5
163
163
  // min; `revoke` y `var.set` CAMBIAN ESTADO, así que reproducir uno dentro de esa
@@ -196,7 +196,7 @@ export function createAdminDesk ({
196
196
  //
197
197
  // El código va aparte del texto porque el texto se traduce y el código no: quien
198
198
  // llama distingue «está cerrada, ábrela» de «no tienes permiso» sin leer la frase.
199
- if (isLocked() && !mientrasCerrada.has(data.op)) {
199
+ if (isLocked() && !whileLocked.has(data.op)) {
200
200
  audit('rejected', { what: 'admin', op: data.op, by, reason: 'locked' })
201
201
  return {
202
202
  ok: false,
@@ -69,7 +69,7 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
69
69
  }
70
70
  }
71
71
 
72
- const avisar = () => { try { onPendingChange() } catch (_) {} }
72
+ const notify = () => { try { onPendingChange() } catch (_) {} }
73
73
  const vault = await startVault({
74
74
  platform: {
75
75
  disk,
@@ -87,7 +87,7 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
87
87
  // El navegador no tiene la contraseña del perfil con la que el binario cierra la copia
88
88
  // de recuperación: se cierra con la llave de este almacén, y el núcleo lo dice.
89
89
  hasPassword: () => false,
90
- onEnrollChallenge: avisar,
90
+ onEnrollChallenge: notify,
91
91
  onAdopted: (info) => { try { onAdopted(info) } catch (_) {} }
92
92
  })
93
93
 
@@ -109,7 +109,7 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
109
109
  * acta: es verdad que este navegador administra la cuenta. `aprueba` NO, a propósito: con
110
110
  * él los servicios pasarían a esperar el visto bueno de una pestaña que puede no estar.
111
111
  */
112
- const asegurarAdmin = async () => {
112
+ const ensureAdmin = async () => {
113
113
  if (core.masterLocked) return
114
114
  const acta = (await identity.profileActa().catch(() => null))?.acta || null
115
115
  const yo = (acta?.members || []).find((m) => m.pub === master)
@@ -119,15 +119,15 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
119
119
  log('[vault] this browser administers the account: admin added to its own key')
120
120
  }
121
121
  const open = (onReply) => vault.localChannel(onReply)
122
- const presentar = async () => {
122
+ const present = async () => {
123
123
  try {
124
- await asegurarAdmin()
124
+ await ensureAdmin()
125
125
  const cert = await selfCert()
126
126
  core.setSelfVault?.(cert ? { cert, proxy: proxyUrl, open } : null)
127
127
  } catch (e) { log('[vault] the console in this browser cannot administer this vault yet: ' + (e?.message || e)) }
128
128
  }
129
- await presentar()
130
- const refresco = setInterval(presentar, SELF_CERT_EVERY_MS)
129
+ await present()
130
+ const refresh = setInterval(present, SELF_CERT_EVERY_MS)
131
131
 
132
132
  return {
133
133
  ...vault,
@@ -135,8 +135,8 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
135
135
  proxy: proxyUrl,
136
136
  disk,
137
137
  /** Aprueba TIPEANDO el código que muestra el aparato (el núcleo comprueba el compromiso). */
138
- approve: async (_deviceId, code) => { try { return await vault.approveDevice(code) } finally { avisar() } },
139
- reject: (deviceId) => { try { return vault.rejectDevice(deviceId) } finally { avisar() } },
138
+ approve: async (_deviceId, code) => { try { return await vault.approveDevice(code) } finally { notify() } },
139
+ reject: (deviceId) => { try { return vault.rejectDevice(deviceId) } finally { notify() } },
140
140
  /**
141
141
  * Las máquinas con papel de firma de esta cuenta (excluye los navegadores enrolados con
142
142
  * etiqueta `cli`, que no atienden pedidos). Se queda el papel del acta más nueva.
@@ -155,7 +155,7 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
155
155
  revokeDevice: (sub) => vault.revokeDevice({ sub }),
156
156
  revoke: (nonce) => vault.revokeDevice(nonce),
157
157
  async close () {
158
- clearInterval(refresco)
158
+ clearInterval(refresh)
159
159
  try { core.setSelfVault?.(null) } catch (_) {}
160
160
  vault.close()
161
161
  try { await disk.flush() } catch (e) { log('[vault] some changes could not be saved: ' + (e?.message || e)) }
@@ -84,7 +84,7 @@ export function createApprovals ({ now = Date.now, pendingTtlMs = PENDING_TTL_MS
84
84
  * apruebe— y tiene que volver por el mismo sitio: desde que la bóveda atiende también
85
85
  * por un socket local, mandarla siempre por el proxio la dejaba en el vacío.
86
86
  */
87
- request ({ ns, device, deviceId, label = '', ek, ctx = null, from = null, ttlMs = null, kind = 'read' }) {
87
+ request ({ ns, device, deviceId, label = '', ek, ctx = null, from = null, ttlMs = null, kind = 'read', re = null }) {
88
88
  // Pedir las claves otra vez reemplaza al pedido anterior: es la misma pregunta. Una
89
89
  // ESCRITURA no: cada una lleva su propio valor, y reemplazarla tiraría la anterior
90
90
  // sin que nadie dijera que no.
@@ -92,7 +92,8 @@ export function createApprovals ({ now = Date.now, pendingTtlMs = PENDING_TTL_MS
92
92
  const ts = now()
93
93
  // `ttlMs` lo pone quien pide: una actualización aguanta un día y un comando cinco
94
94
  // minutos, y la mesa no tiene por qué saber cuál es cuál (ver `PENDING_TTL_MS`).
95
- const p = { id: rnd(), ns, kind, device, deviceId, label, ek, ctx, ts, exp: ts + (ttlMs || pendingTtlMs), from }
95
+ // `re`: la huella de la petición, para firmarle al que pidió el «denegado» (ver `signError`).
96
+ const p = { id: rnd(), ns, kind, device, deviceId, label, ek, ctx, ts, exp: ts + (ttlMs || pendingTtlMs), from, re }
96
97
  pending.set(p.id, p)
97
98
  return publicOf(p)
98
99
  },
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * LA VERSIÓN DE `@dotrino/vault`, escrita aquí porque el navegador no puede leer el
3
3
  * `package.json`. Con esta se anuncia la bóveda de la pestaña y de la extensión
4
- * (`@dotrino/compat`). Una prueba (`test/version-del-navegador.test.mjs`) para el release
4
+ * (`@dotrino/compat`). Una prueba (`test/browser-version.test.mjs`) para el release
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.93.0'
8
+ export const LIB_VERSION = '0.93.1'
@@ -163,8 +163,8 @@ export function makeSealer () {
163
163
  * síntoma sería un servicio arrancando sin configuración y sin decir por qué.
164
164
  */
165
165
  async wrapFor (cek, members) {
166
- const { generation, sinLlave } = await makeGeneration({ members, cek })
167
- return { wraps: generation.wraps, sinLlave }
166
+ const { generation, sinLlave: noKey } = await makeGeneration({ members, cek })
167
+ return { wraps: generation.wraps, sinLlave: noKey }
168
168
  }
169
169
  }
170
170
  }
@@ -59,7 +59,7 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
59
59
  if (!registryId) return () => {}
60
60
 
61
61
  /** Una respuesta a `sealers.whois`, o null si no contesta a tiempo. */
62
- function preguntarQuienEs (token, timeoutMs = 8000) {
62
+ function askWhoItIs (token, timeoutMs = 8000) {
63
63
  return new Promise((resolve) => {
64
64
  const fin = (v) => { try { off() } catch (_) {} ; clearTimeout(t); resolve(v) }
65
65
  const off = client.on('message', (_f, p) => { if (p?.op === WHOIS + '.result') fin(p) })
@@ -82,11 +82,11 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
82
82
  * filtraría nada —el eslabón es público— pero se los tragaría EN SILENCIO, que es peor
83
83
  * que un error.
84
84
  */
85
- async function testigo () {
85
+ async function witness () {
86
86
  let tokens
87
87
  try { tokens = await client.list(canal) } catch (_) { return null }
88
88
  for (const token of tokens || []) {
89
- const r = await preguntarQuienEs(token)
89
+ const r = await askWhoItIs(token)
90
90
  const cert = r?.cert
91
91
  if (!cert?.sub || cert.iss !== registryId) continue
92
92
  // AQUÍ SOMOS EXTRAÑOS: no tenemos el acta del registro, así que no podemos preguntarle
@@ -107,11 +107,11 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
107
107
  return null
108
108
  }
109
109
 
110
- let ultima = null
110
+ let latest = null
111
111
 
112
- let avisadoDeOtroTestigo = false
112
+ let warnedOtherWitness = false
113
113
 
114
- async function publicar (motivo) {
114
+ async function publish (reason) {
115
115
  let actas
116
116
  try { actas = await identity.sealerChain?.() } catch (_) { return }
117
117
  if (!Array.isArray(actas)) return
@@ -122,8 +122,8 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
122
122
  // exactamente lo que ese campo existe para impedir. Se dice una vez y se calla.
123
123
  const genesis = actas[0]
124
124
  if (genesis?.chainUrl && registryId === DOTRINO_REGISTRY_ID) {
125
- if (!avisadoDeOtroTestigo) {
126
- avisadoDeOtroTestigo = true
125
+ if (!warnedOtherWitness) {
126
+ warnedOtherWitness = true
127
127
  log(`[sealers] this account names its own registry (${genesis.chainUrl}): not depositing into Dotrino's`)
128
128
  }
129
129
  return
@@ -136,14 +136,14 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
136
136
  // aparece en el registro hasta que selle un acta nueva.
137
137
  if (chain.length < 2) return
138
138
 
139
- const cabeza = chain[chain.length - 1]?.seq
140
- if (cabeza === ultima) return
139
+ const head = chain[chain.length - 1]?.seq
140
+ if (head === latest) return
141
141
  try {
142
- const a = await testigo()
142
+ const a = await witness()
143
143
  if (!a) { log('[sealers] no witness announced in ' + canal + ': the chain stays for the next time'); return }
144
144
  await client.sendByPubkey(a, { op: OP, chain })
145
- ultima = cabeza
146
- log(`[sealers] chain up to #${cabeza} deposited (${motivo})`)
145
+ latest = head
146
+ log(`[sealers] chain up to #${head} deposited (${reason})`)
147
147
  } catch (e) {
148
148
  // Que no se pueda depositar no rompe nada de lo que la bóveda hace: el registro es
149
149
  // una comodidad para terceros, no una dependencia. Se reintenta en la próxima acta.
@@ -151,8 +151,8 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
151
151
  }
152
152
  }
153
153
 
154
- publicar('startup').catch(() => {})
155
- const off = identity.onVault?.((e) => { if (e?.phase === 'acta') publicar(`record #${e.seq}`).catch(() => {}) })
154
+ publish('startup').catch(() => {})
155
+ const off = identity.onVault?.((e) => { if (e?.phase === 'acta') publish(`record #${e.seq}`).catch(() => {}) })
156
156
  return () => { try { off?.() } catch (_) {} }
157
157
  }
158
158
 
@@ -285,10 +285,10 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
285
285
  *
286
286
  * La cola es de este proceso, que es el único que escribe este archivo.
287
287
  */
288
- let cola = Promise.resolve()
289
- const enFila = (fn) => {
290
- const r = cola.then(fn, fn)
291
- cola = r.then(() => {}, () => {})
288
+ let queue = Promise.resolve()
289
+ const queued = (fn) => {
290
+ const r = queue.then(fn, fn)
291
+ queue = r.then(() => {}, () => {})
292
292
  return r
293
293
  }
294
294
 
@@ -309,13 +309,13 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
309
309
  */
310
310
  const gcKeyring = (bag, k, owner) => {
311
311
  if (!bag[k]) return
312
- const vivos = new Set()
312
+ const aliveOnes = new Set()
313
313
  // TAMBIÉN LAS PÚBLICAS. Se saltaban porque antes no tenían generación —se guardaban en
314
314
  // claro—, así que su llave se recogía por «no la usa nadie» y la variable quedaba
315
315
  // ilegible. Desde 2026-09-02 van en sobre como todas y cuentan como todas.
316
- for (const e of Object.values(bag[k].vars || {})) if (e.gen != null) vivos.add(e.gen)
317
- for (const h of data.history) if (h.owner === owner && h.gen != null) vivos.add(h.gen)
318
- bag[k].keyring = (bag[k].keyring || []).filter((g) => vivos.has(g.gen))
316
+ for (const e of Object.values(bag[k].vars || {})) if (e.gen != null) aliveOnes.add(e.gen)
317
+ for (const h of data.history) if (h.owner === owner && h.gen != null) aliveOnes.add(h.gen)
318
+ bag[k].keyring = (bag[k].keyring || []).filter((g) => aliveOnes.has(g.gen))
319
319
  }
320
320
 
321
321
  /**
@@ -350,9 +350,9 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
350
350
  */
351
351
  const wrapAll = async (cek, owner, isPublic = false) => {
352
352
  const members = (await recipients?.(owner, { public: isPublic })) || []
353
- const { wraps, sinLlave } = await sealer.wrapFor(cek, members)
353
+ const { wraps, sinLlave: noKey } = await sealer.wrapFor(cek, members)
354
354
  wraps[RECOVERY] = await sealer.wrapForKey(cek, data.recovery.pub)
355
- return { wraps, sinLlave }
355
+ return { wraps, sinLlave: noKey }
356
356
  }
357
357
 
358
358
  return {
@@ -375,7 +375,7 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
375
375
  *
376
376
  * Idempotente: si ya está, no toca nada.
377
377
  */
378
- async ensureRecovery (adminKey = null) { return enFila(async () => (await ensureRecovery(adminKey)).pub) },
378
+ async ensureRecovery (adminKey = null) { return queued(async () => (await ensureRecovery(adminKey)).pub) },
379
379
 
380
380
  /**
381
381
  * MUCHAS ESCRITURAS, UN GUARDADO. Cargar la configuración de un servicio son veinte
@@ -410,13 +410,13 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
410
410
  */
411
411
  bundleFor (ns, devicePub = null, { publicOnly = false } = {}) {
412
412
  assertNs(ns)
413
- const todo = { ...entriesOf(data.ns, ns), ...(devicePub ? entriesOf(data.dev, devicePub) : {}) }
413
+ const everything = { ...entriesOf(data.ns, ns), ...(devicePub ? entriesOf(data.dev, devicePub) : {}) }
414
414
  // EL FILTRO LO HACE LA BÓVEDA, no quien pide. Si mandara todo y el cliente eligiera,
415
415
  // pedir «solo públicas» sería la forma de saltarse la aprobación y llevarse las
416
416
  // privadas igual — o sea justo lo contrario de lo que se quiere.
417
417
  const entries = publicOnly
418
- ? Object.fromEntries(Object.entries(todo).filter(([, e]) => e.pub))
419
- : todo
418
+ ? Object.fromEntries(Object.entries(everything).filter(([, e]) => e.pub))
419
+ : everything
420
420
  if (isLegacy()) return { legacy: true, entries }
421
421
 
422
422
  const misWraps = (bag, k) => (bag[k]?.keyring || [])
@@ -628,7 +628,7 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
628
628
  return this._put(data.dev, pub, `dev:${pub}`, key, value, isPublic, by)
629
629
  },
630
630
  /** @private */
631
- async _put (...a) { return enFila(() => this._putRaw(...a)) },
631
+ async _put (...a) { return queued(() => this._putRaw(...a)) },
632
632
  /** @private El cuerpo, ya en fila (ver `enFila`). */
633
633
  async _putRaw (bag, k, owner, key, value, isPublic, by) {
634
634
  // El cajón del perfil tiene su propio alfabeto (`nickname`, no `NICKNAME`). Por aquí
@@ -659,7 +659,7 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
659
659
  // CEK NUEVA, siempre: no se puede reutilizar la de antes sin poder abrirla.
660
660
  const cek = await sealer.newKey()
661
661
  const gen = nextGen(bag, k, owner)
662
- const { wraps, sinLlave } = await wrapAll(cek, owner, pub)
662
+ const { wraps, sinLlave: noKey } = await wrapAll(cek, owner, pub)
663
663
  const e = await sealer.encrypt(cek, value, gen)
664
664
  // La FIRMA dice que este sobre salió de esta bóveda, y con qué acta (§8.8). Si no
665
665
  // hay con qué firmar, el sobre sale sin firma: guardar es más importante.
@@ -670,7 +670,7 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
670
670
  bag[k].keyring = [...(bag[k].keyring || []), { gen, createdAt: Date.now(), wraps }]
671
671
  gcKeyring(bag, k, owner)
672
672
  save()
673
- return { gen, sinLlave }
673
+ return { gen, sinLlave: noKey }
674
674
  },
675
675
 
676
676
  /**
@@ -693,18 +693,18 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
693
693
  * después ni abriendo la bóveda.
694
694
  *
695
695
  * @param {string} owner `ns:<scope>` o `dev:<pub>`
696
- * @param {{e:{iv:string,ct:string,gen?:number}, wraps:Object}} sobre
696
+ * @param {{e:{iv:string,ct:string,gen?:number}, wraps:Object}} envelope
697
697
  */
698
- async putSealed (owner, key, sobre, { by = null, public: isPublic = false } = {}) {
699
- return enFila(() => this._putSealedRaw(owner, key, sobre, by, !!isPublic))
698
+ async putSealed (owner, key, envelope, { by = null, public: isPublic = false } = {}) {
699
+ return queued(() => this._putSealedRaw(owner, key, envelope, by, !!isPublic))
700
700
  },
701
701
  /** @private */
702
- async _putSealedRaw (owner, key, sobre, by, isPublic) {
702
+ async _putSealedRaw (owner, key, envelope, by, isPublic) {
703
703
  if (isLegacy()) throw new Error('putSealed: this store is still v3 (run `migrate` first)')
704
704
  if (needsMigration()) throw new NeedsMigration()
705
705
  const [kind, k] = splitOwner(owner)
706
706
  const bag = kind === 'ns' ? data.ns : data.dev
707
- const e = sobre?.e; const wraps = sobre?.wraps
707
+ const e = envelope?.e; const wraps = envelope?.wraps
708
708
  if (!e || typeof e.iv !== 'string' || typeof e.ct !== 'string') {
709
709
  throw new Error('putSealed: the envelope must carry `iv` and `ct`')
710
710
  }
@@ -823,7 +823,7 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
823
823
  return this._setVis(data.dev, pub, `dev:${pub}`, key, isPublic, adminKey)
824
824
  },
825
825
  /** @private */
826
- async _setVis (...a) { return enFila(() => this._setVisRaw(...a)) },
826
+ async _setVis (...a) { return queued(() => this._setVisRaw(...a)) },
827
827
  /** @private El cuerpo, ya en fila. */
828
828
  async _setVisRaw (bag, k, owner, key, isPublic, adminKey) {
829
829
  const vars = varsOf(bag, k)
@@ -930,7 +930,7 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
930
930
  *
931
931
  * Y por eso ESTO sí pide la frase: heredar lo viejo obliga a abrirlo.
932
932
  */
933
- async rewrap (...a) { return enFila(() => this._rewrap(...a)) },
933
+ async rewrap (...a) { return queued(() => this._rewrap(...a)) },
934
934
  /** Los cajones que existen, para poder recorrerlos todos (`ns:…` y `dev:…`). */
935
935
  owners () {
936
936
  return [...Object.keys(data.ns).map((k) => `ns:${k}`), ...Object.keys(data.dev).map((k) => `dev:${k}`)]
@@ -1004,7 +1004,7 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1004
1004
  * de los secretos se queda intacta.
1005
1005
  */
1006
1006
  async profilePutPublic (key, value, { by = null } = {}) {
1007
- return enFila(async () => {
1007
+ return queued(async () => {
1008
1008
  if (isLegacy()) throw new Error('profile: this store is still v3 (run `migrate` first)')
1009
1009
  if (needsMigration()) throw new NeedsMigration()
1010
1010
  assertProfileKey(key)
@@ -1039,9 +1039,9 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1039
1039
  const priv = await openRecovery(adminKey)
1040
1040
  let wrapped = 0
1041
1041
  let sealed = 0
1042
- const sinLlave = new Set()
1042
+ const noKey = new Set()
1043
1043
  const vars = varsOf(bag, k)
1044
- const paraVisibilidad = async (esPublica) => (typeof members === 'function' ? members(esPublica) : members)
1044
+ const forVisibility = async (isPublic) => (typeof members === 'function' ? members(isPublic) : members)
1045
1045
 
1046
1046
  // UN VALOR QUE SE QUEDÓ EN CLARO SE SELLA AQUÍ, que es el único sitio donde se puede.
1047
1047
  //
@@ -1060,27 +1060,27 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1060
1060
  if (typeof e.v !== 'string' || e.e) continue
1061
1061
  const cek = await sealer.newKey()
1062
1062
  const gen = nextGen(bag, k, owner)
1063
- const r = await sealer.wrapFor(cek, await paraVisibilidad(!!e.pub))
1063
+ const r = await sealer.wrapFor(cek, await forVisibility(!!e.pub))
1064
1064
  r.wraps[RECOVERY] = await sealer.wrapForKey(cek, data.recovery.pub)
1065
- const sobre = await sealer.encrypt(cek, e.v, gen)
1066
- const seal = signer ? await signer({ owner, key, gen, iv: sobre.iv, ct: sobre.ct }) : null
1065
+ const envelope = await sealer.encrypt(cek, e.v, gen)
1066
+ const seal = signer ? await signer({ owner, key, gen, iv: envelope.iv, ct: envelope.ct }) : null
1067
1067
  // `pub` y `at` se conservan: no es un valor nuevo, es el mismo mejor guardado.
1068
- vars[key] = { pub: !!e.pub, owner, gen, e: sobre, seal, at: e.at || Date.now(), by: e.by || null }
1068
+ vars[key] = { pub: !!e.pub, owner, gen, e: envelope, seal, at: e.at || Date.now(), by: e.by || null }
1069
1069
  bag[k].keyring = [...(bag[k].keyring || []), { gen, createdAt: Date.now(), wraps: r.wraps }]
1070
- for (const x of r.sinLlave) sinLlave.add(x)
1070
+ for (const x of r.sinLlave) noKey.add(x)
1071
1071
  sealed++
1072
1072
  }
1073
1073
 
1074
1074
  // De qué variable es cada generación: es lo que dice si esa CEK es de una pública.
1075
1075
  // Se calcula DESPUÉS de sellar, para que las generaciones recién creadas entren.
1076
- const visibilidad = new Map()
1077
- for (const e of Object.values(vars)) if (e.gen != null) visibilidad.set(e.gen, !!e.pub)
1078
- const paraGen = async (gen) => paraVisibilidad(visibilidad.get(gen) === true)
1076
+ const visibility = new Map()
1077
+ for (const e of Object.values(vars)) if (e.gen != null) visibility.set(e.gen, !!e.pub)
1078
+ const forGen = async (gen) => forVisibility(visibility.get(gen) === true)
1079
1079
  for (const g of bag[k].keyring || []) {
1080
1080
  const w = g.wraps?.[RECOVERY]
1081
1081
  if (!w) continue
1082
1082
  const cek = await sealer.openWrapWith(priv, w)
1083
- const r = await sealer.wrapFor(cek, await paraGen(g.gen))
1083
+ const r = await sealer.wrapFor(cek, await forGen(g.gen))
1084
1084
  // `exact`: el llavero queda con lo que dice el acta y NADA más. Es lo que hace
1085
1085
  // falta para rehacerlo al abrir la bóveda:
1086
1086
  // · una envoltura basura que metió alguien se reemplaza por la buena;
@@ -1092,11 +1092,11 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1092
1092
  // OJO con lo que esto NO es: quitarle la envoltura a alguien no le quita lo que
1093
1093
  // ya leyó ni la llave que se haya guardado. Cortar de verdad es `rotate`.
1094
1094
  g.wraps = exact ? { ...r.wraps, [RECOVERY]: w } : { ...g.wraps, ...r.wraps }
1095
- for (const s of r.sinLlave) sinLlave.add(s)
1095
+ for (const s of r.sinLlave) noKey.add(s)
1096
1096
  wrapped += Object.keys(r.wraps).length
1097
1097
  }
1098
1098
  save()
1099
- return { wrapped, sealed, sinLlave: [...sinLlave] }
1099
+ return { wrapped, sealed, sinLlave: [...noKey] }
1100
1100
  },
1101
1101
 
1102
1102
  /**
@@ -1114,7 +1114,7 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1114
1114
  * El HISTÓRICO se muda con ella: es la misma variable, y dejarlo bajo el nombre viejo
1115
1115
  * lo volvería inalcanzable — se vería como un hueco, no como una decisión.
1116
1116
  */
1117
- async rename (owner, from, to) { return enFila(() => this._renameRaw(owner, from, to)) },
1117
+ async rename (owner, from, to) { return queued(() => this._renameRaw(owner, from, to)) },
1118
1118
  /** @private */
1119
1119
  async _renameRaw (owner, from, to) {
1120
1120
  if (needsMigration()) throw new NeedsMigration()
@@ -1148,7 +1148,7 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1148
1148
  *
1149
1149
  * No devuelve lo que el expulsado ya leyó. Eso no se puede deshacer y no se promete.
1150
1150
  */
1151
- async rotate (...a) { return enFila(() => this._rotate(...a)) },
1151
+ async rotate (...a) { return queued(() => this._rotate(...a)) },
1152
1152
  /** @private */
1153
1153
  async _rotate (owner, members, adminKey = null) {
1154
1154
  needSealer('rotate the key of a drawer')
@@ -1159,30 +1159,30 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1159
1159
  const priv = await openRecovery(adminKey)
1160
1160
 
1161
1161
  const vars = bag[k].vars || {}
1162
- const claras = {}
1162
+ const plainOnes = {}
1163
1163
  for (const [key, e] of Object.entries(vars)) {
1164
- if (!e.pub) claras[key] = await sealer.openValue(await this._cekOf(bag, k, e.gen, priv), e.e)
1164
+ if (!e.pub) plainOnes[key] = await sealer.openValue(await this._cekOf(bag, k, e.gen, priv), e.e)
1165
1165
  }
1166
1166
  // Se tira el llavero entero: las generaciones viejas son justamente lo que el que
1167
1167
  // se fue podría abrir. Con ellas se va el histórico de este cajón, que estaba
1168
1168
  // cifrado con ellas — rotar es renunciar a poder revertir lo de antes.
1169
1169
  bag[k].keyring = []
1170
1170
  data.history = data.history.filter((h) => h.owner !== owner)
1171
- const sinLlave = new Set()
1171
+ const noKey = new Set()
1172
1172
  let gen = 0
1173
- for (const [key, value] of Object.entries(claras)) {
1173
+ for (const [key, value] of Object.entries(plainOnes)) {
1174
1174
  const cek = await sealer.newKey()
1175
1175
  gen += 1
1176
- const { wraps, sinLlave: faltan } = await sealer.wrapFor(cek, members)
1176
+ const { wraps, sinLlave: missingOnes } = await sealer.wrapFor(cek, members)
1177
1177
  wraps[RECOVERY] = await sealer.wrapForKey(cek, data.recovery.pub)
1178
- for (const s of faltan) sinLlave.add(s)
1178
+ for (const s of missingOnes) noKey.add(s)
1179
1179
  const e = await sealer.encrypt(cek, value, gen)
1180
1180
  const seal = signer ? await signer({ owner, key, gen, iv: e.iv, ct: e.ct }) : null
1181
1181
  vars[key] = { pub: false, owner, gen, e, seal, at: Date.now(), by: null }
1182
1182
  bag[k].keyring.push({ gen, createdAt: Date.now(), wraps })
1183
1183
  }
1184
1184
  save()
1185
- return { rotated: Object.keys(claras).length, sinLlave: [...sinLlave], gen, cambio: true }
1185
+ return { rotated: Object.keys(plainOnes).length, sinLlave: [...noKey], gen, cambio: true }
1186
1186
  },
1187
1187
 
1188
1188
  /**
@@ -1233,7 +1233,7 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1233
1233
  *
1234
1234
  * `null` en cualquiera de las dos significa «la del perfil sin contraseña».
1235
1235
  */
1236
- async rekeyRecovery (...a) { return enFila(() => this._rekeyRecovery(...a)) },
1236
+ async rekeyRecovery (...a) { return queued(() => this._rekeyRecovery(...a)) },
1237
1237
  /**
1238
1238
  * ¿ESTA llave abre la copia de recuperación? Lanza si no.
1239
1239
  *
@@ -1286,19 +1286,19 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1286
1286
  * el original, y solo entonces se escribe. Si algo no cuadra no se toca nada y se
1287
1287
  * lanza: media migración es peor que ninguna.
1288
1288
  */
1289
- async migrate (...a) { return enFila(() => this._migrate(...a)) },
1289
+ async migrate (...a) { return queued(() => this._migrate(...a)) },
1290
1290
  /** @private */
1291
1291
  async _migrate (membersOf, adminKey = null) {
1292
1292
  if (data.schemaVersion === SCHEMA_VERSION) return { migrated: false, reason: 'already-v5' }
1293
1293
  needSealer('seal the store')
1294
- const desde = data.schemaVersion
1294
+ const since = data.schemaVersion
1295
1295
 
1296
1296
  // De v4: las CEK viejas viven en la copia maestra, y para abrirla hace falta la
1297
1297
  // frase. Es la única vez que se pide.
1298
- const master = desde === SEALED_MASTER_VERSION ? await sealer.openMaster(data.master, keyOr(adminKey)) : null
1299
- const claro = async (owner, e) => {
1298
+ const master = since === SEALED_MASTER_VERSION ? await sealer.openMaster(data.master, keyOr(adminKey)) : null
1299
+ const plain = async (owner, e) => {
1300
1300
  if (e.pub) return e.v
1301
- if (desde === LEGACY_VERSION) return e.v
1301
+ if (since === LEGACY_VERSION) return e.v
1302
1302
  return sealer.decrypt(master, e.e, e.owner || owner)
1303
1303
  }
1304
1304
 
@@ -1312,12 +1312,12 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1312
1312
  history: []
1313
1313
  }
1314
1314
  const antes = {}
1315
- const sinLlave = {}
1315
+ const noKey = {}
1316
1316
 
1317
1317
  for (const [kind, src, dst] of [['ns', data.ns, next.ns], ['dev', data.dev, next.dev]]) {
1318
1318
  for (const [k, bag] of Object.entries(src)) {
1319
1319
  const owner = `${kind}:${k}`
1320
- const entradas = desde === LEGACY_VERSION ? (bag || {}) : (bag?.vars || {})
1320
+ const entries = since === LEGACY_VERSION ? (bag || {}) : (bag?.vars || {})
1321
1321
  const vars = {}
1322
1322
  const keyring = []
1323
1323
  // UNA SOLA generación para todo el cajón, y no es una excepción a «una por
@@ -1328,8 +1328,8 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1328
1328
  // sin apagar a nadie. Lo que se escriba DESPUÉS ya estrena generación.
1329
1329
  const gen = 1
1330
1330
  let cek = null
1331
- for (const [key, e] of Object.entries(entradas)) {
1332
- const value = await claro(owner, e)
1331
+ for (const [key, e] of Object.entries(entries)) {
1332
+ const value = await plain(owner, e)
1333
1333
  antes[`${owner}\u0000${key}`] = value
1334
1334
  // LA PÚBLICA TAMBIÉN SE SELLA (dueño, 2026-09-02). Aquí se dejaba en claro,
1335
1335
  // así que un archivo migrado se quedaba con valores legibles en el disco —
@@ -1337,14 +1337,14 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1337
1337
  // a quién se le despacha sin aprobación, no cómo se guarda.
1338
1338
  if (!cek) {
1339
1339
  cek = await sealer.newKey()
1340
- const { wraps, sinLlave: faltan } = await sealer.wrapFor(cek, (await membersOf(owner)) || [])
1340
+ const { wraps, sinLlave: missingOnes } = await sealer.wrapFor(cek, (await membersOf(owner)) || [])
1341
1341
  wraps[RECOVERY] = await sealer.wrapForKey(cek, next.recovery.pub)
1342
- if (faltan.length) sinLlave[owner] = faltan
1342
+ if (missingOnes.length) noKey[owner] = missingOnes
1343
1343
  keyring.push({ gen, createdAt: Date.now(), wraps })
1344
1344
  }
1345
- const sobre = await sealer.encrypt(cek, value, gen)
1346
- const seal = signer ? await signer({ owner, key, gen, iv: sobre.iv, ct: sobre.ct }) : null
1347
- vars[key] = { pub: !!e.pub, owner, gen, e: sobre, seal, at: Date.now(), by: null }
1345
+ const envelope = await sealer.encrypt(cek, value, gen)
1346
+ const seal = signer ? await signer({ owner, key, gen, iv: envelope.iv, ct: envelope.ct }) : null
1347
+ vars[key] = { pub: !!e.pub, owner, gen, e: envelope, seal, at: Date.now(), by: null }
1348
1348
  }
1349
1349
  dst[k] = { vars, keyring }
1350
1350
  }
@@ -1359,8 +1359,8 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1359
1359
  // Se abre TODO, también las públicas: ahora van selladas igual, así que la
1360
1360
  // comprobación de que la migración no cambió ningún valor vale para las dos.
1361
1361
  const g = bag.keyring.find((x) => x.gen === e.gen)
1362
- const abierto = await sealer.openValue(await sealer.openWrapWith(priv, g.wraps[RECOVERY]), e.e)
1363
- if (abierto !== antes[`${owner}\u0000${key}`]) {
1362
+ const isOpen = await sealer.openValue(await sealer.openWrapWith(priv, g.wraps[RECOVERY]), e.e)
1363
+ if (isOpen !== antes[`${owner}\u0000${key}`]) {
1364
1364
  throw new Error(`secrets: the migration check failed on ${owner}/${key}; nothing was touched`)
1365
1365
  }
1366
1366
  }
@@ -1369,10 +1369,10 @@ export function openSecretsStore (disk, { sealer = null, recipients = null, sign
1369
1369
 
1370
1370
  // Copia de lo anterior antes de pisarlo. Con nodos en producción, deshacer tiene
1371
1371
  // que ser un `mv`, no una restauración. La borra el operador a mano.
1372
- writeJson(disk, `${file}.v${desde}.bak`, data)
1372
+ writeJson(disk, `${file}.v${since}.bak`, data)
1373
1373
  data = next
1374
1374
  flush()
1375
- return { migrated: true, from: desde, sinLlave }
1375
+ return { migrated: true, from: since, sinLlave: noKey }
1376
1376
  }
1377
1377
  }
1378
1378
  }
@@ -59,7 +59,7 @@ export async function isAcceptable (e) {
59
59
  export function openSubacta (disk) {
60
60
  const file = 'subacta.json'
61
61
  let data = readJson(disk, file, null) || { v: 1, entries: [] }
62
- const guardar = () => writeJson(disk, file, data)
62
+ const save = () => writeJson(disk, file, data)
63
63
 
64
64
  return {
65
65
  /** Las entradas vigentes, tal cual se le pasan a `memberCan` y compañía. */
@@ -79,7 +79,7 @@ export function openSubacta (disk) {
79
79
  const id = idOf(e)
80
80
  if (data.entries.some((x) => idOf(x) === id)) return { ok: false, reason: 'already-present' }
81
81
  data.entries = [...data.entries, e]
82
- guardar()
82
+ save()
83
83
  return { ok: true, reason: 'new' }
84
84
  },
85
85
 
@@ -92,10 +92,10 @@ export function openSubacta (disk) {
92
92
 
93
93
  /** Vacía lo ya absorbido. Se le pasa lo que se absorbió, no «todo»: mientras se sella
94
94
  * puede haber entrado una nueva, y tirarla sería perder una renuncia sin aplicar. */
95
- clear (absorbidas) {
96
- const ids = new Set(absorbidas.map(idOf))
95
+ clear (absorbed) {
96
+ const ids = new Set(absorbed.map(idOf))
97
97
  data.entries = data.entries.filter((e) => !ids.has(idOf(e)))
98
- guardar()
98
+ save()
99
99
  }
100
100
  }
101
101
  }
@@ -235,7 +235,7 @@ export function openThreadStore (disk) {
235
235
  // Solo sale lo que ya cumplió su año de respaldo.
236
236
  const antes = data.resealed.length
237
237
  data.resealed = data.resealed.filter((x) => now - (x.at || 0) < RESEALED_KEEP_MS)
238
- const podados = antes - data.resealed.length
238
+ const pruned = antes - data.resealed.length
239
239
  for (const [key, arr] of Object.entries(data.threads)) {
240
240
  for (let i = 0; i < arr.length; i++) {
241
241
  const r = await resealStale(arr[i], { gen, reseal })
@@ -246,7 +246,7 @@ export function openThreadStore (disk) {
246
246
  changed += r.changed; entries++
247
247
  }
248
248
  }
249
- if (entries || podados) save()
249
+ if (entries || pruned) save()
250
250
  return { changed, entries, skipped }
251
251
  }
252
252