@dotrino/remote-agent 0.22.1 → 0.22.3
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 +3 -3
- package/src/agent.js +6 -6
- package/src/client.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/remote-agent",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.3",
|
|
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",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"p2p"
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@dotrino/identity": ">=0.
|
|
50
|
+
"@dotrino/identity": ">=0.121.4",
|
|
51
51
|
"@dotrino/proxy-client": ">=0.36.1",
|
|
52
52
|
"@dotrino/vault": ">=0.85.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@dotrino/identity": "0.
|
|
55
|
+
"@dotrino/identity": "0.121.4",
|
|
56
56
|
"@dotrino/proxy-client": "0.36.2",
|
|
57
57
|
"@dotrino/vault": "0.90.2"
|
|
58
58
|
}
|
package/src/agent.js
CHANGED
|
@@ -312,7 +312,7 @@ export async function startRemoteAgent (opts = {}) {
|
|
|
312
312
|
if (typeof acta?.seq !== 'number') return
|
|
313
313
|
const r = await adoptRecord({ link, candidate: acta, me: myPub })
|
|
314
314
|
if (!r.adopt) {
|
|
315
|
-
if (r.reason !== '
|
|
315
|
+
if (r.reason !== 'same-record') {
|
|
316
316
|
audit('record-rejected', { seq: acta.seq, reason: r.reason })
|
|
317
317
|
if (!opts.quiet) console.error(`[remote-agent] record #${acta.seq} rejected (${r.reason}); keeping the one already trusted`)
|
|
318
318
|
}
|
|
@@ -366,7 +366,7 @@ export async function startRemoteAgent (opts = {}) {
|
|
|
366
366
|
// no por eso se le pregunta a la bóveda cada vez.
|
|
367
367
|
const judge = async () => {
|
|
368
368
|
const chk = await verifyChain({ data, signature, cert, expectedScope: SIGN_SCOPE, ...actaContext(), revoked: revokedSet })
|
|
369
|
-
if (!chk.ok) return {
|
|
369
|
+
if (!chk.ok) return { code: 'unauthorized', reason: chk.reason, error: 'unauthorized: ' + chk.reason }
|
|
370
370
|
return { chk }
|
|
371
371
|
}
|
|
372
372
|
let verdict = await judge()
|
|
@@ -375,7 +375,7 @@ export async function startRemoteAgent (opts = {}) {
|
|
|
375
375
|
return !!acta && (acta.members || []).some((m) => m?.pub === v.chk.device) && memberCan(acta, v.chk.device, 'sign')
|
|
376
376
|
}
|
|
377
377
|
if ((verdict.error || !known(verdict)) && await catchUp()) verdict = await judge()
|
|
378
|
-
if (verdict.error) return send(from, { type: ERROR, error: verdict.error })
|
|
378
|
+
if (verdict.error) return send(from, { type: ERROR, code: verdict.code, reason: verdict.reason, error: verdict.error })
|
|
379
379
|
const chk = verdict.chk
|
|
380
380
|
// CERT ∩ ACTA. `verifyChain` comprueba QUIÉN EMITIÓ el papel; que el APARATO siga siendo
|
|
381
381
|
// isMember y pueda firmar lo dice el acta, y hay que preguntárselo aparte. Sin esto, un
|
|
@@ -394,13 +394,13 @@ export async function startRemoteAgent (opts = {}) {
|
|
|
394
394
|
const acta = trustedActa()
|
|
395
395
|
const isMember = (acta?.members || []).some((m) => m?.pub === chk.device)
|
|
396
396
|
if (!acta || !isMember || !memberCan(acta, chk.device, 'sign')) {
|
|
397
|
-
return send(from, { type: ERROR,
|
|
397
|
+
return send(from, { type: ERROR, code: 'unauthorized', reason: 'not-in-record', error: 'unauthorized: not-in-record' })
|
|
398
398
|
}
|
|
399
399
|
// BLOQUEADO por un aprobador: está en el acta y su papel vale, y aun así no entra. Se le
|
|
400
400
|
// dice con su código, que no es lo mismo que un papel viejo ni que una revocación.
|
|
401
401
|
if (blockedSet.has(chk.device)) {
|
|
402
402
|
audit('session-refused', { reason: 'blocked', device: (await pubkeyId(chk.device)).slice(0, 8).toUpperCase() })
|
|
403
|
-
return send(from, { type: ERROR, code: 'blocked',
|
|
403
|
+
return send(from, { type: ERROR, code: 'blocked', reason: 'blocked', error: 'unauthorized: blocked' })
|
|
404
404
|
}
|
|
405
405
|
if (data.op !== HS || typeof data.eph !== 'string') return send(from, { type: ERROR, error: 'invalid handshake' })
|
|
406
406
|
|
|
@@ -502,7 +502,7 @@ export async function startRemoteAgent (opts = {}) {
|
|
|
502
502
|
})
|
|
503
503
|
|
|
504
504
|
if (!opts.quiet) {
|
|
505
|
-
console.log(`[remote-agent]
|
|
505
|
+
console.log(`[remote-agent] agent running · machine ${myId} · vault ${(await pubkeyId(master)).slice(0, 16)} · proxy ${proxyUrl}`)
|
|
506
506
|
}
|
|
507
507
|
if (opts.onReady) { try { opts.onReady({ machine: myPub, machineId: myId, master }) } catch (_) {} }
|
|
508
508
|
|
package/src/client.js
CHANGED
|
@@ -139,7 +139,7 @@ export class RemoteAgentClient {
|
|
|
139
139
|
* de antes de volver a saludar) no dice nada nuevo y se ignora.
|
|
140
140
|
*/
|
|
141
141
|
_onAgentError (p) {
|
|
142
|
-
if (p.code !== 'unknown-session') { this._emit('error', Object.assign(new Error(p.error), { code: p.code })); return }
|
|
142
|
+
if (p.code !== 'unknown-session') { this._emit('error', Object.assign(new Error(p.error), { code: p.code, reason: p.reason })); return }
|
|
143
143
|
if (p.sid !== this.sid) return
|
|
144
144
|
this._resume()
|
|
145
145
|
}
|
|
@@ -177,7 +177,7 @@ export class RemoteAgentClient {
|
|
|
177
177
|
// El token se apunta AQUÍ, en el mismo tic: si el agente es quien abre el canal
|
|
178
178
|
// directo, su oferta llega justo detrás del ack y tiene que encontrarlo ya.
|
|
179
179
|
if (p.type === ACK && p.ack && p.ack.ceph === eph.pub) { off(); if (from) this._directPeers.add(from); resolve({ ...p, from }) }
|
|
180
|
-
else if (p.type === ERROR) { off(); reject(new Error(p.error)) }
|
|
180
|
+
else if (p.type === ERROR) { off(); reject(Object.assign(new Error(p.error), { code: p.code, reason: p.reason })) }
|
|
181
181
|
})
|
|
182
182
|
setTimeout(() => { off(); reject(new Error('the agent did not reply (is it running there?)')) }, 20000)
|
|
183
183
|
})
|