@dotrino/identity 0.123.0 → 0.125.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/identity",
3
- "version": "0.123.0",
3
+ "version": "0.125.0",
4
4
  "description": "Identidad y rating de usuarios compartidos entre apps de Dotrino (vault iframe + postMessage)",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -431,10 +431,10 @@ export class Identity {
431
431
  * está emparejada con esa misma bóveda. Si no, falla antes de tocar la red.
432
432
  * @returns {Promise<{ ok:boolean, deviceId:string, master:string, exp:number, scope:string[] }>}
433
433
  */
434
- async enrollDevice (qr, { label = '', join = 'current' } = {}) {
434
+ async enrollDevice (qr, { label = '', join = 'current', account = null } = {}) {
435
435
  // DÓNDE CORRE se mira AQUÍ, en la página, y no dentro del iframe: el iframe no ve si la
436
436
  // página es una extensión o la app nativa (`vault/machine.js`).
437
- return this._call('vaultPair', { qr, label, join, machine: browserMachine() }, 200000)
437
+ return this._call('vaultPair', { qr, label, join, account, machine: browserMachine() }, 200000)
438
438
  }
439
439
 
440
440
  /** Estado de emparejamiento: { paired, deviceId?, master?, scope?, exp?, pairedAt? }. */
@@ -474,9 +474,12 @@ export class Identity {
474
474
  * Requiere que el cert de este aparato lleve `vault:admin`, que **no se recibe al
475
475
  * emparejar**: se concede a mano en la bóveda. Cambiar permisos y traspasar el mando
476
476
  * NO se administran a distancia — siguen siendo del master, en su máquina.
477
+ *
478
+ * `args.to`: la llave de comunicación de UNA bóveda de la cuenta (`vault` en el acta), para
479
+ * hablarle a esa y no a la que conteste primero. Espera más: una alojada dormida tarda.
477
480
  */
478
481
  async vaultAdmin (op, args) {
479
- return this._call('vaultAdmin', { op, ...(args || {}) }, 20000)
482
+ return this._call('vaultAdmin', { op, ...(args || {}) }, args?.to ? 50000 : 20000)
480
483
  }
481
484
 
482
485
  /**
package/vault/acta.js CHANGED
@@ -35,7 +35,7 @@
35
35
  * Módulo PURO: sin kv, sin red, sin disco. Cripto de `./capabilities.js`.
36
36
  */
37
37
  import { canonicalStringify } from './core.js'
38
- import { signWithDevice, verifyDeviceSig, verifyDelegation, keyLabel } from './capabilities.js'
38
+ import { signWithDevice, verifyDeviceSig, verifyDelegation, keyLabel, pubkeyId } from './capabilities.js'
39
39
  import { cleanMachine } from './machine.js'
40
40
  export { cleanMachine }
41
41
 
@@ -215,6 +215,12 @@ export const CAP_SCOPE = Object.freeze({ sign: 'vault:sign', store: 'vault:store
215
215
  const enc = (s) => new TextEncoder().encode(s)
216
216
  const hex = (buf) => [...new Uint8Array(buf)].map((b) => b.toString(16).padStart(2, '0')).join('')
217
217
  const isPub = (v) => typeof v === 'string' && v.length > 0
218
+ /** La maestra de la que es una llave de comunicación; solo la del `cn` de la bóveda la lleva. */
219
+ const vaultOfComm = (cn, vault) => {
220
+ if (cn !== VAULT_CN) throw new Error('vault: only the vault communication key says which vault it is')
221
+ if (!isPub(vault)) throw new Error('vault: missing the vault master pubkey')
222
+ return vault
223
+ }
218
224
 
219
225
  /**
220
226
  * La llave de CIFRADO de un miembro (`encPub`): JWK público de una ECDH P-256.
@@ -517,6 +523,9 @@ export function checkShape (acta) {
517
523
  // arrancar en vez de avisar. Primero los servicios registran su llave (op
518
524
  // `encpub`), y cuando no quede ninguno sin ella se aprieta aquí.
519
525
  if (m.encPub != null && !isEncPub(m.encPub)) return 'invalid-encpub'
526
+ // DE QUÉ BÓVEDA ES una llave de comunicación (`vault`: la maestra por la que habla). Solo
527
+ // la lleva un miembro con el `cn` de la bóveda: en cualquier otro no significa nada.
528
+ if (m.vault != null && (!isPub(m.vault) || m.cn !== VAULT_CN)) return 'invalid-vault'
520
529
  }
521
530
  // LA LLAVE DE SELLADO Y SU REGISTRO. `sealPub` puede no estar (un perfil que no sella
522
531
  // secretos), pero si está tiene que decir DESDE QUÉ acta manda: sin `sealSince` no se
@@ -639,6 +648,22 @@ export async function verifySignedBy (args = {}) {
639
648
  return { ok: true, profileId: c.profileId, seq: c.seq, signer: publickey }
640
649
  }
641
650
 
651
+ /**
652
+ * ¿ESTA INVITACIÓN ES DE LA CUENTA QUE ESPERO? Para un aparato que solo puede entrar en una
653
+ * cuenta (la réplica o la bóveda alojadas, que van atadas a la cuenta que las pagó). El reto del
654
+ * alta trae la cadena de selladoras de la bóveda que invita: se verifica, se comprueba que quien
655
+ * contestó sella esa cuenta y se compara el id del perfil con el esperado (`pubkeyId`, 64 hex).
656
+ * Devuelve `null` si es la cuenta, o el porqué si no.
657
+ */
658
+ export async function accountMismatch (chain, iss, account) {
659
+ if (!Array.isArray(chain) || !chain.length) return 'the vault did not say which account it belongs to (it may need an update)'
660
+ const c = await verifySealerChain(chain)
661
+ if (!c.ok) return 'the vault account could not be verified: ' + c.reason
662
+ if (!canSeal(chain[chain.length - 1], iss)) return 'the vault that answered does not seal that account'
663
+ const got = await pubkeyId(c.profileId)
664
+ return got === account ? null : `the invitation is from account ${got}, not from ${account}`
665
+ }
666
+
642
667
  export async function verifySealerChain (chain, { expectedProfileId = null } = {}) {
643
668
  if (!Array.isArray(chain) || !chain.length) return { ok: false, reason: 'empty-chain' }
644
669
  const [raiz] = chain
@@ -818,10 +843,23 @@ export async function applyChanges (acta, changes, { by, now = Date.now(), sealP
818
843
  // Puente con la identidad que este miembro traía de antes (ver makeContinuity).
819
844
  ...(m.continuity ? { continuity: m.continuity } : {}),
820
845
  // DÓNDE CORRE (`machine.js`): lo que dijo al emparejar, para reconocerlo en la lista.
821
- ...(cleanMachine(m.machine) ? { machine: cleanMachine(m.machine) } : {})
846
+ ...(cleanMachine(m.machine) ? { machine: cleanMachine(m.machine) } : {}),
847
+ // DE QUÉ BÓVEDA ES, si es la llave de comunicación de una (ver op `vault`).
848
+ ...(m.vault != null ? { vault: vaultOfComm(cn, m.vault) } : {})
822
849
  })
823
850
  break
824
851
  }
852
+ // DE QUÉ BÓVEDA ES UNA LLAVE DE COMUNICACIÓN. Con dos bóvedas en la cuenta hay dos llaves
853
+ // `cn: 'vault'`, y sin esto nadie sabe a cuál escribirle para hablar con UNA de ellas: la
854
+ // consola elige bóveda y le escribe a su llave, que es la única que la alcanza sin pasar
855
+ // por las demás. La pone la propia bóveda al admitir su llave, o después, a una que entró
856
+ // antes de existir el campo.
857
+ case 'vault': {
858
+ const m = find(ch.pub)
859
+ if (!m) throw new Error('vault: that member is not in the record')
860
+ m.vault = vaultOfComm(m.cn, ch.vault)
861
+ break
862
+ }
825
863
  // Registra (o reemplaza) la llave de CIFRADO de un miembro que YA está admitido.
826
864
  //
827
865
  // Existe para no tener que expulsar y volver a admitir a un servicio solo porque
@@ -1307,7 +1345,7 @@ export async function canAdopt ({ candidate, current }) {
1307
1345
  }
1308
1346
 
1309
1347
  export default {
1310
- ACTA_V, CAPS, CAP_SCOPE, genesisActa, actaBody, actaHash, memberId, checkShape, verifySealerChain, verifySignedBy,
1348
+ ACTA_V, CAPS, CAP_SCOPE, genesisActa, actaBody, actaHash, memberId, checkShape, verifySealerChain, accountMismatch, verifySignedBy,
1311
1349
  sealActa, verifyActa, checkVaultReply, applyChanges, makeRenounce, verifyRenounce,
1312
1350
  makeContinuity, verifyContinuity,
1313
1351
  cardBody, makeProfileCard, verifyProfileCard, canAdoptCard, sealersOf, canSeal,
package/vault/core.js CHANGED
@@ -804,6 +804,8 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
804
804
  * Lo pone quien levanta la bóveda (`setSelfVault`) y lo quita al pararla.
805
805
  */
806
806
  let selfLink = null
807
+ /** Lo que se espera a una bóveda elegida: una alojada dormida arranca antes de contestar. */
808
+ const VAULT_WAKE_MS = 45000
807
809
  let selfLinkOff = null
808
810
  /** El enlace con el que administrar: el emparejamiento si lo hay, y si no, la bóveda local. */
809
811
  const adminLink = () => {
@@ -1329,7 +1331,7 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
1329
1331
  * cert contra la bóveda y entra a su cuenta. Aparte para que la decisión de CUÁL cuenta y
1330
1332
  * el deshacerla si esto falla vivan juntos arriba, y aquí solo quede el trámite.
1331
1333
  */
1332
- async function pairWithVault ({ qr, label = '', machine = undefined }) {
1334
+ async function pairWithVault ({ qr, label = '', machine = undefined, account = null }) {
1333
1335
  // Usa la PROPIA llave de identidad de este navegador como dispositivo: el cert delega
1334
1336
  // TU identidad (P) desde la maestra M → una sola identidad (signData/identify/cert = P).
1335
1337
  // La privada es la CryptoKey del perfil (no extractable): se pasa como `privateKey`
@@ -1343,7 +1345,7 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
1343
1345
  const continuity = (mine && mine.members.length === 1 && !isPendingJoin())
1344
1346
  ? await Acta.makeContinuity({ member: publickeyJwkStr, from: mine.profileId, privateKey: masterKey() })
1345
1347
  : null
1346
- const res = await remoteEnroll({ qr, device, continuity, encPub: encPublickeyJwkStr, label: label || me?.nickname || '', machine: machine === undefined && pageMachine ? pageMachine : machine, onChallenge: (c) => emitVault({ phase: 'challenge', deviceId: c.deviceId, code: c.code }) })
1348
+ const res = await remoteEnroll({ qr, device, continuity, encPub: encPublickeyJwkStr, label: label || me?.nickname || '', machine: machine === undefined && pageMachine ? pageMachine : machine, account, onChallenge: (c) => emitVault({ phase: 'challenge', deviceId: c.deviceId, code: c.code }) })
1347
1349
  kv.setItem(VAULT_DEVICE_STORAGE, JSON.stringify({ useIdentityKey: true, publickey: publickeyJwkStr }))
1348
1350
  kv.setItem(VAULT_CERT_STORAGE, JSON.stringify({ cert: res.cert, master: res.master, proxy: res.proxy, deviceId: res.deviceId, pairedAt: Date.now() }))
1349
1351
  // Conectarse a una bóveda es ENTRAR A SU CUENTA: el acta viene con el cert.
@@ -2598,6 +2600,8 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
2598
2600
  addedAt: m.addedAt || null,
2599
2601
  // Dónde corre, según dijo al emparejarse (`machine.js`). `null` si entró antes.
2600
2602
  machine: m.machine || null,
2603
+ // Si es la llave de comunicación de una bóveda, la maestra de ESA bóveda.
2604
+ vault: m.vault || null,
2601
2605
  isMe: m.pub === publickeyJwkStr,
2602
2606
  isMaster: Acta.canSeal(acta, m.pub),
2603
2607
  // La llave de CIFRADO del miembro y, derivado, si se le puede envolver algo.
@@ -2643,7 +2647,7 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
2643
2647
  * Admite un miembro (solo el master). El cert lo emite quien llama, antes o después.
2644
2648
  * `continuity`: si esa identidad ya existía por su cuenta, su puente firmado (F3).
2645
2649
  */
2646
- async admitMember ({ pub, encPub = null, label = '', cn = null, caps = null, cert = null, continuity = null, machine = null } = {}) {
2650
+ async admitMember ({ pub, encPub = null, label = '', cn = null, caps = null, cert = null, continuity = null, machine = null, vault = null } = {}) {
2647
2651
  // `cn`: si viene, este miembro es un SERVICIO: abre el cajón de secretos de ESE nombre
2648
2652
  // por llevarlo, sin permiso aparte, y no ve nada más del usuario. Sin `cn` es un dispositivo.
2649
2653
  const finales = caps || (cn ? [] : ['store', 'read'])
@@ -2660,10 +2664,20 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
2660
2664
  const mine = encPub ? await myCek() : null
2661
2665
  if (mine) wrap = { op: 'wrap', gen: mine.gen, pub, wrap: await Content.wrapForMember({ cek: mine.cek, memberEncPub: encPub }) }
2662
2666
  } catch (_) { wrap = null }
2663
- const acta = await sealChanges([{ op: 'admit', member: { pub, encPub, label, cn, caps: finales, cert, continuity, machine } }, ...(wrap ? [wrap] : [])])
2667
+ const acta = await sealChanges([{ op: 'admit', member: { pub, encPub, label, cn, caps: finales, cert, continuity, machine, ...(vault ? { vault } : {}) } }, ...(wrap ? [wrap] : [])])
2664
2668
  return { ok: true, seq: acta.seq, wrapped: !!wrap }
2665
2669
  },
2666
2670
 
2671
+ /**
2672
+ * DE QUÉ BÓVEDA ES una llave de comunicación (`vault`: su maestra). La pone la propia
2673
+ * bóveda a la llave que entró antes de existir el campo; sin él, con dos bóvedas en la
2674
+ * cuenta no hay forma de escribirle a una sola.
2675
+ */
2676
+ async setMemberVault ({ pub, vault } = {}) {
2677
+ const acta = await sealChanges([{ op: 'vault', pub, vault }])
2678
+ return { ok: true, seq: acta.seq }
2679
+ },
2680
+
2667
2681
  async setCaps ({ pub, caps } = {}) {
2668
2682
  const acta = await sealChanges([{ op: 'caps', pub, caps }])
2669
2683
  return { ok: true, seq: acta.seq }
@@ -2936,7 +2950,7 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
2936
2950
  * master: si esta cuenta ya la manda otra bóveda, no hay nada que
2937
2951
  * regalar y falla en voz alta.
2938
2952
  */
2939
- async vaultPair ({ qr, label = '', join = 'current', machine = undefined }) {
2953
+ async vaultPair ({ qr, label = '', join = 'current', machine = undefined, account = null }) {
2940
2954
  if (join === 'adopt') return handlers.vaultAdopt({ qr, label, machine })
2941
2955
  // La cuenta abierta AQUÍ y la que se cree para este intento. `born` es la que hay que
2942
2956
  // tirar si el emparejamiento no llega a término: nació para él y no tiene nada dentro.
@@ -2967,7 +2981,7 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
2967
2981
  }
2968
2982
  }
2969
2983
  try {
2970
- return await pairWithVault({ qr, label, machine })
2984
+ return await pairWithVault({ qr, label, machine, account })
2971
2985
  } catch (e) {
2972
2986
  // El intento falló (código vencido, la bóveda dijo que no, se agotó la espera): la
2973
2987
  // cuenta que nació para él se va con él. Si no, cada reintento dejaba una cuenta
@@ -3123,10 +3137,18 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
3123
3137
  * permisos y traspasar el mando NO están, y no es un olvido: eso sigue siendo del
3124
3138
  * master, en su máquina.
3125
3139
  */
3126
- async vaultAdmin ({ op, ...rest } = {}) {
3140
+ async vaultAdmin ({ op, to = null, ...rest } = {}) {
3127
3141
  const link = adminLink()
3128
3142
  if (!link) throw new Error('this device is not paired with a vault')
3129
3143
  const { v, device } = link
3144
+ // A UNA BÓVEDA CONCRETA de la cuenta: `to` es su llave de comunicación (`vault` en el
3145
+ // acta). La alojada puede estar dormida y tarda en despertar, así que se le da más tiempo.
3146
+ if (to) {
3147
+ if (!(loadActa()?.members || []).some((m) => m.pub === to && m.vault)) {
3148
+ throw Object.assign(new Error('vaultAdmin: that key is not a vault of this account'), { code: 'not-a-vault' })
3149
+ }
3150
+ rest = { ...rest, to, timeoutMs: VAULT_WAKE_MS }
3151
+ }
3130
3152
  if (link.self) return remoteAdmin({ master: v.master, proxy: v.proxy, device, cert: v.cert, op, ...rest })
3131
3153
  maybeRenewVaultCert()
3132
3154
  try { return await remoteAdmin({ master: v.master, proxy: v.proxy, device, cert: v.cert, op, ...rest, onRevoked: wipeVaultLink }) }
package/vault/facade.js CHANGED
@@ -110,6 +110,8 @@ export class IdentityFacade {
110
110
  admitMember (member) { return this._h('admitMember', member) }
111
111
  /** Registra la llave de cifrado de un miembro ya admitido (evita re-enrolarlo). */
112
112
  setMemberEncPub (args) { return this._h('setMemberEncPub', args) }
113
+ /** Dice de qué bóveda es una llave de comunicación ya admitida. */
114
+ setMemberVault (args) { return this._h('setMemberVault', args) }
113
115
  setCaps (pub, caps) { return this._h('setCaps', { pub, caps }) }
114
116
  setCapsMany (changes) { return this._h('setCapsMany', { changes }) }
115
117
  setLabel (pub, label) { return this._h('setLabel', { pub, label }) }
@@ -136,7 +138,7 @@ export class IdentityFacade {
136
138
  /** Rota la clave de contenido (corta el acceso al contenido FUTURO de quien ya no está). */
137
139
  rotateContentKey () { return this._h('rotateContentKey') }
138
140
  // Emparejar ESTE dispositivo con el vault del usuario (Fase 1)
139
- enrollDevice (qr, { label = '', join = 'current' } = {}) { return this._h('vaultPair', { qr, label, join }) }
141
+ enrollDevice (qr, { label = '', join = 'current', account = null } = {}) { return this._h('vaultPair', { qr, label, join, account }) }
140
142
  vaultStatus () { return this._h('vaultStatus') }
141
143
  unpairDevice () { return this._h('vaultUnpair') }
142
144
  vaultSign (payload) { return this._h('vaultSign', { payload }) }
@@ -21,7 +21,7 @@ const CONSOLE = /^https:\/\/(vault|profile)\.dotrino\.com$/
21
21
  * sus respaldos) y la contraseña del perfil.
22
22
  */
23
23
  export const CONSOLE_ONLY = Object.freeze([
24
- 'admitMember', 'removeMember', 'setCaps', 'setCapsMany', 'setLabel', 'setMemberEncPub', 'handoverMaster',
24
+ 'admitMember', 'removeMember', 'setCaps', 'setCapsMany', 'setLabel', 'setMemberEncPub', 'setMemberVault', 'handoverMaster',
25
25
  'renounceCaps', 'absorbRenounce', 'adoptActa', 'adoptActaChain', 'joinProfile', 'rotateSealKey', 'setSealKeyProvider',
26
26
  'revokeDevice', 'vaultPair', 'vaultAdopt', 'vaultUnpair', 'prepareForAdoption', 'setSelfVault',
27
27
  'exportIdentity', 'importIdentity', 'deleteProfile', 'setProfilePassword', 'removeProfilePassword',
package/vault/remote.js CHANGED
@@ -14,7 +14,7 @@
14
14
  * `@dotrino/proxy-client` (importado perezosamente; solo se carga al emparejar).
15
15
  */
16
16
  import { makeDeviceKey, signWithDevice, verifyDeviceSig, makePairingCode, commitCode, keyLabel } from './capabilities.js'
17
- import { checkVaultReply } from './acta.js'
17
+ import { checkVaultReply, accountMismatch } from './acta.js'
18
18
  import { cleanMachine, browserMachine } from './machine.js'
19
19
 
20
20
  const MSG = {
@@ -143,9 +143,11 @@ async function askVault (client, qr) {
143
143
  * @param {(c:{deviceId:string, code:string})=>void} [opts.onChallenge] Para mostrar el código a tipear en el PC.
144
144
  * @param {string} [opts.label]
145
145
  * @param {number} [opts.approveTimeoutMs] Espera de la aprobación humana (def 3 min).
146
+ * @param {string} [opts.account] si viene (`pubkeyId` del perfil, 64 hex), SOLO entra en esa cuenta:
147
+ * se comprueba al llegar el reto, antes de enseñar el código (`wrong-account`).
146
148
  * @returns {Promise<{device, cert, master:string, proxy:string, deviceId:string, account:string}>}
147
149
  */
148
- export async function enrollDevice ({ qr, device, onChallenge, label = '', continuity = null, encPub = null, approveTimeoutMs = 180000, intent = 'join', profileId = null, onAdopt = null, machine = undefined } = {}) {
150
+ export async function enrollDevice ({ qr, device, onChallenge, label = '', continuity = null, encPub = null, approveTimeoutMs = 180000, intent = 'join', profileId = null, onAdopt = null, machine = undefined, account = null } = {}) {
149
151
  if (!qr?.sn || !(qr.iss || qr.conn)) throw new Error('invalid qr: missing vault or nonce')
150
152
  const { WebSocketProxyClient } = await import('@dotrino/proxy-client')
151
153
  const client = new WebSocketProxyClient({ url: qr.proxy || 'wss://proxy.dotrino.com', enableWebRTC: false, autoReconnect: false })
@@ -196,7 +198,13 @@ export async function enrollDevice ({ qr, device, onChallenge, label = '', conti
196
198
  const off = client.on('message', async (_from, p) => {
197
199
  if (!p || typeof p !== 'object') return
198
200
  if ((p.type === MSG.ENROLL_CHALLENGE || p.type === MSG.ERROR) && !await fromMyVault(p, qr)) return
199
- if (p.type === MSG.ENROLL_CHALLENGE) { try { onChallenge?.({ deviceId, code }) } catch (_) {} }
201
+ if (p.type === MSG.ENROLL_CHALLENGE) {
202
+ if (account) {
203
+ const why = await accountMismatch(p.signed?.chain, qr.iss, account)
204
+ if (why) { cleanup(); reject(Object.assign(new Error(why), { code: 'wrong-account' })); return }
205
+ }
206
+ try { onChallenge?.({ deviceId, code }) } catch (_) {}
207
+ }
200
208
  // El vault ECHA el código que tipeaste; aceptamos SOLO si coincide con el que generamos.
201
209
  // (Un código distinto = un vault que no lo conoce → lo ignoramos y seguimos esperando.)
202
210
  else if (p.type === MSG.ENROLLED) { if (p.code === code) { cleanup(); resolve(p) } }
@@ -340,9 +348,12 @@ async function clientFor (proxy, master) {
340
348
  return client
341
349
  }
342
350
 
343
- async function vaultRpc ({ master, proxy, device, cert, acta = null, sendType, okType, data, onRevoked, timeoutMs = 15000 }) {
351
+ async function vaultRpc ({ master, to = null, proxy, device, cert, acta = null, sendType, okType, data, onRevoked, timeoutMs = 15000 }) {
352
+ // `to`: a qué llave se escribe, si no es la maestra. Con dos bóvedas en la cuenta, la
353
+ // maestra del perfil las alcanza a todas; la llave de comunicación de una, solo a ella.
354
+ const dest = to || master
344
355
  if (!master || !proxy || !(device?.privateJwk || device?.privateKey || typeof device?.sign === 'function') || !cert) throw new Error('missing pairing data')
345
- const client = await clientFor(proxy, master)
356
+ const client = await clientFor(proxy, dest)
346
357
  try {
347
358
  try { await identifyAsDevice(client, device, { cert, acta }) } catch (_) { /* sin identify seguimos: solo perdemos la cola */ }
348
359
  const signed = { ...data, publickey: device.publickey, ts: Date.now(), ...(cleanMachine(device.machine) ? { machine: cleanMachine(device.machine) } : {}) }
@@ -374,7 +385,7 @@ async function vaultRpc ({ master, proxy, device, cert, acta = null, sendType, o
374
385
  const t = setTimeout(() => { cleanup(); reject(Object.assign(new Error('the vault did not reply (is it running?)'), { code: 'vault-no-reply' })) }, timeoutMs)
375
386
  const cleanup = () => { off(); clearTimeout(t); clearTimeout(graceTimer) }
376
387
  })
377
- client.sendByPubkey(master, { type: sendType, data: signed, signature, cert })
388
+ client.sendByPubkey(dest, { type: sendType, data: signed, signature, cert })
378
389
  return await pending
379
390
  } finally { try { client.close() } catch (_) {} }
380
391
  }
@@ -491,7 +502,7 @@ export async function requestRenounce ({ master, proxy, device, cert, record, on
491
502
  * El `nonce` de un solo uso va en cada petición porque `approve` y `revoke` cambian
492
503
  * estado, y para eso la ventana de frescura de ±5 min no alcanza.
493
504
  */
494
- export async function requestAdmin ({ master, proxy, device, cert, op, onRevoked, nonce: dado, ...rest } = {}) {
505
+ export async function requestAdmin ({ master, to = null, timeoutMs, proxy, device, cert, op, onRevoked, nonce: dado, ...rest } = {}) {
495
506
  // EL NONCE SE PUEDE DAR, y hace falta para abrir la bóveda a distancia: ahí va también
496
507
  // DENTRO del sobre sellado, y quien lo sella tiene que conocerlo antes de llamar. Si se
497
508
  // generara siempre aquí, el de fuera y el de dentro no podrían coincidir — y el de
@@ -501,7 +512,7 @@ export async function requestAdmin ({ master, proxy, device, cert, op, onRevoked
501
512
  : [...crypto.getRandomValues(new Uint8Array(16))]
502
513
  .map((b) => b.toString(16).padStart(2, '0')).join('')
503
514
  const res = await vaultRpc({
504
- master, proxy, device, cert, onRevoked,
515
+ master, to, proxy, device, cert, onRevoked, ...(timeoutMs ? { timeoutMs } : {}),
505
516
  sendType: MSG.ADMIN, okType: MSG.ADMIN_RESULT,
506
517
  data: { op, ...rest, nonce }
507
518
  })
@@ -1,3 +1,3 @@
1
- Copia vendorizada de @dotrino/roadmap@0.4.46 (dotrino-roadmap/src/{index,manifests}.js).
1
+ Copia vendorizada de @dotrino/roadmap@0.4.51 (dotrino-roadmap/src/{index,manifests}.js).
2
2
  NO se edita a mano: la escribe `node vendor.mjs` y la vigila test/vendor-up-to-date.test.mjs.
3
3
  El registro de versiones rotas que viaja con cada versión. Importa @dotrino/compat/ranges.
@@ -31,7 +31,7 @@ export const MANIFESTS = Object.freeze({
31
31
  "identity": {
32
32
  "repo": "imdotrino/dotrino-identity",
33
33
  "npm": "@dotrino/identity",
34
- "current": "0.121.8",
34
+ "current": "0.124.0",
35
35
  "protocol": 1,
36
36
  "requires": {
37
37
  "proxy-client": ">=0.13.1"
@@ -131,7 +131,7 @@ export const MANIFESTS = Object.freeze({
131
131
  "remote-agent": {
132
132
  "repo": "imdotrino/dotrino-remote-agent",
133
133
  "npm": "@dotrino/remote-agent",
134
- "current": "0.22.5",
134
+ "current": "0.23.1",
135
135
  "protocol": 1,
136
136
  "requires": {
137
137
  "identity": ">=0.121.7",
@@ -253,12 +253,12 @@ export const MANIFESTS = Object.freeze({
253
253
  "vault": {
254
254
  "repo": "imdotrino/dotrino-vault",
255
255
  "npm": "@dotrino/vault",
256
- "current": "0.94.0",
256
+ "current": "0.96.0",
257
257
  "protocol": 1,
258
258
  "requires": {
259
259
  "vaultd": ">=0.105.0",
260
260
  "proxy-client": ">=0.39.0",
261
- "identity": ">=0.118.0",
261
+ "identity": ">=0.124.0",
262
262
  "opaque": ">=0.1.0",
263
263
  "compat": ">=0.4.0",
264
264
  "roadmap": ">=0.4.26",
@@ -269,10 +269,10 @@ export const MANIFESTS = Object.freeze({
269
269
  "vaultd": {
270
270
  "repo": "imdotrino/dotrino-vault",
271
271
  "npm": "@dotrino/vaultd",
272
- "current": "0.166.2",
272
+ "current": "0.168.0",
273
273
  "protocol": 1,
274
274
  "requires": {
275
- "identity": ">=0.118.0",
275
+ "identity": ">=0.124.0",
276
276
  "proxy-client": ">=0.39.0",
277
277
  "store": ">=0.11.0",
278
278
  "passmanager": ">=0.18.4",
@@ -332,22 +332,22 @@ export const MANIFESTS = Object.freeze({
332
332
  },
333
333
  "app": {
334
334
  "repo": "imdotrino/dotrino-app",
335
- "current": "0.4.24",
335
+ "current": "0.4.25",
336
336
  "protocol": 1,
337
337
  "requires": {
338
- "proxy": "1.4.7+",
339
- "vaultd": ">=0.114.0",
340
- "identity": ">=0.110.1"
338
+ "proxy": "1.6.0+",
339
+ "vaultd": ">=0.159.0",
340
+ "identity": ">=0.117.2"
341
341
  }
342
342
  },
343
343
  "app-ios": {
344
344
  "repo": "imdotrino/dotrino-app",
345
- "current": "0.4.14",
345
+ "current": "0.4.15",
346
346
  "protocol": 1,
347
347
  "requires": {
348
- "proxy": "1.4.7+",
349
- "vaultd": ">=0.114.0",
350
- "identity": ">=0.110.1"
348
+ "proxy": "1.6.0+",
349
+ "vaultd": ">=0.159.0",
350
+ "identity": ">=0.117.2"
351
351
  }
352
352
  },
353
353
  "social-bot": {
@@ -364,14 +364,14 @@ export const MANIFESTS = Object.freeze({
364
364
  "accounts": {
365
365
  "repo": "imdotrino/dotrino-accounts",
366
366
  "npm": null,
367
- "current": "0.3.2",
367
+ "current": "0.6.0",
368
368
  "protocol": 1,
369
369
  "requires": {
370
370
  "identity": ">=0.116.0",
371
- "remote-agent": ">=0.19.0",
372
- "vault": ">=0.94.0",
371
+ "remote-agent": ">=0.23.1",
372
+ "vault": ">=0.96.0",
373
373
  "pay": ">=0.2.0",
374
- "vaultd": ">=0.166.2"
374
+ "vaultd": ">=0.168.0"
375
375
  }
376
376
  },
377
377
  "ai": {
@@ -381,6 +381,13 @@ export const MANIFESTS = Object.freeze({
381
381
  "protocol": 1,
382
382
  "requires": {}
383
383
  },
384
+ "dictation": {
385
+ "repo": "imdotrino/dotrino-dictation",
386
+ "npm": "@dotrino/dictation",
387
+ "current": "0.1.1",
388
+ "protocol": 1,
389
+ "requires": {}
390
+ },
384
391
  "pay": {
385
392
  "repo": "imdotrino/dotrino-pay",
386
393
  "npm": "@dotrino/pay",
@@ -1,4 +1,4 @@
1
- Copia vendorizada de @dotrino/vault@0.95.0 (dotrino-vault/lib/src/{admin,b64,browser,core/approvals,core/backup,core/blocked,core/browserDisk,core/commKey,core/disk,core/libVersion,core/machines,core/notices,core/notifiable,core/passwords,core/sealKey,core/sealer,core/sealers,core/secretsStore,core/sha256,core/store,core/subacta,core/threadStore,core/transport,core/vault,enroll,index,loginClient,passwordLogins,procContext,protocol,revocation,sealed}.js).
1
+ Copia vendorizada de @dotrino/vault@0.96.0 (dotrino-vault/lib/src/{admin,b64,browser,core/approvals,core/backup,core/blocked,core/browserDisk,core/commKey,core/disk,core/libVersion,core/machines,core/notices,core/notifiable,core/passwords,core/sealKey,core/sealer,core/sealers,core/secretsStore,core/sha256,core/store,core/subacta,core/threadStore,core/transport,core/vault,enroll,index,loginClient,passwordLogins,procContext,protocol,revocation,sealed}.js).
2
2
  NO se edita a mano: la escribe `node vendor.mjs` y la vigila test/vendor-up-to-date.test.mjs.
3
3
  browser.js es la bóveda de esta pestaña: el MISMO núcleo que el binario (core/), con
4
4
  el disco en IndexedDB. Importa @dotrino/{compat,roadmap,passmanager,store/core} y
@@ -5,4 +5,4 @@
5
5
  * si no coincide con la del paquete: una versión anunciada que no es la que corre es peor
6
6
  * que no anunciar ninguna.
7
7
  */
8
- export const LIB_VERSION = '0.95.0'
8
+ export const LIB_VERSION = '0.96.0'
@@ -24,7 +24,11 @@
24
24
  * `bad-action-signature`, `cert-device-mismatch`, `untrusted-issuer`…) son ruido o gente
25
25
  * ajena: ahí no hay a quién avisar de nada.
26
26
  */
27
- export const STALE_PAPER = Object.freeze(['revoked', 'expired', 'scope'])
27
+ // `legacy-cert-retired` (un papel del modelo viejo, sin `seq`) también: se rechaza ANTES de
28
+ // mirar la firma del certificado, pero DESPUÉS de la del aparato, así que el aviso solo
29
+ // puede ir a la llave de quien pregunta. Sin él, un navegador quitado del acta que guardaba
30
+ // un papel viejo se quedaba con la cuenta abierta para siempre (93D9-1B36, 2026-10-19).
31
+ export const STALE_PAPER = Object.freeze(['revoked', 'expired', 'scope', 'legacy-cert-retired'])
28
32
  const STALE = new Set(STALE_PAPER)
29
33
 
30
34
  /** ¿El motivo del rechazo es «tu papel ya no sirve»? */