@dotrino/vaultd 0.181.1 → 0.182.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/core/libVersion.js +1 -1
- package/lib/src/core/vault.js +26 -1
- package/lib/src/service.js +18 -4
- package/package.json +3 -3
- package/src/ctl.js +7 -0
- package/src/tui/app.js +3 -0
- package/src/tui/i18n.js +6 -4
package/lib/src/core/vault.js
CHANGED
|
@@ -31,7 +31,7 @@ import { openMachines } from './machines.js'
|
|
|
31
31
|
import { machineLine } from '@dotrino/identity/machine'
|
|
32
32
|
import { openNotices } from './notices.js'
|
|
33
33
|
import { makeEphemeralKey, openSealed } from '../sealed.js'
|
|
34
|
-
import { declare as compatDeclare, check as compatCheck, annotate as compatAnnotate } from '@dotrino/compat'
|
|
34
|
+
import { declare as compatDeclare, check as compatCheck, annotate as compatAnnotate, missingCaps as compatMissing } from '@dotrino/compat'
|
|
35
35
|
import { loadManifest, brokenOf } from '@dotrino/roadmap'
|
|
36
36
|
// `PENDING_TTL_MS` se usa abajo, al esperar la firma del aprobador: sin importarlo, esa
|
|
37
37
|
// espera reventaba con un ReferenceError y la aprobación del mostrador de contraseñas no
|
|
@@ -662,10 +662,32 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
662
662
|
const verdict = compatCheck({ mine: MI_VERSION, theirs: v, broken: BROKEN })
|
|
663
663
|
versiones.set(pub, { ...v, at: Date.now(), compatible: verdict.compatible, reason: verdict.reason })
|
|
664
664
|
if (!verdict.compatible) log(`[vault] ${v.product} ${v.version}: ${verdict.reason}`)
|
|
665
|
+
if (Array.isArray(v.needs)) sayMissing(pub)
|
|
665
666
|
return verdict
|
|
666
667
|
}
|
|
667
668
|
/** El dictamen de un aparato, para enseñarlo o para pegárselo a un error. */
|
|
668
669
|
const versionDe = (pub) => versiones.get(pub) || null
|
|
670
|
+
/**
|
|
671
|
+
* LOS PERMISOS QUE LE FALTAN (dueño, 2026-10-27): los que la pieza declaró necesitar
|
|
672
|
+
* (`needs`, `@dotrino/compat` ≥ 0.5.0) y el acta no le da. Se ENSEÑA en su fila y se dice en
|
|
673
|
+
* el log cuando cambia; no se concede nada solo. Lo pagó `accounts`: sin `sign`, renovar su
|
|
674
|
+
* papel le devolvía uno que no le servía, y ninguna pantalla lo decía.
|
|
675
|
+
*/
|
|
676
|
+
const missingOf = (pub, acta) => {
|
|
677
|
+
const v = versionDe(pub)
|
|
678
|
+
return v && acta ? compatMissing(v, Acta.effectiveCaps(acta, pub)) : []
|
|
679
|
+
}
|
|
680
|
+
const missingSaid = new Map()
|
|
681
|
+
const sayMissing = async (pub) => {
|
|
682
|
+
try {
|
|
683
|
+
const acta = (await identity.profileActa?.())?.acta || null
|
|
684
|
+
const falta = missingOf(pub, acta)
|
|
685
|
+
const key = falta.join(',')
|
|
686
|
+
if ((missingSaid.get(pub) || '') === key) return
|
|
687
|
+
missingSaid.set(pub, key)
|
|
688
|
+
if (falta.length) log(`[vault] ${await deviceIdOf(pub).catch(() => '????-????')} (${versionDe(pub)?.product || '?'}) needs ${falta.join(', ')} and the record does not give it: grant it with \`dotrino-vault caps <ID> +…\``)
|
|
689
|
+
} catch (e) { log(`[vault] could not compare what a device needs with the record: ${e.message}`) }
|
|
690
|
+
}
|
|
669
691
|
/** Dónde corre un aparato: lo último que dijo firmado (`machines`) o, si no, lo del acta. */
|
|
670
692
|
const machineOf = (pub, record) => machines.of(pub) || (record?.members || []).find((m) => m.pub === pub)?.machine || null
|
|
671
693
|
|
|
@@ -1503,6 +1525,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
1503
1525
|
const devices = await Promise.all(issued.map(async (x) => ({
|
|
1504
1526
|
deviceId: x.sub ? await deviceIdOf(x.sub) : null, sub: x.sub || null, label: x.label || '', scope: x.scope, exp: x.exp, nonce: x.nonce,
|
|
1505
1527
|
running: x.sub ? versionDe(x.sub) : null,
|
|
1528
|
+
missing: x.sub ? missingOf(x.sub, record) : [],
|
|
1506
1529
|
machine: x.sub ? machineOf(x.sub, record) : null,
|
|
1507
1530
|
notifiedAt: x.sub ? notifiable.since(x.sub) : null
|
|
1508
1531
|
})))
|
|
@@ -4954,6 +4977,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
4954
4977
|
*/
|
|
4955
4978
|
profileMembers: async () => {
|
|
4956
4979
|
const r = await identity.profileMembers()
|
|
4980
|
+
const acta = (await identity.profileActa?.().catch(() => null))?.acta || null
|
|
4957
4981
|
return {
|
|
4958
4982
|
...r,
|
|
4959
4983
|
vault: MI_VERSION,
|
|
@@ -4963,6 +4987,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
4963
4987
|
members: (r?.members || []).map((m) => ({
|
|
4964
4988
|
...m,
|
|
4965
4989
|
running: versionDe(m.pub),
|
|
4990
|
+
missing: missingOf(m.pub, acta),
|
|
4966
4991
|
// Dónde corre: lo último que dijo firmado y, si nunca habló, lo del acta.
|
|
4967
4992
|
machine: machines.of(m.pub) || m.machine || null,
|
|
4968
4993
|
// Cuándo dijo que le llegan los avisos (null = no lo ha dicho, o caducó). Solo
|
package/lib/src/service.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import fs from 'node:fs'
|
|
22
22
|
import path from 'node:path'
|
|
23
23
|
import { createHash } from 'node:crypto'
|
|
24
|
+
import { declare as compatDeclare } from '@dotrino/compat'
|
|
24
25
|
import {
|
|
25
26
|
makeDeviceKey, makeDeviceEncKey, importDeviceEncKey, signWithDevice,
|
|
26
27
|
verifyDeviceSig, makePairingCode, commitCode, pubkeyId, keyLabel } from '@dotrino/identity/capabilities'
|
|
@@ -57,6 +58,19 @@ export const MY_VERSION = {
|
|
|
57
58
|
speaks: VAULT_SPEAKS
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
/**
|
|
62
|
+
* El anuncio de quien pide: el de esta librería, o el del SERVICIO que la usa si dice quién es
|
|
63
|
+
* (`product`, `version`) y qué permisos del acta necesita (`needs`, `@dotrino/compat` ≥ 0.5.0).
|
|
64
|
+
* La bóveda enseña lo que le falte en su fila (dueño, 2026-10-27).
|
|
65
|
+
*/
|
|
66
|
+
function declarationOf ({ product, version, needs } = {}) {
|
|
67
|
+
if (!product && !version && !needs) return MY_VERSION
|
|
68
|
+
return compatDeclare({
|
|
69
|
+
product: product || MY_VERSION.product, version: version || MY_VERSION.version,
|
|
70
|
+
protocol: VAULT_PROTOCOL, speaks: VAULT_SPEAKS, ...(needs ? { needs } : {})
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
60
74
|
let _globalsInstalled = false
|
|
61
75
|
function installNodeGlobals () {
|
|
62
76
|
if (_globalsInstalled) return
|
|
@@ -845,7 +859,7 @@ async function reportToVault (op, { product, version, from = null, dir, proxyUrl
|
|
|
845
859
|
* Renueva el cert automáticamente si está por vencer (best-effort).
|
|
846
860
|
* @returns {Promise<Record<string,string>>} secretos KEY→valor
|
|
847
861
|
*/
|
|
848
|
-
export async function fetchSecrets ({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, timeoutMs = 30000, onPending, onCert, approvalTimeoutMs = APPROVAL_TIMEOUT_MS, publicOnly = false } = {}) {
|
|
862
|
+
export async function fetchSecrets ({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, timeoutMs = 30000, onPending, onCert, approvalTimeoutMs = APPROVAL_TIMEOUT_MS, publicOnly = false, product, version, needs } = {}) {
|
|
849
863
|
let saved = null
|
|
850
864
|
if (dir) saved = readServiceIdentity(dir)
|
|
851
865
|
// Sin `dir`: la identidad viene entera por parámetros — es el caso de un agente
|
|
@@ -963,7 +977,7 @@ export async function fetchSecrets ({ dir, ns, proxyUrl, masterPubkey, device, c
|
|
|
963
977
|
const ctx = client.local ? selfContext() : null
|
|
964
978
|
// `publicOnly` VIAJA FIRMADO (va dentro de `data`), así que nadie lo puede quitar ni
|
|
965
979
|
// poner por el camino. Quien decide qué se manda es la bóveda; esto solo es la petición.
|
|
966
|
-
const data = { op: 'secrets', ns, ek: eph.ek, publickey: device.publickey, ts: Date.now(), v:
|
|
980
|
+
const data = { op: 'secrets', ns, ek: eph.ek, publickey: device.publickey, ts: Date.now(), v: declarationOf({ product, version, needs }), machine: selfMachine(), ...(ctx ? { ctx } : {}), ...(publicOnly ? { publicOnly: true } : {}) }
|
|
967
981
|
const { signature } = await signWithDevice({ privateJwk: device.privateJwk, data })
|
|
968
982
|
// A QUIÉN SE LE PREGUNTA: primero a la bóveda, y si no contesta, a los REPLICADORES
|
|
969
983
|
// que el acta nombraba la última vez que la vimos (`docs/replicas.md` §8: «el servicio
|
|
@@ -1663,14 +1677,14 @@ export function retryDelay (backoffMs, rangAt, approvalTimeoutMs = APPROVAL_TIME
|
|
|
1663
1677
|
return Math.max(backoffMs, approvalTimeoutMs - (now - rangAt))
|
|
1664
1678
|
}
|
|
1665
1679
|
|
|
1666
|
-
export async function waitForSecrets ({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, retryMs = 5000, maxRetryMs = 60000, approvalTimeoutMs = APPROVAL_TIMEOUT_MS, onRetry, onPending, onCert, publicOnly = false } = {}) {
|
|
1680
|
+
export async function waitForSecrets ({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, retryMs = 5000, maxRetryMs = 60000, approvalTimeoutMs = APPROVAL_TIMEOUT_MS, onRetry, onPending, onCert, publicOnly = false, product, version, needs } = {}) {
|
|
1667
1681
|
let backoff = retryMs
|
|
1668
1682
|
let rangAt = 0 // cuándo timbró ESTE intento; 0 = no hubo aprobación de por medio
|
|
1669
1683
|
let unanswered = 0
|
|
1670
1684
|
const notePending = (info) => { rangAt = Date.now(); onPending?.(info) }
|
|
1671
1685
|
for (;;) {
|
|
1672
1686
|
try {
|
|
1673
|
-
return await fetchSecrets({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, approvalTimeoutMs, onPending: notePending, onCert, publicOnly })
|
|
1687
|
+
return await fetchSecrets({ dir, ns, proxyUrl, masterPubkey, device, cert, enc, approvalTimeoutMs, onPending: notePending, onCert, publicOnly, product, version, needs })
|
|
1674
1688
|
} catch (e) {
|
|
1675
1689
|
if (isFinal(e)) throw e
|
|
1676
1690
|
// UN PEDIDO QUE NADIE CONTESTÓ NO SE REPITE CADA CINCO MINUTOS (dueño, 2026-09-30:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/vaultd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.182.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": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"node": ">=20"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dotrino/compat": "0.
|
|
25
|
-
"@dotrino/identity": "0.130.
|
|
24
|
+
"@dotrino/compat": "0.5.0",
|
|
25
|
+
"@dotrino/identity": "0.130.5",
|
|
26
26
|
"@dotrino/opaque": "0.1.0",
|
|
27
27
|
"@dotrino/passmanager": "0.18.6",
|
|
28
28
|
"@dotrino/proxy-client": "^0.45.0",
|
package/src/ctl.js
CHANGED
|
@@ -686,6 +686,13 @@ async function cmdMembers () {
|
|
|
686
686
|
if (m.running.compatible) console.log(' %scorre %s%s', D, v, Z)
|
|
687
687
|
else console.log(' %s⚠ corre %s · %s%s', R, v, m.running.reason, Z)
|
|
688
688
|
}
|
|
689
|
+
// LO QUE NECESITA Y EL ACTA NO LE DA (`needs` de su anuncio, dueño 2026-10-27). Se dice
|
|
690
|
+
// con el comando que lo arregla: decidirlo es del dueño, no de la bóveda.
|
|
691
|
+
if (m.missing?.length) {
|
|
692
|
+
const palabra = (c) => Object.keys(CAP_BY_WORD).find((w) => CAP_BY_WORD[w] === c) || c
|
|
693
|
+
console.log(' %s⚠ necesita %s y el acta no se lo da · dotrino-vault caps %s %s%s',
|
|
694
|
+
R, m.missing.map(palabra).join(', '), m.id || '<ID>', m.missing.map((c) => '+' + palabra(c)).join(' '), Z)
|
|
695
|
+
}
|
|
689
696
|
}
|
|
690
697
|
if (record.vault) {
|
|
691
698
|
console.log('\n %sEsta bóveda corre %s %s (protocolo %d)%s',
|
package/src/tui/app.js
CHANGED
|
@@ -167,6 +167,8 @@ function mergeMembersAndCerts (members, issued) {
|
|
|
167
167
|
// QUÉ CORRE ESE APARATO (CONVENCIONES §14). Lo apunta la bóveda cuando le habla, así
|
|
168
168
|
// que aquí solo hay que dejarlo pasar — que es justo lo que le faltaba a `addedAt`.
|
|
169
169
|
running: m.running || null,
|
|
170
|
+
// LO QUE NECESITA Y EL ACTA NO LE DA (`needs` de su anuncio). Se pinta como aviso.
|
|
171
|
+
missing: m.missing || [],
|
|
170
172
|
// DÓNDE CORRE (`@dotrino/identity/machine`): lo último que dijo firmado o, si no, lo
|
|
171
173
|
// que dijo al emparejarse. Es lo que distingue tres navegadores que se llaman igual.
|
|
172
174
|
machine: m.machine || cert?.machine || null,
|
|
@@ -568,6 +570,7 @@ function deviceRows (st, t) {
|
|
|
568
570
|
const extra = (d.certCount > 1 ? t.muted(` certs:${d.certCount}`) : '') +
|
|
569
571
|
(vars ? t.muted(` vars:${vars}`) : '') +
|
|
570
572
|
running +
|
|
573
|
+
(d.missing?.length ? t.warn(` ${i.needsCaps(d.missing.map((c) => i.capName[c] || c).join(', '))}`) : '') +
|
|
571
574
|
// En quien aprueba: si dijo que le llegan los avisos. No cambia a quién se le pide
|
|
572
575
|
// (a todos); deja ver a cuál no le suena el pedido. Es un dato, va en gris.
|
|
573
576
|
(d.notifiedAt === undefined ? '' : t.muted(` ${d.notifiedAt ? i.notifyYes : i.notifyUnknown}`)) +
|
package/src/tui/i18n.js
CHANGED
|
@@ -298,13 +298,14 @@ const es = {
|
|
|
298
298
|
// apagado cuando en realidad no os entendéis.
|
|
299
299
|
runs: 'corre',
|
|
300
300
|
mismatch: (product, version) => `⚠ ${product} ${version} no cuadra`,
|
|
301
|
+
needsCaps: (caps) => `⚠ necesita ${caps}`,
|
|
301
302
|
thisVault: 'esta · sella el acta',
|
|
302
303
|
otherVault: 'sella el acta',
|
|
303
304
|
commKey: 'llave de comunicación',
|
|
304
305
|
groupVaults: 'BÓVEDAS',
|
|
305
306
|
groupDevices: 'APARATOS',
|
|
306
307
|
groupServices: 'SERVICIOS',
|
|
307
|
-
cantRemoveMaster: 'Esta bóveda
|
|
308
|
+
cantRemoveMaster: 'Esta bóveda no se quita a sí misma.',
|
|
308
309
|
revokedCount: (n) => ` Revocados: ${n}`,
|
|
309
310
|
startingPairing: 'Iniciando emparejamiento…',
|
|
310
311
|
deviceSince: 'desde',
|
|
@@ -580,7 +581,7 @@ const es = {
|
|
|
580
581
|
errProfileLocked: 'Bóveda bloqueada: ábrela con su contraseña',
|
|
581
582
|
errWrongPassword: (n) => `Contraseña incorrecta${n ? ` — van ${n} intentos fallidos` : ''}`,
|
|
582
583
|
errTooManyTries: (s) => `Demasiados intentos: espera ${s || '?'} s antes de volver a probar`,
|
|
583
|
-
errMasterWithMembers: '
|
|
584
|
+
errMasterWithMembers: 'Es la única bóveda de esta cuenta y hay otros dispositivos: dale antes el permiso de sellar a otra (`caps <ID> +sella`). Si la borras así, se quedan con su llave y sin nadie que pueda volver a darles permisos.'
|
|
584
585
|
}
|
|
585
586
|
|
|
586
587
|
// ---------------------------------- inglés ----------------------------------
|
|
@@ -836,13 +837,14 @@ const en = {
|
|
|
836
837
|
deviceDebt: (n) => `cannot open ${n}`,
|
|
837
838
|
runs: 'runs',
|
|
838
839
|
mismatch: (product, version) => `⚠ ${product} ${version} does not match`,
|
|
840
|
+
needsCaps: (caps) => `⚠ needs ${caps}`,
|
|
839
841
|
thisVault: 'this one · seals the record',
|
|
840
842
|
otherVault: 'seals the record',
|
|
841
843
|
commKey: 'communication key',
|
|
842
844
|
groupVaults: 'VAULTS',
|
|
843
845
|
groupDevices: 'DEVICES',
|
|
844
846
|
groupServices: 'SERVICES',
|
|
845
|
-
cantRemoveMaster: 'This vault
|
|
847
|
+
cantRemoveMaster: 'This vault does not remove itself.',
|
|
846
848
|
revokedCount: (n) => ` Revoked: ${n}`,
|
|
847
849
|
startingPairing: 'Starting pairing…',
|
|
848
850
|
deviceSince: 'since',
|
|
@@ -1088,7 +1090,7 @@ const en = {
|
|
|
1088
1090
|
errProfileLocked: 'Vault locked: open it with its password',
|
|
1089
1091
|
errWrongPassword: (n) => `Wrong password${n ? ` — ${n} failed attempts so far` : ''}`,
|
|
1090
1092
|
errTooManyTries: (s) => `Too many attempts: wait ${s || '?'} s before trying again`,
|
|
1091
|
-
errMasterWithMembers: 'This
|
|
1093
|
+
errMasterWithMembers: 'This is the only vault of this account and it has other devices: give the sealing permission to another one first (`caps <ID> +sella`). If you delete it like this, they keep their key with nobody able to sign the record again.'
|
|
1092
1094
|
}
|
|
1093
1095
|
|
|
1094
1096
|
// --------------------------- selección y persistencia -----------------------
|