@dotrino/identity 0.135.1 → 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 +16 -3
- package/src/index.d.ts +86 -3
- package/types/acta.d.ts +652 -0
- package/types/assertion.d.ts +208 -0
- package/types/avatar.d.ts +11 -0
- package/types/capabilities.d.ts +188 -0
- package/types/content.d.ts +191 -0
- package/types/core.d.ts +1168 -0
- package/types/keyid.d.ts +12 -0
- package/types/machine.d.ts +54 -0
- package/types/peerSync.d.ts +33 -0
- package/types/remote.d.ts +181 -0
- package/types/session.d.ts +163 -0
- package/types/sessionFlow.d.ts +86 -0
- package/types/vaultSeal.d.ts +58 -0
- package/vault/acta.js +2 -2
- package/vault/core.js +22 -16
- package/vault/remote.js +54 -29
- package/vault/vaultSeal.js +126 -0
- 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
|
@@ -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
|
|
44
|
-
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|