@dotrino/identity 0.140.2 → 0.140.4
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 +1 -1
- package/vault/index.html +1 -0
- package/vault/vendor/passmanager/VERSION.txt +1 -1
- package/vault/vendor/passmanager/sealed/keys.js +39 -1
- package/vault/vendor/passmanager/sealed/store.js +60 -0
- package/vault/vendor/passmanager/vault/sealed.js +7 -18
- package/vault/vendor/proxy-client/VERSION.txt +1 -1
- package/vault/vendor/proxy-client/client.js +74 -8
- package/vault/vendor/proxy-client/parts.js +13 -2
- package/vault/vendor/roadmap/VERSION.txt +1 -1
- package/vault/vendor/roadmap/manifests.js +190 -32
- package/vault/vendor/store/VERSION.txt +1 -1
- package/vault/vendor/vault/VERSION.txt +1 -1
- package/vault/vendor/vault/admin.js +31 -18
- package/vault/vendor/vault/browser.js +9 -9
- package/vault/vendor/vault/core/disk.js +5 -0
- package/vault/vendor/vault/core/gate.js +2 -1
- package/vault/vendor/vault/core/libVersion.js +1 -1
- package/vault/vendor/vault/core/memberGroups.js +9 -4
- package/vault/vendor/vault/core/notices.js +23 -3
- package/vault/vendor/vault/core/passwords.js +63 -0
- package/vault/vendor/vault/core/sealers.js +10 -1
- package/vault/vendor/vault/core/secretsStore.js +9 -3
- package/vault/vendor/vault/core/threadStore.js +1 -0
- package/vault/vendor/vault/core/transport.js +13 -2
- package/vault/vendor/vault/core/vault.js +153 -28
- package/vault/vendor/vault/enroll.js +10 -1
- package/vault/vendor/vault/index.js +3 -0
- package/vault/vendor/vault/invite.js +6 -0
- package/vault/vendor/vault/loginClient.js +32 -6
- package/vault/vendor/vault/passwordLogins.js +50 -21
- package/vault/vendor/vault/revocation.js +6 -4
package/package.json
CHANGED
package/vault/index.html
CHANGED
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
"@dotrino/roadmap": "./vendor/roadmap/index.js",
|
|
164
164
|
"@dotrino/passmanager": "./vendor/passmanager/index.js",
|
|
165
165
|
"@dotrino/passmanager/sealed": "./vendor/passmanager/sealed/index.js",
|
|
166
|
+
"@dotrino/passmanager/match": "./vendor/passmanager/match.js",
|
|
166
167
|
"@dotrino/store/core": "./vendor/store/core.js",
|
|
167
168
|
"@dotrino/identity/facade": "./facade.js",
|
|
168
169
|
"@dotrino/identity/machine": "./machine.js",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Copia vendorizada de @dotrino/passmanager@0.
|
|
1
|
+
Copia vendorizada de @dotrino/passmanager@0.19.2 (dotrino-passmanager/lib/src/{crypto,fields,generate,import,index,match,model,pubkey,sealed/convert,sealed/device,sealed/entry,sealed/index,sealed/keys,sealed/recovery,sealed/store,session-cache,totp,transport/protocol,transport/proxy,transport/sealed,vault/approval,vault/errors,vault/guard,vault/interface,vault/local,vault/remote,vault/responder,vault/sealed-local,vault/sealed-responder,vault/sealed,webauthn}.js).
|
|
2
2
|
NO se edita a mano: la escribe `node vendor.mjs` y la vigila test/vendor-up-to-date.test.mjs.
|
|
3
3
|
El sobre de las contraseñas, el mismo que usan el binario y la extensión. Importa @dotrino/identity/content.
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
// un valor muy corto (un PIN de cuatro cifras) probando resúmenes. Por eso los resúmenes no
|
|
17
17
|
// salen del aparato que los calcula.
|
|
18
18
|
|
|
19
|
+
import { hostOf, registrableDomain } from '../match.js'
|
|
20
|
+
|
|
19
21
|
const subtle = () => {
|
|
20
22
|
const c = globalThis.crypto
|
|
21
23
|
if (!c?.subtle) throw new Error('webcrypto unavailable')
|
|
@@ -117,4 +119,40 @@ export function valueDigest (kcmp, id, field, value) {
|
|
|
117
119
|
return hmac(kcmp, `${id} ${field} ${value}`)
|
|
118
120
|
}
|
|
119
121
|
|
|
120
|
-
|
|
122
|
+
/**
|
|
123
|
+
* LAS HUELLAS DE UNA URL O UN DOMINIO. El sitio guardado puede ser el dominio y la URL un
|
|
124
|
+
* subdominio suyo (`empresa.com` vale en `login.empresa.com`), así que salen las de CADA
|
|
125
|
+
* variante: el host, sus padres hasta el dominio registrable, y las de comodín. Una sola
|
|
126
|
+
* función para el gestor que autocompleta y la consola que busca: dos listas de variantes
|
|
127
|
+
* acabarían encontrando cosas distintas.
|
|
128
|
+
*/
|
|
129
|
+
export async function siteHashes (kidx, url) {
|
|
130
|
+
const host = hostOf(url)
|
|
131
|
+
if (!host) return []
|
|
132
|
+
const out = []
|
|
133
|
+
for (const v of hostVariants(host)) {
|
|
134
|
+
out.push(await siteIndex(kidx, v))
|
|
135
|
+
out.push(await siteIndex(kidx, '*.' + v))
|
|
136
|
+
}
|
|
137
|
+
return out
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Las huellas de passkey (`wa.rp`) que puede tener ese host: él y sus padres. */
|
|
141
|
+
export async function passkeyRpHashes (kidx, url) {
|
|
142
|
+
const host = hostOf(url)
|
|
143
|
+
if (!host) return []
|
|
144
|
+
return Promise.all(hostVariants(host).map((v) => passkeyIndex(kidx, 'rp', v)))
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function hostVariants (host) {
|
|
148
|
+
const base = registrableDomain(host)
|
|
149
|
+
const out = [host]
|
|
150
|
+
let actual = host
|
|
151
|
+
while (actual.includes('.') && actual !== base) {
|
|
152
|
+
actual = actual.slice(actual.indexOf('.') + 1)
|
|
153
|
+
out.push(actual)
|
|
154
|
+
}
|
|
155
|
+
return out
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export default { makePasswordKey, profileKeys, siteIndex, siteHashes, passkeyRpHashes, fieldIndex, passkeyIndex, valueDigest }
|
|
@@ -504,6 +504,66 @@ export class SealedStore {
|
|
|
504
504
|
return [...faltan].map(([pub, generations]) => ({ pub, generations }))
|
|
505
505
|
}
|
|
506
506
|
|
|
507
|
+
/**
|
|
508
|
+
* ¿HAY ALGO PARA ESTE SITIO, Y LO PUEDE ABRIR QUIEN DEBE? Diagnóstico de la consola: no
|
|
509
|
+
* abre nada y **no escribe nada** (ni siquiera reenvuelve: eso es `rewrapAll`, aparte).
|
|
510
|
+
*
|
|
511
|
+
* Busca por las huellas que calculó quien pregunta —de sitio (`idx`) y de passkey (`rp`)—,
|
|
512
|
+
* igual que `find`, pero sin filtrar por destinatario: lo que interesa aquí es justamente
|
|
513
|
+
* a quién le falta la envoltura. De cada entrada dice:
|
|
514
|
+
*
|
|
515
|
+
* · `holders` los aparatos que pueden abrir TODO lo suyo (todas sus generaciones);
|
|
516
|
+
* · `missing` los que el acta dice que deberían y no pueden (falta de sincronizar);
|
|
517
|
+
* · `recovery` si la frase del perfil la abre (sin ella no se puede volver a repartir);
|
|
518
|
+
* · `recoveryWrap` la envoltura de la frase para su VISTA, para quien quiera abrir el
|
|
519
|
+
* título y el usuario. Nunca la de un campo: de aquí no sale ningún valor.
|
|
520
|
+
*
|
|
521
|
+
* Sin huellas no contesta nada, salvo que se pida `all: true` a propósito: es lo que usa la
|
|
522
|
+
* BÚSQUEDA PARCIAL de la consola (`npm` encuentra `www.npmjs.com`), que no se puede hacer
|
|
523
|
+
* con huellas y abre las vistas con la frase para comparar el texto. Igual que con
|
|
524
|
+
* huellas, de aquí sale la vista sellada y nunca un valor.
|
|
525
|
+
*/
|
|
526
|
+
async inspect ({ idx = [], rp = [], all = false } = {}) {
|
|
527
|
+
const busca = new Set(idx)
|
|
528
|
+
const buscaRp = new Set(rp)
|
|
529
|
+
if (!all && !busca.size && !buscaRp.size) return []
|
|
530
|
+
const s = await this.#state()
|
|
531
|
+
const deben = {}
|
|
532
|
+
for (const kind of ['main', 'passkeys']) {
|
|
533
|
+
deben[kind] = (await this.recipients(kind)).filter((m) => m?.encPub).map((m) => m.pub)
|
|
534
|
+
}
|
|
535
|
+
const out = []
|
|
536
|
+
for (const e of s.entries) {
|
|
537
|
+
const porSitio = (e.idx || []).some((h) => busca.has(h))
|
|
538
|
+
const porPasskey = !!e.wa?.rp && buscaRp.has(e.wa.rp)
|
|
539
|
+
if (!all && !porSitio && !porPasskey) continue
|
|
540
|
+
const gens = [...new Set([e.view.gen, ...Object.values(e.fields).map((f) => f.gen)])]
|
|
541
|
+
.map((g) => this.#gen(s, g) || { gen: g, kind: null, wraps: {} })
|
|
542
|
+
const quien = (g) => Object.keys(g.wraps || {}).filter((k) => k !== RECOVERY)
|
|
543
|
+
const holders = gens.reduce((acc, g) => acc.filter((p) => quien(g).includes(p)), quien(gens[0]))
|
|
544
|
+
const missing = new Set()
|
|
545
|
+
for (const g of gens) {
|
|
546
|
+
for (const p of deben[g.kind || 'main'] || []) if (!g.wraps?.[p]) missing.add(p)
|
|
547
|
+
}
|
|
548
|
+
out.push({
|
|
549
|
+
id: e.id,
|
|
550
|
+
createdAt: e.createdAt || null,
|
|
551
|
+
updatedAt: e.updatedAt || null,
|
|
552
|
+
by: e.by || e.author?.pub || null,
|
|
553
|
+
match: porSitio ? 'site' : porPasskey ? 'passkey' : null,
|
|
554
|
+
passkey: !!e.wa,
|
|
555
|
+
// Una generación que ya no está en el llavero es una entrada rota: se dice.
|
|
556
|
+
broken: gens.some((g) => g.kind === null),
|
|
557
|
+
holders,
|
|
558
|
+
missing: [...missing],
|
|
559
|
+
recovery: gens.every((g) => !!g.wraps?.[RECOVERY]),
|
|
560
|
+
view: e.view,
|
|
561
|
+
recoveryWrap: this.#wrapFor(s, e.view.gen, RECOVERY)
|
|
562
|
+
})
|
|
563
|
+
}
|
|
564
|
+
return out
|
|
565
|
+
}
|
|
566
|
+
|
|
507
567
|
/** Cuántas entradas y cuántas generaciones. Diagnóstico: no abre nada. */
|
|
508
568
|
async stats () {
|
|
509
569
|
const s = await this.#state()
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
import { SEALED_OPS } from '../transport/protocol.js'
|
|
19
19
|
import { VaultError, CODES } from './errors.js'
|
|
20
|
-
import {
|
|
21
|
-
import { profileKeys, siteIndex, fieldIndex, passkeyIndex, valueDigest } from '../sealed/keys.js'
|
|
20
|
+
import { findForUrl } from '../match.js'
|
|
21
|
+
import { profileKeys, siteIndex, siteHashes, fieldIndex, passkeyIndex, valueDigest } from '../sealed/keys.js'
|
|
22
22
|
import { buildSealedEntry, buildSealedPatch, buildProfileKey, openSealedEntry, makeOpener } from '../sealed/device.js'
|
|
23
23
|
import { openView, PASSKEY_FIELD } from '../sealed/entry.js'
|
|
24
24
|
import { fieldKey, normalizeFields } from '../fields.js'
|
|
@@ -127,23 +127,10 @@ export class SealedVault {
|
|
|
127
127
|
*/
|
|
128
128
|
async #hashesFor (url) {
|
|
129
129
|
const { kidx } = await this.keys()
|
|
130
|
-
|
|
131
|
-
if (!host) return []
|
|
132
|
-
const base = registrableDomain(host)
|
|
133
|
-
const variantes = new Set([host])
|
|
134
|
-
let actual = host
|
|
135
|
-
while (actual.includes('.') && actual !== base) {
|
|
136
|
-
actual = actual.slice(actual.indexOf('.') + 1)
|
|
137
|
-
variantes.add(actual)
|
|
138
|
-
}
|
|
139
|
-
const out = []
|
|
140
|
-
for (const v of variantes) {
|
|
141
|
-
out.push(await siteIndex(kidx, v))
|
|
142
|
-
out.push(await siteIndex(kidx, '*.' + v))
|
|
143
|
-
}
|
|
144
|
-
return out
|
|
130
|
+
return siteHashes(kidx, url)
|
|
145
131
|
}
|
|
146
132
|
|
|
133
|
+
|
|
147
134
|
/**
|
|
148
135
|
* QUÉ HAY PARA ESTE SITIO. Las huellas son un filtro previo; el emparejamiento de verdad
|
|
149
136
|
* —el que decide si `empresa.com` vale aquí— se rehace con `match.js` sobre las vistas ya
|
|
@@ -181,7 +168,9 @@ export class SealedVault {
|
|
|
181
168
|
await this.#request('pm2.put', sobre)
|
|
182
169
|
// La vista se devuelve ARMADA AQUÍ: quien guardó ya la tiene en claro, y pedírsela a la
|
|
183
170
|
// bóveda sería un viaje para que nos devuelva lo que acabamos de sellar.
|
|
184
|
-
|
|
171
|
+
// Con el id del SOBRE: una entrada nueva llega sin id y se lo pone `newEntry` al
|
|
172
|
+
// sellarla. Con el de `plain`, guardar algo nuevo devolvía una vista sin id.
|
|
173
|
+
return this.#viewOf({ ...plain, id: sobre.entry.id })
|
|
185
174
|
}
|
|
186
175
|
|
|
187
176
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copia vendorizada de @dotrino/proxy-client@0.
|
|
1
|
+
Copia vendorizada de @dotrino/proxy-client@0.51.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.
|
|
@@ -259,8 +259,19 @@ export class WebSocketProxyClient {
|
|
|
259
259
|
this._outChains = new Map()
|
|
260
260
|
// Mensajes grandes que llegan en partes (parts.js). Uno que se queda a medias se DICE:
|
|
261
261
|
// con él se pierde el mensaje entero, y eso no puede pasar callado.
|
|
262
|
+
// Y mientras llega, se AVISA (`incoming`): un archivo grande tarda, y sin aviso el chat no
|
|
263
|
+
// enseña nada hasta la última parte (dueño, 2026-12-05: «si está sincronizando algo, no
|
|
264
|
+
// debería aparecer en el chat algo como (...)?»).
|
|
265
|
+
/** @type {Map<string, { from: string, meta: MessageMeta }>} */
|
|
266
|
+
this._incoming = new Map()
|
|
262
267
|
this._parts = new Reassembler({
|
|
263
|
-
onExpire: (info) =>
|
|
268
|
+
onExpire: (info) => {
|
|
269
|
+
const key = `${info.sender}|${info.id}`
|
|
270
|
+
const seen = this._incoming.get(key)
|
|
271
|
+
this._incoming.delete(key)
|
|
272
|
+
if (seen) this._emit('incoming', seen.from, { id: info.id, got: info.parts - info.missing, of: info.parts, failed: true }, seen.meta)
|
|
273
|
+
this._emit('error', { type: 'parts_incomplete', code: 'parts-incomplete', id: info.id, parts: info.parts, missing: info.missing })
|
|
274
|
+
}
|
|
264
275
|
})
|
|
265
276
|
// Las CEK de los mensajes con bytes ya abiertas, por su sobre: todas las partes de un
|
|
266
277
|
// mensaje traen la misma, y abrirla es una vuelta a la bóveda. Pocas: un mensaje vivo.
|
|
@@ -869,11 +880,23 @@ export class WebSocketProxyClient {
|
|
|
869
880
|
async sendSealed (toPubkeys, payload, { peerEncPub, pilar = false, ...opts } = {}) {
|
|
870
881
|
const list = Array.isArray(toPubkeys) ? toPubkeys : [toPubkeys]
|
|
871
882
|
// Por pubkey el mensaje puede quedarse ESPERANDO en el proxio, y ahí se deja como mucho
|
|
872
|
-
// 8 MB de archivo (parts.js). Lo que pasa de eso
|
|
883
|
+
// 8 MB de archivo (parts.js). Lo que pasa de eso NO PUEDE ESPERAR: va por el token de cada
|
|
884
|
+
// destinatario conectado (en vivo, 25 MB por el proxio, sin tope por canal directo), que
|
|
885
|
+
// se averigua saludándolo (`locate`). Si alguno no está conectado no sale a ninguno —se
|
|
886
|
+
// resuelven todos antes de mandar nada— y se dice con `too-big-for-queue` (dueño,
|
|
887
|
+
// 2026-12-05: la terminal no podía mandarle al teléfono más de 8 MB estando los dos en línea).
|
|
873
888
|
const m = this._measure(payload)
|
|
874
889
|
const queueMax = m.bin ? QUEUE_MAX_BYTES : QUEUE_MAX_CHARS
|
|
875
890
|
if (m.len > queueMax) {
|
|
876
|
-
|
|
891
|
+
const tokens = await Promise.all(list.map((pk) => this.locate(pk, { app: opts.app })))
|
|
892
|
+
const missing = list.filter((_, i) => !tokens[i])
|
|
893
|
+
if (missing.length) {
|
|
894
|
+
throw errorWithCode(`sendSealed: ${m.len} ${m.bin ? 'bytes' : 'chars'} is more than can wait in the proxy (${queueMax}), and ${missing.length === list.length ? 'the peer is' : `${missing.length} of the peers are`} not connected to take it live`, 'too-big-for-queue')
|
|
895
|
+
}
|
|
896
|
+
for (let i = 0; i < list.length; i++) {
|
|
897
|
+
await this.sendSealedTo(/** @type {string} */ (tokens[i]), payload, { peerPubkey: list[i], peerEncPub, pilar })
|
|
898
|
+
}
|
|
899
|
+
return
|
|
877
900
|
}
|
|
878
901
|
// Por pubkey todo va por el proxio: si no admite bytes, se dice antes de mandar nada. Y
|
|
879
902
|
// si alguno de los destinatarios dijo que no los entiende, tampoco.
|
|
@@ -1187,6 +1210,31 @@ export class WebSocketProxyClient {
|
|
|
1187
1210
|
}
|
|
1188
1211
|
}
|
|
1189
1212
|
|
|
1213
|
+
/**
|
|
1214
|
+
* DÓNDE ESTÁ AHORA esta identidad: el token de una conexión suya que esté en línea, o `null`.
|
|
1215
|
+
* La saluda POR PUBKEY y sin cola (`ephemeral`: si no está conectada, no hay nada que
|
|
1216
|
+
* guardarle), y quien la recibe contesta su saludo desde su token (`_onHello`), aunque ya nos
|
|
1217
|
+
* hubiera saludado antes (`ask`; lo entienden proxy-client ≥ 0.50.0 y dotrino-native ≥ 0.52.3:
|
|
1218
|
+
* uno anterior que ya saludó no contesta, y entonces esto da `null`). Con `app`,
|
|
1219
|
+
* solo la conexión de esa app. Es lo que deja mandar por token —en vivo, sin el tope de la
|
|
1220
|
+
* cola— a quien solo se conoce por su llave.
|
|
1221
|
+
* @param {string} pubkey
|
|
1222
|
+
* @param {{ app?: string, timeoutMs?: number }} [opts]
|
|
1223
|
+
* @returns {Promise<string | null>}
|
|
1224
|
+
*/
|
|
1225
|
+
async locate (pubkey, { app, timeoutMs = 6000 } = {}) {
|
|
1226
|
+
if (!this.myPublickey) {
|
|
1227
|
+
throw errorWithCode('locate: identify first — a greeting with no identity says nothing', 'not-identified')
|
|
1228
|
+
}
|
|
1229
|
+
return new Promise(/** @param {(t: string | null) => void} resolve */ (resolve) => {
|
|
1230
|
+
/** @param {string | null} t */
|
|
1231
|
+
const done = (t) => { off(); clearTimeout(timer); resolve(t) }
|
|
1232
|
+
const off = this.on('peer_identity', (/** @type {string} */ t, /** @type {string} */ pk) => { if (samePubkey(pk, pubkey)) done(t) })
|
|
1233
|
+
const timer = setTimeout(() => done(null), timeoutMs)
|
|
1234
|
+
this._sendByPubkeyRaw([pubkey], { t: HELLO_TAG, publickey: this.myPublickey, speaks: SPEAKS, ask: true }, { ephemeral: true, app })
|
|
1235
|
+
})
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1190
1238
|
/**
|
|
1191
1239
|
* De quién es este token, si alguien lo ha dicho. `null` es «todavía no lo sé».
|
|
1192
1240
|
* @param {string} token
|
|
@@ -1274,8 +1322,10 @@ export class WebSocketProxyClient {
|
|
|
1274
1322
|
const speaks = new Set(Array.isArray(msg.speaks) ? msg.speaks.filter((/** @type {unknown} */ x) => typeof x === 'string').slice(0, 32) : [])
|
|
1275
1323
|
this._tokenSpeaks.set(from, speaks)
|
|
1276
1324
|
this._pubkeySpeaks.set(msg.publickey, speaks)
|
|
1277
|
-
// Contestar UNA vez: el saludo queda simétrico sin rebotar para siempre.
|
|
1278
|
-
|
|
1325
|
+
// Contestar UNA vez: el saludo queda simétrico sin rebotar para siempre. Salvo que lo pida
|
|
1326
|
+
// (`ask`, de `locate`): quien busca dónde estoy necesita la respuesta aunque ya lo hubiera
|
|
1327
|
+
// saludado. La respuesta va sin `ask`, así que tampoco rebota.
|
|
1328
|
+
if ((!this._helloSent.has(from) || msg.ask === true) && this.myPublickey) this.helloTo(from)
|
|
1279
1329
|
this._emit('peer_identity', from, msg.publickey)
|
|
1280
1330
|
}
|
|
1281
1331
|
|
|
@@ -1645,10 +1695,26 @@ export class WebSocketProxyClient {
|
|
|
1645
1695
|
_handOpened (from, opened, fullMeta) {
|
|
1646
1696
|
if (isPart(opened)) {
|
|
1647
1697
|
// Se agrupa por quien selló: solo esa llave pudo armar cada parte.
|
|
1698
|
+
const sender = fullMeta.senderEncPub || fullMeta.fromPubkey || from || ''
|
|
1699
|
+
const id = opened.__dotrino_part?.id
|
|
1700
|
+
const key = `${sender}|${id}`
|
|
1648
1701
|
let whole
|
|
1649
|
-
try { whole = this._parts.add(
|
|
1650
|
-
catch (e) {
|
|
1651
|
-
|
|
1702
|
+
try { whole = this._parts.add(sender, opened) }
|
|
1703
|
+
catch (e) {
|
|
1704
|
+
if (this._incoming.delete(key)) this._emit('incoming', from, { id, got: 0, of: opened.__dotrino_part.n, failed: true }, fullMeta)
|
|
1705
|
+
this._emit('error', { type: 'bad_part', from, code: codeOf(e) || 'bad-part', error: e })
|
|
1706
|
+
return
|
|
1707
|
+
}
|
|
1708
|
+
const n = opened.__dotrino_part.n
|
|
1709
|
+
if (whole !== null) {
|
|
1710
|
+
this._incoming.delete(key)
|
|
1711
|
+
this._emit('incoming', from, { id, got: n, of: n, done: true }, fullMeta)
|
|
1712
|
+
this._emit('message', from, whole, { ...fullMeta, parts: n })
|
|
1713
|
+
return
|
|
1714
|
+
}
|
|
1715
|
+
this._incoming.set(key, { from, meta: fullMeta })
|
|
1716
|
+
const p = this._parts.progress(sender, id)
|
|
1717
|
+
if (p) this._emit('incoming', from, { id, got: p.got, of: p.of }, fullMeta)
|
|
1652
1718
|
return
|
|
1653
1719
|
}
|
|
1654
1720
|
this._emit('message', from, opened, fullMeta)
|
|
@@ -108,7 +108,7 @@ export const isPart = (o) => !!(o && typeof o === 'object' && o[PART_TAG])
|
|
|
108
108
|
*/
|
|
109
109
|
|
|
110
110
|
export class Reassembler {
|
|
111
|
-
/** @param {{ onExpire?: (info: { id: string, parts: number, missing: number }) => void }} [opts] */
|
|
111
|
+
/** @param {{ onExpire?: (info: { id: string, parts: number, missing: number, sender: string }) => void }} [opts] */
|
|
112
112
|
constructor ({ onExpire = () => {} } = {}) {
|
|
113
113
|
/** @type {Map<string, PendingParts>} */
|
|
114
114
|
this._open = new Map()
|
|
@@ -159,12 +159,23 @@ export class Reassembler {
|
|
|
159
159
|
a.timer = setTimeout(() => {
|
|
160
160
|
const missing = a.n - a.count
|
|
161
161
|
this._drop(key)
|
|
162
|
-
this._onExpire({ id: p.id, parts: a.n, missing })
|
|
162
|
+
this._onExpire({ id: p.id, parts: a.n, missing, sender })
|
|
163
163
|
}, RECV_IDLE_MS)
|
|
164
164
|
a.timer.unref?.()
|
|
165
165
|
return null
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Cuántas partes van de un mensaje a medio rearmar (para enseñar «recibiendo…»); `null` si no
|
|
170
|
+
* hay ninguno abierto con ese id.
|
|
171
|
+
* @param {string} sender @param {string} id
|
|
172
|
+
* @returns {{ got: number, of: number } | null}
|
|
173
|
+
*/
|
|
174
|
+
progress (sender, id) {
|
|
175
|
+
const a = this._open.get(`${sender}|${id}`)
|
|
176
|
+
return a ? { got: a.count, of: a.n } : null
|
|
177
|
+
}
|
|
178
|
+
|
|
168
179
|
/** @param {string} key */
|
|
169
180
|
_drop (key) {
|
|
170
181
|
const a = this._open.get(key)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Copia vendorizada de @dotrino/roadmap@0.4.
|
|
1
|
+
Copia vendorizada de @dotrino/roadmap@0.4.97 (dotrino-roadmap/src/{index,manifests}.js).
|
|
2
2
|
NO se edita a mano: la escribe `node vendor.mjs` y la vigila test/vendor-up-to-date.test.mjs.
|
|
3
3
|
El registro de versiones rotas que viaja con cada versión. Importa @dotrino/compat/ranges.
|