@dotrino/identity 0.135.0 → 0.136.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 +16 -3
- package/src/index.d.ts +86 -3
- package/types/acta.d.ts +652 -0
- package/types/assertion.d.ts +208 -0
- package/types/avatar.d.ts +11 -0
- package/types/capabilities.d.ts +188 -0
- package/types/content.d.ts +191 -0
- package/types/core.d.ts +1168 -0
- package/types/keyid.d.ts +12 -0
- package/types/machine.d.ts +54 -0
- package/types/peerSync.d.ts +33 -0
- package/types/remote.d.ts +181 -0
- package/types/session.d.ts +163 -0
- package/types/sessionFlow.d.ts +86 -0
- package/types/vaultSeal.d.ts +58 -0
- package/vault/acta.js +2 -2
- package/vault/core.js +25 -16
- package/vault/remote.js +54 -29
- package/vault/vaultSeal.js +126 -0
- package/vault/vendor/proxy-client/VERSION.txt +1 -1
- package/vault/vendor/proxy-client/client.js +45 -0
- package/vault/vendor/proxy-client/webrtc.js +39 -5
- package/vault/vendor/roadmap/VERSION.txt +1 -1
- package/vault/vendor/roadmap/manifests.js +53 -52
- package/vault/vendor/store/VERSION.txt +1 -1
- package/vault/vendor/vault/VERSION.txt +1 -1
- package/vault/vendor/vault/admin.js +17 -2
- package/vault/vendor/vault/core/libVersion.js +1 -1
- package/vault/vendor/vault/core/notices.js +18 -2
- package/vault/vendor/vault/core/passwords.js +4 -0
- package/vault/vendor/vault/core/vault.js +115 -13
|
@@ -2036,6 +2036,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2036
2036
|
}
|
|
2037
2037
|
audit('secrets', { device: await deviceIdOf(chk.device), ns, ...(publicOnly ? { publicOnly: true } : {}) })
|
|
2038
2038
|
reply(from, { type: MSG.SECRETS_RESULT, ...res })
|
|
2039
|
+
if (!publicOnly) announceDelivered({ device: chk.device, ns, kind: 'secrets' })
|
|
2039
2040
|
}
|
|
2040
2041
|
|
|
2041
2042
|
/** El bundle de `ns` para `devicePub`, sellado a su `ek` y firmado por la llave de sellado. */
|
|
@@ -2139,12 +2140,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2139
2140
|
if (op === 'blocked') return answer({ op: 'blocked', items: blocked.list() })
|
|
2140
2141
|
if (op === 'grant-revoke') {
|
|
2141
2142
|
const gid = typeof p.data?.id === 'string' ? p.data.id : ''
|
|
2142
|
-
|
|
2143
|
-
if (ok) {
|
|
2144
|
-
audit('secrets.grant.revoked', { id: gid, by })
|
|
2145
|
-
log(`[vault] grant ${gid} revoked by ${by} — that command will ring again`)
|
|
2146
|
-
}
|
|
2147
|
-
return answer({ op: 'grant-revoke.result', id: gid, ok })
|
|
2143
|
+
return answer({ op: 'grant-revoke.result', id: gid, ok: revokeGrantBy(gid, by) })
|
|
2148
2144
|
}
|
|
2149
2145
|
const id = typeof p.data?.id === 'string' ? p.data.id : ''
|
|
2150
2146
|
const pend = approvals.take(id)
|
|
@@ -2249,6 +2245,52 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2249
2245
|
* en vez de mandárselo en claro «para que al menos lo vea»: eso sería cambiar la promesa
|
|
2250
2246
|
* por comodidad, y encima sin avisar a nadie.
|
|
2251
2247
|
*/
|
|
2248
|
+
/** Un objeto pequeño sellado a un `encPub` del acta: `{ wrap, envelope }`, lo abre `openSealed`. */
|
|
2249
|
+
async function sealTo (encPub, obj) {
|
|
2250
|
+
const cek = await makeContentKey()
|
|
2251
|
+
const envelope = await encryptWithCek({ cek, gen: 0, plaintext: JSON.stringify(obj) })
|
|
2252
|
+
const wrap = await wrapForMember({ cek, memberEncPub: encPub })
|
|
2253
|
+
return { wrap, envelope }
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
/**
|
|
2257
|
+
* EL ASUNTO DEL TIMBRE, SELLADO AL TELÉFONO (dueño, 2026-11-04: «que las notificaciones a
|
|
2258
|
+
* móviles no sean del todo anónimas sino que al menos tengan asunto, para ver quién solicita
|
|
2259
|
+
* qué»). El timbre que sale por FCM/APNs lo leen Google y Apple, así que el proxio lo manda
|
|
2260
|
+
* vacío. Lo que va aquí viaja dentro del mensaje como `ring` y el proxio lo pega al timbre
|
|
2261
|
+
* TAL CUAL: va cifrado a la `encPub` del aprobador, y solo su teléfono lo abre, sin red.
|
|
2262
|
+
*
|
|
2263
|
+
* Es solo el asunto. Quien aprueba sigue decidiendo con la lista (`op: 'approvals'`), que
|
|
2264
|
+
* es la que va firmada: un asunto falso no aprueba nada.
|
|
2265
|
+
*
|
|
2266
|
+
* Sin `encPub` en el acta no hay asunto (y el teléfono enseña el genérico): mandarlo en claro
|
|
2267
|
+
* sería cambiar la promesa sin avisar.
|
|
2268
|
+
*/
|
|
2269
|
+
const RING_CTX_KEYS = ['op', 'fields', 'product', 'version', 'from', 'reporterLabel', 'kind']
|
|
2270
|
+
async function ringFor (pub, record, hint) {
|
|
2271
|
+
const encPub = (record?.members || []).find((m) => m.pub === pub)?.encPub || null
|
|
2272
|
+
if (!encPub) return null
|
|
2273
|
+
let ctx = null
|
|
2274
|
+
if (hint.ctx && typeof hint.ctx === 'object') {
|
|
2275
|
+
ctx = {}
|
|
2276
|
+
for (const k of RING_CTX_KEYS) if (hint.ctx[k] != null) ctx[k] = hint.ctx[k]
|
|
2277
|
+
}
|
|
2278
|
+
try { return await sealTo(encPub, { ...hint, ctx }) } catch (e) {
|
|
2279
|
+
log(`[vault] could not seal the subject of the ring for ${pub.slice(0, 24)}…: ${e.message}`)
|
|
2280
|
+
return null
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
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
|
+
|
|
2252
2294
|
async function withSealedContext (items, approver, record) {
|
|
2253
2295
|
const encPub = (record?.members || []).find((m) => m.pub === approver)?.encPub || null
|
|
2254
2296
|
const output = []
|
|
@@ -2257,9 +2299,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2257
2299
|
if (!ctx) { output.push({ ...rest, ctx: null }); continue }
|
|
2258
2300
|
if (!encPub) { output.push({ ...rest, ctx: null, ctxSealed: false, ctxReason: 'no-enc-key' }); continue }
|
|
2259
2301
|
try {
|
|
2260
|
-
const
|
|
2261
|
-
const envelope = await encryptWithCek({ cek, gen: 0, plaintext: JSON.stringify(ctx) })
|
|
2262
|
-
const wrap = await wrapForMember({ cek, memberEncPub: encPub })
|
|
2302
|
+
const { wrap, envelope } = await sealTo(encPub, ctx)
|
|
2263
2303
|
output.push({ ...rest, ctx: null, ctxSealed: true, ctxWrap: wrap, ctxEnvelope: envelope })
|
|
2264
2304
|
} catch (e) {
|
|
2265
2305
|
// NO SE TRAGA: sin esto, un fallo al sellar se vería en el teléfono igual que un
|
|
@@ -2300,7 +2340,8 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2300
2340
|
for (const pub of who) {
|
|
2301
2341
|
// A la app que APRUEBA (`vault`): en un teléfono la llave es de todas sus apps, y sin
|
|
2302
2342
|
// decirlo el pedido timbraba a messenger (websocket-proxy ≥ 1.4.0).
|
|
2303
|
-
|
|
2343
|
+
const ring = await ringFor(pub, record, { ...body, ctx: pend.ctx || null })
|
|
2344
|
+
try { client.sendByPubkey(pub, { type: MSG.ADMIN_EVENT, body, seal, ...(ring ? { ring } : {}) }, { app: 'vault' }) }
|
|
2304
2345
|
catch (e) { log(`[vault] could not ring ${pub.slice(0, 24)}… about ${pend.ns}: ${e.message}`) }
|
|
2305
2346
|
}
|
|
2306
2347
|
log(`[vault] ${pend.ns}: rang ${who.length} approver(s) for ${pend.id}`)
|
|
@@ -2331,9 +2372,12 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2331
2372
|
const { id, ev, ts, ...rest } = notice
|
|
2332
2373
|
const body = { ev, id, ...rest, ts }
|
|
2333
2374
|
const seal = await sealOrFail(body)
|
|
2375
|
+
// Lo que calla no timbra: no lleva asunto. Lo que suena, sí (ver `ringFor`).
|
|
2376
|
+
const record = quiet ? null : await refreshActa()
|
|
2334
2377
|
let sent = 0
|
|
2335
2378
|
for (const pub of who) {
|
|
2336
|
-
|
|
2379
|
+
const ring = quiet ? null : await ringFor(pub, record, { ev, id, ts, kind: rest.kind || null, ns: rest.ns || null, deviceId: rest.deviceId || null, label: rest.label || null, product: rest.product || null, version: rest.version || null, from: rest.from || null })
|
|
2380
|
+
try { client.sendByPubkey(pub, { type: MSG.ADMIN_EVENT, body, seal, ...(ring ? { ring } : {}) }, { app: 'vault', ...(quiet ? { quiet: true } : {}) }); sent++ }
|
|
2337
2381
|
catch (e) { log(`[vault] could not tell ${pub.slice(0, 24)}… about ${what}: ${e.message}`) }
|
|
2338
2382
|
}
|
|
2339
2383
|
return sent
|
|
@@ -2402,6 +2446,39 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2402
2446
|
return { approvers: who.length, sent, notice }
|
|
2403
2447
|
}
|
|
2404
2448
|
|
|
2449
|
+
/**
|
|
2450
|
+
* «SE LLEVÓ CLAVES SIN PEDIR», a quien aprueba (dueño, 2026-11-04). Un aparato con
|
|
2451
|
+
* `unattended` no pide aprobación —para eso se le dio—, pero que lo haga en silencio deja al
|
|
2452
|
+
* dueño sin saber qué máquina se llevó qué. Se cuenta como aviso (`delivered`), no como pedido.
|
|
2453
|
+
*
|
|
2454
|
+
* UNO POR APARATO, CAJÓN Y HORA: un servicio pide su cajón en cada arranque y el gestor una
|
|
2455
|
+
* contraseña en cada relleno; timbrar cada vez enseña a ignorar el timbre. Solo cuando de
|
|
2456
|
+
* verdad no se pidió por `unattended`: sin aprobadores no hay a quién contar, y lo aprobado
|
|
2457
|
+
* ya lo vio quien aprobó.
|
|
2458
|
+
*/
|
|
2459
|
+
const DELIVERED_EVERY_MS = 60 * 60 * 1000
|
|
2460
|
+
const deliveredAt = new Map()
|
|
2461
|
+
async function announceDelivered ({ device, ns, kind }) {
|
|
2462
|
+
try {
|
|
2463
|
+
const record = await refreshActa()
|
|
2464
|
+
if (!record || !Acta.memberCan(record, device, 'unattended')) return
|
|
2465
|
+
const who = (record.members || []).filter((m) => Acta.memberCan(record, m.pub, 'approve')).map((m) => m.pub)
|
|
2466
|
+
if (!who.length) return
|
|
2467
|
+
const key = `${device}|${kind}|${ns}`
|
|
2468
|
+
const now = Date.now()
|
|
2469
|
+
if (now - (deliveredAt.get(key) || 0) < DELIVERED_EVERY_MS) return
|
|
2470
|
+
deliveredAt.set(key, now)
|
|
2471
|
+
for (const [k, t] of deliveredAt) if (now - t >= DELIVERED_EVERY_MS) deliveredAt.delete(k)
|
|
2472
|
+
const deviceId = await deviceIdOf(device).catch(() => null)
|
|
2473
|
+
if (!deviceId) return log(`[vault] delivered: could not name the device that took ${kind} of ${ns}, so nobody is told`)
|
|
2474
|
+
const label = (record.members || []).find((m) => m.pub === device)?.label || ''
|
|
2475
|
+
const notice = notices.add('delivered', { kind, ns, deviceId, label })
|
|
2476
|
+
const sent = await sendNotice(notice, who, `the delivery of ${kind} of ${ns} to ${deviceId}`)
|
|
2477
|
+
audit('delivered.announced', { device: deviceId, ns, kind, approvers: who.length, sent })
|
|
2478
|
+
log(`[vault] delivered: told ${sent} of ${who.length} approver(s) that ${deviceId} took ${kind} of ${ns} without approval (unattended)`)
|
|
2479
|
+
} catch (e) { log(`[vault] delivered: could not tell the approvers (${e.code || 'error'}: ${e.message})`) }
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2405
2482
|
/**
|
|
2406
2483
|
* UN INCIDENTE: un agente de la cuenta dice que OTRO aparato de la cuenta se equivocó de
|
|
2407
2484
|
* clave tres veces seguidas (la terminal, `dotrino-terminal lock`). No se decide aquí
|
|
@@ -2676,6 +2753,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
2676
2753
|
// el permiso se seguía sirviendo solo.
|
|
2677
2754
|
needsApproval: passwordsNeedApproval,
|
|
2678
2755
|
approve: approvePasswordRequest,
|
|
2756
|
+
onDelivered: (pub) => announceDelivered({ device: pub, ns: 'passwords', kind: 'passwords' }),
|
|
2679
2757
|
audit,
|
|
2680
2758
|
log,
|
|
2681
2759
|
}).start()
|
|
@@ -3019,6 +3097,14 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
3019
3097
|
for (const m of members) notify(m.pub)
|
|
3020
3098
|
for (const d of issued || []) notify(d.sub)
|
|
3021
3099
|
log(`[vault] notified ${seen.size} member(s) of "${ev}" (record #${acta?.seq ?? '?'})`)
|
|
3100
|
+
// Y SE DEJA EN LA CACHÉ DEL PROXIO (websocket-proxy ≥ 1.10.0): así un aparato que va
|
|
3101
|
+
// atrás se pone al día sin despertar a la bóveda (una ventana de Terminal esperaba 4-17 s
|
|
3102
|
+
// por esto, 2026-11-04). El proxio solo guarda; quien la toma la adopta si encadena.
|
|
3103
|
+
if (acta) {
|
|
3104
|
+
Promise.resolve().then(() => client.putActa(acta)).then(
|
|
3105
|
+
(r) => log(`[vault] record #${acta.seq} left on the proxy cache${r.stored ? '' : ' (it already had it)'}`),
|
|
3106
|
+
(e) => log(`[vault] could not leave record #${acta.seq} on the proxy cache: ${e.code || 'error'} · ${e.message}`))
|
|
3107
|
+
}
|
|
3022
3108
|
} catch (e) { log('[vault] could not notify members of the change:', e.message) }
|
|
3023
3109
|
// Y a los replicadores, que no quieren un aviso sino el CONTENIDO: sin esto se
|
|
3024
3110
|
// quedarían con el acta de ayer y repartiendo sobres de un aparato ya revocado.
|
|
@@ -3440,6 +3526,13 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
3440
3526
|
deviceIdOf,
|
|
3441
3527
|
audit,
|
|
3442
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
|
+
},
|
|
3443
3536
|
// Abrir a distancia. Va inyectado porque `admin.js` es puro y esto necesita cripto y
|
|
3444
3537
|
// disco; `null` si este perfil no lo soporta, y entonces la operación contesta que no.
|
|
3445
3538
|
unlockDesk,
|
|
@@ -4721,8 +4814,17 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
|
|
|
4721
4814
|
}
|
|
4722
4815
|
}
|
|
4723
4816
|
} catch (_) { /* comprobar es un extra: si falla, no rompe el cambio */ }
|
|
4724
|
-
|
|
4725
|
-
|
|
4817
|
+
// DISPOSITIVO O SERVICIO (`cn`, identity ≥ 0.135.0). Un pilar viejo ignora la clave y
|
|
4818
|
+
// sella el acta sin tocarlo: eso no es «listo», y se dice.
|
|
4819
|
+
for (const { pub, cn } of changes) {
|
|
4820
|
+
if (cn === undefined) continue
|
|
4821
|
+
const m = await memberOf(pub)
|
|
4822
|
+
if ((m?.cn ?? null) !== cn) {
|
|
4823
|
+
throw Object.assign(new Error(`the device is still ${m?.cn ? `the "${m.cn}" service` : 'a device'}: this build's @dotrino/identity cannot change it (needs 0.135.0)`), { code: 'cn-unavailable' })
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
const devices = await Promise.all(changes.map(async ({ pub, caps, cn }) => ({ deviceId: await deviceIdOf(pub).catch(() => null), caps, ...(cn !== undefined ? { service: cn } : {}) })))
|
|
4827
|
+
for (const d of devices) audit('caps', { device: d.deviceId, caps: d.caps, ...(d.service !== undefined ? { service: d.service } : {}) })
|
|
4726
4828
|
// El acta acaba de cambiar QUIÉN debe tener envoltura de qué: se repasa antes de
|
|
4727
4829
|
// avisar, para que el aviso salga con el llavero ya al día.
|
|
4728
4830
|
await refreshWraps('caps')
|