@dotrino/vaultd 0.187.1 → 0.188.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.
package/README.md CHANGED
@@ -78,7 +78,7 @@ permisos (`sign`, `read`, `store`…) se le dan igual a uno que a otro.
78
78
  | Tus datos | recibe la clave de contenido (lee lo tuyo) | no la recibe |
79
79
 
80
80
  Se pasa de uno a otro **sin re-enrolar**: es la misma llave, cambia lo que el acta dice de
81
- ella (vaultd ≥ 0.187.0, identity ≥ 0.135.0).
81
+ ella (vaultd ≥ 0.187.1, identity ≥ 0.135.0; en la TUI, la última fila de los permisos del aparato desde la 0.188.0).
82
82
 
83
83
  ```sh
84
84
  dotrino-vault caps <ID> +secrets:tunnel # pasa a ser el servicio «tunnel» (si ya era otro, lo reemplaza)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/vaultd",
3
- "version": "0.187.1",
3
+ "version": "0.188.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": {
package/src/tui/app.js CHANGED
@@ -725,15 +725,32 @@ function setCapsDraft (st, member, caps) {
725
725
  else drafts[member.pub] = [...caps]
726
726
  st.capsDrafts = drafts
727
727
  }
728
+ /**
729
+ * DISPOSITIVO O SERVICIO (dueño, 2026-10-28): el cajón (`cn`) va en el mismo borrador y se
730
+ * guarda en la misma acta que los permisos. `st.cnDrafts[pub]` es el cajón que QUEDARÍA
731
+ * (`null` = dispositivo); si vuelve a coincidir con el acta, sale del borrador.
732
+ */
733
+ const draftCnOf = (st, member) => (member.pub in (st.cnDrafts || {}) ? st.cnDrafts[member.pub] : (member.cn || null))
734
+ function setCnDraft (st, member, cn) {
735
+ const drafts = { ...(st.cnDrafts || {}) }
736
+ if ((cn || null) === (member.cn || null)) delete drafts[member.pub]
737
+ else drafts[member.pub] = cn || null
738
+ st.cnDrafts = drafts
739
+ }
728
740
  /** Lo que se firmaría ahora: un cambio por aparato que sigue en el acta y difiere de ella. */
729
741
  function draftChanges (st) {
730
742
  const out = []
731
- for (const [pub, caps] of Object.entries(st.capsDrafts || {})) {
743
+ const pubs = new Set([...Object.keys(st.capsDrafts || {}), ...Object.keys(st.cnDrafts || {})])
744
+ for (const pub of pubs) {
732
745
  const member = (st.members || []).find((m) => m.pub === pub)
733
- if (!member || sameCaps(caps, member.caps)) continue
746
+ if (!member) continue
747
+ const caps = draftCapsOf(st, member)
748
+ const cn = draftCnOf(st, member)
749
+ const cnChanged = cn !== (member.cn || null)
750
+ if (sameCaps(caps, member.caps) && !cnChanged) continue
734
751
  const real = new Set(member.caps || []); const has = new Set(caps)
735
- const n = [...new Set([...has, ...real])].filter((c) => has.has(c) !== real.has(c)).length
736
- out.push({ pub, caps: [...caps], member, n })
752
+ const n = [...new Set([...has, ...real])].filter((c) => has.has(c) !== real.has(c)).length + (cnChanged ? 1 : 0)
753
+ out.push({ pub, caps: [...caps], ...(cnChanged ? { cn } : {}), member, n })
737
754
  }
738
755
  return out
739
756
  }
@@ -746,7 +763,7 @@ function draftChanges (st) {
746
763
  function unlessDrafts (st, fn) {
747
764
  const n = draftChanges(st).length
748
765
  if (!n) return fn()
749
- setConfirm(st, { text: L(st).capsDiscardAll(n), onYes: async () => { st.capsDrafts = {}; await fn() } })
766
+ setConfirm(st, { text: L(st).capsDiscardAll(n), onYes: async () => { st.capsDrafts = {}; st.cnDrafts = {}; await fn() } })
750
767
  }
751
768
 
752
769
  /**
@@ -758,10 +775,10 @@ async function saveCapsDrafts (term, st) {
758
775
  const changes = draftChanges(st)
759
776
  if (!changes.length) { flash(st, i.capsNothing); return }
760
777
  const save = async () => {
761
- const r = await guard(term, st, i.applyingCaps, () => vc.setDevicesCaps(changes.map(({ pub, caps }) => ({ pub, caps })), activeId(st)))
778
+ const r = await guard(term, st, i.applyingCaps, () => vc.setDevicesCaps(changes.map(({ pub, caps, cn }) => ({ pub, caps, ...(cn !== undefined ? { cn } : {}) })), activeId(st)))
762
779
  if (!r.ok) return
763
780
  applyDump(st, r.v)
764
- st.capsDrafts = {}
781
+ st.capsDrafts = {}; st.cnDrafts = {}
765
782
  await refreshMembers(term, st)
766
783
  flash(st, i.capsSavedMany(changes.reduce((a, c) => a + c.n, 0), changes.length))
767
784
  }
@@ -783,11 +800,24 @@ function capsRows (st, t) {
783
800
  // EL BORRADOR manda sobre lo que hay en el acta: es lo que estás a punto de dejar.
784
801
  const real = new Set(member.caps || [])
785
802
  const has = new Set(draftCapsOf(st, member))
786
- const { rows: list, tocados: touched } = capChecklist(i, t, { cn: member.cn, has, real })
803
+ const comm = isCommKey(member)
804
+ const { rows: list, tocados: capsTouched } = capChecklist(i, t, { cn: comm ? member.cn : null, has, real })
805
+ // EL CAJÓN, última fila: decide si es un dispositivo o un servicio, y se cambia sin
806
+ // re-enrolar. La llave de comunicación de la bóveda no tiene esta fila.
807
+ const cn = draftCnOf(st, member)
808
+ const cnChanged = cn !== (member.cn || null)
809
+ const drawer = comm
810
+ ? []
811
+ : [
812
+ { text: ` ${cnChanged ? t.bold('*') : ' '} ${cn ? i.capsDrawerRow(cn) : i.capsDeviceRow}`, sel: true, meta: { drawer: true } },
813
+ { text: t.muted(' ' + (cn ? i.capsDrawer(cn) + ' ' + i.capsServiceHint : i.capsDeviceHint)), sel: false }
814
+ ]
815
+ const touched = capsTouched + (cnChanged ? 1 : 0)
787
816
  const rows = [
788
817
  { text: ' ' + t.bold(i.capsFor(target.deviceId, member.label || '')), sel: false },
789
818
  { text: '', sel: false },
790
819
  ...list,
820
+ ...drawer,
791
821
  { text: '', sel: false }
792
822
  ]
793
823
  // Lo que hay pendiente en OTROS aparatos también se dice aquí: G los guarda juntos.
@@ -1072,7 +1102,7 @@ async function refreshAll (term, st, api = vc) {
1072
1102
  // Cerrada: no se pide su contenido, y tampoco se enseña un error por mirarla desde
1073
1103
  // fuera. Lo que hubiera cargado se suelta, para no dejar en pantalla lo de antes.
1074
1104
  if (activeLocked(st)) {
1075
- st.devices = null; st.secrets = null; st.members = []; st.blocked = []; st.me = undefined; st.capsDrafts = {}
1105
+ st.devices = null; st.secrets = null; st.members = []; st.blocked = []; st.me = undefined; st.capsDrafts = {}; st.cnDrafts = {}
1076
1106
  return
1077
1107
  }
1078
1108
  const r = await guard(term, st, L(st).loading, () => api.snapshot(activeId(st)))
@@ -1679,12 +1709,29 @@ async function onKeyCaps (term, st, key) {
1679
1709
  if (key.name === 'f5') {
1680
1710
  // F5 trae el acta de nuevo y el borrador deja de tener con qué compararse: se pregunta
1681
1711
  // antes de tirarlo, igual que al salir de la bóveda.
1682
- unlessDrafts(st, async () => { st.capsDrafts = {}; await refreshMembers(term, st) })
1712
+ unlessDrafts(st, async () => { st.capsDrafts = {}; st.cnDrafts = {}; await refreshMembers(term, st) })
1683
1713
  return true
1684
1714
  }
1685
1715
  if (ch === 'g') { await saveCapsDrafts(term, st); return true }
1686
1716
 
1687
1717
  if ((key.name !== 'enter' && ch !== ' ') || !cur) return true
1718
+ if (cur.drawer) {
1719
+ // El cajón se ESCRIBE: vacío lo deja como dispositivo. Solo mueve el borrador.
1720
+ const i = L(st)
1721
+ setInput(st, {
1722
+ label: i.cnLabel,
1723
+ hint: i.cnHint,
1724
+ value: draftCnOf(st, member) || '',
1725
+ onSubmit: async (v) => {
1726
+ const cn = v.trim().toLowerCase() || null
1727
+ if (cn && (!/^[a-z0-9-]{1,32}$/.test(cn) || cn === 'vault')) { flash(st, i.cnInvalid, 'danger'); return }
1728
+ st.input = null
1729
+ setCnDraft(st, member, cn)
1730
+ },
1731
+ onCancel: () => { st.input = null }
1732
+ })
1733
+ return true
1734
+ }
1688
1735
  // Enter solo mueve el BORRADOR: no firma, no avisa, no se puede equivocar caro.
1689
1736
  const draft = new Set(draftCapsOf(st, member))
1690
1737
  if (draft.has(cur.cap)) draft.delete(cur.cap); else draft.add(cur.cap)
@@ -3153,6 +3200,7 @@ export function newSession () {
3153
3200
  sel: { profiles: 0, devices: 0, secrets: 0, pairmode: 0, paircaps: 0, devvars: 0, logins: 0, doors: 0, settings: 0 },
3154
3201
  // Permisos tocados y sin guardar, por llave del aparato (ver `setCapsDraft`).
3155
3202
  capsDrafts: {},
3203
+ cnDrafts: {},
3156
3204
  // Las bóvedas que ha abierto ESTA sesión, para volver a cerrarlas al salir.
3157
3205
  unlockedHere: new Set(),
3158
3206
  // Su contraseña, SOLO en memoria y SOLO mientras la pantalla esté abierta: sirve para
@@ -3251,7 +3299,7 @@ export async function handleKey (term, st, key) {
3251
3299
  // entrada). La pantalla de emparejamiento maneja su propio Esc (va a Dispositivos).
3252
3300
  if ((key.name === 'escape' || ch === 'b') && INNER_TABS.includes(st.screen)) {
3253
3301
  // El borrador es de ESTA bóveda: al salir de ella se guarda o se tira.
3254
- unlessDrafts(st, () => { st.capsDrafts = {}; st.screen = 'profiles' })
3302
+ unlessDrafts(st, () => { st.capsDrafts = {}; st.cnDrafts = {}; st.screen = 'profiles' })
3255
3303
  return true
3256
3304
  }
3257
3305
 
package/src/tui/i18n.js CHANGED
@@ -93,6 +93,13 @@ const es = {
93
93
  titleCaps: 'Permisos del dispositivo',
94
94
  capsFor: (id, name) => `Permisos de ${id}${name ? ' · ' + name : ''}`,
95
95
  capsDrawer: (cn) => `Es el servicio «${cn}»: abre el cajón «${cn}» y ningún otro.`,
96
+ capsDrawerRow: (cn) => `cajón «${cn}» · es un servicio`,
97
+ capsDeviceRow: 'sin cajón · es un dispositivo',
98
+ capsServiceHint: 'No firma por ti. Enter lo cambia; vacío lo deja como dispositivo, sin re-enrolar.',
99
+ capsDeviceHint: 'Firma como tú y no abre ningún cajón. Enter le pone uno y pasa a ser un servicio, sin re-enrolar.',
100
+ cnLabel: 'Cajón (vacío = dispositivo)',
101
+ cnHint: 'minúsculas, números y guiones · Enter lo deja en el borrador · Esc cancela',
102
+ cnInvalid: 'Ese nombre no vale: minúsculas, números y guiones, y no «vault».',
96
103
  capsNoMember: ' (este dispositivo ya no está en el perfil)',
97
104
  capsApplyHint: 'Enter marca o desmarca · G guarda · Esc vuelve a la lista sin perder lo marcado',
98
105
  capsPending: (n) => `${n} cambio(s) sin guardar en este aparato (*) · G guarda todo en una sola acta`,
@@ -655,6 +662,13 @@ const en = {
655
662
  titleCaps: 'Device permissions',
656
663
  capsFor: (id, name) => `Permissions for ${id}${name ? ' · ' + name : ''}`,
657
664
  capsDrawer: (cn) => `It is the “${cn}” service: it opens the “${cn}” drawer and no other.`,
665
+ capsDrawerRow: (cn) => `drawer “${cn}” · it is a service`,
666
+ capsDeviceRow: 'no drawer · it is a device',
667
+ capsServiceHint: 'It does not sign for you. Enter changes it; empty makes it a device, without re-enrolling.',
668
+ capsDeviceHint: 'It signs as you and opens no drawer. Enter gives it one and it becomes a service, without re-enrolling.',
669
+ cnLabel: 'Drawer (empty = device)',
670
+ cnHint: 'lowercase, digits and hyphens · Enter puts it in the draft · Esc cancels',
671
+ cnInvalid: 'That name is not valid: lowercase, digits and hyphens, and not “vault”.',
658
672
  capsNoMember: ' (this device is no longer in the record)',
659
673
  capsApplyHint: 'Enter ticks or unticks · G saves · Esc goes back to the list keeping your ticks',
660
674
  capsPending: (n) => `${n} unsaved change(s) on this device (*) · G saves everything in ONE record`,