@dotrino/identity 0.136.0 → 0.136.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/identity",
3
- "version": "0.136.0",
3
+ "version": "0.136.1",
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",
@@ -1,3 +1,3 @@
1
- Copia vendorizada de @dotrino/compat@0.5.0 (dotrino-compat/src/{advisory,index,ranges}.js).
1
+ Copia vendorizada de @dotrino/compat@0.5.1 (dotrino-compat/src/{advisory,index,ranges}.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
  Qué versión es cada pieza y si pueden hablar (CONVENCIONES §14).
@@ -31,26 +31,52 @@
31
31
  * es otro silencio, que es de lo que venimos huyendo.
32
32
  */
33
33
 
34
+ /**
35
+ * Una entrada de la lista de rotas que lleva el aviso.
36
+ * @typedef {object} AdvisoryEntry
37
+ * @property {string} product
38
+ * @property {string[]} versions
39
+ * @property {string} [why]
40
+ * @property {string} [fix]
41
+ */
42
+
43
+ /**
44
+ * El aviso firmado: «actualiza estos componentes».
45
+ * @typedef {object} Advisory
46
+ * @property {'compat.advisory'} op
47
+ * @property {number} seq solo hacia adelante
48
+ * @property {number} issued ms desde epoch
49
+ * @property {AdvisoryEntry[]} broken
50
+ * @property {string} sig ECDSA P-256 (P1363) en base64
51
+ */
52
+
34
53
  /**
35
54
  * JSON canónico (claves ordenadas, recursivo). Es una COPIA deliberada del de
36
55
  * `@dotrino/proxy-client`: este paquete no depende de nadie —lo importan las ~30 apps y el
37
56
  * proxio— y la firma tiene que dar los mismos bytes en las dos puntas. Si algún día
38
57
  * cambian, cambian los dos: hay un test que compara la salida contra la del pilar.
58
+ *
59
+ * @param {unknown} value
60
+ * @returns {string}
39
61
  */
40
62
  export function canonicalStringify (value) {
41
63
  if (value === null || typeof value !== 'object') return JSON.stringify(value)
42
64
  if (Array.isArray(value)) return '[' + value.map(canonicalStringify).join(',') + ']'
43
- const keys = Object.keys(value).sort()
44
- return '{' + keys.map((k) => JSON.stringify(k) + ':' + canonicalStringify(value[k])).join(',') + '}'
65
+ const o = /** @type {Record<string, unknown>} */ (value)
66
+ const keys = Object.keys(o).sort()
67
+ return '{' + keys.map((k) => JSON.stringify(k) + ':' + canonicalStringify(o[k])).join(',') + '}'
45
68
  }
46
69
 
70
+ /** @param {string} s */
47
71
  const enc = (s) => new TextEncoder().encode(s)
72
+ /** @param {ArrayBuffer} buf */
48
73
  const b64 = (buf) => {
49
74
  const b = new Uint8Array(buf)
50
75
  let s = ''
51
76
  for (let i = 0; i < b.length; i++) s += String.fromCharCode(b[i])
52
77
  return btoa(s)
53
78
  }
79
+ /** @param {string} str */
54
80
  const fromB64 = (str) => {
55
81
  const bin = atob(str)
56
82
  const out = new Uint8Array(bin.length)
@@ -58,26 +84,37 @@ const fromB64 = (str) => {
58
84
  return out
59
85
  }
60
86
 
61
- /** El cuerpo que se firma: todo menos la firma. */
87
+ /**
88
+ * El cuerpo que se firma: todo menos la firma.
89
+ * @param {Partial<Advisory> | null | undefined} a
90
+ * @returns {Omit<Partial<Advisory>, 'sig'>}
91
+ */
62
92
  export const advisoryBody = (a) => {
63
93
  const { sig, ...body } = a || {}
64
94
  return body
65
95
  }
66
96
 
67
- /** ¿Tiene forma de aviso? No dice si es de fiar, solo si se puede juzgar. */
97
+ /**
98
+ * ¿Tiene forma de aviso? No dice si es de fiar, solo si se puede juzgar.
99
+ * @param {any} a lo que llegó de la red, sin comprobar: esta función es la que lo comprueba
100
+ * @returns {a is Advisory}
101
+ */
68
102
  export function isAdvisory (a) {
69
103
  return !!a && a.op === 'compat.advisory' && Number.isInteger(a.seq) && a.seq >= 0 &&
70
104
  typeof a.issued === 'number' && Array.isArray(a.broken) && typeof a.sig === 'string' &&
71
- a.broken.every((b) => b && typeof b.product === 'string' && Array.isArray(b.versions) &&
72
- b.versions.every((v) => typeof v === 'string'))
105
+ a.broken.every((/** @type {any} */ b) => b && typeof b.product === 'string' && Array.isArray(b.versions) &&
106
+ b.versions.every((/** @type {unknown} */ v) => typeof v === 'string'))
73
107
  }
74
108
 
75
109
  /**
76
110
  * FIRMA un aviso. Lo corre quien publica, no quien lo recibe: aquí está para que el
77
111
  * formato lo defina un solo sitio y no dos implementaciones que se separan.
112
+ *
113
+ * @param {{ seq: number, broken: AdvisoryEntry[], privateJwk: JsonWebKey, issued?: number }} args
114
+ * @returns {Promise<Advisory>}
78
115
  */
79
116
  export async function signAdvisory ({ seq, broken, privateJwk, issued = Date.now() }) {
80
- const body = { op: 'compat.advisory', seq, issued, broken }
117
+ const body = { op: /** @type {const} */ ('compat.advisory'), seq, issued, broken }
81
118
  const key = await globalThis.crypto.subtle.importKey(
82
119
  'jwk', privateJwk, { name: 'ECDSA', namedCurve: 'P-256' }, false, ['sign'])
83
120
  const sig = await globalThis.crypto.subtle.sign(
@@ -88,6 +125,9 @@ export async function signAdvisory ({ seq, broken, privateJwk, issued = Date.now
88
125
  /**
89
126
  * ¿Lo firmó la llave de release que trae MI build? `publickey` es un JWK en texto, igual
90
127
  * que en el resto del ecosistema.
128
+ *
129
+ * @param {{ advisory: unknown, publickey: unknown }} args
130
+ * @returns {Promise<boolean>}
91
131
  */
92
132
  export async function verifyAdvisory ({ advisory, publickey }) {
93
133
  if (!isAdvisory(advisory) || typeof publickey !== 'string') return false
@@ -103,6 +143,9 @@ export async function verifyAdvisory ({ advisory, publickey }) {
103
143
  /**
104
144
  * ¿ME QUEDO CON EL QUE LLEGA? Solo hacia adelante y solo si lo firma quien yo digo.
105
145
  * Devuelve el aviso vigente (el nuevo o el que ya tenía) y por qué.
146
+ *
147
+ * @param {{ current?: Advisory | null, incoming: unknown, publickey: string }} args
148
+ * @returns {Promise<{ advisory: Advisory | null, adopted: boolean, reason: 'not-an-advisory' | 'not-newer' | 'invalid-signature' | 'newer' | 'first' }>}
106
149
  */
107
150
  export async function adoptAdvisory ({ current, incoming, publickey }) {
108
151
  if (!isAdvisory(incoming)) return { advisory: current || null, adopted: false, reason: 'not-an-advisory' }
@@ -121,12 +164,19 @@ export async function adoptAdvisory ({ current, incoming, publickey }) {
121
164
  * Se suman, no se sustituyen: el aviso puede añadir lo que se descubrió después de esta
122
165
  * build, pero **no puede quitar** lo que esta build ya afirma. Que la red pudiera
123
166
  * desmarcar algo que el código da por roto sería el repliegue de manual.
167
+ *
168
+ * @param {{ baked?: Array<{ product: string, versions: string | string[], why?: string, fix?: string }>, advisory?: unknown }} [args]
169
+ * @returns {Array<{ product: string, versions: string | string[], why?: string, fix?: string }>}
124
170
  */
125
171
  export function brokenNow ({ baked = [], advisory = null } = {}) {
126
172
  return advisory && isAdvisory(advisory) ? [...baked, ...advisory.broken] : [...baked]
127
173
  }
128
174
 
129
- /** Lo que el administrador enseña del aviso vigente (§14: se ve, no se esconde). */
175
+ /**
176
+ * Lo que el administrador enseña del aviso vigente (§14: se ve, no se esconde).
177
+ * @param {unknown} advisory
178
+ * @returns {{ seq: number, issued: number, components: Array<{ product: string, versions: string[], why: string | null, fix: string | null }> } | null}
179
+ */
130
180
  export function advisorySummary (advisory) {
131
181
  if (!isAdvisory(advisory)) return null
132
182
  return {
@@ -21,9 +21,36 @@
21
21
  * consumidor (ver `PENDIENTES.md`, «pilar anidado»).
22
22
  */
23
23
 
24
- /** Lo que responde `check`. El `code` es lo que se compara; el texto puede cambiar. */
25
24
  import { satisfies } from './ranges.js'
26
25
 
26
+ /**
27
+ * El anuncio de una pieza: qué es, qué build corre, qué protocolo habla y cuáles entiende.
28
+ * @typedef {object} Declaration
29
+ * @property {string} product
30
+ * @property {string} version
31
+ * @property {number} protocol entero; sube solo cuando cambia el cable
32
+ * @property {number[]} speaks protocolos que entiende (incluye `protocol`)
33
+ * @property {string[]} [needs] permisos del acta que necesita
34
+ */
35
+
36
+ /**
37
+ * Una entrada de la lista de rotas.
38
+ * @typedef {object} BrokenEntry
39
+ * @property {string} product
40
+ * @property {string | string[]} versions lo mismo que un rango del manifiesto (`ranges.js`)
41
+ * @property {string} [why]
42
+ * @property {string} [fix]
43
+ */
44
+
45
+ /**
46
+ * Lo que responde `check`. El `code` es lo que se compara; el texto puede cambiar.
47
+ * @typedef {object} Verdict
48
+ * @property {boolean} compatible
49
+ * @property {string} code
50
+ * @property {string} reason
51
+ * @property {Declaration | null} peer
52
+ */
53
+
27
54
  export const OK = 'ok'
28
55
  export const INCOMPATIBLE_PROTOCOL = 'incompatible-protocol'
29
56
  export const BROKEN_PEER = 'broken-peer'
@@ -54,9 +81,14 @@ export const UNDECLARED = 'undeclared'
54
81
  * algún día se decide bloquear, se decide arriba y se escribe allí, no aquí.
55
82
  */
56
83
 
84
+ /** @param {unknown} n @returns {n is string[]} */
57
85
  const isNeeds = (n) => Array.isArray(n) && n.every((c) => typeof c === 'string' && c.length > 0)
58
86
 
59
- /** ¿Tiene forma de anuncio? No dice si es compatible, solo si se puede juzgar. */
87
+ /**
88
+ * ¿Tiene forma de anuncio? No dice si es compatible, solo si se puede juzgar.
89
+ * @param {any} d lo que llegó por la red, sin comprobar: esta función es la que lo comprueba
90
+ * @returns {d is Declaration}
91
+ */
60
92
  export function isDeclaration (d) {
61
93
  return !!d && typeof d.product === 'string' && d.product.length > 0 &&
62
94
  typeof d.version === 'string' && d.version.length > 0 &&
@@ -74,12 +106,16 @@ export function isDeclaration (d) {
74
106
  * que el acta le da (`missingCaps`) y ENSEÑA lo que falta, igual que una versión incompatible:
75
107
  * informa, no concede ni bloquea. Lo pagó `accounts`: le faltaba `sign`, renovar su papel le
76
108
  * devolvía uno que no le servía, y ninguna pantalla lo decía.
109
+ *
110
+ * @param {{ product: string, version: string, protocol: number, speaks?: number[], needs?: string[] }} args
111
+ * @returns {Declaration}
77
112
  */
78
113
  export function declare ({ product, version, protocol, speaks, needs }) {
79
114
  if (!Number.isInteger(protocol)) throw new Error('compat: protocol must be an integer')
80
115
  const habla = speaks && speaks.length ? [...new Set(speaks)].sort((a, b) => a - b) : [protocol]
81
116
  if (!habla.includes(protocol)) throw new Error('compat: speaks must include protocol')
82
117
  if (needs !== undefined && !isNeeds(needs)) throw new Error('compat: needs must be a list of record permissions')
118
+ /** @type {Declaration} */
83
119
  const d = { product: String(product), version: String(version), protocol, speaks: habla }
84
120
  if (needs && needs.length) d.needs = [...new Set(needs)].sort()
85
121
  if (!isDeclaration(d)) throw new Error('compat: incomplete declaration')
@@ -90,6 +126,10 @@ export function declare ({ product, version, protocol, speaks, needs }) {
90
126
  * Los permisos que la pieza declaró necesitar (`needs`) y el acta no le da (`caps`). Vacío si
91
127
  * no declaró nada o tiene todo. Lo que el acta no conoce también cuenta como falta: si una
92
128
  * pieza pide un permiso que esta bóveda no sabe dar, eso es lo que hay que ver.
129
+ *
130
+ * @param {Partial<Declaration> | null | undefined} declaration
131
+ * @param {Iterable<string>} [caps]
132
+ * @returns {string[]}
93
133
  */
94
134
  export function missingCaps (declaration, caps = []) {
95
135
  const needs = declaration?.needs
@@ -107,6 +147,10 @@ export function missingCaps (declaration, caps = []) {
107
147
  * de decir «esta versión entra» acaban discrepando, y esa discrepancia no hace ruido.
108
148
  *
109
149
  * Lo que no se entiende no coincide — no marca roto y tampoco absuelve: solo no dice nada.
150
+ *
151
+ * @param {BrokenEntry[] | null | undefined} lista
152
+ * @param {{ product: string, version: string }} who
153
+ * @returns {BrokenEntry | null} la entrada que la marca rota, o null
110
154
  */
111
155
  export function isBroken (lista, { product, version }) {
112
156
  for (const b of lista || []) {
@@ -131,10 +175,11 @@ export function isBroken (lista, { product, version }) {
131
175
  * Y de ahí sale por qué avisar es la otra mitad: si el viejo no puede juzgar, tampoco puede
132
176
  * enterarse solo. El que ve la incompatibilidad es el único que puede decírselo.
133
177
  *
134
- * @param {object} o.mine mi declaración
135
- * @param {object} o.theirs la del otro (o null si no dijo nada)
136
- * @param {Array} [o.broken] mi lista de rotas (la del código más la del aviso de la red)
137
- * @returns {{compatible:boolean, code:string, reason:string, peer:object|null}}
178
+ * @param {object} [o]
179
+ * @param {Declaration} [o.mine] mi declaración
180
+ * @param {unknown} [o.theirs] la del otro (o null si no dijo nada)
181
+ * @param {BrokenEntry[]} [o.broken] mi lista de rotas (la del código más la del aviso de la red)
182
+ * @returns {Verdict}
138
183
  */
139
184
  export function check ({ mine, theirs, broken = [] } = {}) {
140
185
  if (!isDeclaration(mine)) throw new Error('compat: my own declaration is not valid')
@@ -184,6 +229,10 @@ export function check ({ mine, theirs, broken = [] } = {}) {
184
229
  * El mensaje original no se toca: se le añade detrás. Nadie que empareje por texto se rompe
185
230
  * si compara por prefijo, y quien compare por `code` no se entera (ver «los errores son un
186
231
  * contrato»).
232
+ *
233
+ * @param {string} message
234
+ * @param {Verdict | null | undefined} verdict
235
+ * @returns {string}
187
236
  */
188
237
  export function annotate (message, verdict) {
189
238
  if (!verdict || verdict.compatible !== false) return message
@@ -197,6 +246,8 @@ export function annotate (message, verdict) {
197
246
  * Lleva las dos declaraciones porque el que lo recibe suele ser el que NO sabe que está
198
247
  * roto —es el viejo—, así que hay que decirle qué es él, qué somos nosotros y qué hacer.
199
248
  * Sin esto el rechazo sería otro silencio, que es de lo que venimos huyendo.
249
+ *
250
+ * @param {{ mine: Declaration, theirs: unknown, verdict: Verdict }} args
200
251
  */
201
252
  export function incompatibleNotice ({ mine, theirs, verdict }) {
202
253
  return {
@@ -25,13 +25,22 @@
25
25
 
26
26
  const PARTES = /^(\d+)\.(\d+)\.(\d+)$/
27
27
 
28
- /** `[major, minor, patch]`, o `null` si no tiene la forma. */
28
+ /**
29
+ * `[major, minor, patch]`, o `null` si no tiene la forma.
30
+ * @param {unknown} v
31
+ * @returns {[number, number, number] | null}
32
+ */
29
33
  export function parseVersion (v) {
30
34
  const m = PARTES.exec(String(v || '').trim())
31
35
  return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null
32
36
  }
33
37
 
34
- /** -1, 0 o 1. Lanza si alguna no tiene forma: comparar basura no puede dar un resultado. */
38
+ /**
39
+ * -1, 0 o 1. Lanza si alguna no tiene forma: comparar basura no puede dar un resultado.
40
+ * @param {string} a
41
+ * @param {string} b
42
+ * @returns {-1 | 0 | 1}
43
+ */
35
44
  export function compareVersions (a, b) {
36
45
  const x = parseVersion(a)
37
46
  const y = parseVersion(b)
@@ -42,6 +51,7 @@ export function compareVersions (a, b) {
42
51
  return 0
43
52
  }
44
53
 
54
+ /** @type {Array<[string, (c: number) => boolean]>} */
45
55
  const OPS = [
46
56
  ['>=', (c) => c >= 0],
47
57
  ['<=', (c) => c <= 0],
@@ -1,4 +1,4 @@
1
- Copia vendorizada de @dotrino/proxy-client@0.46.0 (dotrino-proxy-client/src/{binpack,ble/manager,ble/wire,canonical,client,encpub,errors,index,parts,sealing,signature,stats-log,stats,webrtc}.js).
1
+ Copia vendorizada de @dotrino/proxy-client@0.47.0 (dotrino-proxy-client/src/{binpack,ble/manager,ble/wire,canonical,client,encpub,errors,index,parts,sealing,signature,stats-log,stats,webrtc}.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
  sealing.js resuelve @dotrino/identity/content de forma PEREZOSA (= ../../content.js
4
4
  por el import map): solo se carga si de verdad se sella algo.
@@ -169,6 +169,11 @@ export class WebSocketProxyClient {
169
169
  *
170
170
  * Pass `sealing: { seal(msg, peerEncPub), open(envelope), isSealed(msg) }` to
171
171
  * plug the second case in. Without it, the built-in sealing is used.
172
+ *
173
+ * BOTH AT ONCE (0.47.0): a vault inside an app (the password extension) seals the app's
174
+ * own messages with `sealing` and still has to open what the ecosystem seals to its
175
+ * transport key with the pilar's envelope. With `myEncPrivateKey` next to `sealing`,
176
+ * the pilar envelope is opened too, and `sendSealed*(…, { pilar: true })` seals with it.
172
177
  */
173
178
  this.sealing = options.sealing || null
174
179
 
@@ -675,7 +680,12 @@ export class WebSocketProxyClient {
675
680
  * Seal a payload towards a peer's encryption key and send it. This is what an app
676
681
  * should use for anything that is not meant for the proxy's eyes.
677
682
  */
678
- async sendSealed (toPubkeys, payload, { peerEncPub, ...opts } = {}) {
683
+ /**
684
+ * @param {string|string[]} toPubkeys
685
+ * @param {any} payload
686
+ * @param {{ peerEncPub?: string, pilar?: boolean, ephemeral?: boolean, quiet?: boolean, app?: string }} [options]
687
+ */
688
+ async sendSealed (toPubkeys, payload, { peerEncPub, pilar = false, ...opts } = {}) {
679
689
  const list = Array.isArray(toPubkeys) ? toPubkeys : [toPubkeys]
680
690
  // Por pubkey el mensaje puede quedarse ESPERANDO en el proxio, y ahí se deja como mucho
681
691
  // 8 MB de archivo (parts.js). Lo que pasa de eso no se manda: se dice, y la app decide.
@@ -693,7 +703,7 @@ export class WebSocketProxyClient {
693
703
  // Con la llave puesta a mano se respeta tal cual: quien la pasa está diciendo que ya
694
704
  // sabe de quién es (se emparejaron), y un sobre vale para todos los destinatarios.
695
705
  if (peerEncPub) {
696
- const sealPiece = await this._sealerFor(m.bin, peerEncPub, list.length === 1 ? list[0] : undefined)
706
+ const sealPiece = await this._sealerFor(m.bin, peerEncPub, list.length === 1 ? list[0] : undefined, pilar)
697
707
  for (const piece of pieces) this._sendByPubkeyRaw(list, await sealPiece(piece), opts)
698
708
  return
699
709
  }
@@ -705,7 +715,7 @@ export class WebSocketProxyClient {
705
715
  // sin forma de saber cuál mitad.
706
716
  const keys = await Promise.all(list.map(async (pk) => [pk, await this.encPubOf(pk)]))
707
717
  for (const [pk, encPub] of keys) {
708
- const sealPiece = await this._sealerFor(m.bin, encPub, pk)
718
+ const sealPiece = await this._sealerFor(m.bin, encPub, pk, pilar)
709
719
  for (const piece of pieces) this._sendByPubkeyRaw([pk], await sealPiece(piece), opts)
710
720
  }
711
721
  }
@@ -721,9 +731,9 @@ export class WebSocketProxyClient {
721
731
  *
722
732
  * @param {string|string[]} toTokens
723
733
  * @param {any} payload
724
- * @param {{ peerPubkey?:string, peerEncPub?:string }} opts
734
+ * @param {{ peerPubkey?:string, peerEncPub?:string, pilar?:boolean }} [opts]
725
735
  */
726
- async sendSealedTo (toTokens, payload, { peerPubkey, peerEncPub } = /** @type {any} */ ({})) {
736
+ async sendSealedTo (toTokens, payload, { peerPubkey, peerEncPub, pilar = false } = /** @type {any} */ ({})) {
727
737
  const tokens = Array.isArray(toTokens) ? toTokens : [toTokens]
728
738
  if (!peerEncPub) {
729
739
  // Si la app no lo dice, lo dice el SALUDO: `helloTo` dejó apuntado de quién es
@@ -750,7 +760,7 @@ export class WebSocketProxyClient {
750
760
  // versión que ya se actualizó.
751
761
  if (m.bin) this._needPeerBinary(tokens)
752
762
  if (m.bin && !direct) this._needBinaryProxy()
753
- const sealPiece = await this._sealerFor(m.bin, peerEncPub, peerPubkey)
763
+ const sealPiece = await this._sealerFor(m.bin, peerEncPub, peerPubkey, pilar)
754
764
  if (m.len <= size) {
755
765
  const envelope = await sealPiece(m.bin ? m.whole : payload)
756
766
  if (tokens.length === 1 && peerPubkey) { this._sendToTokenOrQueue(tokens[0], envelope, peerPubkey); return }
@@ -993,23 +1003,37 @@ export class WebSocketProxyClient {
993
1003
  this._emit('peer_identity', from, msg.publickey)
994
1004
  }
995
1005
 
996
- /** Sella con lo que haya: la bóveda de la app (`sealing`) o las primitivas del pilar. */
997
- async _seal (payload, peerEncPub, peerPubkey) {
1006
+ /**
1007
+ * Sella con lo que haya: la bóveda de la app (`sealing`) o las primitivas del pilar.
1008
+ * `pilar`: con el sobre del pilar aunque haya `sealing` (lo abre quien tenga la privada de
1009
+ * `peerEncPub`, sin pasar por ninguna bóveda).
1010
+ */
1011
+ async _seal (payload, peerEncPub, peerPubkey, pilar = false) {
998
1012
  if (!peerEncPub) throw errorWithCode('seal: missing peerEncPub', 'unsealed')
999
- return this.sealing
1013
+ return this.sealing && !pilar
1000
1014
  ? this.sealing.seal(payload, peerEncPub, { publickey: peerPubkey })
1001
1015
  : seal(payload, peerEncPub)
1002
1016
  }
1003
1017
 
1018
+ /** ¿Este sobre es de la bóveda de la app (`sealing`)? Si no, es el del pilar. */
1019
+ _bySealing (env) { return !!this.sealing && this.sealing.isSealed(env) }
1020
+
1021
+ /** Abre un sobre con quien toca: la bóveda de la app o la llave del pilar. */
1022
+ _openEnvelope (env, meta) {
1023
+ if (this._bySealing(env)) return this.sealing.open(env, meta)
1024
+ if (!this.myEncPrivateKey) throw errorWithCode('no encryption key to open a pilar envelope', 'unsealed')
1025
+ return open(env, this.myEncPrivateKey)
1026
+ }
1027
+
1004
1028
  /**
1005
1029
  * Quién sella las piezas de UN mensaje hacia UN destinatario. Con bytes (sealing.js): una
1006
1030
  * CEK para el mensaje entero, sellada una vez con el sellado de siempre, y cada pieza
1007
1031
  * cifrada como bytes con ella. Sin bytes, el sobre de texto de siempre por pieza.
1008
1032
  */
1009
- async _sealerFor (bin, peerEncPub, peerPubkey) {
1010
- if (!bin) return (piece) => this._seal(piece, peerEncPub, peerPubkey)
1033
+ async _sealerFor (bin, peerEncPub, peerPubkey, pilar = false) {
1034
+ if (!bin) return (piece) => this._seal(piece, peerEncPub, peerPubkey, pilar)
1011
1035
  const cek = await makeMessageKey()
1012
- const k = await this._seal({ cek }, peerEncPub, peerPubkey)
1036
+ const k = await this._seal({ cek }, peerEncPub, peerPubkey, pilar)
1013
1037
  return async (bytes) => {
1014
1038
  const { iv, ct } = await encryptBytes(cek, bytes)
1015
1039
  return pack({ bv: BIN_SEALED, k, iv, ct })
@@ -1046,7 +1070,7 @@ export class WebSocketProxyClient {
1046
1070
  let p = this._msgKeys.get(id)
1047
1071
  if (!p) {
1048
1072
  p = (async () => {
1049
- const o = this.sealing ? await this.sealing.open(k, meta) : await open(k, this.myEncPrivateKey)
1073
+ const o = await this._openEnvelope(k, meta)
1050
1074
  if (!o || typeof o.cek !== 'string') throw errorWithCode('the sealed key of a message has no key inside', 'bad-pack')
1051
1075
  return o.cek
1052
1076
  })()
@@ -1195,7 +1219,7 @@ export class WebSocketProxyClient {
1195
1219
  try { env = unpack(msg) } catch (_) { return false }
1196
1220
  return isBinSealed(env) && this._isSealed(env.k)
1197
1221
  }
1198
- return this.sealing ? this.sealing.isSealed(msg) : isSealed(msg)
1222
+ return this.sealing ? (this.sealing.isSealed(msg) || (!!this.myEncPrivateKey && isSealed(msg))) : isSealed(msg)
1199
1223
  }
1200
1224
 
1201
1225
  sendByPubkey (toPubkeys, payload, opts = {}) {
@@ -1238,7 +1262,7 @@ export class WebSocketProxyClient {
1238
1262
  this._emit('error', { type: 'undecipherable', from, error: e })
1239
1263
  return
1240
1264
  }
1241
- const senderEncPub = this.sealing?.senderOf?.(env.k) || null
1265
+ const senderEncPub = (this._bySealing(env.k) && this.sealing?.senderOf?.(env.k)) || null
1242
1266
  this._handOpened(from, opened, { ...meta, sealed: true, ...(senderEncPub ? { senderEncPub } : {}) })
1243
1267
  return
1244
1268
  }
@@ -1250,12 +1274,10 @@ export class WebSocketProxyClient {
1250
1274
  return
1251
1275
  }
1252
1276
  try {
1253
- const opened = this.sealing
1254
- ? await this.sealing.open(payload, meta)
1255
- : await open(payload, this.myEncPrivateKey)
1277
+ const opened = await this._openEnvelope(payload, meta)
1256
1278
  // Quién selló (la llave de cifrado), si el sobre lo dice: es lo que autentica al
1257
1279
  // remitente, porque solo quien tiene esa privada pudo armarlo.
1258
- const senderEncPub = this.sealing?.senderOf?.(payload) || null
1280
+ const senderEncPub = (this._bySealing(payload) && this.sealing?.senderOf?.(payload)) || null
1259
1281
  this._handOpened(from, opened, { ...meta, sealed: true, ...(senderEncPub ? { senderEncPub } : {}) })
1260
1282
  } catch (e) {
1261
1283
  // Sealed to somebody else, or tampered with. Staying quiet is the point.
@@ -15,7 +15,7 @@ export const MANIFESTS = Object.freeze({
15
15
  "compat": {
16
16
  "repo": "imdotrino/dotrino-compat",
17
17
  "npm": "@dotrino/compat",
18
- "current": "0.5.0",
18
+ "current": "0.5.1",
19
19
  "protocol": 1,
20
20
  "requires": {}
21
21
  },
@@ -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.135.0",
34
+ "current": "0.135.1",
35
35
  "protocol": 1,
36
36
  "requires": {
37
37
  "proxy-client": ">=0.13.1"
@@ -40,7 +40,7 @@ export const MANIFESTS = Object.freeze({
40
40
  "lobby": {
41
41
  "repo": "imdotrino/dotrino-lobby",
42
42
  "npm": "@dotrino/lobby",
43
- "current": "0.10.4",
43
+ "current": "0.10.5",
44
44
  "protocol": 2,
45
45
  "requires": {
46
46
  "proxy-client": ">=0.22.0",
@@ -86,7 +86,7 @@ export const MANIFESTS = Object.freeze({
86
86
  "notifications": {
87
87
  "repo": "imdotrino/dotrino-notifications",
88
88
  "npm": "@dotrino/notifications",
89
- "current": "0.7.2",
89
+ "current": "0.7.3",
90
90
  "protocol": 2,
91
91
  "requires": {
92
92
  "proxy-client": ">=0.20.0"
@@ -102,7 +102,7 @@ export const MANIFESTS = Object.freeze({
102
102
  "profile": {
103
103
  "repo": "imdotrino/dotrino-profile",
104
104
  "npm": "@dotrino/profile",
105
- "current": "0.21.1",
105
+ "current": "0.21.2",
106
106
  "protocol": 1,
107
107
  "requires": {
108
108
  "identity": ">=0.33.0",
@@ -111,7 +111,7 @@ export const MANIFESTS = Object.freeze({
111
111
  },
112
112
  "proxy": {
113
113
  "repo": "imdotrino/dotrino-proxy",
114
- "current": "1.11.0",
114
+ "current": "1.11.1",
115
115
  "protocol": 2,
116
116
  "requires": {
117
117
  "vault": ">=0.87.0",
@@ -123,7 +123,7 @@ export const MANIFESTS = Object.freeze({
123
123
  "proxy-client": {
124
124
  "repo": "imdotrino/dotrino-proxy-client",
125
125
  "npm": "@dotrino/proxy-client",
126
- "current": "0.46.0",
126
+ "current": "0.46.1",
127
127
  "protocol": 2,
128
128
  "requires": {
129
129
  "identity": ">=0.53.0",
@@ -133,7 +133,7 @@ export const MANIFESTS = Object.freeze({
133
133
  "remote-agent": {
134
134
  "repo": "imdotrino/dotrino-remote-agent",
135
135
  "npm": "@dotrino/remote-agent",
136
- "current": "0.32.1",
136
+ "current": "0.32.2",
137
137
  "protocol": 1,
138
138
  "requires": {
139
139
  "identity": ">=0.121.7",
@@ -146,7 +146,7 @@ export const MANIFESTS = Object.freeze({
146
146
  "tunnel": {
147
147
  "repo": "imdotrino/dotrino-tunnel",
148
148
  "npm": "@dotrino/tunnel",
149
- "current": "0.5.2",
149
+ "current": "0.5.3",
150
150
  "protocol": 2,
151
151
  "requires": {
152
152
  "identity": ">=0.127.0",
@@ -224,7 +224,7 @@ export const MANIFESTS = Object.freeze({
224
224
  "sealers": {
225
225
  "repo": "imdotrino/dotrino-sealers",
226
226
  "npm": "@dotrino/sealers",
227
- "current": "0.11.0",
227
+ "current": "0.11.1",
228
228
  "protocol": 1,
229
229
  "requires": {
230
230
  "remote-agent": ">=0.30.0",
@@ -245,7 +245,7 @@ export const MANIFESTS = Object.freeze({
245
245
  "store": {
246
246
  "repo": "imdotrino/dotrino-store",
247
247
  "npm": "@dotrino/store",
248
- "current": "0.14.1",
248
+ "current": "0.14.3",
249
249
  "protocol": 1,
250
250
  "requires": {
251
251
  "identity": ">=0.91.0",
@@ -262,7 +262,7 @@ export const MANIFESTS = Object.freeze({
262
262
  "topbar": {
263
263
  "repo": "imdotrino/dotrino-topbar",
264
264
  "npm": "@dotrino/topbar",
265
- "current": "0.17.0",
265
+ "current": "0.17.2",
266
266
  "protocol": 1,
267
267
  "requires": {
268
268
  "identity": ">=0.96.1",
@@ -272,7 +272,7 @@ export const MANIFESTS = Object.freeze({
272
272
  "vault": {
273
273
  "repo": "imdotrino/dotrino-vault",
274
274
  "npm": "@dotrino/vault",
275
- "current": "0.118.0",
275
+ "current": "0.119.0",
276
276
  "protocol": 1,
277
277
  "requires": {
278
278
  "vaultd": ">=0.105.0",
@@ -288,7 +288,7 @@ export const MANIFESTS = Object.freeze({
288
288
  "vaultd": {
289
289
  "repo": "imdotrino/dotrino-vault",
290
290
  "npm": "@dotrino/vaultd",
291
- "current": "0.190.1",
291
+ "current": "0.191.0",
292
292
  "protocol": 1,
293
293
  "requires": {
294
294
  "identity": ">=0.135.0",
@@ -305,7 +305,7 @@ export const MANIFESTS = Object.freeze({
305
305
  "verifier": {
306
306
  "repo": "imdotrino/dotrino-verifier",
307
307
  "npm": "@dotrino/verifier",
308
- "current": "0.3.1",
308
+ "current": "0.3.2",
309
309
  "protocol": 1,
310
310
  "requires": {
311
311
  "identity": "0.87.0+"
@@ -341,12 +341,12 @@ export const MANIFESTS = Object.freeze({
341
341
  },
342
342
  "passmanager-extension": {
343
343
  "repo": "imdotrino/dotrino-passmanager",
344
- "current": "0.58.3",
344
+ "current": "0.58.4",
345
345
  "protocol": 1,
346
346
  "requires": {
347
- "identity": ">=0.128.0",
348
- "proxy-client": ">=0.36.1",
349
- "vault": ">=0.106.0",
347
+ "identity": ">=0.135.1",
348
+ "proxy-client": ">=0.46.0",
349
+ "vault": ">=0.119.0",
350
350
  "proxy": "1.1.0+",
351
351
  "vaultd": ">=0.160.2"
352
352
  }
@@ -399,14 +399,14 @@ export const MANIFESTS = Object.freeze({
399
399
  "ai": {
400
400
  "repo": "imdotrino/dotrino-ai",
401
401
  "npm": "@dotrino/ai",
402
- "current": "0.1.1",
402
+ "current": "0.1.2",
403
403
  "protocol": 1,
404
404
  "requires": {}
405
405
  },
406
406
  "dictation": {
407
407
  "repo": "imdotrino/dotrino-dictation",
408
408
  "npm": "@dotrino/dictation",
409
- "current": "0.1.1",
409
+ "current": "0.1.2",
410
410
  "protocol": 1,
411
411
  "requires": {}
412
412
  },
@@ -425,14 +425,14 @@ export const MANIFESTS = Object.freeze({
425
425
  "pay": {
426
426
  "repo": "imdotrino/dotrino-pay",
427
427
  "npm": "@dotrino/pay",
428
- "current": "0.2.0",
428
+ "current": "0.2.1",
429
429
  "protocol": 1,
430
430
  "requires": {}
431
431
  },
432
432
  "update": {
433
433
  "repo": "imdotrino/dotrino-update",
434
434
  "npm": "@dotrino/update",
435
- "current": "0.9.2",
435
+ "current": "0.9.3",
436
436
  "protocol": 1,
437
437
  "requires": {}
438
438
  }
@@ -1,3 +1,3 @@
1
- Copia vendorizada de @dotrino/store/core@0.14.2 (dotrino-store/store/{core}.js).
1
+ Copia vendorizada de @dotrino/store/core@0.14.3 (dotrino-store/store/{core}.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
  Las reglas del almacén (lápidas, páginas): las mismas en el store y en la bóveda.
@@ -1,4 +1,4 @@
1
- Copia vendorizada de @dotrino/vault@0.119.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/memberGroups,core/notices,core/notifiable,core/passwords,core/sealKey,core/sealer,core/sealers,core/secretsStore,core/sha256,core/siblingBackup,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.120.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/memberGroups,core/notices,core/notifiable,core/passwords,core/sealKey,core/sealer,core/sealers,core/secretsStore,core/sha256,core/siblingBackup,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.119.0'
8
+ export const LIB_VERSION = '0.120.0'
@@ -81,12 +81,16 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
81
81
  // CON QUÉ SE ABRE LO QUE NOS SELLAN (`commKey.encKeypair`): sin esto la bóveda no podía
82
82
  // recibir nada sellado, y una hermana cerrada no habría podido abrir los cajones que le
83
83
  // manda la otra. El pilar anuncia la pública al identificarse con la llave de comunicación.
84
- const enc = commKey?.pub?.() && typeof commKey.encKeypair === 'function'
84
+ let enc = commKey?.pub?.() && typeof commKey.encKeypair === 'function'
85
85
  ? await commKey.encKeypair().catch((e) => { log('[vault] no transport encryption key: ' + e.message); return null })
86
86
  : null
87
- const client = makeClient ? makeClient({ url, acceptDirectFrom: inActa }) : new WebSocketProxyClient({
87
+ // Y A QUIEN CREA EL CLIENTE TAMBIÉN se le pasa (la extensión, la pestaña): sin esto una bóveda
88
+ // de navegador no anunciaba llave de cifrado, y lo que sus aparatos le sellan
89
+ // (`docs/sealed-requests.md`) no tenía con qué abrirse.
90
+ const encOpts = enc ? { myEncPub: enc.encPub, myEncPrivateKey: enc.privateKey } : {}
91
+ const client = makeClient ? makeClient({ url, acceptDirectFrom: inActa, ...encOpts }) : new WebSocketProxyClient({
88
92
  url, enableWebRTC: true, acceptDirectFrom: inActa, autoReconnect: true,
89
- ...(enc ? { myEncPub: enc.encPub, myEncPrivateKey: enc.privateKey } : {}),
93
+ ...encOpts,
90
94
  maxReconnectAttempts: 100000, reconnectDelay: 4000,
91
95
  // EL BLUETOOTH (proxy-client docs/bluetooth.md) lo decide la plataforma: el binario en
92
96
  // Linux sí; la pestaña y la extensión no pueden. Misma puerta que WebRTC (`inActa`).
@@ -118,6 +122,14 @@ export async function createTransport ({ identity, url = DEFAULT_PROXY, commKey
118
122
  const record = (await identity.profileActa?.().catch(() => null))?.acta || null
119
123
  seenActa = record // la copia que mira la puerta del canal directo
120
124
  const comm = commKey?.pub?.() || null
125
+ // LA LLAVE DE CIFRADO TAMBIÉN SI LA DE COMUNICACIÓN SE ESTRENÓ DESPUÉS de crear el cliente
126
+ // (un perfil con contraseña la estrena al abrirse). Sin esto la bóveda volvía a la red con
127
+ // su llave nueva pero sin anunciar con qué se le sella, y lo que sus aparatos le mandan
128
+ // sellado (`docs/sealed-requests.md`) no tenía con qué abrirse.
129
+ if (comm && !enc && typeof commKey.encKeypair === 'function') {
130
+ enc = await commKey.encKeypair().catch((e) => { log('[vault] no transport encryption key: ' + e.message); return null })
131
+ if (enc) client.updateConfig?.({ myEncPub: enc.encPub, myEncPrivateKey: enc.privateKey })
132
+ }
121
133
  // ¿Nos nombra el acta? Con `cn` o sin él, lo que el proxio mira es la pertenencia.
122
134
  const isMember = comm && (record?.members || []).some((m) => m?.pub === comm)
123
135
 
@@ -46,7 +46,7 @@ import { BACKUP_VERSION, PASSWORDS_DRAWER, wants, assertSelected, planImport, re
46
46
  import { openSealKeys } from './sealKey.js'
47
47
  import { openCommKey, COMM_CN, COMM_CAPS } from './commKey.js'
48
48
  import { seal } from '../sealed.js'
49
- import { MSG, SCOPE, secretsScope, isValidSecretsNs, VAULT_PROTOCOL, VAULT_SPEAKS } from '../protocol.js'
49
+ import { MSG, SCOPE, secretsScope, isValidSecretsNs, VAULT_PROTOCOL, VAULT_SPEAKS, SEALED_REQUEST_TYPES, unsealedRequestsAllowed, UNSEALED_REQUESTS_UNTIL_TEXT } from '../protocol.js'
50
50
  import { sha256Hex } from './sha256.js'
51
51
  import { sealHead, ANCHOR_EVERY_MS, ANCHOR_FIRST_MS } from './logAnchor.js'
52
52
  import { createGate } from './gate.js'
@@ -656,6 +656,63 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
656
656
  */
657
657
  const channels = new Map()
658
658
 
659
+ /**
660
+ * LA RESPUESTA A UNA PETICIÓN SELLADA VUELVE SELLADA (`docs/sealed-requests.md`).
661
+ *
662
+ * El aparato mete en lo firmado una llave de un solo uso (`data.rek`), y a esa llave se le
663
+ * sella todo lo que se le conteste a ESA petición. Se hace con un canal más de `channels`
664
+ * —como el socket local—, así que ningún mostrador tiene que saber nada: contesta a `from`
665
+ * como siempre y el canal sella. El canal es por conexión Y llave: dos peticiones por la
666
+ * misma conexión con llaves distintas no se pisan, y un tercero que escriba «desde» ese
667
+ * token con otra llave se lleva su propio canal, no el del aparato.
668
+ *
669
+ * Viven lo que puede tardar la respuesta más lenta (un pedido que espera al teléfono) y se
670
+ * podan por antigüedad; si ya no está, la respuesta a un pedido aprobado sale por la cola
671
+ * del aparato, como antes.
672
+ */
673
+ const SEALED_CHANNEL_TTL_MS = 24 * 60 * 60 * 1000
674
+ const SEALED_CHANNELS_MAX = 5000
675
+ const sealedChannelAt = new Map()
676
+ function sealedChannel (token, rek) {
677
+ const id = `sealed:${token}:${sha256Hex(rek).slice(0, 16)}`
678
+ const now = Date.now()
679
+ if (!channels.has(id)) {
680
+ for (const [k, t] of sealedChannelAt) {
681
+ if (now - t < SEALED_CHANNEL_TTL_MS && sealedChannelAt.size < SEALED_CHANNELS_MAX) break
682
+ sealedChannelAt.delete(k); channels.delete(k)
683
+ }
684
+ // EN ORDEN: sellar es asíncrono, y dos respuestas seguidas podían adelantarse una a la
685
+ // otra. El orden importa (el aviso firmado de expulsión va ANTES del «no», porque el
686
+ // aparato deja de escuchar al recibir el «no»), así que salen en fila.
687
+ let tail = Promise.resolve()
688
+ channels.set(id, (obj) => {
689
+ tail = tail.then(() => client.sendSealedTo(token, obj, { peerEncPub: rek, pilar: true }))
690
+ .catch((e) => log(`[vault] could not send a sealed reply (${e.code || 'error'}): ${e.message}`))
691
+ })
692
+ }
693
+ sealedChannelAt.delete(id)
694
+ sealedChannelAt.set(id, now)
695
+ return id
696
+ }
697
+ const unsealedTold = new Map()
698
+ /** MIGRACIÓN (caduca 2026-12-15): una petición en claro de un cliente viejo. */
699
+ function unsealedRequest (from, payload) {
700
+ const type = String(payload.type)
701
+ if (!unsealedRequestsAllowed()) {
702
+ audit('rejected', { what: type, reason: 'unsealed' })
703
+ reply(from, { type: MSG.ERROR, error: `${type}: requests must be sealed to this vault — update the client`, code: 'request-unsealed' })
704
+ return false
705
+ }
706
+ const t = Date.now()
707
+ if (t - (unsealedTold.get(type) || 0) > 60 * 60 * 1000) {
708
+ unsealedTold.set(type, t)
709
+ log(`[vault] ${type} arrived UNSEALED from an old client: served until ${UNSEALED_REQUESTS_UNTIL_TEXT} (migration), then refused — update it`)
710
+ }
711
+ return true
712
+ }
713
+ const SEALED_TYPES = new Set(SEALED_REQUEST_TYPES)
714
+
715
+
659
716
  /**
660
717
  * QUÉ SOMOS, Y QUÉ CORRE CADA APARATO (CONVENCIONES §14, `@dotrino/compat`).
661
718
  *
@@ -2575,6 +2632,19 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2575
2632
  if (pass.throttled) reply(from, { type: MSG.ERROR, error: 'too many tries: wait before trying again', code: 'too-many-tries', waitMs: pass.waitMs })
2576
2633
  return
2577
2634
  }
2635
+ // ¿SELLADA? Por el socket local (`channels`) no hace falta: no toca la red. Por el proxio,
2636
+ // lo que pide un aparato tiene que venir sellado, y su respuesta vuelve sellada a `rek`.
2637
+ if (SEALED_TYPES.has(payload.type) && !channels.has(from)) {
2638
+ if (meta?.sealed) {
2639
+ const rek = payload?.data?.rek
2640
+ if (!ActaPilar.isEncPub(rek)) {
2641
+ // Sellada pero sin a dónde sellar la respuesta: contestar en claro sería deshacer el
2642
+ // sobre de la petición. Se dice, en claro y sin nada del aparato dentro.
2643
+ return reply(from, { type: MSG.ERROR, error: `${payload.type}: a sealed request needs data.rek to seal the reply to`, code: 'no-reply-key' })
2644
+ }
2645
+ from = sealedChannel(from, rek)
2646
+ } else if (!unsealedRequest(from, payload)) return
2647
+ }
2578
2648
  try {
2579
2649
  if (payload.type === MSG.HELLO) return desk.handleHello(from, payload)
2580
2650
  if (payload.type === MSG.ENROLL) return await desk.handleEnroll(from, payload)
@@ -168,3 +168,28 @@ export const VAULT_PROTOCOL = 1
168
168
 
169
169
  /** Los protocolos que esta build entiende. Al añadir el 2, aquí van `[1, 2]`. */
170
170
  export const VAULT_SPEAKS = [1]
171
+
172
+ /**
173
+ * LAS PETICIONES DE UN APARATO A SU BÓVEDA VAN SELLADAS (regla `encrypted`, dueño 2026-10-26:
174
+ * nada viaja en claro por la red). El aparato sella la petición ENTERA a la llave de cifrado
175
+ * del transporte de la bóveda (`sendSealed` del pilar, `@dotrino/identity/vault-seal`) y mete
176
+ * dentro de lo firmado la llave de un solo uso a la que se le sella la respuesta (`data.rek`).
177
+ * Diseño: `docs/sealed-requests.md`.
178
+ *
179
+ * Estos son los tipos que lo exigen: lo que pide un aparato con su firma. El emparejamiento,
180
+ * la entrada con contraseña y lo que se cruzan las bóvedas siguen su propio camino.
181
+ */
182
+ export const SEALED_REQUEST_TYPES = Object.freeze([
183
+ MSG.SIGN, MSG.GET, MSG.STORE, MSG.CHECK, MSG.DEVICES, MSG.RENEW, MSG.SECRETS,
184
+ MSG.ADMIN, MSG.RENOUNCE, MSG.INCIDENT, MSG.REWRAP_OK
185
+ ])
186
+
187
+ /**
188
+ * MIGRACIÓN — CADUCA EL 2026-12-15. Hasta esa fecha una petición de esos tipos que llega en
189
+ * claro (un cliente viejo) se atiende y se apunta en el log; desde esa fecha se rechaza con
190
+ * `request-unsealed`. Lo cubre `test/sealed-requests.test.mjs`. Quitar en cuanto pase.
191
+ */
192
+ export const UNSEALED_REQUESTS_UNTIL = Date.UTC(2026, 11, 15)
193
+ export const UNSEALED_REQUESTS_UNTIL_TEXT = '2026-12-15'
194
+ /** ¿Todavía se atiende una petición en claro? (migración, ver arriba) */
195
+ export const unsealedRequestsAllowed = (now = Date.now()) => now < UNSEALED_REQUESTS_UNTIL