@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 +1 -1
- package/lib/src/admin.js +2 -2
- package/lib/src/browser.js +10 -10
- package/lib/src/core/approvals.js +3 -2
- package/lib/src/core/libVersion.js +2 -2
- package/lib/src/core/sealer.js +2 -2
- package/lib/src/core/sealers.js +15 -15
- package/lib/src/core/secretsStore.js +66 -66
- package/lib/src/core/subacta.js +5 -5
- package/lib/src/core/threadStore.js +2 -2
- package/lib/src/core/transport.js +31 -31
- package/lib/src/core/vault.js +222 -189
- package/lib/src/env.js +10 -10
- package/lib/src/index.js +5 -5
- package/lib/src/kek.js +6 -6
- package/lib/src/localdesk.js +10 -10
- package/lib/src/lock.js +18 -18
- package/lib/src/loginClient.js +23 -23
- package/lib/src/passwordLogins.js +7 -7
- package/lib/src/proc.js +5 -5
- package/lib/src/procContext.js +2 -2
- package/lib/src/service.js +67 -43
- package/lib/src/sshKeys.js +3 -3
- package/lib/src/version.js +4 -4
- package/package.json +1 -1
- package/src/ctl.js +72 -72
- package/src/daemon.js +104 -104
- package/src/keyowner.js +3 -3
- package/src/manager.js +5 -5
- package/src/platform.js +16 -16
- package/src/profiles.js +47 -47
- package/src/replica.js +25 -25
- package/src/selfupdate.js +6 -6
- package/src/tui/app.js +81 -81
- package/src/tui/i18n.js +1 -1
- package/src/update.js +12 -12
- package/src/updateApproval.js +1 -1
- package/src/vaultControl.js +4 -4
package/src/tui/app.js
CHANGED
|
@@ -416,8 +416,8 @@ function settingsRows (st, t) {
|
|
|
416
416
|
rows.push({ text: t.muted(' ' + i.settingsUnreadableHint), sel: false })
|
|
417
417
|
rows.push({ text: '', sel: false })
|
|
418
418
|
}
|
|
419
|
-
const
|
|
420
|
-
rows.push({ text: ` ${t.bold(
|
|
419
|
+
const phrase = cfg.error ? i.settingUpdateUnknown : cfg.updateApproval ? i.settingUpdateAsks : i.settingUpdateAlone
|
|
420
|
+
rows.push({ text: ` ${t.bold(phrase)} ${t.accent(i.settingChange)}`, sel: true, meta: { setting: 'updateApproval' } })
|
|
421
421
|
rows.push({ text: t.muted(' ' + i.settingUpdateHint1), sel: false })
|
|
422
422
|
rows.push({ text: t.muted(' ' + i.settingUpdateHint2), sel: false })
|
|
423
423
|
// ARRANCAR AL INICIAR SESIÓN. En Linux lo deja la unidad de systemd; en Windows y macOS no
|
|
@@ -495,19 +495,19 @@ function deviceRows (st, t) {
|
|
|
495
495
|
}
|
|
496
496
|
// PERMISOS SIN GUARDAR en uno o varios aparatos: se dice ARRIBA y se marca cada uno con
|
|
497
497
|
// `*`, porque G los firma todos juntos y hay que ver qué entra antes de pulsarlo.
|
|
498
|
-
const
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
501
|
-
rows.unshift({ text: t.bold(' ' + i.devicesDraft(
|
|
498
|
+
const draft = draftChanges(st)
|
|
499
|
+
const withChanges = new Set(draft.map((c) => c.pub))
|
|
500
|
+
if (draft.length) {
|
|
501
|
+
rows.unshift({ text: t.bold(' ' + i.devicesDraft(draft.length)), sel: false }, { text: '', sel: false })
|
|
502
502
|
}
|
|
503
503
|
for (const d of devices) {
|
|
504
504
|
const label = d.label || t.muted(i.noLabel)
|
|
505
505
|
// Dónde corre (`node · Linux 7.0 · mi-pc`), pegado al nombre: es con lo que se reconoce.
|
|
506
|
-
const
|
|
507
|
-
const
|
|
506
|
+
const machine = machineLine(d.machine)
|
|
507
|
+
const where = machine ? t.muted(` ${machine}`) : ''
|
|
508
508
|
const vars = devVarsOf(st, d.sub).length
|
|
509
509
|
const debt = debtOf(st, d.sub)
|
|
510
|
-
const
|
|
510
|
+
const since = d.addedAt ? t.muted(` ${i.deviceSince}:${fmtExp(d.addedAt)}`) : ''
|
|
511
511
|
// QUÉ VERSIÓN CORRE, y en color de aviso si no cuadra con la nuestra.
|
|
512
512
|
//
|
|
513
513
|
// Sin esto una incompatibilidad de versiones se ve como que ese aparato «no responde»,
|
|
@@ -517,14 +517,14 @@ function deviceRows (st, t) {
|
|
|
517
517
|
//
|
|
518
518
|
// Un aparato que todavía no ha hablado desde que arrancamos no sale: `null` es «no lo
|
|
519
519
|
// sé», y escribir «desconocido» en cada fila sería ruido, no información.
|
|
520
|
-
const
|
|
520
|
+
const running = d.running
|
|
521
521
|
? (d.running.compatible
|
|
522
522
|
? t.muted(` ${i.runs}:${d.running.version}`)
|
|
523
523
|
: t.warn(` ${i.mismatch(d.running.product, d.running.version)}`))
|
|
524
524
|
: ''
|
|
525
525
|
const extra = (d.certCount > 1 ? t.muted(` certs:${d.certCount}`) : '') +
|
|
526
526
|
(vars ? t.muted(` vars:${vars}`) : '') +
|
|
527
|
-
|
|
527
|
+
running +
|
|
528
528
|
// En quien aprueba: si dijo que le llegan los avisos. No cambia a quién se le pide
|
|
529
529
|
// (a todos); deja ver a cuál no le suena el pedido. Es un dato, va en gris.
|
|
530
530
|
(d.notifiedAt === undefined ? '' : t.muted(` ${d.notifiedAt ? i.notifyYes : i.notifyUnknown}`)) +
|
|
@@ -542,8 +542,8 @@ function deviceRows (st, t) {
|
|
|
542
542
|
: d.isMaster
|
|
543
543
|
? t.muted(i.thisVault)
|
|
544
544
|
: t.muted('scope:' + shortScope(d.scope)) + ' ' + t.muted('exp:' + fmtExp(d.exp)))
|
|
545
|
-
const
|
|
546
|
-
rows.push({ text: `${
|
|
545
|
+
const mark = withChanges.has(d.sub) ? t.bold('*') : ' '
|
|
546
|
+
rows.push({ text: `${mark}${t.bold(d.deviceId)} ${label}${where}${since} ${status}${extra}`, sel: true, meta: d })
|
|
547
547
|
}
|
|
548
548
|
const revoked = st.devices?.revoked || []
|
|
549
549
|
if (revoked.length) {
|
|
@@ -576,12 +576,12 @@ function loginRows (st, t) {
|
|
|
576
576
|
return rows
|
|
577
577
|
}
|
|
578
578
|
for (const l of list) {
|
|
579
|
-
const
|
|
580
|
-
const
|
|
579
|
+
const wait = l.blockedUntil > Date.now() ? Math.ceil((l.blockedUntil - Date.now()) / 1000) : 0
|
|
580
|
+
const opened = (l.sessions || []).length
|
|
581
581
|
const extra = [
|
|
582
|
-
|
|
582
|
+
opened ? t.warn(' ' + i.loginOpen(opened)) : t.muted(' ' + i.loginOpen(0)),
|
|
583
583
|
l.label ? t.muted(' «' + l.label + '»') : '',
|
|
584
|
-
|
|
584
|
+
wait ? t.danger(' ' + i.loginWait(wait)) : '',
|
|
585
585
|
l.createdAt ? t.muted(' ' + i.loginCreated(fmtExp(l.createdAt))) : ''
|
|
586
586
|
].join('')
|
|
587
587
|
rows.push({ text: ` ${t.bold(l.address || l.user)} ${t.muted(l.deviceId || '????-????')}${extra}`, sel: true, meta: l })
|
|
@@ -647,11 +647,11 @@ function pairModeRows (st, t) {
|
|
|
647
647
|
* invisible aquí durante semanas —`sealer`, `unattended` y `secrets`, tres veces el mismo
|
|
648
648
|
* fallo—. Ahora el orden se cura a mano, que es una decisión de diseño, pero lo que no
|
|
649
649
|
* esté nombrado se añade al final: un permiso puede salir en mal sitio, nunca desaparecer.
|
|
650
|
-
* `test/tui-
|
|
650
|
+
* `test/tui-permissions.test.mjs` exige además que todos tengan nombre en los dos idiomas.
|
|
651
651
|
*/
|
|
652
|
-
const
|
|
653
|
-
const CAPS_ORDER = [...
|
|
654
|
-
...DEVICE_CAPS.filter((c) => !
|
|
652
|
+
const ORDER = ['sign', 'store', 'read', 'admin', 'approve', 'passwords', 'sealer', 'unattended', 'replica']
|
|
653
|
+
const CAPS_ORDER = [...ORDER.filter((c) => DEVICE_CAPS.includes(c)),
|
|
654
|
+
...DEVICE_CAPS.filter((c) => !ORDER.includes(c))]
|
|
655
655
|
|
|
656
656
|
/**
|
|
657
657
|
* EL CAJÓN NO ES UNA CASILLA (dueño, 2026-10-13: «no entiendo por qué es un permiso el
|
|
@@ -672,7 +672,7 @@ const PAIR_DEFAULT_CAPS = ['sign', 'read', 'store']
|
|
|
672
672
|
*/
|
|
673
673
|
function capChecklist (i, t, { cn = null, has, real = has }) {
|
|
674
674
|
const rows = []
|
|
675
|
-
let
|
|
675
|
+
let touched = 0
|
|
676
676
|
if (cn) rows.push({ text: t.muted(' ' + i.capsDrawer(cn)), sel: false }, { text: '', sel: false })
|
|
677
677
|
for (const cap of CAPS_ORDER) {
|
|
678
678
|
const mark = has.has(cap) ? '[x]' : '[ ]'
|
|
@@ -680,14 +680,14 @@ function capChecklist (i, t, { cn = null, has, real = has }) {
|
|
|
680
680
|
// LO QUE CAMBIA SE SEÑALA. Sin esto el borrador es indistinguible del acta y no sabes
|
|
681
681
|
// qué vas a firmar — que es justo lo que hace peligroso acumular cambios.
|
|
682
682
|
const cambia = has.has(cap) !== real.has(cap)
|
|
683
|
-
if (cambia)
|
|
683
|
+
if (cambia) touched++
|
|
684
684
|
// El título ES el nombre del permiso —el mismo que se teclea en `caps <ID> +administra`—
|
|
685
685
|
// así que no hay que repetirlo al lado. Lo que hace va debajo.
|
|
686
686
|
const line = ` ${mark}${cambia ? t.bold('*') : ' '} ${cap === 'admin' ? t.bold(name) : name}`
|
|
687
687
|
rows.push({ text: line, sel: true, meta: { cap } })
|
|
688
688
|
rows.push({ text: t.muted(' ' + i.capHint[cap]), sel: false })
|
|
689
689
|
}
|
|
690
|
-
return { rows, tocados }
|
|
690
|
+
return { rows, tocados: touched }
|
|
691
691
|
}
|
|
692
692
|
|
|
693
693
|
/**
|
|
@@ -736,7 +736,7 @@ async function saveCapsDrafts (term, st) {
|
|
|
736
736
|
const i = L(st)
|
|
737
737
|
const changes = draftChanges(st)
|
|
738
738
|
if (!changes.length) { flash(st, i.capsNothing); return }
|
|
739
|
-
const
|
|
739
|
+
const save = async () => {
|
|
740
740
|
const r = await guard(term, st, i.applyingCaps, () => vc.setDevicesCaps(changes.map(({ pub, caps }) => ({ pub, caps })), activeId(st)))
|
|
741
741
|
if (!r.ok) return
|
|
742
742
|
applyDump(st, r.v)
|
|
@@ -744,12 +744,12 @@ async function saveCapsDrafts (term, st) {
|
|
|
744
744
|
await refreshMembers(term, st)
|
|
745
745
|
flash(st, i.capsSavedMany(changes.reduce((a, c) => a + c.n, 0), changes.length))
|
|
746
746
|
}
|
|
747
|
-
const
|
|
748
|
-
if (
|
|
749
|
-
setConfirm(st, { text: i.confirmAdmin(
|
|
747
|
+
const newAdmins = changes.filter((c) => c.caps.includes('admin') && !(c.member.caps || []).includes('admin'))
|
|
748
|
+
if (newAdmins.length) {
|
|
749
|
+
setConfirm(st, { text: i.confirmAdmin(newAdmins.map((c) => c.member.id || deviceIdOf(st, c.pub)).join(', ')), onYes: save })
|
|
750
750
|
return
|
|
751
751
|
}
|
|
752
|
-
await
|
|
752
|
+
await save()
|
|
753
753
|
}
|
|
754
754
|
|
|
755
755
|
function capsRows (st, t) {
|
|
@@ -762,18 +762,18 @@ function capsRows (st, t) {
|
|
|
762
762
|
// EL BORRADOR manda sobre lo que hay en el acta: es lo que estás a punto de dejar.
|
|
763
763
|
const real = new Set(member.caps || [])
|
|
764
764
|
const has = new Set(draftCapsOf(st, member))
|
|
765
|
-
const { rows:
|
|
765
|
+
const { rows: list, tocados: touched } = capChecklist(i, t, { cn: member.cn, has, real })
|
|
766
766
|
const rows = [
|
|
767
767
|
{ text: ' ' + t.bold(i.capsFor(target.deviceId, member.label || '')), sel: false },
|
|
768
768
|
{ text: '', sel: false },
|
|
769
|
-
...
|
|
769
|
+
...list,
|
|
770
770
|
{ text: '', sel: false }
|
|
771
771
|
]
|
|
772
772
|
// Lo que hay pendiente en OTROS aparatos también se dice aquí: G los guarda juntos.
|
|
773
|
-
const
|
|
774
|
-
if (
|
|
775
|
-
if (
|
|
776
|
-
if (!
|
|
773
|
+
const others = draftChanges(st).filter((c) => c.pub !== member.pub)
|
|
774
|
+
if (touched) rows.push({ text: ' ' + t.bold(i.capsPending(touched)), sel: false })
|
|
775
|
+
if (others.length) rows.push({ text: ' ' + t.bold(i.capsPendingOthers(others.length)), sel: false })
|
|
776
|
+
if (!touched && !others.length) rows.push({ text: t.muted(' ' + i.capsApplyHint), sel: false })
|
|
777
777
|
return rows
|
|
778
778
|
}
|
|
779
779
|
|
|
@@ -787,11 +787,11 @@ function pairCapsRows (st, t) {
|
|
|
787
787
|
const i = L(st)
|
|
788
788
|
const pc = st.pairCaps
|
|
789
789
|
if (!pc) return [{ text: t.muted(i.loading), sel: false }]
|
|
790
|
-
const { rows:
|
|
790
|
+
const { rows: list } = capChecklist(i, t, { cn: pc.service || null, has: new Set(pc.caps) })
|
|
791
791
|
return [
|
|
792
792
|
{ text: ' ' + t.bold(pc.service ? i.pairCapsService(pc.service) : i.pairCapsFor(pc.label || '')), sel: false },
|
|
793
793
|
{ text: '', sel: false },
|
|
794
|
-
...
|
|
794
|
+
...list,
|
|
795
795
|
{ text: '', sel: false },
|
|
796
796
|
{ text: t.muted(' ' + i.pairCapsHint), sel: false }
|
|
797
797
|
]
|
|
@@ -997,7 +997,7 @@ function autoLockWakeIn (st, now = Date.now()) {
|
|
|
997
997
|
*/
|
|
998
998
|
/** Cada cuánto se le dice al daemon «sigo aquí». Muy por debajo del plazo del candado. */
|
|
999
999
|
const TOUCH_MS = 60_000
|
|
1000
|
-
let
|
|
1000
|
+
let lastTouch = 0
|
|
1001
1001
|
|
|
1002
1002
|
/**
|
|
1003
1003
|
* Le dice al daemon que sigues delante, sin pedirle nada. Se llama al teclear.
|
|
@@ -1006,14 +1006,14 @@ let ultimoToque = 0
|
|
|
1006
1006
|
* haciendo, y si se pierde un aviso, el siguiente llega un minuto después — con cinco de
|
|
1007
1007
|
* plazo, no pasa nada.
|
|
1008
1008
|
*/
|
|
1009
|
-
function
|
|
1010
|
-
const
|
|
1011
|
-
if (
|
|
1009
|
+
function stayHere (st, api = vc) {
|
|
1010
|
+
const now = Date.now()
|
|
1011
|
+
if (now - lastTouch < TOUCH_MS) return
|
|
1012
1012
|
const p = (st.state?.profiles || []).find((x) => x.current)
|
|
1013
1013
|
// Solo tiene sentido en un perfil con contraseña y abierto: sin candado no hay plazo
|
|
1014
1014
|
// que estirar, y cerrado no hay nada que mantener abierto.
|
|
1015
1015
|
if (!p?.protected || p.locked) return
|
|
1016
|
-
|
|
1016
|
+
lastTouch = now
|
|
1017
1017
|
try { Promise.resolve(api.touchProfile(p.id)).catch(() => {}) } catch (_) {}
|
|
1018
1018
|
}
|
|
1019
1019
|
|
|
@@ -1516,8 +1516,8 @@ async function onKeyLogins (term, st, key, api = vc) {
|
|
|
1516
1516
|
() => api.addLogin({ user, password: pw1, label }))
|
|
1517
1517
|
if (r.ok) {
|
|
1518
1518
|
await refreshLogins(term, st, api)
|
|
1519
|
-
const
|
|
1520
|
-
flash(st, i.loginCreatedOk(
|
|
1519
|
+
const newer = (st.logins || []).find((l) => l.user === user)
|
|
1520
|
+
flash(st, i.loginCreatedOk(newer?.address || user))
|
|
1521
1521
|
}
|
|
1522
1522
|
}
|
|
1523
1523
|
})
|
|
@@ -1532,16 +1532,16 @@ async function onKeyLogins (term, st, key, api = vc) {
|
|
|
1532
1532
|
label: i.loginOldPass(cur.user),
|
|
1533
1533
|
hint: i.loginPassHint,
|
|
1534
1534
|
mask: true,
|
|
1535
|
-
onSubmit: async (
|
|
1535
|
+
onSubmit: async (oldOne) => {
|
|
1536
1536
|
setInput(st, {
|
|
1537
1537
|
label: i.loginNewPass,
|
|
1538
1538
|
hint: i.loginPassHint,
|
|
1539
1539
|
mask: true,
|
|
1540
|
-
onSubmit: async (
|
|
1541
|
-
if (String(
|
|
1540
|
+
onSubmit: async (newOne) => {
|
|
1541
|
+
if (String(newOne || '').length < MIN_LOGIN_PASSWORD) { flash(st, i.loginPassShort, 'warn'); return }
|
|
1542
1542
|
st.input = null
|
|
1543
1543
|
const r = await guard(term, st, i.loginChanging,
|
|
1544
|
-
() => api.passwdLogin({ user: cur.user, oldPassword:
|
|
1544
|
+
() => api.passwdLogin({ user: cur.user, oldPassword: oldOne, newPassword: newOne }))
|
|
1545
1545
|
if (r.ok) { flash(st, i.loginChanged); await refreshLogins(term, st, api) }
|
|
1546
1546
|
}
|
|
1547
1547
|
})
|
|
@@ -1576,10 +1576,10 @@ async function onKeyLogins (term, st, key, api = vc) {
|
|
|
1576
1576
|
* estabas usando. Es una cuenta recién creada y vacía —el aparato nunca entró—, así que no
|
|
1577
1577
|
* hay nada dentro que perder; lo que sí molesta es que se queden acumulando.
|
|
1578
1578
|
*/
|
|
1579
|
-
async function
|
|
1579
|
+
async function discardAccount (term, st, id, backTo) {
|
|
1580
1580
|
const i = L(st)
|
|
1581
1581
|
const r = await guard(term, st, i.discardingAccount, () => vc.removeProfile(id))
|
|
1582
|
-
if (
|
|
1582
|
+
if (backTo) await guard(term, st, i.switchingVault, () => vc.useProfile(backTo))
|
|
1583
1583
|
await refreshAll(term, st)
|
|
1584
1584
|
if (r.ok) flash(st, i.accountDiscarded)
|
|
1585
1585
|
}
|
|
@@ -1600,12 +1600,12 @@ function beginPairingNamed (term, st, profile, service = null, after = null) {
|
|
|
1600
1600
|
setInput(st, {
|
|
1601
1601
|
label: i.nameDeviceLabel,
|
|
1602
1602
|
hint: i.nameDeviceHint,
|
|
1603
|
-
onSubmit: async (
|
|
1603
|
+
onSubmit: async (name) => {
|
|
1604
1604
|
st.input = null
|
|
1605
1605
|
// Después del nombre, LOS PERMISOS: el aparato entra al acta ya con ellos. `after` es
|
|
1606
1606
|
// para quien tenga que limpiar si el emparejamiento no llega a abrirse (la cuenta
|
|
1607
1607
|
// que nació para él); lo llama la pantalla de permisos, al generar o al cancelar.
|
|
1608
|
-
choosePairCaps(st, { profile, service, label: (
|
|
1608
|
+
choosePairCaps(st, { profile, service, label: (name || '').trim().slice(0, 60) || null, after })
|
|
1609
1609
|
},
|
|
1610
1610
|
onCancel: async () => { st.input = null; if (after) await after(false) }
|
|
1611
1611
|
})
|
|
@@ -1647,14 +1647,14 @@ async function onKeyCaps (term, st, key) {
|
|
|
1647
1647
|
const cur = sels[Math.min(st.sel.caps || 0, sels.length - 1)]
|
|
1648
1648
|
const ch = key.name === 'char' ? key.ch.toLowerCase() : null
|
|
1649
1649
|
|
|
1650
|
-
const
|
|
1650
|
+
const goBack = () => { st.screen = 'devices'; st.capsFor = null }
|
|
1651
1651
|
const member = (st.members || []).find((m) => m.pub === st.capsFor?.pub)
|
|
1652
1652
|
if (!member) {
|
|
1653
|
-
if (key.name === 'escape' || ch === 'b')
|
|
1653
|
+
if (key.name === 'escape' || ch === 'b') goBack()
|
|
1654
1654
|
return true
|
|
1655
1655
|
}
|
|
1656
1656
|
// Volver a la lista NO tira el borrador: es como se pasa al siguiente aparato.
|
|
1657
|
-
if (key.name === 'escape' || ch === 'b') {
|
|
1657
|
+
if (key.name === 'escape' || ch === 'b') { goBack(); return true }
|
|
1658
1658
|
if (key.name === 'f5') {
|
|
1659
1659
|
// F5 trae el acta de nuevo y el borrador deja de tener con qué compararse: se pregunta
|
|
1660
1660
|
// antes de tirarlo, igual que al salir de la bóveda.
|
|
@@ -1732,10 +1732,10 @@ async function onKeyDoors (term, st, key) {
|
|
|
1732
1732
|
|
|
1733
1733
|
if ((key.name === 'delete' || ch === 'd') && cur?.door) {
|
|
1734
1734
|
const d = cur.door
|
|
1735
|
-
const
|
|
1735
|
+
const latest = (p.doors || []).length <= 1
|
|
1736
1736
|
const what = d.label ? `${doorLabel(i, d)} · ${d.label}` : doorLabel(i, d)
|
|
1737
1737
|
setConfirm(st, {
|
|
1738
|
-
text:
|
|
1738
|
+
text: latest ? i.removeLastDoorConfirm(what) : i.removeDoorConfirm(what),
|
|
1739
1739
|
onYes: () => ensureUnlocked(term, st, p, async (q = p) => {
|
|
1740
1740
|
const r = await guard(term, st, i.removingDoor, () => vc.removeProfileDoor(q.id, d.kind === 'password' ? 'password' : d.id))
|
|
1741
1741
|
if (r.ok) {
|
|
@@ -1794,9 +1794,9 @@ async function addKeyDoor (term, st, p, mode) {
|
|
|
1794
1794
|
busy(i.lookingForKey)
|
|
1795
1795
|
serial = await hw.ykSerial()
|
|
1796
1796
|
if (!serial) throw Object.assign(new Error('no key'), { code: 'HWKEY_NO_DEVICE' })
|
|
1797
|
-
const
|
|
1797
|
+
const slotBusy = await hw.ykSlot2Busy()
|
|
1798
1798
|
st.busy = null
|
|
1799
|
-
const
|
|
1799
|
+
const schedule = async (overwrite) => {
|
|
1800
1800
|
try {
|
|
1801
1801
|
busy(i.programmingSlot)
|
|
1802
1802
|
await hw.ykProgramSlot2({ overwrite })
|
|
@@ -1807,8 +1807,8 @@ async function addKeyDoor (term, st, p, mode) {
|
|
|
1807
1807
|
} catch (e) { fail(e) }
|
|
1808
1808
|
}
|
|
1809
1809
|
// Sobrescribir la ranura borra lo que tenga: eso lo decide la persona, aquí y en voz alta.
|
|
1810
|
-
if (
|
|
1811
|
-
await
|
|
1810
|
+
if (slotBusy) { setConfirm(st, { text: i.slotBusyConfirm(serial), onYes: () => schedule(true), onNo: () => { st.confirm = null } }); return }
|
|
1811
|
+
await schedule(false)
|
|
1812
1812
|
} catch (e) { fail(e) }
|
|
1813
1813
|
return
|
|
1814
1814
|
}
|
|
@@ -1868,7 +1868,7 @@ async function onKeyPairMode (term, st, key) {
|
|
|
1868
1868
|
st.input = null
|
|
1869
1869
|
const name = raw.trim()
|
|
1870
1870
|
if (!name) { flash(st, i.nameEmpty, 'danger'); return }
|
|
1871
|
-
const
|
|
1871
|
+
const previous = activeId(st)
|
|
1872
1872
|
const r = await guard(term, st, i.creatingVault, () => vc.addProfile(name))
|
|
1873
1873
|
if (!r.ok) return
|
|
1874
1874
|
const created = r.v?.id || (r.v?.profiles || []).find((p) => p.name === name)?.id
|
|
@@ -1881,8 +1881,8 @@ async function onKeyPairMode (term, st, key) {
|
|
|
1881
1881
|
// él: si no, cada intento fallido dejaba una cuenta vacía —y encima activa— que
|
|
1882
1882
|
// luego había que ir a borrar a mano adivinando cuál era.
|
|
1883
1883
|
beginPairingNamed(term, st, created, null, async (ok) => {
|
|
1884
|
-
if (!ok) await
|
|
1885
|
-
else st.pairing.born = { id: created, from:
|
|
1884
|
+
if (!ok) await discardAccount(term, st, created, previous)
|
|
1885
|
+
else st.pairing.born = { id: created, from: previous }
|
|
1886
1886
|
})
|
|
1887
1887
|
},
|
|
1888
1888
|
onCancel: () => { st.input = null }
|
|
@@ -2057,7 +2057,7 @@ async function onKeyPairing (term, st, key) {
|
|
|
2057
2057
|
if (born) {
|
|
2058
2058
|
setConfirm(st, {
|
|
2059
2059
|
text: i.confirmDiscardAccount,
|
|
2060
|
-
onYes: async () => { st.confirm = null; st.pairing = null; st.screen = 'devices'; await
|
|
2060
|
+
onYes: async () => { st.confirm = null; st.pairing = null; st.screen = 'devices'; await discardAccount(term, st, born.id, born.from) },
|
|
2061
2061
|
onNo: async () => { st.confirm = null; st.pairing = null; st.screen = 'devices'; await refreshDevices(term, st) }
|
|
2062
2062
|
})
|
|
2063
2063
|
return true
|
|
@@ -2152,8 +2152,8 @@ function promptRenameVariable (term, st, cur) {
|
|
|
2152
2152
|
label: i.renameLabel(cur.key),
|
|
2153
2153
|
hint: i.renameHint,
|
|
2154
2154
|
value: cur.key,
|
|
2155
|
-
onSubmit: async (
|
|
2156
|
-
const nv =
|
|
2155
|
+
onSubmit: async (newer) => {
|
|
2156
|
+
const nv = newer.trim()
|
|
2157
2157
|
st.input = null
|
|
2158
2158
|
if (!nv || nv === cur.key) return
|
|
2159
2159
|
if (!KEY_RE.test(nv)) { flash(st, i.keyInvalid, 'danger'); return }
|
|
@@ -2179,14 +2179,14 @@ function promptRenameVariable (term, st, cur) {
|
|
|
2179
2179
|
async function revealValue (term, st, owner, key, isPublic) {
|
|
2180
2180
|
const i = L(st)
|
|
2181
2181
|
const p = activeProfile(st)
|
|
2182
|
-
const
|
|
2182
|
+
const show = async (pwd) => {
|
|
2183
2183
|
const r = await guard(term, st, i.revealing, () => vc.revealSecret(owner, key, activeId(st), pwd))
|
|
2184
2184
|
if (r.ok) flash(st, i.revealed(key, r.v), 'ok')
|
|
2185
2185
|
}
|
|
2186
|
-
if (isPublic) return
|
|
2187
|
-
if (!p?.protected) { flash(st, i.revealNoPwd, 'warn'); return
|
|
2188
|
-
const
|
|
2189
|
-
if (
|
|
2186
|
+
if (isPublic) return show(undefined) // una pública no está cerrada
|
|
2187
|
+
if (!p?.protected) { flash(st, i.revealNoPwd, 'warn'); return show(undefined) }
|
|
2188
|
+
const saved = activePwd(st)
|
|
2189
|
+
if (saved) return show(saved)
|
|
2190
2190
|
setInput(st, {
|
|
2191
2191
|
label: i.revealAsk,
|
|
2192
2192
|
hint: i.revealHint,
|
|
@@ -2194,7 +2194,7 @@ async function revealValue (term, st, owner, key, isPublic) {
|
|
|
2194
2194
|
onSubmit: async (pwd) => {
|
|
2195
2195
|
st.input = null
|
|
2196
2196
|
if (!pwd) return
|
|
2197
|
-
await
|
|
2197
|
+
await show(pwd)
|
|
2198
2198
|
},
|
|
2199
2199
|
onCancel: () => { st.input = null }
|
|
2200
2200
|
})
|
|
@@ -2886,11 +2886,11 @@ function render (term, st) {
|
|
|
2886
2886
|
// normal y simplemente no se actualiza, así que se dice aquí.
|
|
2887
2887
|
if (!lines[2] && up && s?.updateAsk?.version) {
|
|
2888
2888
|
const u = s.updateAsk
|
|
2889
|
-
const
|
|
2889
|
+
const day = (ms) => new Date(ms).toISOString().slice(0, 16).replace('T', ' ')
|
|
2890
2890
|
// Esperando es un estado normal (gris); no aprobada es lo que hay que ver (aviso).
|
|
2891
2891
|
lines[2] = ' ' + (u.result === 'pending'
|
|
2892
|
-
? t.muted(i.updateWaiting(u.version,
|
|
2893
|
-
: t.warn(i.updateNotApproved(u.version,
|
|
2892
|
+
? t.muted(i.updateWaiting(u.version, day(u.askedAt + 24 * 60 * 60 * 1000)))
|
|
2893
|
+
: t.warn(i.updateNotApproved(u.version, day(u.askedAt))))
|
|
2894
2894
|
}
|
|
2895
2895
|
// Hay versión nueva y se dijo que no (o todavía no se preguntó): se queda dicho aquí.
|
|
2896
2896
|
if (!lines[2] && st.update?.release) lines[2] = ' ' + t.warn(i.updateAvailable(st.update.release.version))
|
|
@@ -3004,10 +3004,10 @@ export function viewModel (st, t) {
|
|
|
3004
3004
|
if (up && s?.version && VERSION !== 'dev' && s.version !== VERSION) vm.notice = { text: i.daemonStale(s.version, VERSION), kind: 'warn' }
|
|
3005
3005
|
else if (up && s?.updateAsk?.version) {
|
|
3006
3006
|
const u = s.updateAsk
|
|
3007
|
-
const
|
|
3007
|
+
const day = (ms) => new Date(ms).toISOString().slice(0, 16).replace('T', ' ')
|
|
3008
3008
|
vm.notice = u.result === 'pending'
|
|
3009
|
-
? { text: i.updateWaiting(u.version,
|
|
3010
|
-
: { text: i.updateNotApproved(u.version,
|
|
3009
|
+
? { text: i.updateWaiting(u.version, day(u.askedAt + 24 * 60 * 60 * 1000)), kind: 'muted' }
|
|
3010
|
+
: { text: i.updateNotApproved(u.version, day(u.askedAt)), kind: 'warn' }
|
|
3011
3011
|
} else if (st.update?.release) vm.notice = { text: i.updateAvailable(st.update.release.version), kind: 'warn' }
|
|
3012
3012
|
|
|
3013
3013
|
if (INNER_TABS.includes(st.screen)) vm.tabs = INNER_TABS.map((k) => ({ key: k, label: tabLabel(i, k), active: st.screen === k }))
|
|
@@ -3209,7 +3209,7 @@ export async function handleKey (term, st, key) {
|
|
|
3209
3209
|
// navegando esta pantalla y se cerraba igual, que es lo contrario de lo que se
|
|
3210
3210
|
// quería. Se avisa como mucho una vez por minuto —el plazo son cinco, así que
|
|
3211
3211
|
// sobra— para no escribir un archivo por tecla.
|
|
3212
|
-
|
|
3212
|
+
stayHere(st)
|
|
3213
3213
|
|
|
3214
3214
|
const ch = key.name === 'char' ? key.ch.toLowerCase() : null
|
|
3215
3215
|
// 'q' global sale — preguntando antes si hay permisos sin guardar.
|
|
@@ -3308,4 +3308,4 @@ export async function runTui () {
|
|
|
3308
3308
|
}
|
|
3309
3309
|
|
|
3310
3310
|
// Solo para pruebas headless (render sin terminal real). No usar en runtime.
|
|
3311
|
-
export const __test = { checkForUpdate, offerUpdate, installUpdate, render, settingsRows, onKeySettings, doorRows, onKeyDoors, pairCapsRows, onKeyPairCaps, onKeyDevices, draftChanges, saveCapsDrafts, onKeySecrets, loginRows, onKeyLogins, refreshLogins, activeLocked, autoLockedIds, autoLockWakeIn, forgetAutoLocked, autoLockMin, refreshAll, ensureUnlocked, profileRows, deviceRows, secretRows, devVarRows, meRows, capsRows, onKeyCaps, pairModeRows, pairingBody, scrollBody, fitHelp, wrapHelp, wrapWords, joinBody, onKeyJoin, promptJoin, onKeyProfiles, onInputKey, toggleLang, mergeMembersAndCerts, seguirAqui, backupRows, backupPlanRows, onKeyBackup, onKeyBackupPlan, resetToque: () => {
|
|
3311
|
+
export const __test = { checkForUpdate, offerUpdate, installUpdate, render, settingsRows, onKeySettings, doorRows, onKeyDoors, pairCapsRows, onKeyPairCaps, onKeyDevices, draftChanges, saveCapsDrafts, onKeySecrets, loginRows, onKeyLogins, refreshLogins, activeLocked, autoLockedIds, autoLockWakeIn, forgetAutoLocked, autoLockMin, refreshAll, ensureUnlocked, profileRows, deviceRows, secretRows, devVarRows, meRows, capsRows, onKeyCaps, pairModeRows, pairingBody, scrollBody, fitHelp, wrapHelp, wrapWords, joinBody, onKeyJoin, promptJoin, onKeyProfiles, onInputKey, toggleLang, mergeMembersAndCerts, seguirAqui: stayHere, backupRows, backupPlanRows, onKeyBackup, onKeyBackupPlan, resetToque: () => { lastTouch = 0 } }
|
package/src/tui/i18n.js
CHANGED
|
@@ -297,7 +297,7 @@ const es = {
|
|
|
297
297
|
// en color, porque una versión que no cuadra es lo que hace que ese aparato parezca
|
|
298
298
|
// apagado cuando en realidad no os entendéis.
|
|
299
299
|
runs: 'corre',
|
|
300
|
-
mismatch: (
|
|
300
|
+
mismatch: (product, version) => `⚠ ${product} ${version} no cuadra`,
|
|
301
301
|
thisVault: 'esta bóveda (manda ella)',
|
|
302
302
|
cantRemoveMaster: 'Esta bóveda es la que manda: no se quita a sí misma.',
|
|
303
303
|
revokedCount: (n) => ` Revocados: ${n}`,
|
package/src/update.js
CHANGED
|
@@ -107,13 +107,13 @@ export async function installUserRelease (release, { binDir = userBinDir(), log
|
|
|
107
107
|
fs.rmSync(work, { recursive: true, force: true })
|
|
108
108
|
fs.mkdirSync(work, { recursive: true, mode: 0o700 })
|
|
109
109
|
try {
|
|
110
|
-
return await
|
|
110
|
+
return await installFrom(work, pick, release, { binDir, log, fetchVerifiedImpl })
|
|
111
111
|
} finally {
|
|
112
112
|
try { fs.rmSync(work, { recursive: true, force: true }) } catch (_) {}
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
async function
|
|
116
|
+
async function installFrom (work, pick, release, { binDir, log, fetchVerifiedImpl }) {
|
|
117
117
|
const got = await fetchVerifiedImpl(pick.asset, { repo: REPO, product: 'dotrino-vault', version: VERSION, dir: work })
|
|
118
118
|
if (!got.ok) return got
|
|
119
119
|
log(`[vault] update: ${pick.asset.name} verified against its attestation`)
|
|
@@ -209,7 +209,7 @@ function spawnDetached (cmd, args, { log } = {}) {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
/** Baja y verifica un archivo del release a una carpeta propia (que se vacía antes). */
|
|
212
|
-
async function
|
|
212
|
+
async function downloadVerified (release, re, { log, fetchVerifiedImpl, work }) {
|
|
213
213
|
const pick = pickAsset(release.assets, [{ kind: 'asset', re }])
|
|
214
214
|
if (!pick.ok) return pick
|
|
215
215
|
fs.rmSync(work, { recursive: true, force: true })
|
|
@@ -227,7 +227,7 @@ async function bajarVerificado (release, re, { log, fetchVerifiedImpl, work }) {
|
|
|
227
227
|
*/
|
|
228
228
|
async function installWindows (release, { log, fetchVerifiedImpl, run }) {
|
|
229
229
|
const work = updateWorkDir('win32')
|
|
230
|
-
const got = await
|
|
230
|
+
const got = await downloadVerified(release, /-windows-x64-setup\.exe$/, { log, fetchVerifiedImpl, work })
|
|
231
231
|
if (!got.ok) return got
|
|
232
232
|
run(got.file, ['/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/FORCECLOSEAPPLICATIONS', `/LOG=${path.join(work, 'setup.log')}`], { log })
|
|
233
233
|
log(`[vault] update: installer for ${release.version} started; it restarts the vault when it finishes`)
|
|
@@ -246,7 +246,7 @@ async function installMac (release, { log, fetchVerifiedImpl, run, execPath, pid
|
|
|
246
246
|
const app = appBundleOf(execPath)
|
|
247
247
|
if (!app) return { ok: false, code: 'CANNOT_SELF_UPDATE', reason: 'not running from Dotrino Vault.app' }
|
|
248
248
|
const work = updateWorkDir('darwin')
|
|
249
|
-
const got = await
|
|
249
|
+
const got = await downloadVerified(release, /-macos-universal\.zip$/, { log, fetchVerifiedImpl, work })
|
|
250
250
|
if (!got.ok) return got
|
|
251
251
|
const parent = path.dirname(app)
|
|
252
252
|
const stage = path.join(parent, `.dotrino-vault-update-${process.pid}`)
|
|
@@ -255,15 +255,15 @@ async function installMac (release, { log, fetchVerifiedImpl, run, execPath, pid
|
|
|
255
255
|
try { execFileSync('ditto', ['-x', '-k', got.file, stage], { stdio: ['ignore', 'ignore', 'pipe'] }) } catch (e) {
|
|
256
256
|
return { ok: false, code: 'UNPACK_FAILED', reason: `could not unpack the release: ${String(e.stderr || e.message).trim().split('\n').slice(-2).join(' · ')}` }
|
|
257
257
|
}
|
|
258
|
-
const
|
|
259
|
-
if (!fs.existsSync(path.join(
|
|
260
|
-
const
|
|
261
|
-
fs.renameSync(app,
|
|
262
|
-
try { fs.renameSync(
|
|
263
|
-
fs.renameSync(
|
|
258
|
+
const newOne = path.join(stage, 'Dotrino Vault.app')
|
|
259
|
+
if (!fs.existsSync(path.join(newOne, 'Contents', 'MacOS', 'dotrino-vaultd'))) return { ok: false, code: 'BAD_ARCHIVE', reason: 'the archive has no Dotrino Vault.app inside' }
|
|
260
|
+
const oldOne = `${app}.old-${process.pid}`
|
|
261
|
+
fs.renameSync(app, oldOne)
|
|
262
|
+
try { fs.renameSync(newOne, app) } catch (e) {
|
|
263
|
+
fs.renameSync(oldOne, app) // se deja como estaba
|
|
264
264
|
return { ok: false, code: 'SWAP_FAILED', reason: `could not put the new app in place: ${e.message}` }
|
|
265
265
|
}
|
|
266
|
-
fs.rmSync(
|
|
266
|
+
fs.rmSync(oldOne, { recursive: true, force: true })
|
|
267
267
|
} finally {
|
|
268
268
|
fs.rmSync(stage, { recursive: true, force: true })
|
|
269
269
|
fs.rmSync(work, { recursive: true, force: true })
|
package/src/updateApproval.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* cuentas que viven aquí decide por la máquina.
|
|
8
8
|
*
|
|
9
9
|
* Sin estado y sin red: recibe los perfiles en marcha y lo que cada uno sabe hacer, para
|
|
10
|
-
* poder probarse sin daemon (`test/
|
|
10
|
+
* poder probarse sin daemon (`test/update-all-profiles.test.mjs`).
|
|
11
11
|
*/
|
|
12
12
|
import fs from 'node:fs'
|
|
13
13
|
import path from 'node:path'
|
package/src/vaultControl.js
CHANGED
|
@@ -327,13 +327,13 @@ export async function passwdLogin ({ user, oldPassword, newPassword } = {}) {
|
|
|
327
327
|
let fin
|
|
328
328
|
try { fin = opaque.loginFinish({ state: start.state, response: begun.response, password: oldPassword }) }
|
|
329
329
|
catch (_) { throw coded('wrong password', 'login-failed') }
|
|
330
|
-
const
|
|
331
|
-
const keys = await openDeviceKeys(fin.exportKey,
|
|
330
|
+
const entry = await loginsOp('login-end', { lid: begun.lid, finalization: fin.finalization, label: 'la consola' })
|
|
331
|
+
const keys = await openDeviceKeys(fin.exportKey, entry.blob)
|
|
332
332
|
const reg = opaque.registrationStart({ password: newPassword })
|
|
333
333
|
const { response } = await loginsOp('register-begin', { user, request: reg.request, replace: true })
|
|
334
|
-
const
|
|
334
|
+
const newOne = opaque.registrationFinish({ state: reg.state, response, password: newPassword })
|
|
335
335
|
return loginsOp('register-finish', {
|
|
336
|
-
user, upload:
|
|
336
|
+
user, upload: newOne.upload, blob: await sealDeviceKeys(newOne.exportKey, keys), replace: true
|
|
337
337
|
})
|
|
338
338
|
}
|
|
339
339
|
|