@dotrino/remote-agent 0.21.0 → 0.22.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 -1
- package/src/browser-link.js +32 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/remote-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
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",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"./agent": "./src/agent.js",
|
|
10
10
|
"./client": "./src/client.js",
|
|
11
11
|
"./link": "./src/link.js",
|
|
12
|
+
"./browser-link": "./src/browser-link.js",
|
|
12
13
|
"./discover": "./src/discover.js",
|
|
13
14
|
"./node-globals": "./node-globals.js",
|
|
14
15
|
"./instances": "./src/instances.js"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* El enlace de un NAVEGADOR a su bóveda, sacado del pilar de identidad (iframe
|
|
3
|
+
* id.dotrino.com): es lo que necesita `RemoteAgentClient` para hablar con un agente.
|
|
4
|
+
* Antes lo armaba cada app por su cuenta (terminal, ia, eco, content-client).
|
|
5
|
+
*
|
|
6
|
+
* Sin repliegues: si la identidad no contesta, lanza. «No pude preguntar» no es «no
|
|
7
|
+
* estás emparejado», y quien llama tiene que poder distinguirlo.
|
|
8
|
+
*
|
|
9
|
+
* @param {any} id una instancia de `Identity` (`@dotrino/identity`)
|
|
10
|
+
* @returns {Promise<{ paired: false, id: any, expired?: boolean, exp?: number }
|
|
11
|
+
* | { paired: true, id: any, cert: any, iss: string, proxy: string, deviceId: string, scope: string[] }>}
|
|
12
|
+
*/
|
|
13
|
+
export async function linkFromIdentity (id) {
|
|
14
|
+
if (!id) throw Object.assign(new Error('linkFromIdentity: no identity'), { code: 'no-identity' })
|
|
15
|
+
const status = await id.vaultStatus()
|
|
16
|
+
if (!status?.paired) return { paired: false, id }
|
|
17
|
+
// Cert vencido = la bóveda rechazará todo: no emparejado, y se dice para volver a enlazar.
|
|
18
|
+
if (status.exp && status.exp <= Date.now()) return { paired: false, expired: true, exp: status.exp, id }
|
|
19
|
+
const v = await id.getVaultCert()
|
|
20
|
+
if (!v?.cert) return { paired: false, id }
|
|
21
|
+
return {
|
|
22
|
+
paired: true,
|
|
23
|
+
id,
|
|
24
|
+
cert: v.cert,
|
|
25
|
+
iss: status.master,
|
|
26
|
+
proxy: status.proxy || 'wss://proxy.dotrino.com',
|
|
27
|
+
deviceId: status.deviceId,
|
|
28
|
+
scope: status.scope || []
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default { linkFromIdentity }
|