@dotrino/identity 0.121.7 → 0.122.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/vault/assertion.js +25 -1
- package/vault/vendor/roadmap/VERSION.txt +1 -1
- package/vault/vendor/roadmap/manifests.js +28 -20
- package/vault/vendor/vault/VERSION.txt +1 -1
- package/vault/vendor/vault/admin.js +2 -2
- package/vault/vendor/vault/browser.js +10 -10
- package/vault/vendor/vault/core/approvals.js +3 -2
- package/vault/vendor/vault/core/libVersion.js +2 -2
- package/vault/vendor/vault/core/sealer.js +2 -2
- package/vault/vendor/vault/core/sealers.js +15 -15
- package/vault/vendor/vault/core/secretsStore.js +66 -66
- package/vault/vendor/vault/core/subacta.js +5 -5
- package/vault/vendor/vault/core/threadStore.js +2 -2
- package/vault/vendor/vault/core/transport.js +31 -31
- package/vault/vendor/vault/core/vault.js +223 -190
- package/vault/vendor/vault/index.js +6 -6
- package/vault/vendor/vault/loginClient.js +23 -23
- package/vault/vendor/vault/passwordLogins.js +7 -7
- package/vault/vendor/vault/procContext.js +2 -2
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -312,6 +312,7 @@ export function assertionBody (args: { sub: string; aud: string; nonce: string;
|
|
|
312
312
|
export function verifyAssertion (assertion: Assertion, opts: { audience: string; nonce: string; expectedProfileId?: string | null; now?: number; maxSkewMs?: number }): Promise<VerifiedAssertion>
|
|
313
313
|
/** ¿Este contenido firmado (un pin, una atestación) va dirigido a mí? `aud` obligatorio; `exp` opcional. */
|
|
314
314
|
export function verifySignedFor (args: { data: any; signature: string; publickey: string; chain: any[]; audience: string; expectedProfileId?: string | null; now?: number; maxSkewMs?: number }): Promise<{ ok: boolean; reason?: string; profileId?: string; signer?: string; seq?: number; aud?: string }>
|
|
315
|
+
export function signedFor (identity: { signData: (d: object) => Promise<{ signature: string; publickey: string; chain?: any[] }> }, opts: { aud: string; fields?: object; ttlMs?: number; now?: number }): Promise<{ body: Record<string, any>; signature: string; publickey: string; chain: any[] }>
|
|
315
316
|
|
|
316
317
|
// ----- Sesiones: entrar sin enrolar (`@dotrino/identity/session`) -----
|
|
317
318
|
|
package/vault/assertion.js
CHANGED
|
@@ -215,4 +215,28 @@ export async function verifySignedFor (args = {}) {
|
|
|
215
215
|
return { ok: true, profileId: v.profileId, signer: v.signer, seq: v.seq, aud: data.aud }
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
/**
|
|
219
|
+
* LA OTRA MITAD DE `verifySignedFor`: firma una petición dirigida a un servicio (`aud`) con el
|
|
220
|
+
* perfil activo, lista para mandarla. Es lo que usan las páginas que hablan con un servicio de
|
|
221
|
+
* la cuenta sin sesiones ni cookies (el directorio de nombres, las cuentas de la bóveda
|
|
222
|
+
* alojada): cada petición lleva su firma, la llave del aparato y la cadena de selladores que
|
|
223
|
+
* prueba que ese aparato habla por la cuenta. Una vez aquí, y no copiado en cada página.
|
|
224
|
+
*
|
|
225
|
+
* const req = await signedFor(identity, { aud: 'https://accounts.dotrino.com', fields: { v: 1, op: 'mine' } })
|
|
226
|
+
* → { body: { aud, iat, exp, nonce, v, op }, signature, publickey, chain }
|
|
227
|
+
*
|
|
228
|
+
* Sin cadena no hay petición: el servicio no podría saber de qué cuenta es, y mandarla igual
|
|
229
|
+
* sería mandar algo que va a rechazar. Se para con `no-chain`.
|
|
230
|
+
*
|
|
231
|
+
* @param {{ signData: (d: object) => Promise<{ signature: string, publickey: string, chain?: any[] }> }} identity
|
|
232
|
+
* @param {{ aud: string, fields?: object, ttlMs?: number, now?: number }} opts
|
|
233
|
+
*/
|
|
234
|
+
export async function signedFor (identity, { aud, fields = {}, ttlMs = 24 * 60 * 60 * 1000, now = Date.now() } = {}) {
|
|
235
|
+
if (typeof aud !== 'string' || !aud.trim()) throw Object.assign(new Error('signedFor: aud is required'), { code: 'no-audience' })
|
|
236
|
+
const body = { aud: aud.trim(), iat: now, exp: now + ttlMs, nonce: crypto.randomUUID(), ...fields }
|
|
237
|
+
const s = await identity.signData(body)
|
|
238
|
+
if (!Array.isArray(s?.chain) || !s.chain.length) throw Object.assign(new Error('this device cannot prove it belongs to the account'), { code: 'no-chain' })
|
|
239
|
+
return { body, signature: s.signature, publickey: s.publickey, chain: s.chain }
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export default { ASSERTION_V, ASSERTION_MAX_TTL_MS, ASSERTION_DEFAULT_TTL_MS, ASSERTION_MAX_SKEW_MS, SCOPES, SCOPE_CLAIMS, newAssertionNonce, cleanScopes, claimsAllowed, assertionBody, verifyAssertion, verifySignedFor, signedFor }
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Copia vendorizada de @dotrino/roadmap@0.4.
|
|
1
|
+
Copia vendorizada de @dotrino/roadmap@0.4.42 (dotrino-roadmap/src/{index,manifests}.js).
|
|
2
2
|
NO se edita a mano: la escribe `node vendor.mjs` y la vigila test/vendor-up-to-date.test.mjs.
|
|
3
3
|
El registro de versiones rotas que viaja con cada versión. Importa @dotrino/compat/ranges.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export const MANIFESTS = Object.freeze({
|
|
9
9
|
"dotrino": {
|
|
10
10
|
"manifest": "dotrino",
|
|
11
|
-
"seq":
|
|
11
|
+
"seq": 36,
|
|
12
12
|
"issued": "2026-10-18",
|
|
13
13
|
"note": "Registro comun de compatibilidad del ecosistema. Se edita a mano en este repo y se consulta con @dotrino/roadmap. Rangos: ver @dotrino/compat/ranges (x.y.z, >= > <= <, «a - b», «*», o una lista que es un O).",
|
|
14
14
|
"products": {
|
|
@@ -22,7 +22,7 @@ export const MANIFESTS = Object.freeze({
|
|
|
22
22
|
"env": {
|
|
23
23
|
"repo": "imdotrino/dotrino-vault",
|
|
24
24
|
"npm": "@dotrino/env",
|
|
25
|
-
"current": "0.93.
|
|
25
|
+
"current": "0.93.1",
|
|
26
26
|
"protocol": 1,
|
|
27
27
|
"requires": {
|
|
28
28
|
"vault": ">=0.93.0"
|
|
@@ -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.121.
|
|
34
|
+
"current": "0.121.8",
|
|
35
35
|
"protocol": 1,
|
|
36
36
|
"requires": {
|
|
37
37
|
"proxy-client": ">=0.13.1"
|
|
@@ -121,7 +121,7 @@ export const MANIFESTS = Object.freeze({
|
|
|
121
121
|
"proxy-client": {
|
|
122
122
|
"repo": "imdotrino/dotrino-proxy-client",
|
|
123
123
|
"npm": "@dotrino/proxy-client",
|
|
124
|
-
"current": "0.38.
|
|
124
|
+
"current": "0.38.4",
|
|
125
125
|
"protocol": 2,
|
|
126
126
|
"requires": {
|
|
127
127
|
"identity": ">=0.53.0",
|
|
@@ -131,10 +131,10 @@ export const MANIFESTS = Object.freeze({
|
|
|
131
131
|
"remote-agent": {
|
|
132
132
|
"repo": "imdotrino/dotrino-remote-agent",
|
|
133
133
|
"npm": "@dotrino/remote-agent",
|
|
134
|
-
"current": "0.22.
|
|
134
|
+
"current": "0.22.5",
|
|
135
135
|
"protocol": 1,
|
|
136
136
|
"requires": {
|
|
137
|
-
"identity": ">=0.121.
|
|
137
|
+
"identity": ">=0.121.7",
|
|
138
138
|
"vault": ">=0.85.0",
|
|
139
139
|
"proxy-client": ">=0.36.1",
|
|
140
140
|
"vaultd": ">=0.154.0"
|
|
@@ -143,13 +143,13 @@ export const MANIFESTS = Object.freeze({
|
|
|
143
143
|
"terminal-agent": {
|
|
144
144
|
"repo": "imdotrino/dotrino-terminal",
|
|
145
145
|
"npm": "@dotrino/terminal-agent",
|
|
146
|
-
"current": "0.
|
|
146
|
+
"current": "0.49.1",
|
|
147
147
|
"protocol": 2,
|
|
148
148
|
"requires": {
|
|
149
|
-
"remote-agent": ">=0.
|
|
150
|
-
"identity": ">=0.
|
|
151
|
-
"vault": ">=0.
|
|
152
|
-
"proxy-client": ">=0.
|
|
149
|
+
"remote-agent": ">=0.22.5",
|
|
150
|
+
"identity": ">=0.121.7",
|
|
151
|
+
"vault": ">=0.93.0",
|
|
152
|
+
"proxy-client": ">=0.38.4",
|
|
153
153
|
"vaultd": ">=0.142.0"
|
|
154
154
|
}
|
|
155
155
|
},
|
|
@@ -193,7 +193,7 @@ export const MANIFESTS = Object.freeze({
|
|
|
193
193
|
"content": {
|
|
194
194
|
"repo": "imdotrino/dotrino-content",
|
|
195
195
|
"npm": "@dotrino/content",
|
|
196
|
-
"current": "0.6.
|
|
196
|
+
"current": "0.6.9",
|
|
197
197
|
"protocol": 1,
|
|
198
198
|
"requires": {
|
|
199
199
|
"remote-agent": ">=0.22.2",
|
|
@@ -205,13 +205,13 @@ export const MANIFESTS = Object.freeze({
|
|
|
205
205
|
"sealers": {
|
|
206
206
|
"repo": "imdotrino/dotrino-sealers",
|
|
207
207
|
"npm": "@dotrino/sealers",
|
|
208
|
-
"current": "0.10.
|
|
208
|
+
"current": "0.10.4",
|
|
209
209
|
"protocol": 1,
|
|
210
210
|
"requires": {
|
|
211
|
-
"remote-agent": ">=0.
|
|
212
|
-
"identity": ">=0.
|
|
213
|
-
"vault": ">=0.
|
|
214
|
-
"proxy-client": ">=0.
|
|
211
|
+
"remote-agent": ">=0.22.4",
|
|
212
|
+
"identity": ">=0.121.7",
|
|
213
|
+
"vault": ">=0.93.1",
|
|
214
|
+
"proxy-client": ">=0.38.4"
|
|
215
215
|
}
|
|
216
216
|
},
|
|
217
217
|
"roadmap": {
|
|
@@ -253,7 +253,7 @@ export const MANIFESTS = Object.freeze({
|
|
|
253
253
|
"vault": {
|
|
254
254
|
"repo": "imdotrino/dotrino-vault",
|
|
255
255
|
"npm": "@dotrino/vault",
|
|
256
|
-
"current": "0.93.
|
|
256
|
+
"current": "0.93.1",
|
|
257
257
|
"protocol": 1,
|
|
258
258
|
"requires": {
|
|
259
259
|
"vaultd": ">=0.105.0",
|
|
@@ -269,7 +269,7 @@ export const MANIFESTS = Object.freeze({
|
|
|
269
269
|
"vaultd": {
|
|
270
270
|
"repo": "imdotrino/dotrino-vault",
|
|
271
271
|
"npm": "@dotrino/vaultd",
|
|
272
|
-
"current": "0.165.
|
|
272
|
+
"current": "0.165.1",
|
|
273
273
|
"protocol": 1,
|
|
274
274
|
"requires": {
|
|
275
275
|
"identity": ">=0.118.0",
|
|
@@ -369,7 +369,8 @@ export const MANIFESTS = Object.freeze({
|
|
|
369
369
|
"requires": {
|
|
370
370
|
"identity": ">=0.116.0",
|
|
371
371
|
"remote-agent": ">=0.19.0",
|
|
372
|
-
"vault": ">=0.
|
|
372
|
+
"vault": ">=0.93.1",
|
|
373
|
+
"pay": ">=0.1.0"
|
|
373
374
|
}
|
|
374
375
|
},
|
|
375
376
|
"ai": {
|
|
@@ -378,6 +379,13 @@ export const MANIFESTS = Object.freeze({
|
|
|
378
379
|
"current": "0.1.1",
|
|
379
380
|
"protocol": 1,
|
|
380
381
|
"requires": {}
|
|
382
|
+
},
|
|
383
|
+
"pay": {
|
|
384
|
+
"repo": "imdotrino/dotrino-pay",
|
|
385
|
+
"npm": "@dotrino/pay",
|
|
386
|
+
"current": "0.1.0",
|
|
387
|
+
"protocol": 1,
|
|
388
|
+
"requires": {}
|
|
381
389
|
}
|
|
382
390
|
},
|
|
383
391
|
"broken": [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copia vendorizada de @dotrino/vault@0.93.
|
|
1
|
+
Copia vendorizada de @dotrino/vault@0.93.1 (dotrino-vault/lib/src/{admin,b64,browser,core/approvals,core/backup,core/blocked,core/browserDisk,core/commKey,core/disk,core/libVersion,core/machines,core/notices,core/notifiable,core/passwords,core/sealKey,core/sealer,core/sealers,core/secretsStore,core/sha256,core/store,core/subacta,core/threadStore,core/transport,core/vault,enroll,index,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
|
|
@@ -157,7 +157,7 @@ export function createAdminDesk ({
|
|
|
157
157
|
now = () => Date.now()
|
|
158
158
|
}) {
|
|
159
159
|
const ops = new Set(ADMIN_OPS)
|
|
160
|
-
const
|
|
160
|
+
const whileLocked = new Set(ADMIN_OPS_WHILE_LOCKED)
|
|
161
161
|
|
|
162
162
|
// NONCE de un solo uso. `sign`/`get` son idempotentes y les basta la ventana de ±5
|
|
163
163
|
// min; `revoke` y `var.set` CAMBIAN ESTADO, así que reproducir uno dentro de esa
|
|
@@ -196,7 +196,7 @@ export function createAdminDesk ({
|
|
|
196
196
|
//
|
|
197
197
|
// El código va aparte del texto porque el texto se traduce y el código no: quien
|
|
198
198
|
// llama distingue «está cerrada, ábrela» de «no tienes permiso» sin leer la frase.
|
|
199
|
-
if (isLocked() && !
|
|
199
|
+
if (isLocked() && !whileLocked.has(data.op)) {
|
|
200
200
|
audit('rejected', { what: 'admin', op: data.op, by, reason: 'locked' })
|
|
201
201
|
return {
|
|
202
202
|
ok: false,
|
|
@@ -69,7 +69,7 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const
|
|
72
|
+
const notify = () => { try { onPendingChange() } catch (_) {} }
|
|
73
73
|
const vault = await startVault({
|
|
74
74
|
platform: {
|
|
75
75
|
disk,
|
|
@@ -87,7 +87,7 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
|
|
|
87
87
|
// El navegador no tiene la contraseña del perfil con la que el binario cierra la copia
|
|
88
88
|
// de recuperación: se cierra con la llave de este almacén, y el núcleo lo dice.
|
|
89
89
|
hasPassword: () => false,
|
|
90
|
-
onEnrollChallenge:
|
|
90
|
+
onEnrollChallenge: notify,
|
|
91
91
|
onAdopted: (info) => { try { onAdopted(info) } catch (_) {} }
|
|
92
92
|
})
|
|
93
93
|
|
|
@@ -109,7 +109,7 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
|
|
|
109
109
|
* acta: es verdad que este navegador administra la cuenta. `aprueba` NO, a propósito: con
|
|
110
110
|
* él los servicios pasarían a esperar el visto bueno de una pestaña que puede no estar.
|
|
111
111
|
*/
|
|
112
|
-
const
|
|
112
|
+
const ensureAdmin = async () => {
|
|
113
113
|
if (core.masterLocked) return
|
|
114
114
|
const acta = (await identity.profileActa().catch(() => null))?.acta || null
|
|
115
115
|
const yo = (acta?.members || []).find((m) => m.pub === master)
|
|
@@ -119,15 +119,15 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
|
|
|
119
119
|
log('[vault] this browser administers the account: admin added to its own key')
|
|
120
120
|
}
|
|
121
121
|
const open = (onReply) => vault.localChannel(onReply)
|
|
122
|
-
const
|
|
122
|
+
const present = async () => {
|
|
123
123
|
try {
|
|
124
|
-
await
|
|
124
|
+
await ensureAdmin()
|
|
125
125
|
const cert = await selfCert()
|
|
126
126
|
core.setSelfVault?.(cert ? { cert, proxy: proxyUrl, open } : null)
|
|
127
127
|
} catch (e) { log('[vault] the console in this browser cannot administer this vault yet: ' + (e?.message || e)) }
|
|
128
128
|
}
|
|
129
|
-
await
|
|
130
|
-
const
|
|
129
|
+
await present()
|
|
130
|
+
const refresh = setInterval(present, SELF_CERT_EVERY_MS)
|
|
131
131
|
|
|
132
132
|
return {
|
|
133
133
|
...vault,
|
|
@@ -135,8 +135,8 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
|
|
|
135
135
|
proxy: proxyUrl,
|
|
136
136
|
disk,
|
|
137
137
|
/** Aprueba TIPEANDO el código que muestra el aparato (el núcleo comprueba el compromiso). */
|
|
138
|
-
approve: async (_deviceId, code) => { try { return await vault.approveDevice(code) } finally {
|
|
139
|
-
reject: (deviceId) => { try { return vault.rejectDevice(deviceId) } finally {
|
|
138
|
+
approve: async (_deviceId, code) => { try { return await vault.approveDevice(code) } finally { notify() } },
|
|
139
|
+
reject: (deviceId) => { try { return vault.rejectDevice(deviceId) } finally { notify() } },
|
|
140
140
|
/**
|
|
141
141
|
* Las máquinas con papel de firma de esta cuenta (excluye los navegadores enrolados con
|
|
142
142
|
* etiqueta `cli`, que no atienden pedidos). Se queda el papel del acta más nueva.
|
|
@@ -155,7 +155,7 @@ export async function startBrowserVault ({ core, proxyUrl = DEFAULT_PROXY, makeC
|
|
|
155
155
|
revokeDevice: (sub) => vault.revokeDevice({ sub }),
|
|
156
156
|
revoke: (nonce) => vault.revokeDevice(nonce),
|
|
157
157
|
async close () {
|
|
158
|
-
clearInterval(
|
|
158
|
+
clearInterval(refresh)
|
|
159
159
|
try { core.setSelfVault?.(null) } catch (_) {}
|
|
160
160
|
vault.close()
|
|
161
161
|
try { await disk.flush() } catch (e) { log('[vault] some changes could not be saved: ' + (e?.message || e)) }
|
|
@@ -84,7 +84,7 @@ export function createApprovals ({ now = Date.now, pendingTtlMs = PENDING_TTL_MS
|
|
|
84
84
|
* apruebe— y tiene que volver por el mismo sitio: desde que la bóveda atiende también
|
|
85
85
|
* por un socket local, mandarla siempre por el proxio la dejaba en el vacío.
|
|
86
86
|
*/
|
|
87
|
-
request ({ ns, device, deviceId, label = '', ek, ctx = null, from = null, ttlMs = null, kind = 'read' }) {
|
|
87
|
+
request ({ ns, device, deviceId, label = '', ek, ctx = null, from = null, ttlMs = null, kind = 'read', re = null }) {
|
|
88
88
|
// Pedir las claves otra vez reemplaza al pedido anterior: es la misma pregunta. Una
|
|
89
89
|
// ESCRITURA no: cada una lleva su propio valor, y reemplazarla tiraría la anterior
|
|
90
90
|
// sin que nadie dijera que no.
|
|
@@ -92,7 +92,8 @@ export function createApprovals ({ now = Date.now, pendingTtlMs = PENDING_TTL_MS
|
|
|
92
92
|
const ts = now()
|
|
93
93
|
// `ttlMs` lo pone quien pide: una actualización aguanta un día y un comando cinco
|
|
94
94
|
// minutos, y la mesa no tiene por qué saber cuál es cuál (ver `PENDING_TTL_MS`).
|
|
95
|
-
|
|
95
|
+
// `re`: la huella de la petición, para firmarle al que pidió el «denegado» (ver `signError`).
|
|
96
|
+
const p = { id: rnd(), ns, kind, device, deviceId, label, ek, ctx, ts, exp: ts + (ttlMs || pendingTtlMs), from, re }
|
|
96
97
|
pending.set(p.id, p)
|
|
97
98
|
return publicOf(p)
|
|
98
99
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LA VERSIÓN DE `@dotrino/vault`, escrita aquí porque el navegador no puede leer el
|
|
3
3
|
* `package.json`. Con esta se anuncia la bóveda de la pestaña y de la extensión
|
|
4
|
-
* (`@dotrino/compat`). Una prueba (`test/version
|
|
4
|
+
* (`@dotrino/compat`). Una prueba (`test/browser-version.test.mjs`) para el release
|
|
5
5
|
* si no coincide con la del paquete: una versión anunciada que no es la que corre es peor
|
|
6
6
|
* que no anunciar ninguna.
|
|
7
7
|
*/
|
|
8
|
-
export const LIB_VERSION = '0.93.
|
|
8
|
+
export const LIB_VERSION = '0.93.1'
|
|
@@ -163,8 +163,8 @@ export function makeSealer () {
|
|
|
163
163
|
* síntoma sería un servicio arrancando sin configuración y sin decir por qué.
|
|
164
164
|
*/
|
|
165
165
|
async wrapFor (cek, members) {
|
|
166
|
-
const { generation, sinLlave } = await makeGeneration({ members, cek })
|
|
167
|
-
return { wraps: generation.wraps, sinLlave }
|
|
166
|
+
const { generation, sinLlave: noKey } = await makeGeneration({ members, cek })
|
|
167
|
+
return { wraps: generation.wraps, sinLlave: noKey }
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
}
|
|
@@ -59,7 +59,7 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
|
|
|
59
59
|
if (!registryId) return () => {}
|
|
60
60
|
|
|
61
61
|
/** Una respuesta a `sealers.whois`, o null si no contesta a tiempo. */
|
|
62
|
-
function
|
|
62
|
+
function askWhoItIs (token, timeoutMs = 8000) {
|
|
63
63
|
return new Promise((resolve) => {
|
|
64
64
|
const fin = (v) => { try { off() } catch (_) {} ; clearTimeout(t); resolve(v) }
|
|
65
65
|
const off = client.on('message', (_f, p) => { if (p?.op === WHOIS + '.result') fin(p) })
|
|
@@ -82,11 +82,11 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
|
|
|
82
82
|
* filtraría nada —el eslabón es público— pero se los tragaría EN SILENCIO, que es peor
|
|
83
83
|
* que un error.
|
|
84
84
|
*/
|
|
85
|
-
async function
|
|
85
|
+
async function witness () {
|
|
86
86
|
let tokens
|
|
87
87
|
try { tokens = await client.list(canal) } catch (_) { return null }
|
|
88
88
|
for (const token of tokens || []) {
|
|
89
|
-
const r = await
|
|
89
|
+
const r = await askWhoItIs(token)
|
|
90
90
|
const cert = r?.cert
|
|
91
91
|
if (!cert?.sub || cert.iss !== registryId) continue
|
|
92
92
|
// AQUÍ SOMOS EXTRAÑOS: no tenemos el acta del registro, así que no podemos preguntarle
|
|
@@ -107,11 +107,11 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
|
|
|
107
107
|
return null
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
let
|
|
110
|
+
let latest = null
|
|
111
111
|
|
|
112
|
-
let
|
|
112
|
+
let warnedOtherWitness = false
|
|
113
113
|
|
|
114
|
-
async function
|
|
114
|
+
async function publish (reason) {
|
|
115
115
|
let actas
|
|
116
116
|
try { actas = await identity.sealerChain?.() } catch (_) { return }
|
|
117
117
|
if (!Array.isArray(actas)) return
|
|
@@ -122,8 +122,8 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
|
|
|
122
122
|
// exactamente lo que ese campo existe para impedir. Se dice una vez y se calla.
|
|
123
123
|
const genesis = actas[0]
|
|
124
124
|
if (genesis?.chainUrl && registryId === DOTRINO_REGISTRY_ID) {
|
|
125
|
-
if (!
|
|
126
|
-
|
|
125
|
+
if (!warnedOtherWitness) {
|
|
126
|
+
warnedOtherWitness = true
|
|
127
127
|
log(`[sealers] this account names its own registry (${genesis.chainUrl}): not depositing into Dotrino's`)
|
|
128
128
|
}
|
|
129
129
|
return
|
|
@@ -136,14 +136,14 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
|
|
|
136
136
|
// aparece en el registro hasta que selle un acta nueva.
|
|
137
137
|
if (chain.length < 2) return
|
|
138
138
|
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
139
|
+
const head = chain[chain.length - 1]?.seq
|
|
140
|
+
if (head === latest) return
|
|
141
141
|
try {
|
|
142
|
-
const a = await
|
|
142
|
+
const a = await witness()
|
|
143
143
|
if (!a) { log('[sealers] no witness announced in ' + canal + ': the chain stays for the next time'); return }
|
|
144
144
|
await client.sendByPubkey(a, { op: OP, chain })
|
|
145
|
-
|
|
146
|
-
log(`[sealers] chain up to #${
|
|
145
|
+
latest = head
|
|
146
|
+
log(`[sealers] chain up to #${head} deposited (${reason})`)
|
|
147
147
|
} catch (e) {
|
|
148
148
|
// Que no se pueda depositar no rompe nada de lo que la bóveda hace: el registro es
|
|
149
149
|
// una comodidad para terceros, no una dependencia. Se reintenta en la próxima acta.
|
|
@@ -151,8 +151,8 @@ export function startSealersPublisher ({ identity, client, log = console.log, re
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
const off = identity.onVault?.((e) => { if (e?.phase === 'acta')
|
|
154
|
+
publish('startup').catch(() => {})
|
|
155
|
+
const off = identity.onVault?.((e) => { if (e?.phase === 'acta') publish(`record #${e.seq}`).catch(() => {}) })
|
|
156
156
|
return () => { try { off?.() } catch (_) {} }
|
|
157
157
|
}
|
|
158
158
|
|