@dotrino/vaultd 0.167.1 → 0.169.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/lib/src/core/libVersion.js +1 -1
- package/lib/src/core/transport.js +21 -1
- package/lib/src/core/vault.js +20 -6
- package/lib/src/service.js +5 -18
- package/package.json +2 -2
- package/src/adminDoor.js +62 -0
- package/src/ctl.js +2 -1
- package/src/profiles.js +8 -18
|
@@ -85,6 +85,21 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
|
|
|
85
85
|
|
|
86
86
|
await client.connect()
|
|
87
87
|
|
|
88
|
+
// LO ENCOLADO LLEGA AL IDENTIFICARSE, y quien monta la bóveda todavía no escucha: pone su
|
|
89
|
+
// oyente cuando ya tiene todo listo, bastante después. Sin esto, lo que el proxio guardaba
|
|
90
|
+
// para una bóveda dormida —el acta nueva que sacó la otra bóveda, un pedido— se entregaba
|
|
91
|
+
// a nadie y se perdía. Se guarda aquí hasta que llegue el oyente (`listen`).
|
|
92
|
+
let early = []
|
|
93
|
+
const offEarly = client.on('message', (from, payload) => { early?.push([from, payload]) })
|
|
94
|
+
const listen = (fn) => {
|
|
95
|
+
const off = client.on('message', fn)
|
|
96
|
+
const pending = early || []
|
|
97
|
+
early = null
|
|
98
|
+
try { offEarly?.() } catch (_) {}
|
|
99
|
+
for (const [from, payload] of pending) { try { fn(from, payload) } catch (_) {} }
|
|
100
|
+
return off
|
|
101
|
+
}
|
|
102
|
+
|
|
88
103
|
const identify = async () => {
|
|
89
104
|
identified = false
|
|
90
105
|
if (!client.token) return
|
|
@@ -195,6 +210,11 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
|
|
|
195
210
|
if (!comm || !seenActa) { log('[vault] cannot register the wake URL: no communication key in the record yet'); return }
|
|
196
211
|
try {
|
|
197
212
|
await client.registerWake({ publicKey: comm, sign: (d) => commKey.sign(d), url: wakeUrl, acta: seenActa, channel: announce || undefined })
|
|
213
|
+
// Y POR SU PROPIA LLAVE. Lo dirigido a la cuenta solo la despierta si no hay nadie más
|
|
214
|
+
// de la cuenta conectado; con otra bóveda encendida, nunca. La consola que elige ESTA
|
|
215
|
+
// bóveda le escribe a su llave de comunicación (`vault` en el acta), y es por ella
|
|
216
|
+
// por donde tiene que despertarse.
|
|
217
|
+
await client.registerWake({ publicKey: comm, sign: (d) => commKey.sign(d), url: wakeUrl, acta: seenActa, self: true })
|
|
198
218
|
log('[vault] wake URL registered on the proxy')
|
|
199
219
|
} catch (e) {
|
|
200
220
|
log(`[vault] could not register the wake URL (${e.code || ''} ${e.message}) — the proxy will not wake this vault`)
|
|
@@ -286,5 +306,5 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
|
|
|
286
306
|
}, RECHECK_MS)
|
|
287
307
|
watchdog.unref?.()
|
|
288
308
|
|
|
289
|
-
return { client, token: client.token, identify: identifyWithRetry, isIdentified: () => identified }
|
|
309
|
+
return { client, token: client.token, identify: identifyWithRetry, isIdentified: () => identified, listen }
|
|
290
310
|
}
|
package/lib/src/core/vault.js
CHANGED
|
@@ -478,9 +478,17 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
478
478
|
const acta = info?.acta
|
|
479
479
|
if (!acta || isLocked() || identity.masterLocked) return false
|
|
480
480
|
const pub = await commKey.ensure()
|
|
481
|
-
|
|
481
|
+
const mine = (acta.members || []).find((m) => m?.pub === pub)
|
|
482
482
|
if (!info?.isMaster) return false
|
|
483
|
-
|
|
483
|
+
// DE QUÉ BÓVEDA ES (`vault`: esta maestra). Con dos bóvedas en la cuenta es lo único que
|
|
484
|
+
// deja a la consola escribirle a una sola. A la llave que entró antes del campo se le pone.
|
|
485
|
+
if (mine) {
|
|
486
|
+
if (mine.vault || !master) return false
|
|
487
|
+
await identity.setMemberVault({ pub, vault: master })
|
|
488
|
+
log('[vault] the record now says which vault this communication key speaks for')
|
|
489
|
+
return true
|
|
490
|
+
}
|
|
491
|
+
await identity.admitMember({ pub, label: 'esta bóveda', cn: COMM_CN, caps: [...COMM_CAPS], ...(master ? { vault: master } : {}) })
|
|
484
492
|
log('[vault] this vault is now a member of its own record: it talks with its own key, not the master one')
|
|
485
493
|
return true
|
|
486
494
|
} catch (e) {
|
|
@@ -488,12 +496,14 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
488
496
|
return false
|
|
489
497
|
}
|
|
490
498
|
}
|
|
491
|
-
|
|
499
|
+
// Lo que se selló aquí se anuncia cuando ya hay transporte (más abajo): sin el aviso, la otra
|
|
500
|
+
// bóveda de la cuenta no se entera y las dos acaban con actas distintas del mismo número.
|
|
501
|
+
const commSealedAtStart = await ensureCommKeyInActa()
|
|
492
502
|
|
|
493
503
|
// `announce`: el canal de ESTA cuenta, para que una máquina prestada —que no tiene
|
|
494
504
|
// ninguna llave y solo sabe la dirección `nombre@AB12-CD34-EF56`— pueda encontrar a quien
|
|
495
505
|
// la atiende. Lo construye la pieza compartida, porque quien lo busca es la extensión.
|
|
496
|
-
const { client, identify: reidentify, isIdentified } = await createTransport({
|
|
506
|
+
const { client, identify: reidentify, isIdentified, listen } = await createTransport({
|
|
497
507
|
identity, url: proxyUrl, commKey, log, announce: vaultChannel(fp), makeClient: platform.makeClient || null, wakeUrl: platform.wakeUrl || null
|
|
498
508
|
})
|
|
499
509
|
|
|
@@ -501,6 +511,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
501
511
|
// que le dicen a un tercero si esta cuenta sigue sellada por quien él cree. Ver
|
|
502
512
|
// `sealers.js` — es una comodidad para quien lee, nunca una dependencia de la bóveda.
|
|
503
513
|
startSealersPublisher({ identity, client, log })
|
|
514
|
+
if (commSealedAtStart) await notifyMembers('commkey')
|
|
504
515
|
|
|
505
516
|
async function revocationSet () {
|
|
506
517
|
const { revoked } = await identity.listDelegations()
|
|
@@ -2218,7 +2229,8 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2218
2229
|
reply(from, { type: MSG.INCIDENT_RESULT, id: pend.id, approvers, blocked: false })
|
|
2219
2230
|
}
|
|
2220
2231
|
|
|
2221
|
-
client.on
|
|
2232
|
+
// `listen` y no `client.on`: entrega también lo que llegó encolado antes de este punto.
|
|
2233
|
+
listen((from, payload) => {
|
|
2222
2234
|
// Quien monta la bóveda puede querer saber que hay trabajo (la Lambda se apaga cuando
|
|
2223
2235
|
// deja de haberlo). Es un aviso, no decide nada.
|
|
2224
2236
|
try { platform.onActivity?.() } catch (_) {}
|
|
@@ -4293,7 +4305,9 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
4293
4305
|
// la bóveda seguía muda en el proxio con su llave ya admitida en el acta. Al dueño le
|
|
4294
4306
|
// pasó el 2026-09-05: hizo lo que el log pedía y la consola siguió sin contestar.
|
|
4295
4307
|
if (r?.locked === false) {
|
|
4296
|
-
try {
|
|
4308
|
+
try {
|
|
4309
|
+
if (await ensureCommKeyInActa()) { await reidentify?.(); await notifyMembers('commkey') }
|
|
4310
|
+
} catch (_) {}
|
|
4297
4311
|
}
|
|
4298
4312
|
// Y ABSORBER LO PENDIENTE. La subacta ya lo estaba honrando con el perfil cerrado —de
|
|
4299
4313
|
// eso vive—, pero mientras siga ahí solo lo sabe esta máquina: al sellarlo, entra en
|
package/lib/src/service.js
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
makeDeviceKey, makeDeviceEncKey, importDeviceEncKey, signWithDevice,
|
|
26
26
|
verifyDeviceSig, makePairingCode, commitCode, pubkeyId, keyLabel } from '@dotrino/identity/capabilities'
|
|
27
27
|
import { openWrap, wrapForMember, decryptWithCek } from '@dotrino/identity/content'
|
|
28
|
-
import { verifyActa, sealKeyAt, memberCan, checkVaultReply,
|
|
28
|
+
import { verifyActa, sealKeyAt, memberCan, checkVaultReply, accountMismatch } from '@dotrino/identity/acta'
|
|
29
29
|
import { MSG, secretsScope, isValidSecretsNs, VAULT_PROTOCOL, VAULT_SPEAKS } from './protocol.js'
|
|
30
30
|
import { PKG_VERSION } from './version.js'
|
|
31
31
|
import { makeEphemeralKey, openSealed } from './sealed.js'
|
|
@@ -391,24 +391,11 @@ export async function vaultAccountName (qr) {
|
|
|
391
391
|
return (await vaultHello(qr)).acct || ''
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
/**
|
|
395
|
-
* ¿Es esta bóveda de la cuenta `account` (`pubkeyId` de la llave del perfil)? Lo dice la cadena de
|
|
396
|
-
* selladoras que viaja en el reto: la raíz la firma la llave del perfil y cada eslabón lo sella
|
|
397
|
-
* quien el anterior autorizaba, así que no se puede fingir otra cuenta. Y la bóveda que contesta
|
|
398
|
-
* tiene que ser selladora de la última acta. Devuelve `null` si sí, o el motivo.
|
|
399
|
-
*/
|
|
400
|
-
async function notFromAccount (chain, iss, account) {
|
|
401
|
-
if (!Array.isArray(chain) || !chain.length) return 'the vault did not say which account it belongs to (it may need an update)'
|
|
402
|
-
const c = await verifySealerChain(chain)
|
|
403
|
-
if (!c.ok) return 'the vault account could not be verified: ' + c.reason
|
|
404
|
-
if (!canSeal(chain[chain.length - 1], iss)) return 'the vault that answered does not seal that account'
|
|
405
|
-
const got = await pubkeyId(c.profileId)
|
|
406
|
-
return got === account ? null : `the invitation is from account ${got}, not from ${account}`
|
|
407
|
-
}
|
|
408
|
-
|
|
409
394
|
/**
|
|
410
395
|
* `account`: si viene, el aparato SOLO entra en esa cuenta. Se comprueba al llegar el reto,
|
|
411
|
-
* antes de enseñar el código: con otra cuenta no hay código que aprobar (`wrong-account`).
|
|
396
|
+
* antes de enseñar el código: con otra cuenta no hay código que aprobar (`wrong-account`). La
|
|
397
|
+
* regla es `accountMismatch` de `@dotrino/identity/acta`, la misma que usa el `join` de la
|
|
398
|
+
* bóveda alojada.
|
|
412
399
|
*/
|
|
413
400
|
export async function enrollWithVault ({ qr, label = 'agent', expectedScope = null, onCode, approveTimeoutMs = 180000, withEncKey = true, account = null } = {}) {
|
|
414
401
|
// `parseInvite` y NO `JSON.parse`: el vault no imprime JSON desde hace rato.
|
|
@@ -446,7 +433,7 @@ export async function enrollWithVault ({ qr, label = 'agent', expectedScope = nu
|
|
|
446
433
|
if ((p.type === MSG.ENROLL_CHALLENGE || p.type === MSG.ERROR) && !await fromMyVault(p, qr)) return
|
|
447
434
|
if (p.type === MSG.ENROLL_CHALLENGE) {
|
|
448
435
|
if (account) {
|
|
449
|
-
const why = await
|
|
436
|
+
const why = await accountMismatch(p.signed?.chain, qr.iss, account)
|
|
450
437
|
if (why) { cleanup(); reject(Object.assign(new Error(why), { code: 'wrong-account' })); return }
|
|
451
438
|
}
|
|
452
439
|
const show = onCode || (({ deviceId, code }) => console.log(`[vault] device ${deviceId} · approve it on the vault: dotrino-vault approve ${code}`))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/vaultd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.169.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": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@dotrino/compat": "0.4.0",
|
|
25
|
-
"@dotrino/identity": "0.
|
|
25
|
+
"@dotrino/identity": "0.125.0",
|
|
26
26
|
"@dotrino/opaque": "0.1.0",
|
|
27
27
|
"@dotrino/passmanager": "0.18.4",
|
|
28
28
|
"@dotrino/proxy-client": "0.39.0",
|
package/src/adminDoor.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LA PUERTA DEL ADMIN: la llave del perfil `K` envuelta con lo que sale de una contraseña
|
|
3
|
+
* (`docs/abrir-a-distancia.md`), y el freno de intentos que la protege.
|
|
4
|
+
*
|
|
5
|
+
* La usan las dos bóvedas que se abren desde la consola: la de escritorio (`profiles.js`, el
|
|
6
|
+
* sobre `kdf2` junto a la puerta principal) y la alojada en la Lambda (`lambda/lock.mjs`, donde
|
|
7
|
+
* es la ÚNICA puerta). Vive aquí para que la regla sea una: si el freno o el sobre cambiaran en
|
|
8
|
+
* un sitio y no en el otro, la misma contraseña abriría en una y no en la otra.
|
|
9
|
+
*
|
|
10
|
+
* El molino (scrypt) lo hace quien teclea, en el navegador: aquí solo llega la derivada.
|
|
11
|
+
*/
|
|
12
|
+
import { encryptText, decryptText } from '../lib/src/atrest.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Los números del molino. El navegador tiene que derivar con EXACTAMENTE estos, así que se le
|
|
16
|
+
* mandan (`params`) en vez de que los copie.
|
|
17
|
+
*/
|
|
18
|
+
export const SCRYPT = Object.freeze({ N: 16384, r: 8, p: 1, len: 32 })
|
|
19
|
+
|
|
20
|
+
/** El freno olvida los fallos viejos: estorba a una ráfaga, no a quien vuelve al día siguiente. */
|
|
21
|
+
export const TRIES_FORGET_MS = 15 * 60 * 1000
|
|
22
|
+
|
|
23
|
+
const b64 = (u8) => Buffer.from(u8).toString('base64')
|
|
24
|
+
|
|
25
|
+
/** Un salt nuevo para una puerta (32 bytes, base64). */
|
|
26
|
+
export const newSalt = () => b64(crypto.getRandomValues(new Uint8Array(32)))
|
|
27
|
+
|
|
28
|
+
/** Envuelve la llave del perfil con la derivada de la contraseña. */
|
|
29
|
+
export function wrapKey (key, derived) {
|
|
30
|
+
if (!(derived instanceof Uint8Array) || derived.length !== 32) throw new Error('the admin key must be 32 bytes')
|
|
31
|
+
return encryptText(b64(key), Buffer.from(derived))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* La desenvuelve. AES-GCM autentica, así que una derivada equivocada NO descifra: eso ES la
|
|
36
|
+
* comprobación, y no hace falta un verificador aparte. `null` si no abre.
|
|
37
|
+
*/
|
|
38
|
+
export function unwrapKey (wrapped, derived) {
|
|
39
|
+
let key = null
|
|
40
|
+
try { key = Buffer.from(decryptText(wrapped, Buffer.from(derived)), 'base64') } catch (_) { key = null }
|
|
41
|
+
return key && key.length === 32 ? new Uint8Array(key) : null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* EL FRENO. Recibe los intentos guardados (`{ n, at }` o nada) y devuelve los vigentes: los
|
|
46
|
+
* vencidos vuelven a cero (`reset`). Cinco fallos y espera exponencial, hasta cinco minutos;
|
|
47
|
+
* mientras dure, lanza `TOO_MANY_TRIES` con `waitSec`.
|
|
48
|
+
*/
|
|
49
|
+
export function checkTries (saved, now = Date.now()) {
|
|
50
|
+
let tries = saved || { n: 0, at: 0 }
|
|
51
|
+
let reset = false
|
|
52
|
+
if (tries.at && now - tries.at > TRIES_FORGET_MS) { tries = { n: 0, at: 0 }; reset = !!saved }
|
|
53
|
+
const waitMs = tries.n >= 5 ? Math.min(2 ** (tries.n - 4) * 1000, 5 * 60 * 1000) : 0
|
|
54
|
+
const left = tries.at + waitMs - now
|
|
55
|
+
if (left > 0) {
|
|
56
|
+
throw Object.assign(new Error(`too many tries: wait ${Math.ceil(left / 1000)} s`),
|
|
57
|
+
{ code: 'TOO_MANY_TRIES', waitSec: Math.ceil(left / 1000) })
|
|
58
|
+
}
|
|
59
|
+
return { tries, reset }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default { SCRYPT, TRIES_FORGET_MS, newSalt, wrapKey, unwrapKey, checkTries }
|
package/src/ctl.js
CHANGED
|
@@ -776,7 +776,8 @@ const CAP_BY_WORD = {
|
|
|
776
776
|
firma: 'sign', guarda: 'store', lee: 'read', administra: 'admin', aprueba: 'approve',
|
|
777
777
|
// `sella`: SELLAR EL ACTA. Es lo que convierte a otra bóveda en respaldo de esta —
|
|
778
778
|
// podrá admitir aparatos y cambiar permisos si esta se pierde. No es un traspaso:
|
|
779
|
-
// quien manda sigue mandando.
|
|
779
|
+
// quien manda sigue mandando. Se concede con `caps` o al emparejar (`pair --scope sella,…`,
|
|
780
|
+
// que es como entra la bóveda alojada de `dotrino-accounts`).
|
|
780
781
|
sella: 'sealer', sealer: 'sealer',
|
|
781
782
|
// `replica`: reparte los sobres que esta bóveda ya firmó, cuando ella no está. No
|
|
782
783
|
// tiene maestra y no puede abrir nada. A diferencia de `sella`, SÍ se empareja.
|
package/src/profiles.js
CHANGED
|
@@ -27,6 +27,7 @@ import { dataDir, ensureDir, readJson, writeJson } from './paths.js'
|
|
|
27
27
|
import { atRestFor, migrateFile, kekFor, encryptText, decryptText } from './atrest.js'
|
|
28
28
|
import { probe as probeKek, writeConfig as writeKekConfig, configFromEnv } from './atrest.js'
|
|
29
29
|
import { keyDirName, keyOwnerOf } from './keyowner.js'
|
|
30
|
+
import { SCRYPT, wrapKey, unwrapKey, checkTries } from './adminDoor.js'
|
|
30
31
|
|
|
31
32
|
const REGISTRY = 'profiles.json'
|
|
32
33
|
const PWD_ITER = 300000 // PBKDF2 del verificador v1 (heredado); v2 usa scrypt
|
|
@@ -39,7 +40,7 @@ const PWD_ITER = 300000 // PBKDF2 del verificador v1 (heredado); v2 usa scrypt
|
|
|
39
40
|
*
|
|
40
41
|
* Por eso también se le mandan al admin (`secondaryParams`) en vez de que los copie.
|
|
41
42
|
*/
|
|
42
|
-
export
|
|
43
|
+
export { SCRYPT }
|
|
43
44
|
const MAX_NAME = 40
|
|
44
45
|
/**
|
|
45
46
|
* Lo MÍNIMO que se acepta al poner una contraseña.
|
|
@@ -62,7 +63,6 @@ const PWD_MIN = 12
|
|
|
62
63
|
* bueno) la alargaba sin llegar a comprobarse: la bóveda quedaba cerrada para su dueño.
|
|
63
64
|
* El freno tiene que estorbar a una RÁFAGA, no a quien vuelve al día siguiente.
|
|
64
65
|
*/
|
|
65
|
-
const TRIES_FORGET_MS = 15 * 60 * 1000
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* BLOQUEO AUTOMÁTICO. Cuánto aguanta abierto el candado sin que nadie lo use.
|
|
@@ -353,17 +353,8 @@ export function openProfiles (root = dataDir(), { autoLockMs = AUTO_LOCK_MS, onA
|
|
|
353
353
|
* «se volvió a pedir la contraseña porque sí».
|
|
354
354
|
*/
|
|
355
355
|
function throttle (p) {
|
|
356
|
-
|
|
357
|
-
if (
|
|
358
|
-
tries = { n: 0, at: 0 }
|
|
359
|
-
if (p.tries) { delete p.tries; save() }
|
|
360
|
-
}
|
|
361
|
-
const waitMs = tries.n >= 5 ? Math.min(2 ** (tries.n - 4) * 1000, 5 * 60 * 1000) : 0
|
|
362
|
-
const left = tries.at + waitMs - Date.now()
|
|
363
|
-
if (left > 0) {
|
|
364
|
-
throw Object.assign(new Error(`too many tries: wait ${Math.ceil(left / 1000)} s`),
|
|
365
|
-
{ code: 'TOO_MANY_TRIES', waitSec: Math.ceil(left / 1000) })
|
|
366
|
-
}
|
|
356
|
+
const { tries, reset } = checkTries(p.tries)
|
|
357
|
+
if (reset) { delete p.tries; save() }
|
|
367
358
|
return tries
|
|
368
359
|
}
|
|
369
360
|
|
|
@@ -874,7 +865,7 @@ export function openProfiles (root = dataDir(), { autoLockMs = AUTO_LOCK_MS, onA
|
|
|
874
865
|
if (!key) throw Object.assign(new Error('open the profile first (dotrino-vault unlock)'), { code: 'PROFILE_LOCKED' })
|
|
875
866
|
if (!(derived instanceof Uint8Array) || derived.length !== 32) throw new Error('the admin key must be 32 bytes')
|
|
876
867
|
const salt = p.kdf2?.salt || b64(crypto.getRandomValues(new Uint8Array(32)))
|
|
877
|
-
p.kdf2 = { v: 1, salt, wrapped:
|
|
868
|
+
p.kdf2 = { v: 1, salt, wrapped: wrapKey(key, derived) }
|
|
878
869
|
save()
|
|
879
870
|
return { ok: true }
|
|
880
871
|
},
|
|
@@ -901,9 +892,8 @@ export function openProfiles (root = dataDir(), { autoLockMs = AUTO_LOCK_MS, onA
|
|
|
901
892
|
const p = assertExists(id)
|
|
902
893
|
if (!p.kdf2?.wrapped) throw Object.assign(new Error('this profile has no admin password'), { code: 'NO_SECONDARY' })
|
|
903
894
|
const tries = throttle(p)
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
if (!key || key.length !== 32) {
|
|
895
|
+
const key = unwrapKey(p.kdf2.wrapped, derived)
|
|
896
|
+
if (!key) {
|
|
907
897
|
p.tries = { n: tries.n + 1, at: Date.now() }
|
|
908
898
|
save()
|
|
909
899
|
throw Object.assign(new Error('wrong admin password'), { code: 'WRONG_PASSWORD', tries: p.tries.n })
|
|
@@ -911,7 +901,7 @@ export function openProfiles (root = dataDir(), { autoLockMs = AUTO_LOCK_MS, onA
|
|
|
911
901
|
delete p.tries
|
|
912
902
|
save()
|
|
913
903
|
open(id)
|
|
914
|
-
keys.set(id,
|
|
904
|
+
keys.set(id, key)
|
|
915
905
|
return { ok: true, locked: false }
|
|
916
906
|
},
|
|
917
907
|
|