@dotrino/remote-agent 0.34.0 → 0.35.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/README.md +1 -1
- package/package.json +1 -1
- package/src/link.js +44 -1
- package/types/src/link.d.ts +19 -0
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ Provee lo común — y **solo** eso:
|
|
|
38
38
|
| `@dotrino/remote-agent` | isomórfico | `e2e` (`makeEphemeral`/`deriveKey`/`seal`/`open`) + constantes de protocolo |
|
|
39
39
|
| `@dotrino/remote-agent/agent` | Node | `startRemoteAgent(opts)` |
|
|
40
40
|
| `@dotrino/remote-agent/client` | navegador | `RemoteAgentClient` |
|
|
41
|
-
| `@dotrino/remote-agent/link` | Node | `enroll`, `selfLink`, `isSelfLink`, `loadLink`, `saveLink`, `dataDir`, `parseQr`, `identityFromLink`, `clientLink`, `renewLink` |
|
|
41
|
+
| `@dotrino/remote-agent/link` | Node | `enroll`, `enrollInteractive` (pregunta la invitación en la terminal, 0.35.0), `selfLink`, `isSelfLink`, `loadLink`, `saveLink`, `dataDir`, `parseQr`, `identityFromLink`, `clientLink`, `renewLink` |
|
|
42
42
|
| `@dotrino/remote-agent/discover` | navegador | `listAgentsByLabel`, `probeAgents` |
|
|
43
43
|
| `@dotrino/remote-agent/instances` | Node | `resolveInstance`, `listInstances`, `lockInstance`, `instancesRoot` |
|
|
44
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/remote-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.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",
|
package/src/link.js
CHANGED
|
@@ -179,6 +179,49 @@ export async function enroll ({ qr, label = 'remote-agent', dir = dataDir(), ns
|
|
|
179
179
|
return link
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
/**
|
|
183
|
+
* ENLAZAR PREGUNTANDO EN LA TERMINAL: pide la invitación de `dotrino-vault pair`, la canjea y,
|
|
184
|
+
* mientras espera, enseña el código que hay que aprobar en la bóveda. Es lo que corre un agente
|
|
185
|
+
* la primera vez (`dotrino-terminal-agent`, `dotrino-remote-desktop-agent`): antes cada uno
|
|
186
|
+
* traía su copia. La copy de la terminal va en español, como la de los comandos que la usan.
|
|
187
|
+
*
|
|
188
|
+
* Lanza `no-tty` sin terminal delante (un servicio): enlazar necesita a alguien que pegue la
|
|
189
|
+
* invitación y apruebe el código.
|
|
190
|
+
*
|
|
191
|
+
* @param {{ dir: string, label: string, input?: NodeJS.ReadableStream, output?: NodeJS.WritableStream }} opts
|
|
192
|
+
* @returns {Promise<AgentLink>}
|
|
193
|
+
*/
|
|
194
|
+
export async function enrollInteractive ({ dir, label, input = process.stdin, output = process.stdout }) {
|
|
195
|
+
if (!(/** @type {any} */ (input)).isTTY && input === process.stdin) {
|
|
196
|
+
throw Object.assign(new Error('this machine is not linked, and linking needs an interactive terminal. Run it once in a terminal, then start it as a service.'), { code: 'no-tty' })
|
|
197
|
+
}
|
|
198
|
+
const say = (/** @type {string} */ t) => { output.write(t + '\n') }
|
|
199
|
+
const readline = await import('node:readline')
|
|
200
|
+
/** @param {string} q @returns {Promise<string>} */
|
|
201
|
+
const ask = (q) => {
|
|
202
|
+
const rl = readline.createInterface({ input, output })
|
|
203
|
+
return new Promise((resolve) => rl.question(q, (a) => { rl.close(); resolve(a) }))
|
|
204
|
+
}
|
|
205
|
+
say('Enlazar esta máquina con tu bóveda.')
|
|
206
|
+
say('En el PC de tu bóveda corre `dotrino-vault pair` y copia la invitación.\n')
|
|
207
|
+
const qr = await parseQr(await ask('Pega la invitación y pulsa Enter:\n> '))
|
|
208
|
+
say('\nConectando…')
|
|
209
|
+
const link = await enroll({
|
|
210
|
+
qr,
|
|
211
|
+
dir,
|
|
212
|
+
label,
|
|
213
|
+
onChallenge: ({ deviceId, code }) => {
|
|
214
|
+
say('\n Escribe ESTE código en tu bóveda para aprobar esta máquina:')
|
|
215
|
+
say(` código: ${code}`)
|
|
216
|
+
say(` máquina: ${deviceId}`)
|
|
217
|
+
say(` (en el PC de la bóveda: dotrino-vault approve ${code})\n`)
|
|
218
|
+
say(' Esperando la aprobación…')
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
say('\n ✓ Máquina enlazada.\n')
|
|
222
|
+
return link
|
|
223
|
+
}
|
|
224
|
+
|
|
182
225
|
/**
|
|
183
226
|
* UNA IDENTIDAD PROPIA, SIN BÓVEDA. El aparato cumple el rol cuando no hay pieza dedicada:
|
|
184
227
|
* crea sus llaves (firma y cifrado) y un acta de génesis autofirmada donde él es el único
|
|
@@ -449,4 +492,4 @@ export function clientLink (link, opts) {
|
|
|
449
492
|
return { id: identityFromLink(link, opts), cert: link.cert, iss: link.iss, proxy: link.proxy || DEFAULT_PROXY }
|
|
450
493
|
}
|
|
451
494
|
|
|
452
|
-
export default { dataDir, loadLink, saveLink, parseQr, enroll, selfLink, isSelfLink, identityFromLink, clientLink, renewLink, renewalReason, storeRenewedCert, refreshChain }
|
|
495
|
+
export default { dataDir, loadLink, saveLink, parseQr, enroll, enrollInteractive, selfLink, isSelfLink, identityFromLink, clientLink, renewLink, renewalReason, storeRenewedCert, refreshChain }
|
package/types/src/link.d.ts
CHANGED
|
@@ -88,6 +88,24 @@ export function enroll({ qr, label, dir, ns, onChallenge, timeoutMs }?: {
|
|
|
88
88
|
}) => void) | undefined;
|
|
89
89
|
timeoutMs?: number | undefined;
|
|
90
90
|
}): Promise<AgentLink>;
|
|
91
|
+
/**
|
|
92
|
+
* ENLAZAR PREGUNTANDO EN LA TERMINAL: pide la invitación de `dotrino-vault pair`, la canjea y,
|
|
93
|
+
* mientras espera, enseña el código que hay que aprobar en la bóveda. Es lo que corre un agente
|
|
94
|
+
* la primera vez (`dotrino-terminal-agent`, `dotrino-remote-desktop-agent`): antes cada uno
|
|
95
|
+
* traía su copia. La copy de la terminal va en español, como la de los comandos que la usan.
|
|
96
|
+
*
|
|
97
|
+
* Lanza `no-tty` sin terminal delante (un servicio): enlazar necesita a alguien que pegue la
|
|
98
|
+
* invitación y apruebe el código.
|
|
99
|
+
*
|
|
100
|
+
* @param {{ dir: string, label: string, input?: NodeJS.ReadableStream, output?: NodeJS.WritableStream }} opts
|
|
101
|
+
* @returns {Promise<AgentLink>}
|
|
102
|
+
*/
|
|
103
|
+
export function enrollInteractive({ dir, label, input, output }: {
|
|
104
|
+
dir: string;
|
|
105
|
+
label: string;
|
|
106
|
+
input?: NodeJS.ReadableStream;
|
|
107
|
+
output?: NodeJS.WritableStream;
|
|
108
|
+
}): Promise<AgentLink>;
|
|
91
109
|
/**
|
|
92
110
|
* UNA IDENTIDAD PROPIA, SIN BÓVEDA. El aparato cumple el rol cuando no hay pieza dedicada:
|
|
93
111
|
* crea sus llaves (firma y cifrado) y un acta de génesis autofirmada donde él es el único
|
|
@@ -220,6 +238,7 @@ declare namespace _default {
|
|
|
220
238
|
export { saveLink };
|
|
221
239
|
export { parseQr };
|
|
222
240
|
export { enroll };
|
|
241
|
+
export { enrollInteractive };
|
|
223
242
|
export { selfLink };
|
|
224
243
|
export { isSelfLink };
|
|
225
244
|
export { identityFromLink };
|