@dotrino/vaultd 0.190.1 → 0.191.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/admin.js +17 -2
- package/lib/src/core/libVersion.js +1 -1
- package/lib/src/core/vault.js +18 -6
- package/package.json +1 -1
package/lib/src/admin.js
CHANGED
|
@@ -50,6 +50,11 @@ export const ADMIN_OPS = Object.freeze([
|
|
|
50
50
|
// Los BLOQUEADOS por un aprobador (`src/blocked.js`): verlos y desbloquearlos. Bloquear a
|
|
51
51
|
// distancia también, por si el administrador llega antes que el teléfono. No toca el acta.
|
|
52
52
|
'blocked', 'block', 'unblock',
|
|
53
|
+
// LAS CONCESIONES (un pedido aprobado deja pasar ese comando una hora que se renueva con
|
|
54
|
+
// cada uso): verlas y cortarlas. Las mismas que el aprobador ve en /approvals; aquí las ve
|
|
55
|
+
// quien administra, igual que la TUI del binario. Cortar no sella nada: la lista es de la
|
|
56
|
+
// bóveda, no del acta.
|
|
57
|
+
'grants', 'grant-revoke',
|
|
53
58
|
// Variables de entorno: verlas (nombres siempre; valor solo de las públicas) y
|
|
54
59
|
// ponerles valor (de las dos). Borrar NO está, y es a propósito: un aparato robado
|
|
55
60
|
// no debe poder dejar sin configuración a los servicios.
|
|
@@ -99,8 +104,8 @@ export const ADMIN_OPS = Object.freeze([
|
|
|
99
104
|
*/
|
|
100
105
|
export const ADMIN_OPS_WHILE_LOCKED = Object.freeze([
|
|
101
106
|
'audit', 'vars', 'var.set', 'var.setMany', 'var.recipients', 'var.reveal.begin', 'var.reveal',
|
|
102
|
-
// Bloquear no sella nada: la lista es de la bóveda, no del acta.
|
|
103
|
-
'blocked', 'block', 'unblock',
|
|
107
|
+
// Bloquear no sella nada: la lista es de la bóveda, no del acta. Las concesiones, igual.
|
|
108
|
+
'blocked', 'block', 'unblock', 'grants', 'grant-revoke',
|
|
104
109
|
// Las dos de abrir, obviamente: son las únicas que solo tienen sentido con el candado
|
|
105
110
|
// echado. Que estén aquí NO las deja pasar sin más — siguen exigiendo cert, acta, nonce
|
|
106
111
|
// y frescura como todas, y además la contraseña dentro del sobre.
|
|
@@ -154,6 +159,9 @@ export function createAdminDesk ({
|
|
|
154
159
|
unlockDesk = null,
|
|
155
160
|
// La lista de bloqueados, inyectada como `vars`: `{ list(), set(pub, on, { by }) }`.
|
|
156
161
|
blocked = null,
|
|
162
|
+
// Las CONCESIONES, inyectadas igual: `{ list(device), revoke(id, { by }) }`. `list` recibe
|
|
163
|
+
// a quien pregunta porque el comando de cada una va sellado a su llave de cifrado.
|
|
164
|
+
grants = null,
|
|
157
165
|
now = () => Date.now()
|
|
158
166
|
}) {
|
|
159
167
|
const ops = new Set(ADMIN_OPS)
|
|
@@ -352,6 +360,13 @@ export function createAdminDesk ({
|
|
|
352
360
|
// usarlo para quitar dejaba un miembro sin certificados al que la bóveda ya nunca le
|
|
353
361
|
// mandaba el aviso de expulsión (mientras siga en el acta, un papel retirado
|
|
354
362
|
// significa «renueva»). Ese era el dispositivo fantasma.
|
|
363
|
+
if (data.op === 'grants' || data.op === 'grant-revoke') {
|
|
364
|
+
if (!grants) return { ok: false, error: 'admin: this vault has no grants' }
|
|
365
|
+
if (data.op === 'grants') return { ok: true, result: await grants.list(chk.device) }
|
|
366
|
+
if (typeof data.id !== 'string' || !data.id) return { ok: false, error: 'admin: grant-revoke needs the grant id' }
|
|
367
|
+
const ok = await grants.revoke(data.id, { by })
|
|
368
|
+
return { ok: true, result: { id: data.id, ok } }
|
|
369
|
+
}
|
|
355
370
|
if (data.op === 'blocked' || data.op === 'block' || data.op === 'unblock') {
|
|
356
371
|
if (!blocked) return { ok: false, error: 'admin: this vault cannot block devices' }
|
|
357
372
|
if (data.op === 'blocked') return { ok: true, result: { items: blocked.list() } }
|
package/lib/src/core/vault.js
CHANGED
|
@@ -2140,12 +2140,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2140
2140
|
if (op === 'blocked') return answer({ op: 'blocked', items: blocked.list() })
|
|
2141
2141
|
if (op === 'grant-revoke') {
|
|
2142
2142
|
const gid = typeof p.data?.id === 'string' ? p.data.id : ''
|
|
2143
|
-
|
|
2144
|
-
if (ok) {
|
|
2145
|
-
audit('secrets.grant.revoked', { id: gid, by })
|
|
2146
|
-
log(`[vault] grant ${gid} revoked by ${by} — that command will ring again`)
|
|
2147
|
-
}
|
|
2148
|
-
return answer({ op: 'grant-revoke.result', id: gid, ok })
|
|
2143
|
+
return answer({ op: 'grant-revoke.result', id: gid, ok: revokeGrantBy(gid, by) })
|
|
2149
2144
|
}
|
|
2150
2145
|
const id = typeof p.data?.id === 'string' ? p.data.id : ''
|
|
2151
2146
|
const pend = approvals.take(id)
|
|
@@ -2286,6 +2281,16 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2286
2281
|
}
|
|
2287
2282
|
}
|
|
2288
2283
|
|
|
2284
|
+
/** Corta una concesión (desde /approvals o desde la consola de administración). */
|
|
2285
|
+
function revokeGrantBy (gid, by) {
|
|
2286
|
+
const ok = gid ? grants.revoke(gid) : false
|
|
2287
|
+
if (ok) {
|
|
2288
|
+
audit('secrets.grant.revoked', { id: gid, by })
|
|
2289
|
+
log(`[vault] grant ${gid} revoked by ${by} — that command will ring again`)
|
|
2290
|
+
}
|
|
2291
|
+
return ok
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2289
2294
|
async function withSealedContext (items, approver, record) {
|
|
2290
2295
|
const encPub = (record?.members || []).find((m) => m.pub === approver)?.encPub || null
|
|
2291
2296
|
const output = []
|
|
@@ -3521,6 +3526,13 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
3521
3526
|
deviceIdOf,
|
|
3522
3527
|
audit,
|
|
3523
3528
|
blocked: { list: () => blocked.list(), set: setBlocked },
|
|
3529
|
+
grants: {
|
|
3530
|
+
list: async (device) => {
|
|
3531
|
+
const record = (await identity.profileActa?.().catch(() => null))?.acta
|
|
3532
|
+
return { items: await withSealedContext(grants.list(), device, record), ttlMs: GRANT_TTL_MS }
|
|
3533
|
+
},
|
|
3534
|
+
revoke: async (id, { by }) => revokeGrantBy(id, by)
|
|
3535
|
+
},
|
|
3524
3536
|
// Abrir a distancia. Va inyectado porque `admin.js` es puro y esto necesita cripto y
|
|
3525
3537
|
// disco; `null` si este perfil no lo soporta, y entonces la operación contesta que no.
|
|
3526
3538
|
unlockDesk,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/vaultd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.191.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": {
|