@dotrino/vault 0.60.2 → 0.60.4

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/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
@@ -121,7 +121,7 @@ function etiquetaBoveda ({ exigida = false } = {}) {
121
121
  async function cmdEnroll () {
122
122
  const ns = flag('ns')
123
123
  if (!ns) { console.error('falta --ns <ns> (el mismo del `dotrino-vault pair --service <ns>`)'); process.exit(2) }
124
- const qr = parseInvite((flag('qr') || flag('code')) || await readInvite())
124
+ let qr = parseInvite((flag('qr') || flag('code')) || await readInvite())
125
125
  // SIN `--vault`, SE LO PREGUNTA A LA BÓVEDA (dueño, 2026-09-03: «en el enroll si no se
126
126
  // pone vault debería usar el nombre del perfil»). Al enrolar ya sabes contra qué bóveda
127
127
  // vas —la invitación lo dice, o ella lo contesta—, así que pedir la etiqueta era hacer
@@ -132,8 +132,12 @@ async function cmdEnroll () {
132
132
  // sale nada utilizable, se pide — no se inventa un nombre.
133
133
  let boveda = etiquetaBoveda()
134
134
  if (!boveda) {
135
- const { vaultAccountName } = await import('../src/service.js')
136
- const nombre = await vaultAccountName(qr).catch(() => '')
135
+ const { vaultHello } = await import('../src/service.js')
136
+ // Se REUSA el qr que vuelve del hello: la cita se quema al canjearla, así que
137
+ // preguntar el nombre y después enrolar con el qr original gastaba la invitación
138
+ // en la pregunta y dejaba al enrolamiento sin nada que canjear.
139
+ qr = await vaultHello(qr).catch(() => qr)
140
+ const nombre = qr.acct || ''
137
141
  boveda = String(nombre || '').toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 32)
138
142
  if (!boveda) {
139
143
  console.error('esa bóveda no dice cómo se llama su cuenta: dime tú la etiqueta')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/vault",
3
- "version": "0.60.2",
3
+ "version": "0.60.4",
4
4
  "description": "Usa ESTE dispositivo (navegador) como bóveda/CA del ecosistema Dotrino: atiende enrolamientos por el proxy y firma certificados de delegación a tus máquinas. Incluye el cliente de SERVICIO (Node): un proyecto se enrola una vez y jala sus credenciales del vault en vez del .env (`import '@dotrino/vault/config'`).",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/admin.js CHANGED
File without changes
package/src/atrest.js CHANGED
File without changes
package/src/config.js CHANGED
File without changes
package/src/enroll.js CHANGED
File without changes
package/src/env.js CHANGED
File without changes
package/src/envtext.js CHANGED
File without changes
package/src/index.js CHANGED
File without changes
package/src/invite.js CHANGED
File without changes
package/src/kek.js CHANGED
File without changes
package/src/localdesk.js CHANGED
File without changes
package/src/lock.js CHANGED
File without changes
package/src/protocol.js CHANGED
File without changes
package/src/revocation.js CHANGED
File without changes
package/src/sealed.js CHANGED
File without changes
package/src/service.js CHANGED
@@ -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/src/sshAgent.js CHANGED
File without changes
package/src/sshKeys.js CHANGED
File without changes