@dotrino/identity 0.102.0 → 0.102.1
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/package.json +1 -1
- package/vault/remote.js +6 -3
package/package.json
CHANGED
package/vault/remote.js
CHANGED
|
@@ -128,7 +128,7 @@ async function askVault (client, qr) {
|
|
|
128
128
|
* @param {(c:{deviceId:string, code:string})=>void} [opts.onChallenge] Para mostrar el código a tipear en el PC.
|
|
129
129
|
* @param {string} [opts.label]
|
|
130
130
|
* @param {number} [opts.approveTimeoutMs] Espera de la aprobación humana (def 3 min).
|
|
131
|
-
* @returns {Promise<{device, cert, master:string, proxy:string, deviceId:string}>}
|
|
131
|
+
* @returns {Promise<{device, cert, master:string, proxy:string, deviceId:string, account:string}>}
|
|
132
132
|
*/
|
|
133
133
|
export async function enrollDevice ({ qr, device, onChallenge, label = '', continuity = null, encPub = null, approveTimeoutMs = 180000, intent = 'join', profileId = null, onAdopt = null } = {}) {
|
|
134
134
|
if (!qr?.sn || !(qr.iss || qr.conn)) throw new Error('invalid qr: missing vault or nonce')
|
|
@@ -206,7 +206,7 @@ export async function enrollDevice ({ qr, device, onChallenge, label = '', conti
|
|
|
206
206
|
if (adopting) {
|
|
207
207
|
if (!res.acta) throw new Error('the vault did not return the adopted record')
|
|
208
208
|
if (res.acta.sealer !== qr.iss) throw new Error('the record is sealed by a vault other than the one you saw')
|
|
209
|
-
return { device: dev, cert: null, master: qr.iss, proxy: qr.proxy, deviceId, acta: res.acta, adopted: true }
|
|
209
|
+
return { device: dev, cert: null, master: qr.iss, proxy: qr.proxy, deviceId, acta: res.acta, adopted: true, account: qr.acct || '' }
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
// Validación estricta antes de guardar (cierra inyección de cert / sustitución de maestra).
|
|
@@ -225,7 +225,10 @@ export async function enrollDevice ({ qr, device, onChallenge, label = '', conti
|
|
|
225
225
|
// emparejaba con una segunda bóveda o con una que adoptó la cuenta (`checkVaultReply`).
|
|
226
226
|
const chk = await checkVaultReply({ acta: res.acta, cert: res.cert, vault: qr.iss, sub: dev.publickey, justSealed: true })
|
|
227
227
|
if (!chk.ok) throw new Error('the vault reply does not check out: ' + chk.reason)
|
|
228
|
-
|
|
228
|
+
// `account`: el nombre que la bóveda dio a la cuenta. Con la invitación corta no viene en
|
|
229
|
+
// el QR sino en el `hello`, así que solo lo sabe esto — y sin él, quien tiene varias
|
|
230
|
+
// cuentas en un aparato no sabe de cuál es cada cosa.
|
|
231
|
+
return { device: dev, cert: res.cert, master: qr.iss, proxy: qr.proxy, deviceId, acta: res.acta || null, account: qr.acct || '' }
|
|
229
232
|
} finally { try { client.close() } catch (_) {} }
|
|
230
233
|
}
|
|
231
234
|
|