@dotrino/vaultd 0.199.1 → 0.199.3

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.
@@ -5,4 +5,4 @@
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.123.1'
8
+ export const LIB_VERSION = '0.123.3'
@@ -74,6 +74,8 @@ const MAX_REPLY_BYTES = 768 * 1024
74
74
  // Cuántas actas viajan con el aviso a las hermanas: cada una es el acta entera (unos KB), y el
75
75
  // frame del proxio corta en 1 MB.
76
76
  const SIBLING_ACTAS = 5
77
+ /** Lo más que ocupa el aviso del acta a las hermanas: la trama del proxio es de 1 MB, con margen. */
78
+ const ANNOUNCE_MAX_BYTES = 900 * 1024
77
79
 
78
80
  /**
79
81
  * LA BÓVEDA, la misma en las tres versiones (binario, pestaña y extensión).
@@ -3025,6 +3027,32 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
3025
3027
  * por las reglas de siempre (`handleAdminEvent` → `adoptActa`, en fila desde identity
3026
3028
  * 0.129.2), así que una vieja se rechaza sola.
3027
3029
  */
3030
+ /**
3031
+ * QUE QUEPA EN UNA TRAMA DEL PROXIO. Va en claro por `sendByPubkey`, que no parte el mensaje,
3032
+ * para que una hermana dormida (la Lambda) lo reciba de la cola sin tener que anunciar antes su
3033
+ * llave de cifrado. El proxio corta la conexión entera con 1009 si una trama pasa de 1 MB, y eso
3034
+ * pasaba cada 5 min: el PC de Seyacat se quedaba 24 s fuera de la red y lo que le pedían sus
3035
+ * aparatos no recibía respuesta (2026-12-05). Se quita primero la cadena de selladoras y luego
3036
+ * las actas más viejas; lo que se quita se dice. Si ni el acta sola cabe, no se manda y se dice.
3037
+ */
3038
+ function fitAnnounce (msg) {
3039
+ const size = (o) => byteLength(JSON.stringify(o))
3040
+ let out = msg
3041
+ if (size(out) > ANNOUNCE_MAX_BYTES && out.sealerChain) {
3042
+ out = { ...out, sealerChain: null }
3043
+ log('[vault] record announce too big for one proxy frame: sent without the sealer chain')
3044
+ }
3045
+ while (size(out) > ANNOUNCE_MAX_BYTES && Array.isArray(out.actas) && out.actas.length) {
3046
+ out = { ...out, actas: out.actas.length > 1 ? out.actas.slice(1) : null }
3047
+ log(`[vault] record announce too big for one proxy frame: sent with ${out.actas?.length || 0} past record(s)`)
3048
+ }
3049
+ if (size(out) > ANNOUNCE_MAX_BYTES) {
3050
+ log(`[vault] record #${msg.acta?.seq ?? '?'} does not fit in one proxy frame (${size(out)} bytes): not announced to the sibling vaults`)
3051
+ return null
3052
+ }
3053
+ return out
3054
+ }
3055
+
3028
3056
  async function announceToSiblings (reason) {
3029
3057
  try {
3030
3058
  const acta = (await identity.profileActa?.().catch(() => null))?.acta || null
@@ -3035,11 +3063,14 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
3035
3063
  // que hay detrás —el PC se quedó sin la #75 y la #76 que selló la Nube— y sin ellas no
3036
3064
  // puede poner al día a sus aparatos. Se autentican solas: cada una nombra a la anterior
3037
3065
  // por su hash, y quien las recibe solo acepta las que encajan.
3038
- const actas = (await identity.recentActas?.(SIBLING_ACTAS).catch(() => null))?.actas || null
3066
+ // `{ count }`: con el número a secas la identidad tomaba su valor por defecto (10).
3067
+ const actas = (await identity.recentActas?.({ count: SIBLING_ACTAS }).catch(() => null))?.actas || null
3039
3068
  // Y la cadena de selladoras: con ella llega aunque le falten las de en medio.
3040
3069
  const sealerChain = (await identity.sealerChain?.().catch(() => null)) || null
3070
+ const msg = fitAnnounce({ type: MSG.ADMIN_EVENT, body: { ev: 'record', reason, ts: Date.now() }, acta, actas, sealerChain })
3071
+ if (!msg) return
3041
3072
  for (const m of siblings) {
3042
- try { client.sendByPubkey(m.pub, { type: MSG.ADMIN_EVENT, body: { ev: 'record', reason, ts: Date.now() }, acta, actas, sealerChain }, { quiet: true, app: 'vault' }) }
3073
+ try { client.sendByPubkey(m.pub, msg, { quiet: true, app: 'vault' }) }
3043
3074
  catch (e) { log(`[vault] could not send the record to a sibling vault: ${e.message}`) }
3044
3075
  }
3045
3076
  if (siblings.length) log(`[vault] sent record #${acta.seq} to ${siblings.length} sibling vault(s) on ${reason}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/vaultd",
3
- "version": "0.199.1",
3
+ "version": "0.199.3",
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/daemon.js CHANGED
@@ -25,10 +25,10 @@ import { parseInvite } from '../lib/src/invite.js'
25
25
  import { scopeToCaps, scopeToCn } from '../lib/src/enroll.js'
26
26
  import { capScope } from '@dotrino/identity/acta'
27
27
  import { watchBinary } from './selfupdate.js'
28
- import { latestRelease, isNewer, CHECK_EVERY_MS, installKind, installRelease } from './update.js'
28
+ import { latestRelease, isNewer, CHECK_EVERY_MS, installKind, installRelease, installUserRelease, userBinDir } from './update.js'
29
29
  import { VERSION } from './version.js'
30
30
  import { readSettings } from './settings.js'
31
- import { startTray } from './tray.js'
31
+ import { startTray, findGui, guiSupportsTray } from './tray.js'
32
32
  import { approversOfAll, firstYes, readAsked, writeAsked, clearAsked, shouldAsk, resultOfNo, readRootTold, writeRootTold, shouldTellRoot } from './updateApproval.js'
33
33
  import { UPDATE_TTL_MS } from '../lib/src/core/approvals.js'
34
34
  import crypto from 'node:crypto'
@@ -1136,7 +1136,7 @@ export async function runDaemon () {
1136
1136
 
1137
1137
  // El icono en la bandeja mientras la bóveda corre (Windows y Linux, con sesión gráfica).
1138
1138
  // Al irse el daemon se cierra la tubería y el icono se va solo: no hace falta pararlo.
1139
- startTray({ log: console.log })
1139
+ if (!startTray({ log: console.log })) ensureTrayWindow().catch((e) => console.log('[vault] tray icon: could not install the window next to the vault: %s', e.message))
1140
1140
 
1141
1141
  /**
1142
1142
  * ¿SALIÓ UNA VERSIÓN NUEVA? Una lectura al día, y nada más.
@@ -1391,3 +1391,25 @@ export async function runDaemon () {
1391
1391
  console.log('[vault] servicio listo.')
1392
1392
  return mgr
1393
1393
  }
1394
+
1395
+ /**
1396
+ * LA VENTANA AL LADO DE LA BÓVEDA, sola. En un Linux con el .deb viejo la ventana que se encuentra
1397
+ * es la de /usr/bin, que el actualizador no toca y que no entiende `--tray` (abría la interfaz
1398
+ * entera cada 30 s: PC de Seyacat, 2026-12-05). Con una instalación de usuario se baja la ventana
1399
+ * del release (verificada, como cualquier actualización) y se pone al lado; desde ahí la pone al
1400
+ * día cada actualización. Cada paso se dice.
1401
+ */
1402
+ async function ensureTrayWindow () {
1403
+ if (process.platform !== 'linux' || installKind() !== 'user') return
1404
+ const gui = findGui()
1405
+ if (!gui || path.dirname(gui) === userBinDir()) return
1406
+ if (guiSupportsTray(gui)) return
1407
+ const rel = await latestRelease()
1408
+ if (!rel?.ok) { console.log('[vault] tray icon: could not read the release to get the window: %s', rel?.reason || 'no reason given'); return }
1409
+ console.log('[vault] tray icon: %s is too old; installing the window of %s next to the vault', gui, rel.version)
1410
+ const r = await installUserRelease(rel, { log: console.log, onlyWindow: true })
1411
+ if (!r.ok) { console.log('[vault] tray icon: could not install the window (%s): %s', r.code || 'error', r.reason); return }
1412
+ console.log('[vault] tray icon: window %s installed next to the vault', rel.version)
1413
+ startTray({ log: console.log })
1414
+ }
1415
+
package/src/update.js CHANGED
@@ -16,6 +16,7 @@ import { execFileSync, spawn } from 'node:child_process'
16
16
  import { latestVersion, isNewer, CHECK_EVERY_MS } from '@dotrino/update'
17
17
  import { pickAsset, download, verifyArtifact as verify, fetchVerified } from '@dotrino/update/fetch'
18
18
  import { VERSION } from './version.js'
19
+ import { findGui } from './tray.js'
19
20
  import { ipcWrite } from './ipc.js'
20
21
 
21
22
  export const REPO = 'imdotrino/dotrino-vault'
@@ -96,7 +97,7 @@ export function isUserInstall (execPath = process.execPath, home = os.homedir())
96
97
  *
97
98
  * @returns {Promise<{ok:true, version:string} | {ok:false, code?:string, reason:string, file?:string}>}
98
99
  */
99
- export async function installUserRelease (release, { binDir = userBinDir(), log = () => {}, fetchVerifiedImpl = fetchVerified } = {}) {
100
+ export async function installUserRelease (release, { binDir = userBinDir(), log = () => {}, fetchVerifiedImpl = fetchVerified, withWindow = false, onlyWindow = false } = {}) {
100
101
  const pick = pickAsset(release.assets, [{ kind: 'tar', re: /-linux-x64\.tar\.gz$/ }])
101
102
  if (!pick.ok) return pick
102
103
  // SE TRABAJA EN DISCO, al lado de los binarios, y no en /tmp: en un VPS /tmp es un tmpfs
@@ -107,13 +108,13 @@ export async function installUserRelease (release, { binDir = userBinDir(), log
107
108
  fs.rmSync(work, { recursive: true, force: true })
108
109
  fs.mkdirSync(work, { recursive: true, mode: 0o700 })
109
110
  try {
110
- return await installFrom(work, pick, release, { binDir, log, fetchVerifiedImpl })
111
+ return await installFrom(work, pick, release, { binDir, log, fetchVerifiedImpl, withWindow, onlyWindow })
111
112
  } finally {
112
113
  try { fs.rmSync(work, { recursive: true, force: true }) } catch (_) {}
113
114
  }
114
115
  }
115
116
 
116
- async function installFrom (work, pick, release, { binDir, log, fetchVerifiedImpl }) {
117
+ async function installFrom (work, pick, release, { binDir, log, fetchVerifiedImpl, withWindow = false, onlyWindow = false }) {
117
118
  const got = await fetchVerifiedImpl(pick.asset, { repo: REPO, product: 'dotrino-vault', version: VERSION, dir: work })
118
119
  if (!got.ok) return got
119
120
  log(`[vault] update: ${pick.asset.name} verified against its attestation`)
@@ -124,10 +125,13 @@ async function installFrom (work, pick, release, { binDir, log, fetchVerifiedImp
124
125
  const src = fs.readdirSync(work).map((d) => path.join(work, d)).find((d) => fs.existsSync(path.join(d, 'dotrino-vaultd')))
125
126
  if (!src) return { ok: false, code: 'BAD_TARBALL', reason: 'the tarball has no dotrino-vaultd inside' }
126
127
  fs.mkdirSync(binDir, { recursive: true })
127
- // LA VENTANA se pone al día con la bóveda, pero solo donde ya estaba: una bóveda de
128
- // servidor no tiene por qué recibir un programa de escritorio que nadie instaló.
129
- const names = ['dotrino-vault', 'dotrino-vaultd']
130
- if (fs.existsSync(path.join(binDir, 'dotrino-vault-desktop')) && fs.existsSync(path.join(src, 'dotrino-vault-desktop'))) names.unshift('dotrino-vault-desktop')
128
+ // LA VENTANA se pone al día con la bóveda donde ya estaba, o donde se pide (`withWindow`: la
129
+ // máquina tiene una ventana en el PATH, la del .deb, que el actualizador no puede tocar).
130
+ // Una bóveda de servidor no tiene por qué recibir un programa de escritorio que nadie instaló.
131
+ const hasWindow = fs.existsSync(path.join(src, 'dotrino-vault-desktop'))
132
+ if (onlyWindow && !hasWindow) return { ok: false, code: 'BAD_TARBALL', reason: 'the tarball has no dotrino-vault-desktop inside' }
133
+ const names = onlyWindow ? [] : ['dotrino-vault', 'dotrino-vaultd']
134
+ if (hasWindow && (onlyWindow || withWindow || fs.existsSync(path.join(binDir, 'dotrino-vault-desktop')))) names.unshift('dotrino-vault-desktop')
131
135
  // El CLI primero y el daemon al final: cambiar el daemon es lo que dispara el reinicio.
132
136
  for (const name of names) {
133
137
  const tmp = path.join(binDir, `.${name}.new`)
@@ -194,7 +198,7 @@ function updateWorkDir (platform = process.platform) {
194
198
  */
195
199
  export async function installRelease (release, { log = () => {}, kind = installKind(), fetchVerifiedImpl = fetchVerified, run = spawnDetached, execPath = process.execPath, pid = null } = {}) {
196
200
  if (kind === 'user') {
197
- const r = await installUserRelease(release, { log, fetchVerifiedImpl })
201
+ const r = await installUserRelease(release, { log, fetchVerifiedImpl, withWindow: !!findGui() })
198
202
  return r.ok ? { ...r, then: 'watch' } : r
199
203
  }
200
204
  if (kind === 'inno') return installWindows(release, { log, fetchVerifiedImpl, run })