@dotrino/identity 0.136.0 → 0.136.2
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 +3 -2
- package/src/index.d.ts +60 -2
- package/src/index.js +364 -81
- package/src/node.js +29 -5
- package/types/acta.d.ts +397 -175
- package/types/assertion.d.ts +25 -18
- package/types/avatar.d.ts +14 -3
- package/types/capabilities.d.ts +110 -61
- package/types/content.d.ts +88 -45
- package/types/core.d.ts +578 -383
- package/types/keyid.d.ts +10 -3
- package/types/machine.d.ts +5 -1
- package/types/peerStore.d.ts +80 -0
- package/types/peerSync.d.ts +20 -6
- package/types/remote.d.ts +170 -42
- package/types/session.d.ts +74 -81
- package/types/sessionFlow.d.ts +108 -33
- package/types/vaultSeal.d.ts +21 -9
- package/vault/acta.js +245 -29
- package/vault/assertion.js +13 -4
- package/vault/avatar.js +12 -1
- package/vault/capabilities.js +56 -6
- package/vault/channel.js +18 -2
- package/vault/content.js +60 -6
- package/vault/core.js +419 -88
- package/vault/externalKeys.js +34 -2
- package/vault/facade.js +182 -24
- package/vault/globals.d.ts +60 -0
- package/vault/keyid.js +10 -1
- package/vault/machine.js +7 -1
- package/vault/nativeStore.js +21 -4
- package/vault/originPolicy.js +13 -2
- package/vault/peerStore.js +57 -10
- package/vault/peerSync.js +23 -4
- package/vault/remote.js +132 -32
- package/vault/session.js +24 -7
- package/vault/sessionFlow.js +43 -9
- package/vault/sync.js +59 -15
- package/vault/vault.js +78 -49
- package/vault/vaultSeal.js +18 -7
- package/vault/vendor/compat/VERSION.txt +1 -1
- package/vault/vendor/compat/advisory.js +58 -8
- package/vault/vendor/compat/index.js +57 -6
- package/vault/vendor/compat/ranges.js +12 -2
- package/vault/vendor/proxy-client/VERSION.txt +1 -1
- package/vault/vendor/proxy-client/client.js +41 -19
- package/vault/vendor/roadmap/manifests.js +23 -23
- package/vault/vendor/store/VERSION.txt +1 -1
- package/vault/vendor/vault/VERSION.txt +1 -1
- package/vault/vendor/vault/core/libVersion.js +1 -1
- package/vault/vendor/vault/core/transport.js +15 -3
- package/vault/vendor/vault/core/vault.js +71 -1
- package/vault/vendor/vault/protocol.js +25 -0
|
@@ -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
|
-
/**
|
|
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
|
|
135
|
-
* @param {
|
|
136
|
-
* @param {
|
|
137
|
-
* @
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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.
|
|
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
|
-
|
|
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
|
-
/**
|
|
997
|
-
|
|
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 =
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
344
|
+
"current": "0.58.4",
|
|
345
345
|
"protocol": 1,
|
|
346
346
|
"requires": {
|
|
347
|
-
"identity": ">=0.
|
|
348
|
-
"proxy-client": ">=0.
|
|
349
|
-
"vault": ">=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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
...
|
|
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)
|