@dotrino/remote-agent 0.9.0 → 0.9.1
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 +1 -1
- package/src/client.js +31 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/remote-agent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Middleware compartido del ecosistema Dotrino para apps de agente remoto cifrado punto a punto (handshake E2E, emparejamiento SAS con vault, revocación, descubrimiento). Lo consumen dotrino-terminal (PTY) y dotrino-ia (chat con IA).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
package/src/client.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* `on('message', cb)` recibe los payloads del agente, ya descifrados.
|
|
22
22
|
*/
|
|
23
23
|
import { verifyChain } from '@dotrino/identity/capabilities'
|
|
24
|
+
import { sealersOf } from '@dotrino/identity/acta'
|
|
24
25
|
import { makeEphemeral, deriveKey, seal, open } from '../e2e.js'
|
|
25
26
|
import { HS, ACK, DATA, PING, PONG, ERROR } from '../protocol.js'
|
|
26
27
|
|
|
@@ -52,6 +53,23 @@ export class RemoteAgentClient {
|
|
|
52
53
|
|
|
53
54
|
_emit (ev, ...args) { for (const h of (this._h[ev] || [])) { try { h(...args) } catch (_) {} } }
|
|
54
55
|
|
|
56
|
+
/**
|
|
57
|
+
* El acta con la que se juzga el papel del agente. Se pide UNA vez por cliente y se
|
|
58
|
+
* guarda: es la política vigente del perfil, no cambia a mitad de una sesión.
|
|
59
|
+
*
|
|
60
|
+
* Si no se puede traer, se devuelve `null` a propósito y `verifyChain` corta con
|
|
61
|
+
* `no-acta`. No hay repliegue: sin acta no hay con qué decidir, y no decidir es que no.
|
|
62
|
+
*/
|
|
63
|
+
async _acta () {
|
|
64
|
+
if (this._actaCache !== undefined) return this._actaCache
|
|
65
|
+
let acta = this.link.acta || null
|
|
66
|
+
if (!acta) {
|
|
67
|
+
try { acta = (await this.link.id?.listVaultDevices?.())?.acta || null } catch (_) { acta = null }
|
|
68
|
+
}
|
|
69
|
+
this._actaCache = acta
|
|
70
|
+
return acta
|
|
71
|
+
}
|
|
72
|
+
|
|
55
73
|
async _identify () {
|
|
56
74
|
// En modo self NO identificamos esta conexión como P: el proxy enruta por token
|
|
57
75
|
// las respuestas del agente (no por pubkey), y así no recibimos el fan-out de
|
|
@@ -115,7 +133,19 @@ export class RemoteAgentClient {
|
|
|
115
133
|
|
|
116
134
|
// El ack debe: (1) encadenar a NUESTRA maestra, (2) estar firmado por el agente
|
|
117
135
|
// que apuntamos, (3) atar nuestra pub efímera y el sid.
|
|
118
|
-
|
|
136
|
+
//
|
|
137
|
+
// CON EL ACTA, o no se juzga. Desde que el papel no vence, `verifyChain` necesita el
|
|
138
|
+
// `seq` del acta y su lista de SELLADORAS: sin eso no puede decir si quien firmó el
|
|
139
|
+
// papel del agente podía hacerlo, y contesta `no-acta` — que es lo correcto, porque
|
|
140
|
+
// decir «vale» sin haber comprobado nada es como entraba un papel viejo. Aquí no se le
|
|
141
|
+
// pasaba: el lado del agente sí lo hacía (`contextoActa`) y este lado se quedó atrás,
|
|
142
|
+
// así que TODA sesión moría con «el agente no está certificado por tu vault: no-acta».
|
|
143
|
+
// `clientLink` no trae el acta, así que se le pide a la bóveda una vez y se guarda.
|
|
144
|
+
const acta = await this._acta()
|
|
145
|
+
const chk = await verifyChain({
|
|
146
|
+
data: res.ack, signature: res.signature, cert: res.cert, trustedIssuer: this.link.iss,
|
|
147
|
+
actaSeq: acta?.seq ?? null, sealers: acta ? sealersOf(acta) : null
|
|
148
|
+
})
|
|
119
149
|
if (!chk.ok) throw new Error('el agente no está certificado por tu vault: ' + chk.reason)
|
|
120
150
|
if (res.ack.machine !== this.agentPubkey) throw new Error('el ack vino de otro agente')
|
|
121
151
|
if (res.ack.ceph !== eph.pub || res.ack.sid !== res.sid) throw new Error('ack no corresponde a este handshake')
|