@dotrino/vaultd 0.165.0 → 0.165.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.
- 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 +223 -190
- package/lib/src/env.js +10 -10
- package/lib/src/index.js +6 -6
- 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 +68 -44
- package/lib/src/sshKeys.js +3 -3
- package/lib/src/version.js +5 -5
- 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
|
@@ -67,38 +67,38 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
|
|
|
67
67
|
// La puerta tiene que decidir AL INSTANTE (la señal llega y o se atiende o no), y pedir
|
|
68
68
|
// el acta es asíncrono. Así que se guarda una copia y se refresca donde ya se refresca
|
|
69
69
|
// todo: en `identify`, que es lo que corre cada vez que el acta cambia o se reconecta.
|
|
70
|
-
let
|
|
70
|
+
let seenActa = null
|
|
71
71
|
// ¿Está esta bóveda ATADA al proxio ahora mismo? Conectado no es identificado: el socket
|
|
72
72
|
// puede estar perfectamente abierto y el sobre rechazado, y entonces nadie la alcanza por
|
|
73
73
|
// su pubkey. Se expone para que `status` lo enseñe en vez de dejarlo a un log del arranque.
|
|
74
|
-
let
|
|
75
|
-
const
|
|
74
|
+
let identified = false
|
|
75
|
+
const inActa = (token) => {
|
|
76
76
|
// SIN ACTA NO SE NEGOCIA. No se sabe quién es nadie, y en la duda no se arranca a
|
|
77
77
|
// parsear red no confiable. Se sigue por el proxio, que es el escalón que siempre está.
|
|
78
|
-
if (!
|
|
79
|
-
return (
|
|
78
|
+
if (!seenActa) return false
|
|
79
|
+
return (seenActa.members || []).some((m) => m?.pub === token)
|
|
80
80
|
}
|
|
81
|
-
const client = makeClient ? makeClient({ url, acceptDirectFrom:
|
|
82
|
-
url, enableWebRTC: true, acceptDirectFrom:
|
|
81
|
+
const client = makeClient ? makeClient({ url, acceptDirectFrom: inActa }) : new WebSocketProxyClient({
|
|
82
|
+
url, enableWebRTC: true, acceptDirectFrom: inActa, autoReconnect: true,
|
|
83
83
|
maxReconnectAttempts: 100000, reconnectDelay: 4000
|
|
84
84
|
})
|
|
85
85
|
|
|
86
86
|
await client.connect()
|
|
87
87
|
|
|
88
88
|
const identify = async () => {
|
|
89
|
-
|
|
89
|
+
identified = false
|
|
90
90
|
if (!client.token) return
|
|
91
91
|
const record = (await identity.profileActa?.().catch(() => null))?.acta || null
|
|
92
|
-
|
|
92
|
+
seenActa = record // la copia que mira la puerta del canal directo
|
|
93
93
|
const comm = commKey?.pub?.() || null
|
|
94
94
|
// ¿Nos nombra el acta? Con `cn` o sin él, lo que el proxio mira es la pertenencia.
|
|
95
|
-
const
|
|
95
|
+
const isMember = comm && (record?.members || []).some((m) => m?.pub === comm)
|
|
96
96
|
|
|
97
|
-
if (comm &&
|
|
97
|
+
if (comm && isMember) {
|
|
98
98
|
// El sobre lo arma el pilar (`identifyAs`), que le pone el destinatario.
|
|
99
99
|
try {
|
|
100
100
|
await client.identifyAs({ publickey: comm, sign: (d) => commKey.sign(d), acta: record })
|
|
101
|
-
|
|
101
|
+
identified = true
|
|
102
102
|
// SE DICE QUE SE IDENTIFICÓ, y con qué llave. Este camino era MUDO: al pasar de la
|
|
103
103
|
// maestra a la llave de comunicación, el único rastro de «estoy alcanzable» que
|
|
104
104
|
// quedaba en el log era el del repliegue. Así que cuando la consola decía «no
|
|
@@ -133,7 +133,7 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
|
|
|
133
133
|
if (!publickey) return
|
|
134
134
|
log('[vault] identifying with the master key: this vault is not in its own record yet (open the profile once to fix it)')
|
|
135
135
|
await client.identifyAs({ publickey, sign: (d) => identity.signData(d), acta: record })
|
|
136
|
-
|
|
136
|
+
identified = true
|
|
137
137
|
} catch (e) {
|
|
138
138
|
log(`[vault] cannot identify on the proxy yet: ${e.message} — the profile still opens; unlock it once and it gets its own communication key`)
|
|
139
139
|
}
|
|
@@ -175,7 +175,7 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
|
|
|
175
175
|
*/
|
|
176
176
|
let announcedAt = 0
|
|
177
177
|
const announceAccount = async () => {
|
|
178
|
-
if (!announce || !
|
|
178
|
+
if (!announce || !identified) return
|
|
179
179
|
announcedAt = Date.now()
|
|
180
180
|
try { await client.publish(announce) } catch (e) {
|
|
181
181
|
log(`[vault] could not announce this account on the proxy (${e.message}) — a borrowed machine will not find this vault by its address`)
|
|
@@ -190,38 +190,38 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
|
|
|
190
190
|
* lo que se pierde es que la despierten, y eso no se puede callar.
|
|
191
191
|
*/
|
|
192
192
|
const registerWake = async () => {
|
|
193
|
-
if (!wakeUrl || !
|
|
193
|
+
if (!wakeUrl || !identified) return
|
|
194
194
|
const comm = commKey?.pub?.() || null
|
|
195
|
-
if (!comm || !
|
|
195
|
+
if (!comm || !seenActa) { log('[vault] cannot register the wake URL: no communication key in the record yet'); return }
|
|
196
196
|
try {
|
|
197
|
-
await client.registerWake({ publicKey: comm, sign: (d) => commKey.sign(d), url: wakeUrl, acta:
|
|
197
|
+
await client.registerWake({ publicKey: comm, sign: (d) => commKey.sign(d), url: wakeUrl, acta: seenActa, channel: announce || undefined })
|
|
198
198
|
log('[vault] wake URL registered on the proxy')
|
|
199
199
|
} catch (e) {
|
|
200
200
|
log(`[vault] could not register the wake URL (${e.code || ''} ${e.message}) — the proxy will not wake this vault`)
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
let
|
|
205
|
-
let
|
|
204
|
+
let retry = null
|
|
205
|
+
let failures = 0
|
|
206
206
|
const identifyWithRetry = async () => {
|
|
207
|
-
if (
|
|
207
|
+
if (retry) { clearTimeout(retry); retry = null }
|
|
208
208
|
try {
|
|
209
209
|
await identify()
|
|
210
210
|
await announceAccount()
|
|
211
211
|
await registerWake()
|
|
212
|
-
if (
|
|
213
|
-
|
|
212
|
+
if (failures) log(`[vault] identified on the proxy after ${failures + 1} attempt(s)`)
|
|
213
|
+
failures = 0
|
|
214
214
|
} catch (e) {
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
log(`[vault] could not identify on the proxy (${e.message}) — retrying in ${Math.round(
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
failures++
|
|
216
|
+
const wait = Math.min(60000, 5000 * failures)
|
|
217
|
+
log(`[vault] could not identify on the proxy (${e.message}) — retrying in ${Math.round(wait / 1000)}s; until then this vault is unreachable and cannot ring anyone`)
|
|
218
|
+
retry = setTimeout(() => { retry = null; identifyWithRetry() }, wait)
|
|
219
|
+
retry.unref?.()
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
await identifyWithRetry()
|
|
223
223
|
// Re-identificar al reconectar (el token cambia).
|
|
224
|
-
client.on('token', () => {
|
|
224
|
+
client.on('token', () => { failures = 0; identifyWithRetry() })
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
227
|
* QUE NO SE PUEDA VOLVER A QUEDAR MUDA.
|
|
@@ -247,7 +247,7 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
|
|
|
247
247
|
let saidDown = false
|
|
248
248
|
client.on('disconnect', ({ code, reason } = {}) => {
|
|
249
249
|
// Sin socket no hay nadie atado al proxio: lo que se identificó era la conexión anterior.
|
|
250
|
-
|
|
250
|
+
identified = false
|
|
251
251
|
if (!downSince) downSince = Date.now()
|
|
252
252
|
if (saidDown) return
|
|
253
253
|
saidDown = true
|
|
@@ -267,7 +267,7 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
|
|
|
267
267
|
// borra al caerse, así que mirarlo daba la bóveda por vuelta con el socket cerrado: el
|
|
268
268
|
// 2026-10-15 dijo «back on the proxy after 50s», no volvió a marcar nunca y pasó hora y
|
|
269
269
|
// media fuera, avisando cada 10 minutos de que no podía anunciarse.
|
|
270
|
-
if (
|
|
270
|
+
if (identified && client.isConnected && client.token) {
|
|
271
271
|
if (downSince) log(`[vault] back on the proxy after ${Math.round((Date.now() - downSince) / 1000)}s`)
|
|
272
272
|
downSince = 0; saidDown = false
|
|
273
273
|
// EL ANUNCIO CADUCA: el proxio borra una entrada de canal a los 20 minutos de publicada.
|
|
@@ -286,5 +286,5 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
|
|
|
286
286
|
}, RECHECK_MS)
|
|
287
287
|
watchdog.unref?.()
|
|
288
288
|
|
|
289
|
-
return { client, token: client.token, identify: identifyWithRetry, isIdentified: () =>
|
|
289
|
+
return { client, token: client.token, identify: identifyWithRetry, isIdentified: () => identified }
|
|
290
290
|
}
|