@dotrino/vaultd 0.21.0 → 0.22.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.
@@ -42,6 +42,8 @@ export const MSG = Object.freeze({
42
42
  DEVICES: 'vault.devices', // dispositivo → vault: { data:{publickey,ts}, signature, cert }
43
43
  DEVICES_RESULT: 'vault.devices.result', // vault → dispositivo: { devices, revoked }
44
44
  RENEW: 'vault.renew', // dispositivo → vault: { data:{op,publickey,ts}, signature, cert }
45
+ RENOUNCE: 'vault.renounce', // dispositivo → vault: { record } (RENUNCIA firmada por el propio miembro)
46
+ RENOUNCE_RESULT: 'vault.renounce.result', // vault → dispositivo: { ok, seq }
45
47
  RENEWED: 'vault.renewed', // vault → dispositivo: { cert } (cert fresco, misma sub-clave/scope)
46
48
  SECRETS: 'vault.secrets', // servicio → vault: { data:{op,ns,ek,publickey,ts}, signature, cert }
47
49
  SECRETS_RESULT: 'vault.secrets.result', // vault → servicio: { body:{op,ns,enc,ts}, signature } (enc SELLADO a ek; body firmado por la maestra)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/vaultd",
3
- "version": "0.21.0",
3
+ "version": "0.22.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": {
@@ -19,7 +19,7 @@
19
19
  "node": ">=20"
20
20
  },
21
21
  "dependencies": {
22
- "@dotrino/identity": "^0.41.0",
22
+ "@dotrino/identity": "^0.42.0",
23
23
  "@dotrino/proxy-client": "^0.10.0",
24
24
  "ws": "^8.18.0"
25
25
  },
package/src/vault.js CHANGED
@@ -331,6 +331,7 @@ export async function startVault ({ dir = dataDir(), proxyUrl, log = console.log
331
331
  if (payload.type === MSG.RENEW) return await handleRenew(from, payload)
332
332
  if (payload.type === MSG.SECRETS) return await handleSecrets(from, payload)
333
333
  if (payload.type === MSG.ADMIN) return await handleAdmin(from, payload)
334
+ if (payload.type === MSG.RENOUNCE) return await handleRenounce(from, payload)
334
335
  } catch (e) {
335
336
  reply(from, { type: MSG.ERROR, error: e.message })
336
337
  }
@@ -456,6 +457,34 @@ export async function startVault ({ dir = dataDir(), proxyUrl, log = console.log
456
457
  }
457
458
  })
458
459
 
460
+ /**
461
+ * RENUNCIA: un miembro se quita capacidades a sí mismo y la bóveda la SELLA en el acta.
462
+ *
463
+ * NO se pide certificado, y es a propósito: el registro va firmado por el propio miembro
464
+ * y solo puede QUITAR, así que honrarlo no puede hacer daño — y exigir un cert válido
465
+ * dejaría fuera justo el caso que la justifica (un aparato que ya no es de fiar, o cuyo
466
+ * cert caducó). Sin esto la renuncia se quedaba en el dispositivo: la bóveda seguía
467
+ * teniendo escrito que podía firmar y le seguía aceptando peticiones.
468
+ */
469
+ async function handleRenounce (from, p) {
470
+ const record = p?.data?.record || p?.record
471
+ if (!record || typeof record !== 'object') return reply(from, { type: MSG.ERROR, error: 'renounce: record required' })
472
+ if (!(await Acta.verifyRenounce(record).catch(() => false))) {
473
+ audit('rejected', { what: 'renounce', reason: 'signature' })
474
+ return reply(from, { type: MSG.ERROR, error: 'renounce: the signature is not the member own' })
475
+ }
476
+ try {
477
+ const r = await identity.absorbRenounce(record)
478
+ const device = await deviceIdOf(record.member).catch(() => null)
479
+ audit('renounce', { device, caps: record.caps })
480
+ log(`[vault] ${device} renounced: ${(record.caps || []).join(', ')}`)
481
+ await notifyMembers('renounce', { deviceId: device, caps: record.caps })
482
+ reply(from, { type: MSG.RENOUNCE_RESULT, ok: true, seq: r?.seq ?? null })
483
+ } catch (e) {
484
+ reply(from, { type: MSG.ERROR, error: 'renounce: ' + e.message })
485
+ }
486
+ }
487
+
459
488
  async function handleAdmin (from, p) {
460
489
  // La frescura se comprueba aquí (es del transporte, igual que en el resto de
461
490
  // handlers); el resto de la regla vive en el módulo puro.