@dotrino/identity 0.127.0 → 0.128.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.127.0",
3
+ "version": "0.128.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/vault/acta.js CHANGED
@@ -453,7 +453,7 @@ export function genesisActa ({ pub, encPub = null, sealPub = null, label = '', c
453
453
  // EL ESLABÓN 1 de la cadena publicable, todavía SIN FIRMAR: lo firma `sealActa` con la
454
454
  // misma llave, y después firma el acta que lo lleva. Es lo único que sale al registro.
455
455
  sealerLink: { v: SEALER_LINK_V, profileId: pub, seq: 1, by: pub, sealers: [pub], prev: null, iat: now },
456
- members: [{ pub, encPub, label: String(label || '').slice(0, 60), cn: null, caps: [...PAIRED_CAPS, 'sealer'], addedAt: now, cert: null }],
456
+ members: [{ pub, encPub, label: String(label || '').slice(0, 60), cn: null, caps: [...PAIRED_CAPS, 'sealer'], addedAt: now, cert: null, ...(sealPub ? { sealPub, sealSince: 1 } : {}) }],
457
457
  revoked: [],
458
458
  renounced: [],
459
459
  // Llavero del contenido: una entrada por generación, con la clave del perfil ENVUELTA
@@ -527,6 +527,13 @@ export function checkShape (acta) {
527
527
  // DE QUÉ BÓVEDA ES una llave de comunicación (`vault`: la maestra por la que habla). Solo
528
528
  // la lleva un miembro con el `cn` de la bóveda: en cualquier otro no significa nada.
529
529
  if (m.vault != null && (!isPub(m.vault) || m.cn !== VAULT_CN)) return 'invalid-vault'
530
+ // LA LLAVE DE SELLADO DE ESTA BÓVEDA (`docs/replicas.md` §11.5 de dotrino-vault). Cada bóveda
531
+ // de la cuenta tiene la suya, y el acta las nombra todas: la que sella nombra la suya y
532
+ // conserva las de sus hermanas. Desde qué acta manda (`sealSince`), igual que la del acta.
533
+ if (m.sealPub != null) {
534
+ if (!isPub(m.sealPub)) return 'invalid-sealpub'
535
+ if (!Number.isInteger(m.sealSince) || m.sealSince < 1 || m.sealSince > acta.seq) return 'sealsince'
536
+ } else if (m.sealSince != null) return 'sealsince'
530
537
  }
531
538
  // LA LLAVE DE SELLADO Y SU REGISTRO. `sealPub` puede no estar (un perfil que no sella
532
539
  // secretos), pero si está tiene que decir DESDE QUÉ acta manda: sin `sealSince` no se
@@ -540,6 +547,8 @@ export function checkShape (acta) {
540
547
  for (const k of acta.sealKeys) {
541
548
  if (!isPub(k?.pub)) return 'invalid-sealkey'
542
549
  if (!Number.isInteger(k.from) || !Number.isInteger(k.to) || k.from < 1 || k.to < k.from) return 'sealkey-range'
550
+ // `by`: de qué bóveda era esa llave. Sin él es una del acta (la de antes de §11.5).
551
+ if (k.by != null && !isPub(k.by)) return 'invalid-sealkey'
543
552
  }
544
553
  }
545
554
  if (new Set(acta.members.map((m) => m.pub)).size !== acta.members.length) return 'duplicate-member'
@@ -822,6 +831,22 @@ export async function applyChanges (acta, changes, { by, now = Date.now(), sealP
822
831
 
823
832
  const find = (pub) => next.members.find((m) => m.pub === pub)
824
833
 
834
+ // CADA BÓVEDA, SU LLAVE (§11.5 de `docs/replicas.md` de dotrino-vault). La que sella nombra
835
+ // la suya recién estrenada en su propio miembro; las de sus hermanas siguen como estaban,
836
+ // porque los miembros se copian enteros. La de antes pasa al registro con `by`, para que los
837
+ // sobres que firmó sigan verificando.
838
+ const nameSealKey = (m, pub) => {
839
+ if (!isPub(pub)) throw new Error('sealkey: invalid sealing key (expected a P-256 public JWK)')
840
+ if (m.sealPub === pub) return
841
+ if (m.sealPub) next.sealKeys.push({ pub: m.sealPub, from: m.sealSince, to: acta.seq, by: m.pub })
842
+ m.sealPub = pub
843
+ m.sealSince = next.seq
844
+ }
845
+ if (sealPub) {
846
+ const mine = find(by)
847
+ if (mine) nameSealKey(mine, sealPub)
848
+ }
849
+
825
850
  for (const ch of list) {
826
851
  switch (ch?.op) {
827
852
  case 'admit': {
@@ -848,6 +873,19 @@ export async function applyChanges (acta, changes, { by, now = Date.now(), sealP
848
873
  // DE QUÉ BÓVEDA ES, si es la llave de comunicación de una (ver op `vault`).
849
874
  ...(m.vault != null ? { vault: vaultOfComm(cn, m.vault) } : {})
850
875
  })
876
+ // Una bóveda que entra puede traer ya su llave de sellado: la que la admite la nombra
877
+ // («presellar»), y la nueva sirve firmado desde el primer momento sin tener que sellar.
878
+ if (m.sealPub != null) nameSealKey(next.members[next.members.length - 1], m.sealPub)
879
+ break
880
+ }
881
+ // NOMBRAR LA LLAVE DE SELLADO DE UNA HERMANA (§11.5). Su pública llega por la
882
+ // sincronización; la privada no sale de su máquina. Solo a quien puede sellar: es la
883
+ // llave de una bóveda, y un aparato que no sella no firma nada de lo que se sirve.
884
+ case 'sealkey': {
885
+ const m = find(ch.pub)
886
+ if (!m) throw new Error('sealkey: that member is not in the record')
887
+ if (!cleanCaps(m.caps).includes('sealer')) throw new Error('sealkey: only a vault that can seal has a sealing key')
888
+ nameSealKey(m, ch.sealPub)
851
889
  break
852
890
  }
853
891
  // DE QUÉ BÓVEDA ES UNA LLAVE DE COMUNICACIÓN. Con dos bóvedas en la cuenta hay dos llaves
@@ -1049,10 +1087,19 @@ export async function applyChanges (acta, changes, { by, now = Date.now(), sealP
1049
1087
  * que comprobarlo. `null` si no había ninguna (perfil que no sellaba) o si el `seq` viene
1050
1088
  * del futuro, que es un sobre que no puede ser bueno.
1051
1089
  */
1052
- export function sealKeyAt (acta, seq) {
1090
+ export function sealKeyAt (acta, seq, vault = null) {
1053
1091
  if (!acta || !Number.isInteger(seq) || seq < 1 || seq > acta.seq) return null
1092
+ // LA DE UNA BÓVEDA CONCRETA (§11.5): la firma dice de cuál es (`seal.vault`). Tiene que seguir
1093
+ // pudiendo sellar: una bóveda a la que se le quitó no firma nada que valga.
1094
+ if (vault != null) {
1095
+ const m = (acta.members || []).find((x) => samePubkey(x.pub, vault))
1096
+ if (!m || !memberCan(acta, m.pub, 'sealer')) return null
1097
+ if (m.sealPub && seq >= m.sealSince) return m.sealPub
1098
+ for (const k of acta.sealKeys || []) if (k.by && samePubkey(k.by, m.pub) && seq >= k.from && seq <= k.to) return k.pub
1099
+ return null
1100
+ }
1054
1101
  if (acta.sealPub && seq >= acta.sealSince) return acta.sealPub
1055
- for (const k of acta.sealKeys || []) if (seq >= k.from && seq <= k.to) return k.pub
1102
+ for (const k of acta.sealKeys || []) if (!k.by && seq >= k.from && seq <= k.to) return k.pub
1056
1103
  return null
1057
1104
  }
1058
1105
 
package/vault/core.js CHANGED
@@ -2582,8 +2582,8 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
2582
2582
  },
2583
2583
 
2584
2584
  /** La llave con la que se firmaron los sobres de un acta dada. Para VERIFICARLOS. */
2585
- sealKeyAt ({ seq } = {}) {
2586
- return Acta.sealKeyAt(loadActa(), seq)
2585
+ sealKeyAt ({ seq, vault = null } = {}) {
2586
+ return Acta.sealKeyAt(loadActa(), seq, vault)
2587
2587
  },
2588
2588
 
2589
2589
  async profileMembers () {
package/vault/facade.js CHANGED
@@ -93,7 +93,7 @@ export class IdentityFacade {
93
93
  /** Estrena la llave de sellado en un acta nueva, sin tocar a ningún miembro. */
94
94
  rotateSealKey () { return this._h('rotateSealKey') }
95
95
  /** Con qué llave se comprueban los sobres que se firmaron con el acta `seq`. */
96
- sealKeyAt (seq) { return this._h('sealKeyAt', { seq }) }
96
+ sealKeyAt (seq, vault = null) { return this._h('sealKeyAt', { seq, vault }) }
97
97
  myMembership () { return this._h('myMembership') }
98
98
  /**
99
99
  * La CADENA de actas desde `sinceSeq` (para que un dispositivo que estuvo apagado
@@ -1,3 +1,3 @@
1
- Copia vendorizada de @dotrino/passmanager@0.18.5 (dotrino-passmanager/lib/src/{crypto,fields,generate,import,index,match,model,pubkey,sealed/convert,sealed/device,sealed/entry,sealed/index,sealed/keys,sealed/recovery,sealed/store,session-cache,totp,transport/protocol,transport/proxy,transport/sealed,vault/approval,vault/errors,vault/guard,vault/interface,vault/local,vault/remote,vault/responder,vault/sealed-local,vault/sealed-responder,vault/sealed,webauthn}.js).
1
+ Copia vendorizada de @dotrino/passmanager@0.18.6 (dotrino-passmanager/lib/src/{crypto,fields,generate,import,index,match,model,pubkey,sealed/convert,sealed/device,sealed/entry,sealed/index,sealed/keys,sealed/recovery,sealed/store,session-cache,totp,transport/protocol,transport/proxy,transport/sealed,vault/approval,vault/errors,vault/guard,vault/interface,vault/local,vault/remote,vault/responder,vault/sealed-local,vault/sealed-responder,vault/sealed,webauthn}.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 sobre de las contraseñas, el mismo que usan el binario y la extensión. Importa @dotrino/identity/content.
@@ -77,7 +77,15 @@ export class SealedResponder {
77
77
  // contestar sellado, así que no se contesta — el token no es una llave.
78
78
  const pubkey = meta?.fromPubkey || this.client?.pubkeyOfToken?.(from) || null
79
79
  if (!pubkey) { this.onRequest({ op: p.op, outcome: 'anonymous', from: null }); return }
80
- await this.handle({ from, pubkey, msg: p, sealed: meta?.sealed === true })
80
+ // UN PEDIDO NO TUMBA LA BÓVEDA. Este manejador corre suelto en el evento del socket:
81
+ // lo que se escape de aquí es un rechazo sin dueño, y Node cierra el proceso. Pasó el
82
+ // 2026-10-26 con un aparato sin llave de cifrado en el acta: cada pedido suyo reiniciaba
83
+ // la bóveda entera. Se anota y se sigue atendiendo a los demás.
84
+ try {
85
+ await this.handle({ from, pubkey, msg: p, sealed: meta?.sealed === true })
86
+ } catch (e) {
87
+ this.onRequest({ op: p.op, outcome: 'unanswered', from: pubkey, code: e?.code || null })
88
+ }
81
89
  }
82
90
  this.client.on('message', this._handler)
83
91
  }
@@ -98,6 +106,9 @@ export class SealedResponder {
98
106
  // Los códigos son los del responder de siempre (`responder.js`): «la política dice que
99
107
  // no» es `denied` y «el humano dijo que no» es `not-approved`. Se arreglan distinto —uno
100
108
  // dando permiso al aparato, el otro volviendo a pedir— y quien pide los distingue así.
109
+ // SIN SU LLAVE DE CIFRADO NO HAY RESPUESTA POSIBLE, así que tampoco se hace el trabajo:
110
+ // abrir o escribir algo para no poder contárselo a nadie es tocar la bóveda en balde.
111
+ if (!this.encPubOf(pubkey)) { anota('no-encpub', { code: 'no-encpub' }); return }
101
112
  if (!sealed) { anota('unsealed'); return this.#send(from, pubkey, replyError(rid, CODES.UNSEALED, 'unsealed request')) }
102
113
  if (!SEALED_OPS.includes(op)) { anota('unknown-op'); return this.#send(from, pubkey, replyError(rid, CODES.DENIED, 'operation not allowed: ' + op)) }
103
114
  if (!this.isAllowed(pubkey)) { anota('denied'); return this.#send(from, pubkey, replyError(rid, CODES.DENIED, 'this device cannot ask for passwords')) }
@@ -1,3 +1,3 @@
1
- Copia vendorizada de @dotrino/roadmap@0.4.66 (dotrino-roadmap/src/{index,manifests}.js).
1
+ Copia vendorizada de @dotrino/roadmap@0.4.71 (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.
@@ -8,8 +8,8 @@
8
8
  export const MANIFESTS = Object.freeze({
9
9
  "dotrino": {
10
10
  "manifest": "dotrino",
11
- "seq": 47,
12
- "issued": "2026-10-25T19:07:53.892Z",
11
+ "seq": 49,
12
+ "issued": "2026-10-26T17:10:35.872Z",
13
13
  "note": "Registro comun de compatibilidad del ecosistema. Se edita a mano en este repo y se consulta con @dotrino/roadmap. Rangos: ver @dotrino/compat/ranges (x.y.z, >= > <= <, «a - b», «*», o una lista que es un O).",
14
14
  "products": {
15
15
  "compat": {
@@ -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.126.5",
34
+ "current": "0.127.1",
35
35
  "protocol": 1,
36
36
  "requires": {
37
37
  "proxy-client": ">=0.13.1"
@@ -142,6 +142,20 @@ export const MANIFESTS = Object.freeze({
142
142
  "vaultd": ">=0.154.0"
143
143
  }
144
144
  },
145
+ "tunnel": {
146
+ "repo": "imdotrino/dotrino-tunnel",
147
+ "npm": "@dotrino/tunnel",
148
+ "current": "0.3.0",
149
+ "protocol": 2,
150
+ "requires": {
151
+ "identity": ">=0.127.0",
152
+ "remote-agent": ">=0.25.0",
153
+ "vault": ">=0.104.0",
154
+ "proxy-client": ">=0.44.1",
155
+ "store": ">=0.12.3",
156
+ "update": ">=0.9.2"
157
+ }
158
+ },
145
159
  "terminal-agent": {
146
160
  "repo": "imdotrino/dotrino-terminal",
147
161
  "npm": "@dotrino/terminal-agent",
@@ -255,33 +269,34 @@ export const MANIFESTS = Object.freeze({
255
269
  "vault": {
256
270
  "repo": "imdotrino/dotrino-vault",
257
271
  "npm": "@dotrino/vault",
258
- "current": "0.103.0",
272
+ "current": "0.104.0",
259
273
  "protocol": 1,
260
274
  "requires": {
261
275
  "vaultd": ">=0.105.0",
262
276
  "proxy-client": ">=0.44.1",
263
- "identity": ">=0.126.0",
277
+ "identity": ">=0.127.0",
264
278
  "opaque": ">=0.1.0",
265
279
  "compat": ">=0.4.0",
266
280
  "roadmap": ">=0.4.26",
267
- "passmanager": ">=0.18.4",
281
+ "passmanager": ">=0.18.6",
268
282
  "store": ">=0.12.3"
269
283
  }
270
284
  },
271
285
  "vaultd": {
272
286
  "repo": "imdotrino/dotrino-vault",
273
287
  "npm": "@dotrino/vaultd",
274
- "current": "0.175.0",
288
+ "current": "0.176.1",
275
289
  "protocol": 1,
276
290
  "requires": {
277
- "identity": ">=0.126.3",
291
+ "identity": ">=0.127.0",
278
292
  "proxy-client": ">=0.44.1",
279
293
  "store": ">=0.11.0",
280
- "passmanager": ">=0.18.4",
294
+ "passmanager": ">=0.18.6",
281
295
  "compat": ">=0.4.0",
282
296
  "opaque": ">=0.1.0",
283
297
  "roadmap": ">=0.4.58",
284
- "remote-agent": ">=0.24.0"
298
+ "remote-agent": ">=0.24.0",
299
+ "update": ">=0.9.0"
285
300
  }
286
301
  },
287
302
  "verifier": {
@@ -296,7 +311,7 @@ export const MANIFESTS = Object.freeze({
296
311
  "passmanager": {
297
312
  "repo": "imdotrino/dotrino-passmanager",
298
313
  "npm": "@dotrino/passmanager",
299
- "current": "0.18.5",
314
+ "current": "0.18.6",
300
315
  "protocol": 1,
301
316
  "requires": {
302
317
  "identity": ">=0.117.2",
@@ -323,7 +338,7 @@ export const MANIFESTS = Object.freeze({
323
338
  },
324
339
  "passmanager-extension": {
325
340
  "repo": "imdotrino/dotrino-passmanager",
326
- "current": "0.57.3",
341
+ "current": "0.58.0",
327
342
  "protocol": 1,
328
343
  "requires": {
329
344
  "identity": ">=0.118.0",
@@ -335,7 +350,7 @@ export const MANIFESTS = Object.freeze({
335
350
  },
336
351
  "app": {
337
352
  "repo": "imdotrino/dotrino-app",
338
- "current": "0.4.27",
353
+ "current": "0.4.29",
339
354
  "protocol": 1,
340
355
  "requires": {
341
356
  "proxy": "1.6.0+",
@@ -985,6 +1000,166 @@ export const MANIFESTS = Object.freeze({
985
1000
  ],
986
1001
  "why": "el anuncio en la red local (mDNS) mantenía vivo el proceso: quien anunciaba una invitación sin cerrarla no terminaba nunca (las pruebas de la bóveda se colgaban en CI)",
987
1002
  "fix": "sube a @dotrino/proxy-client 0.44.1"
1003
+ },
1004
+ {
1005
+ "product": "vaultd",
1006
+ "versions": [
1007
+ "0.121.0",
1008
+ "0.122.0",
1009
+ "0.123.0",
1010
+ "0.123.1",
1011
+ "0.124.0",
1012
+ "0.124.1",
1013
+ "0.124.2",
1014
+ "0.125.0",
1015
+ "0.126.0",
1016
+ "0.127.0",
1017
+ "0.128.0",
1018
+ "0.129.0",
1019
+ "0.129.1",
1020
+ "0.130.0",
1021
+ "0.131.0",
1022
+ "0.131.1",
1023
+ "0.131.2",
1024
+ "0.131.3",
1025
+ "0.131.4",
1026
+ "0.131.5",
1027
+ "0.131.6",
1028
+ "0.132.0",
1029
+ "0.133.0",
1030
+ "0.134.0",
1031
+ "0.135.0",
1032
+ "0.136.0",
1033
+ "0.137.0",
1034
+ "0.138.0",
1035
+ "0.139.0",
1036
+ "0.139.1",
1037
+ "0.140.0",
1038
+ "0.141.0",
1039
+ "0.141.1",
1040
+ "0.142.0",
1041
+ "0.143.0",
1042
+ "0.144.0",
1043
+ "0.145.0",
1044
+ "0.146.0",
1045
+ "0.147.0",
1046
+ "0.148.0",
1047
+ "0.148.1",
1048
+ "0.149.0",
1049
+ "0.150.0",
1050
+ "0.150.1",
1051
+ "0.151.0",
1052
+ "0.152.0",
1053
+ "0.153.0",
1054
+ "0.153.1",
1055
+ "0.153.2",
1056
+ "0.154.0",
1057
+ "0.154.1",
1058
+ "0.155.0",
1059
+ "0.156.0",
1060
+ "0.157.0",
1061
+ "0.158.0",
1062
+ "0.158.1",
1063
+ "0.159.0",
1064
+ "0.160.0",
1065
+ "0.160.1",
1066
+ "0.160.2",
1067
+ "0.160.3",
1068
+ "0.161.0",
1069
+ "0.162.0",
1070
+ "0.162.1",
1071
+ "0.162.2",
1072
+ "0.162.3",
1073
+ "0.163.0",
1074
+ "0.163.1",
1075
+ "0.163.2",
1076
+ "0.163.4",
1077
+ "0.164.0",
1078
+ "0.164.1",
1079
+ "0.165.0",
1080
+ "0.165.1",
1081
+ "0.165.3",
1082
+ "0.166.1",
1083
+ "0.166.2",
1084
+ "0.167.0",
1085
+ "0.167.1",
1086
+ "0.168.0",
1087
+ "0.169.0",
1088
+ "0.170.0",
1089
+ "0.171.0",
1090
+ "0.172.0",
1091
+ "0.172.1",
1092
+ "0.173.0",
1093
+ "0.174.1",
1094
+ "0.174.3",
1095
+ "0.174.4",
1096
+ "0.175.0",
1097
+ "0.175.1"
1098
+ ],
1099
+ "why": "«dotrino-vault logins add» creaba el aparato de usuario y contraseña sin llave de cifrado: entraba al acta sin encPub, no se le podía sellar nada, y cada pedido suyo de contraseñas tumbaba la bóveda",
1100
+ "fix": "sube a @dotrino/vaultd 0.175.2 y vuelve a crear el aparato (logins rm + logins add)"
1101
+ },
1102
+ {
1103
+ "product": "vault",
1104
+ "versions": [
1105
+ "0.91.0",
1106
+ "0.91.1",
1107
+ "0.92.0",
1108
+ "0.93.0",
1109
+ "0.93.1",
1110
+ "0.94.0",
1111
+ "0.95.0",
1112
+ "0.95.1",
1113
+ "0.96.0",
1114
+ "0.97.0",
1115
+ "0.98.0",
1116
+ "0.99.0",
1117
+ "0.100.0",
1118
+ "0.101.0",
1119
+ "0.102.1",
1120
+ "0.102.2",
1121
+ "0.103.0",
1122
+ "0.103.1"
1123
+ ],
1124
+ "why": "createPasswordLogin creaba el aparato de usuario y contraseña sin llave de cifrado (leía enc.publickey, que no existe)",
1125
+ "fix": "sube a @dotrino/vault 0.103.2"
1126
+ },
1127
+ {
1128
+ "product": "passmanager",
1129
+ "versions": [
1130
+ "0.10.1",
1131
+ "0.12.0",
1132
+ "0.13.0",
1133
+ "0.14.0",
1134
+ "0.14.1",
1135
+ "0.15.0",
1136
+ "0.16.0",
1137
+ "0.17.0",
1138
+ "0.18.0",
1139
+ "0.18.1",
1140
+ "0.18.2",
1141
+ "0.18.3",
1142
+ "0.18.4",
1143
+ "0.18.5"
1144
+ ],
1145
+ "why": "un pedido de contraseñas de un aparato sin llave de cifrado en el acta lanzaba no-encpub fuera del manejador del socket y cerraba el proceso de la bóveda",
1146
+ "fix": "sube a @dotrino/passmanager 0.18.6"
1147
+ },
1148
+ {
1149
+ "product": "tunnel",
1150
+ "versions": [
1151
+ "0.1.0",
1152
+ "0.1.1",
1153
+ "0.1.2",
1154
+ "0.1.3",
1155
+ "0.1.4",
1156
+ "0.1.5",
1157
+ "0.1.6",
1158
+ "0.1.7",
1159
+ "0.1.8"
1160
+ ],
1161
+ "why": "la llave de la URL la elegía cualquiera y el relay no pedía prueba: quien la supiera se conectaba como agente, echaba al legítimo y se quedaba con sus peticiones. El relay (2026-10-26) ya no las acepta",
1162
+ "fix": "sube a @dotrino/tunnel 0.2.0 y enrola cada túnel en tu bóveda (dotrino-tunnel enroll [--name n]); la dirección cambia"
988
1163
  }
989
1164
  ]
990
1165
  }
@@ -1,4 +1,4 @@
1
- Copia vendorizada de @dotrino/vault@0.103.1 (dotrino-vault/lib/src/{admin,b64,browser,core/approvals,core/backup,core/blocked,core/browserDisk,core/commKey,core/disk,core/exNotices,core/gate,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,invite,loginClient,passwordLogins,procContext,protocol,revocation,sealed}.js).
1
+ Copia vendorizada de @dotrino/vault@0.104.0 (dotrino-vault/lib/src/{admin,b64,browser,core/approvals,core/backup,core/blocked,core/browserDisk,core/commKey,core/disk,core/exNotices,core/gate,core/libVersion,core/logAnchor,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,invite,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.103.1'
8
+ export const LIB_VERSION = '0.104.0'
@@ -0,0 +1,87 @@
1
+ /**
2
+ * EL ANCLA DE LA BITÁCORA: que no se pueda cortar el final sin que se note.
3
+ *
4
+ * La bitácora es una cadena (`logSeq` + hash de la anterior), así que reescribir o quitar
5
+ * una entrada del medio se ve. Cortar el FINAL no: un prefijo sigue siendo una cadena
6
+ * válida (modelo de amenazas §4.3). Eso no se cierra en local, porque quien corta tiene la
7
+ * máquina. Se cierra sacando la cabeza de la máquina.
8
+ *
9
+ * Decidido por el dueño (2026-10-26): la cabeza se sella con `signer.dotrino.com` —que da
10
+ * el CUÁNDO, firmado por un tercero— y el recibo viaja a los aparatos con `approve`, que
11
+ * lo GUARDAN. El signer no guarda nada: un recibo que se quedara en este disco se borraría
12
+ * junto con el final que pretende proteger. Un aprobador que recibe un ancla con un
13
+ * `logSeq` menor que el último que guardó, o con el mismo `logSeq` y otra cabeza, sabe que
14
+ * cortaron la bitácora.
15
+ *
16
+ * Al signer solo llega un hash: ni el contenido de la bitácora ni quién es esta bóveda.
17
+ * Sin dependencias de Node: lo corren el binario, la pestaña y la extensión.
18
+ */
19
+ import { bytesToB64url } from '../b64.js'
20
+
21
+ export const SIGNER_URL = 'https://signer.dotrino.com'
22
+ /** Cada cuánto se mira si hay algo nuevo que anclar. Sin entradas nuevas no se manda nada. */
23
+ export const ANCHOR_EVERY_MS = 6 * 60 * 60 * 1000
24
+ /** Cuánto espera la primera, desde que arranca la bóveda. */
25
+ export const ANCHOR_FIRST_MS = 10 * 60 * 1000
26
+ const SIGNER_TIMEOUT_MS = 15000
27
+
28
+ const fail = (code, message) => Object.assign(new Error(message), { code })
29
+
30
+ /** hex → base64url, que es como el signer pide el hash. */
31
+ export function hexToB64url (hex) {
32
+ if (typeof hex !== 'string' || !/^[0-9a-f]{64}$/.test(hex)) throw fail('anchor-bad-head', 'the log head must be a sha256 in hex')
33
+ const bytes = new Uint8Array(32)
34
+ for (let i = 0; i < 32; i++) bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16)
35
+ return bytesToB64url(bytes)
36
+ }
37
+
38
+ /**
39
+ * Pide al signer que selle la cabeza. Devuelve su recibo tal cual (`{ v, op, hash, ts, alg,
40
+ * signature, pubkey }`), que es lo que el aprobador puede verificar sin red. Si el signer no
41
+ * contesta, LANZA: un ancla sin sello no se manda como si lo tuviera.
42
+ */
43
+ export async function sealHead (head, { fetchFn = globalThis.fetch, signerUrl = SIGNER_URL, timeoutMs = SIGNER_TIMEOUT_MS } = {}) {
44
+ if (typeof fetchFn !== 'function') throw fail('anchor-no-fetch', 'this platform cannot reach the signer')
45
+ const hash = hexToB64url(head)
46
+ const ctl = typeof AbortController === 'function' ? new AbortController() : null
47
+ const timer = ctl ? setTimeout(() => ctl.abort(), timeoutMs) : null
48
+ try {
49
+ const res = await fetchFn(signerUrl + '/seal', {
50
+ method: 'POST',
51
+ headers: { 'content-type': 'application/json' },
52
+ body: JSON.stringify({ hash }),
53
+ ...(ctl ? { signal: ctl.signal } : {})
54
+ })
55
+ if (!res.ok) throw fail('anchor-signer-error', `the signer answered ${res.status}`)
56
+ const r = await res.json()
57
+ if (r?.op !== 'seal' || r.hash !== hash || typeof r.ts !== 'number' || typeof r.signature !== 'string') {
58
+ throw fail('anchor-signer-bad-receipt', 'the signer receipt does not match the head it was asked to seal')
59
+ }
60
+ return r
61
+ } catch (e) {
62
+ if (e?.code) throw e
63
+ throw fail('anchor-signer-unreachable', `could not reach the signer: ${e?.message || e}`)
64
+ } finally {
65
+ if (timer) clearTimeout(timer)
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Lo que decide el APROBADOR al recibir un ancla, frente a la última que guardó de esa
71
+ * bóveda. Pura, para que el navegador, Kotlin y Swift hagan exactamente lo mismo.
72
+ *
73
+ * · `first` no tenía ninguna: se guarda.
74
+ * · `advanced` la bitácora creció: se guarda la nueva.
75
+ * · `same` nada nuevo.
76
+ * · `truncated` `logSeq` menor que el guardado: cortaron el final.
77
+ * · `forked` mismo `logSeq`, otra cabeza: reescribieron el final.
78
+ *
79
+ * Los dos últimos son la alarma. No se guarda el ancla nueva: la buena es la que ya estaba.
80
+ */
81
+ export function compareAnchor (last, next) {
82
+ if (!next || typeof next.logSeq !== 'number' || typeof next.head !== 'string') throw fail('anchor-malformed', 'an anchor needs logSeq and head')
83
+ if (!last) return 'first'
84
+ if (next.logSeq < last.logSeq) return 'truncated'
85
+ if (next.logSeq === last.logSeq) return next.head === last.head ? 'same' : 'forked'
86
+ return 'advanced'
87
+ }
@@ -22,7 +22,7 @@ export const NOTICE_TTL_MS = 24 * 60 * 60 * 1000
22
22
  * (`docs/pairing-protocol.md` §1.7). No pide nada: no hay a quién bloquear, porque ninguno
23
23
  * entró. Lo cuenta, con el ID y la máquina de los dos.
24
24
  */
25
- export const NOTICE_EVS = ['updated', 'update-needs-root', 'pairing-contested']
25
+ export const NOTICE_EVS = ['updated', 'update-needs-root', 'pairing-contested', 'log-anchor']
26
26
 
27
27
  const newId = () => [...crypto.getRandomValues(new Uint8Array(8))].map((b) => b.toString(16).padStart(2, '0')).join('')
28
28
 
@@ -58,8 +58,19 @@ export function openNotices ({ disk, now = Date.now }) {
58
58
  * administrador). `product`: qué (`@dotrino/vaultd` es la propia bóveda);
59
59
  * `deviceId`/`label`: el aparato, si fue uno.
60
60
  */
61
- add (ev, { version, from = null, product = '@dotrino/vaultd', deviceId = null, label = null, devices = null }) {
61
+ add (ev, { version, from = null, product = '@dotrino/vaultd', deviceId = null, label = null, devices = null, logSeq = null, head = null, tsa = null }) {
62
62
  if (!NOTICE_EVS.includes(ev)) throw fail('bad-notice', `unknown notice: ${ev}`)
63
+ // EL ANCLA DE LA BITÁCORA (`logAnchor.js`): la cabeza sellada por el signer, para que el
64
+ // aprobador la guarde. Solo se queda la última: la anterior ya no dice nada que esta no diga.
65
+ if (ev === 'log-anchor') {
66
+ if (typeof logSeq !== 'number' || typeof head !== 'string' || !tsa || typeof tsa.signature !== 'string') {
67
+ throw fail('bad-notice', `${ev}: logSeq, head and the signer receipt are required`)
68
+ }
69
+ const n = { id: newId(), ev, logSeq, head, tsa, ts: now() }
70
+ items = [...items.filter(alive).filter((x) => x.ev !== 'log-anchor'), n]
71
+ save()
72
+ return n
73
+ }
63
74
  if (ev === 'pairing-contested') {
64
75
  if (!Array.isArray(devices) || devices.length < 2) throw fail('bad-notice', `${ev}: the devices that answered are required`)
65
76
  const n = {
@@ -47,6 +47,7 @@ import { openCommKey, COMM_CN, COMM_CAPS } from './commKey.js'
47
47
  import { seal } from '../sealed.js'
48
48
  import { MSG, SCOPE, secretsScope, isValidSecretsNs, VAULT_PROTOCOL, VAULT_SPEAKS } from '../protocol.js'
49
49
  import { sha256Hex } from './sha256.js'
50
+ import { sealHead, ANCHOR_EVERY_MS, ANCHOR_FIRST_MS } from './logAnchor.js'
50
51
  import { createGate } from './gate.js'
51
52
 
52
53
  const b64ToBytes = (s) => Uint8Array.from(atob(s), (c) => c.charCodeAt(0))
@@ -798,8 +799,9 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
798
799
  *
799
800
  * **Lo que esto NO resuelve, dicho para no venderlo de más:** quien tenga la máquina
800
801
  * puede cortar el final de la cadena y quedarse con un prefijo válido. Eso no se cierra
801
- * en local — pide anclar el último hash fuera (un TSA, otro aparato). Lo que sí cierra
802
- * es reescribir el pasado sin dejar rastro, que es el caso que importaba.
802
+ * en local: la cabeza se ancla fuera, sellada por el signer y guardada por los aparatos
803
+ * con `approve` (`anchorLog`, `logAnchor.js`). Lo que la cadena cierra sola es reescribir
804
+ * el pasado sin dejar rastro, que es el caso que importaba.
803
805
  */
804
806
  const AUDIT_MAX_BYTES = 1024 * 1024
805
807
  /** Cuántos archivos viejos se guardan. Es la RETENCIÓN, y va declarada. */
@@ -2234,13 +2236,13 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2234
2236
  * @returns {Promise<{ approvers: number, sent: number, notice: object|null }>}
2235
2237
  */
2236
2238
  /** Manda un aviso ya apuntado (`notices`) a cada aprobador, sellado. Devuelve a cuántos salió. */
2237
- async function sendNotice (notice, who, what) {
2239
+ async function sendNotice (notice, who, what, { quiet = false } = {}) {
2238
2240
  const { id, ev, ts, ...rest } = notice
2239
2241
  const body = { ev, id, ...rest, ts }
2240
2242
  const seal = await sealOrFail(body)
2241
2243
  let sent = 0
2242
2244
  for (const pub of who) {
2243
- try { client.sendByPubkey(pub, { type: MSG.ADMIN_EVENT, body, seal }, { app: 'vault' }); sent++ }
2245
+ try { client.sendByPubkey(pub, { type: MSG.ADMIN_EVENT, body, seal }, { app: 'vault', ...(quiet ? { quiet: true } : {}) }); sent++ }
2244
2246
  catch (e) { log(`[vault] could not tell ${pub.slice(0, 24)}… about ${what}: ${e.message}`) }
2245
2247
  }
2246
2248
  return sent
@@ -2266,6 +2268,35 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2266
2268
  return { approvers: who.length, sent }
2267
2269
  }
2268
2270
 
2271
+ /**
2272
+ * ANCLAR LA BITÁCORA (`logAnchor.js`, modelo de amenazas §4.3): la cabeza, sellada por el
2273
+ * signer, a cada aparato con `approve`. Solo si la bitácora creció desde la última vez, y
2274
+ * sin apuntarlo en ella: una entrada nueva cambiaría la cabeza que se acaba de anclar.
2275
+ * Sin aprobadores no hay dónde dejarla, y se dice. Si el signer no contesta, no se manda
2276
+ * sin sello: se reintenta en la próxima vuelta.
2277
+ */
2278
+ let anchoredSeq = 0
2279
+ async function anchorLog () {
2280
+ if (!auditPrev || auditSeq <= anchoredSeq) return { anchored: false, reason: 'nothing-new' }
2281
+ const record = await refreshActa()
2282
+ const who = (record?.members || []).filter((m) => Acta.memberCan(record, m.pub, 'approve')).map((m) => m.pub)
2283
+ if (!who.length) {
2284
+ log('[vault] log anchor: nobody can approve, so the log head stays only on this machine (grant it with: dotrino-vault caps <ID> +aprueba)')
2285
+ return { anchored: false, reason: 'no-approvers' }
2286
+ }
2287
+ const logSeq = auditSeq; const head = auditPrev
2288
+ const tsa = await sealHead(head, { fetchFn: platform.fetch || globalThis.fetch })
2289
+ const notice = notices.add('log-anchor', { logSeq, head, tsa })
2290
+ // CALLADO: no es nada que hacer, y timbrar cada pocas horas haría sonar el teléfono con un
2291
+ // pedido vacío. La app lo lee de la lista de avisos la próxima vez que pregunte.
2292
+ const sent = await sendNotice(notice, who, 'the log anchor', { quiet: true })
2293
+ if (!sent) throw Object.assign(new Error('no approver could be told'), { code: 'announce-failed' })
2294
+ anchoredSeq = logSeq
2295
+ log(`[vault] log anchor: entry ${logSeq} sealed and sent to ${sent} of ${who.length} approver(s)`)
2296
+ return { anchored: true, logSeq, sent }
2297
+ }
2298
+ const runAnchor = () => anchorLog().catch((e) => log(`[vault] log anchor: not sent this round (${e.code || 'error'}: ${e.message}); retrying in ${Math.round(ANCHOR_EVERY_MS / 3600000)} h`))
2299
+
2269
2300
  async function announceUpdate ({ version, from = null, product = '@dotrino/vaultd', deviceId = null, label = null, ev = 'updated' }) {
2270
2301
  const record = await refreshActa()
2271
2302
  const who = (record?.members || []).filter((m) => Acta.memberCan(record, m.pub, 'approve')).map((m) => m.pub)
@@ -2546,6 +2577,14 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2546
2577
  log(`[vault] passwords: could not start (${e.message}); everything else keeps going`)
2547
2578
  }
2548
2579
 
2580
+ // La primera ancla sale a los diez minutos de arrancar (lo escrito mientras estuvo apagada) y
2581
+ // luego cada pocas horas. No antes: un arranque no es actividad, y una bóveda que vive menos
2582
+ // —una prueba, un reinicio— no tiene por qué llamar al signer.
2583
+ const anchorFirst = setTimeout(runAnchor, ANCHOR_FIRST_MS)
2584
+ anchorFirst.unref?.()
2585
+ const anchorSweeper = setInterval(runAnchor, ANCHOR_EVERY_MS)
2586
+ anchorSweeper.unref?.()
2587
+
2549
2588
  log(`[vault] listo · id ${fp} · ${store.getTree().children.length} nodos`)
2550
2589
 
2551
2590
  // ----- API local (CLI/UI de control) -----
@@ -3116,14 +3155,18 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
3116
3155
  // ese aparato no hizo.
3117
3156
  //
3118
3157
  // Mirando lo que el acta dice HOY, un registro repetido no quita nada y se para aquí.
3119
- // Lo que esto NO cierra, y queda anotado: si el dueño vuelve a conceder ese permiso, el
3120
- // mismo registro viejo lo quita otra vez. Cerrarlo del todo pide que el acta recuerde
3121
- // la fecha de la última renuncia por miembro y rechace las que no sean posteriores.
3158
+ // Y si el dueño volvió a conceder ese permiso, el acta recuerda la fecha de la última
3159
+ // renuncia del miembro (`renouncedAt`, identity ≥ 0.127.0): una que no sea posterior es
3160
+ // una repetición y no se honra (modelo de amenazas §4.4.bis, cerrado el 2026-10-25).
3122
3161
  const actual = (await identity.profileActa?.().catch(() => null))?.acta || null
3123
3162
  if (!actual) {
3124
3163
  audit('rejected', { what: 'renounce', reason: 'no-record' })
3125
3164
  return reply(from, { type: MSG.ERROR, error: 'renounce: this vault has no record to apply it to' })
3126
3165
  }
3166
+ if (!Acta.renounceIsFresh(actual, record)) {
3167
+ audit('rejected', { what: 'renounce', reason: 'stale' })
3168
+ return reply(from, { type: MSG.ERROR, error: 'renounce: not newer than the last renounce this record saw', code: 'renounce-stale' })
3169
+ }
3127
3170
  const has = new Set(Acta.effectiveCaps(actual, record.member) || [])
3128
3171
  if (!(record.caps || []).some((c) => has.has(c))) {
3129
3172
  audit('rejected', { what: 'renounce', reason: 'nothing-to-remove' })
@@ -4527,6 +4570,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
4527
4570
  return { answer, withdraw: () => { withdrawn = true; retire() } }
4528
4571
  },
4529
4572
  announceUpdate,
4573
+ anchorLog,
4530
4574
  approvers: async () => {
4531
4575
  const record = await refreshActa()
4532
4576
  if (!record) return []
@@ -4759,6 +4803,8 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
4759
4803
  close () {
4760
4804
  for (const stop of [...announcing]) { try { stop() } catch (_) {} }
4761
4805
  clearInterval(approvalsSweeper)
4806
+ clearTimeout(anchorFirst)
4807
+ clearInterval(anchorSweeper)
4762
4808
  for (const t of pendingNotices.values()) clearTimeout(t)
4763
4809
  pendingNotices.clear()
4764
4810
  closeTransport()
@@ -507,8 +507,8 @@ export async function createPasswordLogin ({ user, password, label, caps, begin,
507
507
  const fin = opaque.registrationFinish({ state: start.state, response: begun.response, password })
508
508
  const device = await makeDeviceKey({ label })
509
509
  const enc = await makeDeviceEncKey()
510
- const blob = await sealDeviceKeys(fin.exportKey, { sign: device.privateJwk, enc: enc.privateJwk })
511
- return finish({ user, upload: fin.upload, pub: device.publickey, encPub: enc.publickey, label, blob, caps })
510
+ const blob = await sealDeviceKeys(fin.exportKey, { sign: device.privateJwk, enc: enc.encPrivateJwk })
511
+ return finish({ user, upload: fin.upload, pub: device.publickey, encPub: enc.encPublickey, label, blob, caps })
512
512
  }
513
513
 
514
514
  export async function registerLogin ({
@@ -540,6 +540,10 @@ export async function registerLogin ({
540
540
  if (typeof identity?.admitMember !== 'function') {
541
541
  throw Object.assign(new Error('this vault cannot add devices to the account record: no login was created'), { code: 'admit-unavailable' })
542
542
  }
543
+ // SIN LLAVE DE CIFRADO NO ENTRA. Un aparato así está en el acta pero nada se le puede
544
+ // sellar: no recibe contraseñas ni cajones, y lo único que hace es pedir. Pasó el
545
+ // 2026-10-26 (el alta leía `enc.publickey`, que no existe) y nadie lo vio hasta usarlo.
546
+ if (!encPub) throw Object.assign(new Error('a password login needs its encryption public key'), { code: 'no-encpub' })
543
547
  const deviceId = await deviceIdOf(pub)
544
548
  await logins.registerFinish({ user, upload, pub, encPub, deviceId, label, blob })
545
549
  try {