@dotrino/vaultd 0.105.1 → 0.105.2

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.
Files changed (2) hide show
  1. package/lib/src/service.js +24 -4
  2. package/package.json +3 -2
@@ -302,14 +302,34 @@ export async function sayHello (client, qr) {
302
302
  }
303
303
 
304
304
  /**
305
- * Cómo se llama la cuenta de esa invitación, sin enrolar nada. Una conexión y una pregunta.
305
+ * El hello de esa invitación, sin enrolar nada: devuelve el `qr` ENRIQUECIDO con
306
+ * `iss`, `proxy` y `acct`.
307
+ *
308
+ * Devuelve el qr y no solo el nombre PORQUE LA CITA SE QUEMA AL CANJEARLA. Quien
309
+ * pregunta el nombre de la cuenta y después enrola estaría canjeando dos veces la
310
+ * misma cita, y el segundo canje falla con «código no válido o ya usado» — un error
311
+ * que señala a la invitación cuando el problema es haberla gastado uno mismo.
312
+ * Con el qr enriquecido, `sayHello` corta por su `if (qr.iss) return qr` y el
313
+ * enrolamiento no vuelve a salir a preguntar.
306
314
  */
307
- export async function vaultAccountName (qr) {
315
+ export async function vaultHello (qr) {
308
316
  if (typeof qr === 'string') qr = parseInvite(qr)
309
317
  if (!qr?.sn) throw new Error('that does not look like a vault invitation')
310
- if (qr.acct) return qr.acct
318
+ if (qr.iss) return qr
311
319
  const client = await freshClient(qr.proxy || 'wss://proxy.dotrino.com')
312
- try { return (await sayHello(client, qr)).acct || '' } finally { try { client.close() } catch (_) {} }
320
+ try { return await sayHello(client, qr) } finally { try { client.close() } catch (_) {} }
321
+ }
322
+
323
+ /**
324
+ * Cómo se llama la cuenta de esa invitación, sin enrolar nada.
325
+ *
326
+ * OJO: gasta la cita. Si además vas a enrolar, usá `vaultHello` y pasale al enroll el
327
+ * qr que devuelve; si no, el enrolamiento se encuentra la cita quemada.
328
+ */
329
+ export async function vaultAccountName (qr) {
330
+ if (typeof qr === 'string') qr = parseInvite(qr)
331
+ if (qr?.acct) return qr.acct
332
+ return (await vaultHello(qr)).acct || ''
313
333
  }
314
334
 
315
335
  export async function enrollWithVault ({ qr, label = 'agent', expectedScope = null, onCode, approveTimeoutMs = 180000, withEncKey = true } = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/vaultd",
3
- "version": "0.105.1",
3
+ "version": "0.105.2",
4
4
  "type": "module",
5
5
  "description": "Certificador personal de Dotrino: daemon headless que custodia la clave maestra y delega capacidades a tus dispositivos por el proxy. Tu CA propia.",
6
6
  "bin": {
@@ -14,7 +14,8 @@
14
14
  "pair": "node bin/dotrino-vaultd.js --pair",
15
15
  "tui": "node bin/dotrino-vault-tui.js",
16
16
  "test": "node --test test/*.test.mjs",
17
- "type-check": "tsc --noEmit"
17
+ "type-check": "tsc --noEmit",
18
+ "release:env": "node packaging/release-env.mjs"
18
19
  },
19
20
  "engines": {
20
21
  "node": ">=20"