@dotrino/terminal-agent 0.2.9 → 0.2.11
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/link.js +17 -1
- package/package.json +2 -2
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.11",
|
|
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": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@dotrino/identity": "0.17.0",
|
|
17
17
|
"@dotrino/proxy-client": "0.6.4",
|
|
18
|
-
"@homebridge/node-pty-prebuilt-multiarch": "0.
|
|
18
|
+
"@homebridge/node-pty-prebuilt-multiarch": "0.14.1-beta.2",
|
|
19
19
|
"ws": "8.21.0"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT"
|