@dotrino/terminal-agent 0.2.10 → 0.2.12
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/bin/cli.js +4 -4
- package/link.js +17 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -34,9 +34,9 @@ datos en ${dataDir()} (override DOTRINO_TERMINAL_DIR)`)
|
|
|
34
34
|
|
|
35
35
|
async function doEnroll (dir) {
|
|
36
36
|
console.log('Enlazar esta máquina con tu vault.')
|
|
37
|
-
console.log('El código lo generas en
|
|
38
|
-
console.log(' · Sin vault externo → abre https://
|
|
39
|
-
console.log('
|
|
37
|
+
console.log('El código lo generas en tu bóveda. Hay dos formas:')
|
|
38
|
+
console.log(' · Sin vault externo → abre https://profile.dotrino.com/#myvault,')
|
|
39
|
+
console.log(' activa la bóveda y pulsa "Generar código de emparejamiento"; copia el código.')
|
|
40
40
|
console.log(' · Con vault en un PC → ahí corre `dotrino-vault pair` y copia el QR/JSON.\n')
|
|
41
41
|
const text = await ask('Pega el código y Enter:\n> ')
|
|
42
42
|
const qr = parseQr(text)
|
|
@@ -49,7 +49,7 @@ async function doEnroll (dir) {
|
|
|
49
49
|
console.log('\n Escribe ESTE código en tu bóveda para aprobar esta máquina:')
|
|
50
50
|
console.log(` código: ${code}`)
|
|
51
51
|
console.log(` máquina: ${deviceId}`)
|
|
52
|
-
console.log(' (en
|
|
52
|
+
console.log(' (en profile.dotrino.com/#myvault escríbelo en el campo y pulsa "Aprobar";')
|
|
53
53
|
console.log(` en el PC del vault: dotrino-vault approve ${code})\n`)
|
|
54
54
|
console.log(' Esperando aprobación…')
|
|
55
55
|
}
|
package/link.js
CHANGED
|
@@ -41,8 +41,24 @@ function saveLink (dir, link) {
|
|
|
41
41
|
fs.writeFileSync(linkPath(dir), JSON.stringify(link, null, 2), { mode: 0o600 })
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// Decodifica base64url a string UTF-8 (Node). El código copiable de la web
|
|
45
|
+
// (profile.dotrino.com/#myvault) viaja en base64url para no exponer iss/token/sn.
|
|
46
|
+
function b64urlDecode (s) {
|
|
47
|
+
s = String(s).replace(/-/g, '+').replace(/_/g, '/')
|
|
48
|
+
while (s.length % 4) s += '='
|
|
49
|
+
return Buffer.from(s, 'base64').toString('utf8')
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
export function parseQr (text) {
|
|
45
|
-
|
|
53
|
+
let s = String(text ?? '').trim()
|
|
54
|
+
const i = s.indexOf('#vault=')
|
|
55
|
+
if (i >= 0) s = s.slice(i + 7).trim() // profile.dotrino.com/#vault=…
|
|
56
|
+
if (!s.startsWith('{')) { // no es JSON crudo → probar base64url
|
|
57
|
+
const json = b64urlDecode(s)
|
|
58
|
+
if (json && json.trim().startsWith('{')) s = json
|
|
59
|
+
else throw new Error('código de emparejamiento inválido (se espera JSON o base64url)')
|
|
60
|
+
}
|
|
61
|
+
const qr = JSON.parse(s)
|
|
46
62
|
if (!qr?.iss || !qr?.proxy || !qr?.token || !qr?.sn) throw new Error('QR inválido (v2): faltan iss/proxy/token/sn')
|
|
47
63
|
return qr
|
|
48
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/terminal-agent",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Agente de Dotrino Terminal: abre una shell (PTY) en la máquina del vault solo para el dispositivo enlazado, vía @dotrino/tunnel y cifrado E2E.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|