@dotrino/vault 0.63.0 → 0.64.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/package.json +2 -2
- package/src/service.js +17 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/vault",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"description": "Usa ESTE dispositivo (navegador) como bóveda/CA del ecosistema Dotrino: atiende enrolamientos por el proxy y firma certificados de delegación a tus máquinas. Incluye el cliente de SERVICIO (Node): un proyecto se enrola una vez y jala sus credenciales del vault en vez del .env (`import '@dotrino/vault/config'`).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"pairing"
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@dotrino/identity": ">=0.
|
|
53
|
+
"@dotrino/identity": ">=0.92.0",
|
|
54
54
|
"@dotrino/proxy-client": ">=0.18.0"
|
|
55
55
|
},
|
|
56
56
|
"license": "MIT",
|
package/src/service.js
CHANGED
|
@@ -22,10 +22,10 @@ import fs from 'node:fs'
|
|
|
22
22
|
import path from 'node:path'
|
|
23
23
|
import { createHash } from 'node:crypto'
|
|
24
24
|
import {
|
|
25
|
-
makeDeviceKey, makeDeviceEncKey, importDeviceEncKey, signWithDevice,
|
|
25
|
+
makeDeviceKey, makeDeviceEncKey, importDeviceEncKey, signWithDevice,
|
|
26
26
|
verifyDeviceSig, makePairingCode, commitCode, pubkeyId } from '@dotrino/identity/capabilities'
|
|
27
27
|
import { openWrap, wrapForMember, decryptWithCek } from '@dotrino/identity/content'
|
|
28
|
-
import { verifyActa, sealKeyAt,
|
|
28
|
+
import { verifyActa, sealKeyAt, memberCan, checkVaultReply } 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'
|
|
@@ -400,18 +400,15 @@ export async function enrollWithVault ({ qr, label = 'agent', expectedScope = nu
|
|
|
400
400
|
// por reloj, dice el `seq` del acta con el que se emitió, y quien lo emitió tiene que
|
|
401
401
|
// ser SELLADORA de ese acta. Sin acta no se puede comprobar nada de eso, y entrar a
|
|
402
402
|
// ciegas en un perfil es justo lo que no se hace.
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
//
|
|
406
|
-
//
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
cert: res.cert, expectedSub: device.publickey,
|
|
411
|
-
actaSeq: acta.seq, sealers: sealersOf(acta),
|
|
412
|
-
...(expectedScope ? { expectedScope } : {})
|
|
403
|
+
//
|
|
404
|
+
// Se juzga contra la llave de LA BÓVEDA del QR, con la regla del pilar. Antes se exigía
|
|
405
|
+
// `acta.profileId === qr.iss`, que solo es verdad en una cuenta que nació en esa bóveda:
|
|
406
|
+
// un servicio no podía emparejarse con una segunda bóveda ni con una que adoptó la cuenta.
|
|
407
|
+
const chk = await checkVaultReply({
|
|
408
|
+
acta: res.acta, cert: res.cert, vault: qr.iss, sub: device.publickey,
|
|
409
|
+
scope: expectedScope || null, justSealed: true
|
|
413
410
|
})
|
|
414
|
-
if (!
|
|
411
|
+
if (!chk.ok) throw new Error('the vault reply does not check out: ' + chk.reason)
|
|
415
412
|
|
|
416
413
|
return { device, enc: enc ? { publickey: enc.encPublickey, privateJwk: enc.encPrivateJwk } : null, cert: res.cert, iss: qr.iss, proxy: qr.proxy || 'wss://proxy.dotrino.com' }
|
|
417
414
|
} finally { client.close() }
|
|
@@ -599,7 +596,13 @@ export async function fetchSecrets ({ dir, ns, proxyUrl, masterPubkey, device, c
|
|
|
599
596
|
const pending = waitForMsg(client, (p) => p.type === MSG.RENEWED || p.type === MSG.ERROR, 15000)
|
|
600
597
|
client.sendByPubkey(masterPubkey, { type: MSG.RENEW, data, signature, cert })
|
|
601
598
|
const res = await pending
|
|
602
|
-
|
|
599
|
+
// SE VERIFICA ANTES DE GUARDARLO. Aquí solo se miraba que fuera para esta llave: un
|
|
600
|
+
// papel cualquiera, sin firma que valga, sustituía al bueno y el servicio se quedaba
|
|
601
|
+
// fuera hasta el siguiente arranque. Misma regla que al enrolarse, sin `justSealed`:
|
|
602
|
+
// la última acta pudo sellarla otra selladora de la cuenta.
|
|
603
|
+
const ok = res.type === MSG.RENEWED &&
|
|
604
|
+
(await checkVaultReply({ acta: res.acta, cert: res.cert, vault: masterPubkey, sub: device.publickey })).ok
|
|
605
|
+
if (ok) {
|
|
603
606
|
cert = res.cert
|
|
604
607
|
recordar({ cert })
|
|
605
608
|
// QUIEN NO PASA `dir` GUARDA ÉL. Un servicio que lleva su identidad en su propio
|