@dotrino/identity 0.134.1 → 0.135.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/identity",
3
- "version": "0.134.1",
3
+ "version": "0.135.1",
4
4
  "description": "Identidad y rating de usuarios compartidos entre apps de Dotrino (vault iframe + postMessage)",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/vault/acta.js CHANGED
@@ -915,8 +915,8 @@ export async function applyChanges (acta, changes, { by, now = Date.now(), sealP
915
915
  case 'caps': {
916
916
  const m = find(ch.pub)
917
917
  if (!m) throw new Error('caps: that member is not in the record')
918
- // El CN no cambia por aquí (quitar el cajón es sacar al miembro y volver a admitirlo,
919
- // que es un gesto visible); las capacidades sí.
918
+ // El CN no cambia por aquí: tiene su propio cambio (`cn`), que también saca o pone
919
+ // las envolturas de la clave de contenido.
920
920
  m.caps = cleanCaps(ch.caps)
921
921
  // CONCEDER LIMPIA LA RENUNCIA. `effectiveCaps` resta lo renunciado, así que sin
922
922
  // esto una renuncia sellada era IRREVERSIBLE: el master le devolvía el permiso en
@@ -946,6 +946,30 @@ export async function applyChanges (acta, changes, { by, now = Date.now(), sealP
946
946
  m.label = String(ch.label || '').slice(0, 60)
947
947
  break
948
948
  }
949
+ case 'cn': {
950
+ // DISPOSITIVO O SERVICIO, y se cambia sin re-enrolar (dueño, 2026-10-28). La única
951
+ // diferencia entre los dos es llevar `cn`: con él, el miembro abre el cajón de ese
952
+ // nombre, firma solo dentro de él y no ve lo del usuario; sin él, es un aparato tuyo.
953
+ // Antes el `cn` solo se ponía al admitir, y cambiarlo era revocar y volver a emparejar.
954
+ const m = find(ch.pub)
955
+ if (!m) throw new Error('cn: that member is not in the record')
956
+ // La llave de comunicación de una bóveda no es ni lo uno ni lo otro: su `cn` es el que
957
+ // la deja hablar por la bóveda con el perfil cerrado, y quitárselo la haría firmar como tú.
958
+ if (m.cn === VAULT_CN || m.vault != null) throw new Error('cn: the vault communication key is neither a device nor a service')
959
+ const cn = ch.cn != null ? String(ch.cn) : null
960
+ if (cn !== null && !hasDrawer(cn)) throw new Error('cn: invalid CN (lowercase, digits and hyphens, and not "vault")')
961
+ m.cn = cn
962
+ // Un servicio no ve lo del usuario: sus envolturas de la clave de contenido se van,
963
+ // igual que al quitarlo (lo ya leído no vuelve; el contenido futuro se corta rotando).
964
+ // De servicio a dispositivo, la envoltura la pone quien sella, en la misma acta (`wrap`).
965
+ if (cn) {
966
+ next.keyring = next.keyring.map((g) => {
967
+ const { [m.pub]: _, ...resto } = g.wraps || {}
968
+ return { ...g, wraps: resto }
969
+ })
970
+ }
971
+ break
972
+ }
949
973
  case 'remove': {
950
974
  const i = next.members.findIndex((m) => m.pub === ch.pub)
951
975
  if (i < 0) throw new Error('remove: that member is not in the record')
package/vault/core.js CHANGED
@@ -2906,8 +2906,29 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
2906
2906
  */
2907
2907
  async setCapsMany ({ changes } = {}) {
2908
2908
  if (!Array.isArray(changes) || !changes.length) throw new Error('setCapsMany: no changes')
2909
- const acta = await sealChanges(changes.map(({ pub, caps }) => ({ op: 'caps', pub, caps })))
2910
- return { ok: true, seq: acta.seq }
2909
+ // `cn` (opcional): DISPOSITIVO O SERVICIO. Un texto lo hace servicio de ese cajón;
2910
+ // `null`, dispositivo; sin la clave, no se toca. Va en la misma acta que los permisos.
2911
+ // De servicio a dispositivo se le envuelve la clave de contenido vigente, como al
2912
+ // admitirlo: un aparato tuyo lee lo tuyo.
2913
+ const acta0 = loadActa()
2914
+ const list = []
2915
+ let wrapped = 0
2916
+ for (const { pub, caps, cn } of changes) {
2917
+ if (Array.isArray(caps)) list.push({ op: 'caps', pub, caps })
2918
+ if (cn === undefined) continue
2919
+ list.push({ op: 'cn', pub, cn })
2920
+ const m = (acta0?.members || []).find((x) => x.pub === pub)
2921
+ if (cn === null && m?.cn && m.encPub) {
2922
+ const mine = await myCek()
2923
+ if (mine) {
2924
+ list.push({ op: 'wrap', gen: mine.gen, pub, wrap: await Content.wrapForMember({ cek: mine.cek, memberEncPub: m.encPub }) })
2925
+ wrapped++
2926
+ }
2927
+ }
2928
+ }
2929
+ if (!list.length) throw new Error('setCapsMany: no changes')
2930
+ const acta = await sealChanges(list)
2931
+ return { ok: true, seq: acta.seq, wrapped }
2911
2932
  },
2912
2933
 
2913
2934
  /**
@@ -3415,9 +3436,12 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
3415
3436
  }
3416
3437
  rest = { ...rest, to, timeoutMs: VAULT_WAKE_MS }
3417
3438
  }
3418
- if (link.self) return remoteAdmin({ master: v.master, proxy: v.proxy, device, cert: v.cert, op, ...rest })
3439
+ // LAS CONCESIONES (`grants`) traen el comando sellado a este aparato, como los pedidos:
3440
+ // se abre aquí, donde está la llave. Lo que no trae nada sellado pasa tal cual.
3441
+ const opened = async (r) => (Array.isArray(r?.items) ? { ...r, items: await abrirContextos(r.items, currentPid) } : r)
3442
+ if (link.self) return opened(await remoteAdmin({ master: v.master, proxy: v.proxy, device, cert: v.cert, op, ...rest }))
3419
3443
  maybeRenewVaultCert()
3420
- try { return await remoteAdmin({ master: v.master, proxy: v.proxy, device, cert: v.cert, op, ...rest, onRevoked: wipeVaultLink }) }
3444
+ try { return await opened(await remoteAdmin({ master: v.master, proxy: v.proxy, device, cert: v.cert, op, ...rest, onRevoked: wipeVaultLink })) }
3421
3445
  catch (e) { return handleVaultError(e) }
3422
3446
  },
3423
3447
 
@@ -1,4 +1,4 @@
1
- Copia vendorizada de @dotrino/proxy-client@0.45.1 (dotrino-proxy-client/src/{binpack,ble/manager,ble/wire,canonical,client,encpub,errors,index,parts,sealing,signature,stats-log,stats,webrtc}.js).
1
+ Copia vendorizada de @dotrino/proxy-client@0.46.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.
@@ -276,7 +276,10 @@ export class WebSocketProxyClient {
276
276
  adapter = await openBluez()
277
277
  if (!adapter) return
278
278
  }
279
+ // Cerrado mientras se abría el bus: el stop() de close() no lo vio, así que se cierra aquí.
280
+ if (this._closed) { if (this._bleOption === true) await adapter.stop().catch(() => {}); return }
279
281
  await this._ble.start(adapter)
282
+ if (this._closed) await this._ble.stop().catch(() => {})
280
283
  })().catch((e) => {
281
284
  this._emit('error', { type: 'bluetooth_unavailable', error: e, code: e?.code || null })
282
285
  }).finally(() => { this._bleStarting = null })
@@ -371,6 +374,8 @@ export class WebSocketProxyClient {
371
374
  }
372
375
 
373
376
  connect () {
377
+ this._closed = false
378
+ this._rtc?.reopen()
374
379
  this._prepareBluetooth()
375
380
  return new Promise((resolve, reject) => {
376
381
  if (this._connected) return resolve(this.token)
@@ -383,6 +388,7 @@ export class WebSocketProxyClient {
383
388
  }
384
389
 
385
390
  close () {
391
+ this._closed = true
386
392
  this.autoReconnect = false
387
393
  unregisterTransport(this)
388
394
  if (this._reconnectTimer) {
@@ -1097,6 +1103,43 @@ export class WebSocketProxyClient {
1097
1103
  return promise
1098
1104
  }
1099
1105
 
1106
+ /**
1107
+ * LAS ÚLTIMAS ACTAS DE UNA CUENTA que guarda el proxio (websocket-proxy ≥ 1.10.0), con `seq`
1108
+ * mayor que `sinceSeq`, de la más nueva a la más vieja. Sirve para saber si la tuya va atrás
1109
+ * sin despertar a la bóveda.
1110
+ *
1111
+ * NO SON DE CONFIANZA por venir de aquí: el proxio solo comprobó que las selló su cuenta.
1112
+ * Quien las use las adopta SOLO si encadenan desde la que ya tiene de confianza. Lista vacía
1113
+ * es «el proxio no tiene ninguna más nueva», no «no existe»: la bóveda sigue mandando.
1114
+ *
1115
+ * Lanza `no-acta-cache` si el proxio dice que no sabe de esto (es viejo).
1116
+ */
1117
+ async getActas (profileId, { sinceSeq } = {}) {
1118
+ if (typeof profileId !== 'string' || !profileId) throw errorWithCode('getActas: missing profileId', 'bad-input')
1119
+ this._needActaCache()
1120
+ const res = await this._request({ type: 'acta-get', profileId, ...(Number.isInteger(sinceSeq) ? { sinceSeq } : {}) }, 'acta-get')
1121
+ return Array.isArray(res.actas) ? res.actas : []
1122
+ }
1123
+
1124
+ /**
1125
+ * Le deja al proxio un acta de la cuenta, para que otros aparatos se enteren sin preguntar
1126
+ * a la bóveda. Devuelve `{ stored }`: `false` es que ya la tenía o tiene más nuevas.
1127
+ * Lanza `bad-acta` si no la selló su cuenta y `no-acta-cache` si el proxio es viejo.
1128
+ */
1129
+ async putActa (acta) {
1130
+ if (!acta || typeof acta !== 'object') throw errorWithCode('putActa: missing acta', 'bad-input')
1131
+ this._needActaCache()
1132
+ const res = await this._request({ type: 'acta-put', acta }, 'acta-put')
1133
+ return { stored: res.stored === true }
1134
+ }
1135
+
1136
+ _needActaCache () {
1137
+ // Un proxio que no manda `caps` es de antes de que existieran: se pregunta igual.
1138
+ if (Array.isArray(this.caps) && !this.caps.includes('acta-cache')) {
1139
+ throw errorWithCode(`this proxy (${this.url}) does not keep records: it needs websocket-proxy >= 1.10.0`, 'no-acta-cache')
1140
+ }
1141
+ }
1142
+
1100
1143
  async _lookupEncPub (publickey) {
1101
1144
  // EL CAMINO MÁS DIRECTO PRIMERO. Si la app comparte acta con el destinatario, la llave
1102
1145
  // ya la tiene en la mano y firmada por el master: preguntársela a un servidor sería
@@ -1969,6 +2012,8 @@ export class WebSocketProxyClient {
1969
2012
  case 'pair-redeem':
1970
2013
  case 'encpub-announced':
1971
2014
  case 'enc-lookup':
2015
+ case 'acta-get':
2016
+ case 'acta-put':
1972
2017
  this._resolvePending(data, type)
1973
2018
  break
1974
2019
  case 'error':
@@ -154,8 +154,12 @@ export class WebRTCManager {
154
154
  this.count = typeof opts.count === 'function' ? opts.count : null
155
155
  this.iceServers = (opts.config && opts.config.iceServers) || DEFAULT_ICE_SERVERS
156
156
  this.peers = new Map() // remoteToken -> PeerState
157
+ this.closed = false // `closeAll()`: no se abre nada más hasta `reopen()`
157
158
  }
158
159
 
160
+ /** El cliente vuelve a conectar tras un `close()`: se puede negociar otra vez. */
161
+ reopen () { this.closed = false }
162
+
159
163
  /**
160
164
  * True if this is a control envelope and was consumed.
161
165
  * Otherwise the caller should keep delivering it normally.
@@ -173,6 +177,8 @@ export class WebRTCManager {
173
177
  handleIncoming (from, parsed) {
174
178
  if (!parsed || typeof parsed !== 'object' || parsed.t !== RTC_TAG) return false
175
179
  if (this.acceptFrom && !this.acceptFrom(from)) return false
180
+ // Cerrado: una señal que llega tarde no abre una conexión que ya nadie va a cerrar.
181
+ if (this.closed) return true
176
182
  const peer = this._ensurePeer(from)
177
183
  this._handleSignal(peer, parsed).catch((e) => {
178
184
  this.emit('error', { type: 'webrtc_signal', error: e, peer: from })
@@ -186,6 +192,7 @@ export class WebRTCManager {
186
192
  * to the proxy. Also opportunistically starts the connection negotiation.
187
193
  */
188
194
  trySend (to, payloadString) {
195
+ if (this.closed) return false
189
196
  const peer = this._ensurePeer(to)
190
197
  if (usable(peer)) {
191
198
  try {
@@ -225,6 +232,7 @@ export class WebRTCManager {
225
232
 
226
233
  /** Optional: explicitly preconnect to a peer. */
227
234
  connect (to) {
235
+ if (this.closed) return Promise.reject(new Error('WebRTC closed'))
228
236
  const peer = this._ensurePeer(to)
229
237
  if (usable(peer)) return Promise.resolve()
230
238
  if (!peer.negotiating) this._startNegotiation(peer).catch(() => {})
@@ -233,18 +241,41 @@ export class WebRTCManager {
233
241
  })
234
242
  }
235
243
 
244
+ /**
245
+ * CERRAR CON UNA DESCRIPCIÓN EN VUELO DEJA SOCKETS ABIERTOS. En Node (`@dotrino/webrtc`, o
246
+ * sea werift), `setLocalDescription` reúne los candidatos y abre un socket UDP por
247
+ * dirección; si `close()` llega en medio, cierra los que ya estaban y los que terminan de
248
+ * abrirse después no los cierra nadie. El proceso no sale nunca: así se colgaron las
249
+ * pruebas de la bóveda en CI (0.186.0 y 0.186.1). Por eso, con una descripción en vuelo,
250
+ * la conexión se cierra al terminar esta, que ya ha reunido todo.
251
+ */
236
252
  closePeer (to) {
237
253
  const peer = this.peers.get(to)
238
254
  if (!peer) return
239
- try { if (peer.dc) peer.dc.close() } catch (_) {}
240
- try { if (peer.pc) peer.pc.close() } catch (_) {}
241
255
  this.peers.delete(to)
256
+ peer.closing = true
257
+ try { if (peer.dc) peer.dc.close() } catch (_) {}
258
+ if (!peer.busy) this._closePC(peer)
242
259
  }
243
260
 
244
261
  closeAll () {
262
+ this.closed = true
245
263
  for (const t of Array.from(this.peers.keys())) this.closePeer(t)
246
264
  }
247
265
 
266
+ _closePC (peer) {
267
+ try { if (peer.pc) peer.pc.close() } catch (_) {}
268
+ }
269
+
270
+ /** Una descripción (local o remota) en vuelo: mientras dure, cerrar espera a que acabe. */
271
+ async _describe (peer, fn) {
272
+ peer.busy = (peer.busy || 0) + 1
273
+ try { return await fn() } finally {
274
+ peer.busy--
275
+ if (peer.closing && !peer.busy) this._closePC(peer)
276
+ }
277
+ }
278
+
248
279
  /**
249
280
  * Reemplaza la lista de ICE servers para las PRÓXIMAS conexiones (los peers
250
281
  * ya negociados conservan la suya). Lo usa `client.enableTurn()` para
@@ -340,7 +371,8 @@ export class WebRTCManager {
340
371
  pc.onnegotiationneeded = async () => {
341
372
  try {
342
373
  peer.makingOffer = true
343
- await pc.setLocalDescription()
374
+ await this._describe(peer, () => pc.setLocalDescription())
375
+ if (peer.closing) return
344
376
  this._signal(peer, { kind: 'sdp', sdp: pc.localDescription })
345
377
  } catch (e) {
346
378
  this.emit('error', { type: 'webrtc_negotiate', error: e, peer: peer.remote })
@@ -443,14 +475,16 @@ export class WebRTCManager {
443
475
  (peer.makingOffer || pc.signalingState !== 'stable')
444
476
  peer.ignoreOffer = !peer.polite && offerCollision
445
477
  if (peer.ignoreOffer) return
446
- await pc.setRemoteDescription(msg.sdp)
478
+ await this._describe(peer, () => pc.setRemoteDescription(msg.sdp))
479
+ if (peer.closing) return
447
480
  // flush any queued candidates
448
481
  for (const c of peer.pendingCandidates) {
449
482
  try { await pc.addIceCandidate(c) } catch (_) {}
450
483
  }
451
484
  peer.pendingCandidates = []
452
485
  if (msg.sdp.type === 'offer') {
453
- await pc.setLocalDescription()
486
+ await this._describe(peer, () => pc.setLocalDescription())
487
+ if (peer.closing) return
454
488
  this._signal(peer, { kind: 'sdp', sdp: pc.localDescription })
455
489
  }
456
490
  } else if (msg.kind === 'ice' && msg.candidate) {
@@ -1,3 +1,3 @@
1
- Copia vendorizada de @dotrino/roadmap@0.4.84 (dotrino-roadmap/src/{index,manifests}.js).
1
+ Copia vendorizada de @dotrino/roadmap@0.4.87 (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.
@@ -22,16 +22,16 @@ export const MANIFESTS = Object.freeze({
22
22
  "env": {
23
23
  "repo": "imdotrino/dotrino-vault",
24
24
  "npm": "@dotrino/env",
25
- "current": "0.109.0",
25
+ "current": "0.118.0",
26
26
  "protocol": 1,
27
27
  "requires": {
28
- "vault": ">=0.109.0"
28
+ "vault": ">=0.118.0"
29
29
  }
30
30
  },
31
31
  "identity": {
32
32
  "repo": "imdotrino/dotrino-identity",
33
33
  "npm": "@dotrino/identity",
34
- "current": "0.133.1",
34
+ "current": "0.135.0",
35
35
  "protocol": 1,
36
36
  "requires": {
37
37
  "proxy-client": ">=0.13.1"
@@ -111,7 +111,7 @@ export const MANIFESTS = Object.freeze({
111
111
  },
112
112
  "proxy": {
113
113
  "repo": "imdotrino/dotrino-proxy",
114
- "current": "1.9.2",
114
+ "current": "1.11.0",
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.45.1",
126
+ "current": "0.46.0",
127
127
  "protocol": 2,
128
128
  "requires": {
129
129
  "identity": ">=0.53.0",
@@ -133,12 +133,12 @@ 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.26.0",
136
+ "current": "0.32.1",
137
137
  "protocol": 1,
138
138
  "requires": {
139
139
  "identity": ">=0.121.7",
140
- "vault": ">=0.90.0",
141
- "proxy-client": ">=0.36.1",
140
+ "vault": ">=0.115.0",
141
+ "proxy-client": ">=0.46.0",
142
142
  "vaultd": ">=0.154.0",
143
143
  "compat": ">=0.5.0"
144
144
  }
@@ -146,12 +146,12 @@ export const MANIFESTS = Object.freeze({
146
146
  "tunnel": {
147
147
  "repo": "imdotrino/dotrino-tunnel",
148
148
  "npm": "@dotrino/tunnel",
149
- "current": "0.3.0",
149
+ "current": "0.5.2",
150
150
  "protocol": 2,
151
151
  "requires": {
152
152
  "identity": ">=0.127.0",
153
- "remote-agent": ">=0.25.0",
154
- "vault": ">=0.104.0",
153
+ "remote-agent": ">=0.30.0",
154
+ "vault": ">=0.115.0",
155
155
  "proxy-client": ">=0.44.1",
156
156
  "store": ">=0.12.3",
157
157
  "update": ">=0.9.2"
@@ -160,20 +160,20 @@ export const MANIFESTS = Object.freeze({
160
160
  "terminal-agent": {
161
161
  "repo": "imdotrino/dotrino-terminal",
162
162
  "npm": "@dotrino/terminal-agent",
163
- "current": "0.49.5",
163
+ "current": "0.54.0",
164
164
  "protocol": 2,
165
165
  "requires": {
166
- "remote-agent": ">=0.24.0",
166
+ "remote-agent": ">=0.32.1",
167
167
  "identity": ">=0.130.6",
168
- "vault": ">=0.109.2",
169
- "proxy-client": ">=0.44.1",
168
+ "vault": ">=0.115.0",
169
+ "proxy-client": ">=0.46.0",
170
170
  "update": ">=0.9.2",
171
171
  "vaultd": ">=0.142.0"
172
172
  }
173
173
  },
174
174
  "terminal-ios": {
175
175
  "repo": "imdotrino/dotrino-terminal",
176
- "current": "0.13.7",
176
+ "current": "0.13.8",
177
177
  "protocol": 1,
178
178
  "requires": {
179
179
  "terminal-agent": ">=0.37.0"
@@ -181,7 +181,7 @@ export const MANIFESTS = Object.freeze({
181
181
  },
182
182
  "terminal-android": {
183
183
  "repo": "imdotrino/dotrino-terminal",
184
- "current": "0.13.7",
184
+ "current": "0.13.8",
185
185
  "protocol": 1,
186
186
  "requires": {
187
187
  "terminal-agent": ">=0.37.0"
@@ -189,7 +189,7 @@ export const MANIFESTS = Object.freeze({
189
189
  },
190
190
  "terminal-desktop": {
191
191
  "repo": "imdotrino/dotrino-terminal",
192
- "current": "0.2.81",
192
+ "current": "0.2.92",
193
193
  "protocol": 1,
194
194
  "requires": {
195
195
  "terminal-agent": ">=0.37.0"
@@ -211,31 +211,32 @@ export const MANIFESTS = Object.freeze({
211
211
  "content": {
212
212
  "repo": "imdotrino/dotrino-content",
213
213
  "npm": "@dotrino/content",
214
- "current": "0.6.10",
214
+ "current": "0.7.2",
215
215
  "protocol": 1,
216
216
  "requires": {
217
- "remote-agent": ">=0.24.0",
217
+ "remote-agent": ">=0.30.0",
218
218
  "identity": ">=0.126.2",
219
- "vault": ">=0.87.0",
220
- "proxy-client": ">=0.42.1"
219
+ "vault": ">=0.115.0",
220
+ "proxy-client": ">=0.42.1",
221
+ "update": ">=0.9.0"
221
222
  }
222
223
  },
223
224
  "sealers": {
224
225
  "repo": "imdotrino/dotrino-sealers",
225
226
  "npm": "@dotrino/sealers",
226
- "current": "0.10.5",
227
+ "current": "0.11.0",
227
228
  "protocol": 1,
228
229
  "requires": {
229
- "remote-agent": ">=0.24.0",
230
- "identity": ">=0.121.7",
231
- "vault": ">=0.93.1",
232
- "proxy-client": ">=0.38.4"
230
+ "remote-agent": ">=0.30.0",
231
+ "identity": ">=0.135.0",
232
+ "vault": ">=0.115.0",
233
+ "proxy-client": ">=0.45.3"
233
234
  }
234
235
  },
235
236
  "roadmap": {
236
237
  "repo": "imdotrino/dotrino-roadmap",
237
238
  "npm": "@dotrino/roadmap",
238
- "current": "0.4.59",
239
+ "current": "0.4.87",
239
240
  "protocol": 1,
240
241
  "requires": {
241
242
  "compat": "0.4.0+"
@@ -244,11 +245,11 @@ export const MANIFESTS = Object.freeze({
244
245
  "store": {
245
246
  "repo": "imdotrino/dotrino-store",
246
247
  "npm": "@dotrino/store",
247
- "current": "0.12.4",
248
+ "current": "0.14.1",
248
249
  "protocol": 1,
249
250
  "requires": {
250
251
  "identity": ">=0.91.0",
251
- "vaultd": ">=0.115.0"
252
+ "vaultd": ">=0.186.2"
252
253
  }
253
254
  },
254
255
  "theme": {
@@ -261,7 +262,7 @@ export const MANIFESTS = Object.freeze({
261
262
  "topbar": {
262
263
  "repo": "imdotrino/dotrino-topbar",
263
264
  "npm": "@dotrino/topbar",
264
- "current": "0.16.3",
265
+ "current": "0.17.0",
265
266
  "protocol": 1,
266
267
  "requires": {
267
268
  "identity": ">=0.96.1",
@@ -271,28 +272,28 @@ export const MANIFESTS = Object.freeze({
271
272
  "vault": {
272
273
  "repo": "imdotrino/dotrino-vault",
273
274
  "npm": "@dotrino/vault",
274
- "current": "0.112.0",
275
+ "current": "0.118.0",
275
276
  "protocol": 1,
276
277
  "requires": {
277
278
  "vaultd": ">=0.105.0",
278
- "proxy-client": ">=0.44.1",
279
- "identity": ">=0.133.1",
279
+ "proxy-client": ">=0.46.0",
280
+ "identity": ">=0.135.0",
280
281
  "opaque": ">=0.1.0",
281
282
  "compat": ">=0.5.0",
282
283
  "roadmap": ">=0.4.26",
283
284
  "passmanager": ">=0.18.6",
284
- "store": ">=0.12.3"
285
+ "store": ">=0.13.0"
285
286
  }
286
287
  },
287
288
  "vaultd": {
288
289
  "repo": "imdotrino/dotrino-vault",
289
290
  "npm": "@dotrino/vaultd",
290
- "current": "0.185.0",
291
+ "current": "0.190.1",
291
292
  "protocol": 1,
292
293
  "requires": {
293
- "identity": ">=0.133.1",
294
- "proxy-client": ">=0.44.1",
295
- "store": ">=0.11.0",
294
+ "identity": ">=0.135.0",
295
+ "proxy-client": ">=0.46.0",
296
+ "store": ">=0.13.0",
296
297
  "passmanager": ">=0.18.6",
297
298
  "compat": ">=0.5.0",
298
299
  "opaque": ">=0.1.0",
@@ -340,7 +341,7 @@ export const MANIFESTS = Object.freeze({
340
341
  },
341
342
  "passmanager-extension": {
342
343
  "repo": "imdotrino/dotrino-passmanager",
343
- "current": "0.58.2",
344
+ "current": "0.58.3",
344
345
  "protocol": 1,
345
346
  "requires": {
346
347
  "identity": ">=0.128.0",
@@ -372,24 +373,24 @@ export const MANIFESTS = Object.freeze({
372
373
  },
373
374
  "social-bot": {
374
375
  "repo": "imdotrino/dotrino-social-bot",
375
- "current": "0.3.1",
376
+ "current": "0.4.0",
376
377
  "protocol": 1,
377
378
  "requires": {
378
- "vault": ">=0.87.0",
379
- "identity": ">=0.126.2",
380
- "proxy-client": ">=0.42.1",
381
- "remote-agent": ">=0.24.0"
379
+ "vault": ">=0.115.0",
380
+ "identity": ">=0.135.0",
381
+ "proxy-client": ">=0.45.3",
382
+ "remote-agent": ">=0.30.0"
382
383
  }
383
384
  },
384
385
  "accounts": {
385
386
  "repo": "imdotrino/dotrino-accounts",
386
387
  "npm": null,
387
- "current": "0.7.1",
388
+ "current": "0.8.0",
388
389
  "protocol": 1,
389
390
  "requires": {
390
- "identity": ">=0.130.4",
391
- "remote-agent": ">=0.26.0",
392
- "vault": ">=0.109.0",
391
+ "identity": ">=0.135.0",
392
+ "remote-agent": ">=0.30.0",
393
+ "vault": ">=0.115.0",
393
394
  "pay": ">=0.2.0",
394
395
  "vaultd": ">=0.168.0",
395
396
  "update": ">=0.9.2"
@@ -412,11 +413,11 @@ export const MANIFESTS = Object.freeze({
412
413
  "expenses-agent": {
413
414
  "repo": "imdotrino/dotrino-expenses-agent",
414
415
  "npm": "@dotrino/expenses-agent",
415
- "current": "0.1.3",
416
+ "current": "0.2.0",
416
417
  "protocol": 1,
417
418
  "requires": {
418
- "remote-agent": ">=0.24.0",
419
- "vault": ">=0.96.0",
419
+ "remote-agent": ">=0.30.0",
420
+ "vault": ">=0.115.0",
420
421
  "update": ">=0.9.2",
421
422
  "vaultd": ">=0.154.0"
422
423
  }
@@ -1,3 +1,3 @@
1
- Copia vendorizada de @dotrino/store/core@0.13.0 (dotrino-store/store/{core}.js).
1
+ Copia vendorizada de @dotrino/store/core@0.14.2 (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.113.0 (dotrino-vault/lib/src/{admin,b64,browser,core/approvals,core/backup,core/blocked,core/browserDisk,core/commKey,core/disk,core/exNotices,core/gate,core/libVersion,core/logAnchor,core/machines,core/memberGroups,core/notices,core/notifiable,core/passwords,core/sealKey,core/sealer,core/sealers,core/secretsStore,core/sha256,core/siblingBackup,core/store,core/subacta,core/threadStore,core/transport,core/vault,enroll,index,invite,loginClient,passwordLogins,procContext,protocol,revocation,sealed}.js).
1
+ Copia vendorizada de @dotrino/vault@0.119.0 (dotrino-vault/lib/src/{admin,b64,browser,core/approvals,core/backup,core/blocked,core/browserDisk,core/commKey,core/disk,core/exNotices,core/gate,core/libVersion,core/logAnchor,core/machines,core/memberGroups,core/notices,core/notifiable,core/passwords,core/sealKey,core/sealer,core/sealers,core/secretsStore,core/sha256,core/siblingBackup,core/store,core/subacta,core/threadStore,core/transport,core/vault,enroll,index,invite,loginClient,passwordLogins,procContext,protocol,revocation,sealed}.js).
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
@@ -50,6 +50,11 @@ export const ADMIN_OPS = Object.freeze([
50
50
  // Los BLOQUEADOS por un aprobador (`src/blocked.js`): verlos y desbloquearlos. Bloquear a
51
51
  // distancia también, por si el administrador llega antes que el teléfono. No toca el acta.
52
52
  'blocked', 'block', 'unblock',
53
+ // LAS CONCESIONES (un pedido aprobado deja pasar ese comando una hora que se renueva con
54
+ // cada uso): verlas y cortarlas. Las mismas que el aprobador ve en /approvals; aquí las ve
55
+ // quien administra, igual que la TUI del binario. Cortar no sella nada: la lista es de la
56
+ // bóveda, no del acta.
57
+ 'grants', 'grant-revoke',
53
58
  // Variables de entorno: verlas (nombres siempre; valor solo de las públicas) y
54
59
  // ponerles valor (de las dos). Borrar NO está, y es a propósito: un aparato robado
55
60
  // no debe poder dejar sin configuración a los servicios.
@@ -99,8 +104,8 @@ export const ADMIN_OPS = Object.freeze([
99
104
  */
100
105
  export const ADMIN_OPS_WHILE_LOCKED = Object.freeze([
101
106
  'audit', 'vars', 'var.set', 'var.setMany', 'var.recipients', 'var.reveal.begin', 'var.reveal',
102
- // Bloquear no sella nada: la lista es de la bóveda, no del acta.
103
- 'blocked', 'block', 'unblock',
107
+ // Bloquear no sella nada: la lista es de la bóveda, no del acta. Las concesiones, igual.
108
+ 'blocked', 'block', 'unblock', 'grants', 'grant-revoke',
104
109
  // Las dos de abrir, obviamente: son las únicas que solo tienen sentido con el candado
105
110
  // echado. Que estén aquí NO las deja pasar sin más — siguen exigiendo cert, acta, nonce
106
111
  // y frescura como todas, y además la contraseña dentro del sobre.
@@ -154,6 +159,9 @@ export function createAdminDesk ({
154
159
  unlockDesk = null,
155
160
  // La lista de bloqueados, inyectada como `vars`: `{ list(), set(pub, on, { by }) }`.
156
161
  blocked = null,
162
+ // Las CONCESIONES, inyectadas igual: `{ list(device), revoke(id, { by }) }`. `list` recibe
163
+ // a quien pregunta porque el comando de cada una va sellado a su llave de cifrado.
164
+ grants = null,
157
165
  now = () => Date.now()
158
166
  }) {
159
167
  const ops = new Set(ADMIN_OPS)
@@ -352,6 +360,13 @@ export function createAdminDesk ({
352
360
  // usarlo para quitar dejaba un miembro sin certificados al que la bóveda ya nunca le
353
361
  // mandaba el aviso de expulsión (mientras siga en el acta, un papel retirado
354
362
  // significa «renueva»). Ese era el dispositivo fantasma.
363
+ if (data.op === 'grants' || data.op === 'grant-revoke') {
364
+ if (!grants) return { ok: false, error: 'admin: this vault has no grants' }
365
+ if (data.op === 'grants') return { ok: true, result: await grants.list(chk.device) }
366
+ if (typeof data.id !== 'string' || !data.id) return { ok: false, error: 'admin: grant-revoke needs the grant id' }
367
+ const ok = await grants.revoke(data.id, { by })
368
+ return { ok: true, result: { id: data.id, ok } }
369
+ }
355
370
  if (data.op === 'blocked' || data.op === 'block' || data.op === 'unblock') {
356
371
  if (!blocked) return { ok: false, error: 'admin: this vault cannot block devices' }
357
372
  if (data.op === 'blocked') return { ok: true, result: { items: blocked.list() } }
@@ -5,4 +5,4 @@
5
5
  * si no coincide con la del paquete: una versión anunciada que no es la que corre es peor
6
6
  * que no anunciar ninguna.
7
7
  */
8
- export const LIB_VERSION = '0.112.0'
8
+ export const LIB_VERSION = '0.119.0'
@@ -22,7 +22,14 @@ export const NOTICE_TTL_MS = 24 * 60 * 60 * 1000
22
22
  * (`docs/pairing-protocol.md` §1.7). No pide nada: no hay a quién bloquear, porque ninguno
23
23
  * entró. Lo cuenta, con el ID y la máquina de los dos.
24
24
  */
25
- export const NOTICE_EVS = ['updated', 'update-needs-root', 'pairing-contested', 'log-anchor']
25
+ export const NOTICE_EVS = ['updated', 'update-needs-root', 'pairing-contested', 'log-anchor', 'delivered']
26
+ /**
27
+ * `delivered`: un aparato con `unattended` se llevó claves de un cajón (`kind: 'secrets'`) o
28
+ * una contraseña (`kind: 'passwords'`) sin que nadie aprobara, porque no le hacía falta (dueño,
29
+ * 2026-11-04: «equipos unattended no deben pedir aprobación, quizás sí notificar que han
30
+ * entregado contraseñas»). No pide nada: lo cuenta. Lleva `ns`, `deviceId` y `label`.
31
+ */
32
+ const DELIVERED_KINDS = ['secrets', 'passwords']
26
33
 
27
34
  const newId = () => [...crypto.getRandomValues(new Uint8Array(8))].map((b) => b.toString(16).padStart(2, '0')).join('')
28
35
 
@@ -58,8 +65,17 @@ export function openNotices ({ disk, now = Date.now }) {
58
65
  * administrador). `product`: qué (`@dotrino/vaultd` es la propia bóveda);
59
66
  * `deviceId`/`label`: el aparato, si fue uno.
60
67
  */
61
- add (ev, { version, from = null, product = '@dotrino/vaultd', deviceId = null, label = null, devices = null, logSeq = null, head = null, tsa = null }) {
68
+ add (ev, { version, from = null, product = '@dotrino/vaultd', deviceId = null, label = null, devices = null, logSeq = null, head = null, tsa = null, ns = null, kind = null }) {
62
69
  if (!NOTICE_EVS.includes(ev)) throw fail('bad-notice', `unknown notice: ${ev}`)
70
+ if (ev === 'delivered') {
71
+ if (!DELIVERED_KINDS.includes(kind)) throw fail('bad-notice', `${ev}: kind must be one of ${DELIVERED_KINDS.join(', ')}`)
72
+ if (typeof ns !== 'string' || !ns) throw fail('bad-notice', `${ev}: the drawer (ns) is required`)
73
+ if (typeof deviceId !== 'string' || !deviceId) throw fail('bad-notice', `${ev}: the device is required`)
74
+ const n = { id: newId(), ev, kind, ns, deviceId, label: typeof label === 'string' ? label : '', ts: now() }
75
+ items = [...items.filter(alive), n]
76
+ save()
77
+ return n
78
+ }
63
79
  // EL ANCLA DE LA BITÁCORA (`logAnchor.js`): la cabeza sellada por el signer, para que el
64
80
  // aprobador la guarde. Solo se queda la última: la anterior ya no dice nada que esta no diga.
65
81
  if (ev === 'log-anchor') {
@@ -36,6 +36,7 @@ export const PASSWORDS_CAP = 'passwords'
36
36
  * `encPubOf(pubkey)` su llave de cifrado, para sellarle la respuesta
37
37
  * `needsApproval(pubkey)` (async) si ese aparato tiene que pedir aprobación (`unattended`)
38
38
  * `approve({ pubkey, op })` pide el visto bueno (el teléfono) y espera
39
+ * `onDelivered(pubkey)` se sirvió una lectura (`pm2.get`) a ese aparato
39
40
  * `audit(op, info)` la bitácora del vault
40
41
  */
41
42
  export function createPasswordDesk (opts = {}) {
@@ -48,6 +49,7 @@ export function createPasswordDesk (opts = {}) {
48
49
  encPubOf = () => null,
49
50
  needsApproval = () => true,
50
51
  approve = async () => false,
52
+ onDelivered = () => {},
51
53
  audit = () => {},
52
54
  log = () => {},
53
55
  } = opts
@@ -73,6 +75,8 @@ export function createPasswordDesk (opts = {}) {
73
75
  // La bitácora NO lleva qué credencial se pidió: eso es contenido del usuario.
74
76
  audit('passwords', { op: r.op, outcome: r.outcome, device: (r.from || '').slice(0, 24) })
75
77
  if (r.outcome !== 'ok') log(`[vault] passwords: ${r.op} ${r.outcome}`)
78
+ // Una LECTURA servida: quien llama decide si hay que contarla (`unattended`, ver vault.js).
79
+ else if (r.op === 'pm2.get' && r.from) onDelivered(r.from)
76
80
  },
77
81
  })
78
82
 
@@ -2036,6 +2036,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2036
2036
  }
2037
2037
  audit('secrets', { device: await deviceIdOf(chk.device), ns, ...(publicOnly ? { publicOnly: true } : {}) })
2038
2038
  reply(from, { type: MSG.SECRETS_RESULT, ...res })
2039
+ if (!publicOnly) announceDelivered({ device: chk.device, ns, kind: 'secrets' })
2039
2040
  }
2040
2041
 
2041
2042
  /** El bundle de `ns` para `devicePub`, sellado a su `ek` y firmado por la llave de sellado. */
@@ -2139,12 +2140,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2139
2140
  if (op === 'blocked') return answer({ op: 'blocked', items: blocked.list() })
2140
2141
  if (op === 'grant-revoke') {
2141
2142
  const gid = typeof p.data?.id === 'string' ? p.data.id : ''
2142
- const ok = gid ? grants.revoke(gid) : false
2143
- if (ok) {
2144
- audit('secrets.grant.revoked', { id: gid, by })
2145
- log(`[vault] grant ${gid} revoked by ${by} — that command will ring again`)
2146
- }
2147
- return answer({ op: 'grant-revoke.result', id: gid, ok })
2143
+ return answer({ op: 'grant-revoke.result', id: gid, ok: revokeGrantBy(gid, by) })
2148
2144
  }
2149
2145
  const id = typeof p.data?.id === 'string' ? p.data.id : ''
2150
2146
  const pend = approvals.take(id)
@@ -2249,6 +2245,52 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2249
2245
  * en vez de mandárselo en claro «para que al menos lo vea»: eso sería cambiar la promesa
2250
2246
  * por comodidad, y encima sin avisar a nadie.
2251
2247
  */
2248
+ /** Un objeto pequeño sellado a un `encPub` del acta: `{ wrap, envelope }`, lo abre `openSealed`. */
2249
+ async function sealTo (encPub, obj) {
2250
+ const cek = await makeContentKey()
2251
+ const envelope = await encryptWithCek({ cek, gen: 0, plaintext: JSON.stringify(obj) })
2252
+ const wrap = await wrapForMember({ cek, memberEncPub: encPub })
2253
+ return { wrap, envelope }
2254
+ }
2255
+
2256
+ /**
2257
+ * EL ASUNTO DEL TIMBRE, SELLADO AL TELÉFONO (dueño, 2026-11-04: «que las notificaciones a
2258
+ * móviles no sean del todo anónimas sino que al menos tengan asunto, para ver quién solicita
2259
+ * qué»). El timbre que sale por FCM/APNs lo leen Google y Apple, así que el proxio lo manda
2260
+ * vacío. Lo que va aquí viaja dentro del mensaje como `ring` y el proxio lo pega al timbre
2261
+ * TAL CUAL: va cifrado a la `encPub` del aprobador, y solo su teléfono lo abre, sin red.
2262
+ *
2263
+ * Es solo el asunto. Quien aprueba sigue decidiendo con la lista (`op: 'approvals'`), que
2264
+ * es la que va firmada: un asunto falso no aprueba nada.
2265
+ *
2266
+ * Sin `encPub` en el acta no hay asunto (y el teléfono enseña el genérico): mandarlo en claro
2267
+ * sería cambiar la promesa sin avisar.
2268
+ */
2269
+ const RING_CTX_KEYS = ['op', 'fields', 'product', 'version', 'from', 'reporterLabel', 'kind']
2270
+ async function ringFor (pub, record, hint) {
2271
+ const encPub = (record?.members || []).find((m) => m.pub === pub)?.encPub || null
2272
+ if (!encPub) return null
2273
+ let ctx = null
2274
+ if (hint.ctx && typeof hint.ctx === 'object') {
2275
+ ctx = {}
2276
+ for (const k of RING_CTX_KEYS) if (hint.ctx[k] != null) ctx[k] = hint.ctx[k]
2277
+ }
2278
+ try { return await sealTo(encPub, { ...hint, ctx }) } catch (e) {
2279
+ log(`[vault] could not seal the subject of the ring for ${pub.slice(0, 24)}…: ${e.message}`)
2280
+ return null
2281
+ }
2282
+ }
2283
+
2284
+ /** Corta una concesión (desde /approvals o desde la consola de administración). */
2285
+ function revokeGrantBy (gid, by) {
2286
+ const ok = gid ? grants.revoke(gid) : false
2287
+ if (ok) {
2288
+ audit('secrets.grant.revoked', { id: gid, by })
2289
+ log(`[vault] grant ${gid} revoked by ${by} — that command will ring again`)
2290
+ }
2291
+ return ok
2292
+ }
2293
+
2252
2294
  async function withSealedContext (items, approver, record) {
2253
2295
  const encPub = (record?.members || []).find((m) => m.pub === approver)?.encPub || null
2254
2296
  const output = []
@@ -2257,9 +2299,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2257
2299
  if (!ctx) { output.push({ ...rest, ctx: null }); continue }
2258
2300
  if (!encPub) { output.push({ ...rest, ctx: null, ctxSealed: false, ctxReason: 'no-enc-key' }); continue }
2259
2301
  try {
2260
- const cek = await makeContentKey()
2261
- const envelope = await encryptWithCek({ cek, gen: 0, plaintext: JSON.stringify(ctx) })
2262
- const wrap = await wrapForMember({ cek, memberEncPub: encPub })
2302
+ const { wrap, envelope } = await sealTo(encPub, ctx)
2263
2303
  output.push({ ...rest, ctx: null, ctxSealed: true, ctxWrap: wrap, ctxEnvelope: envelope })
2264
2304
  } catch (e) {
2265
2305
  // NO SE TRAGA: sin esto, un fallo al sellar se vería en el teléfono igual que un
@@ -2300,7 +2340,8 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2300
2340
  for (const pub of who) {
2301
2341
  // A la app que APRUEBA (`vault`): en un teléfono la llave es de todas sus apps, y sin
2302
2342
  // decirlo el pedido timbraba a messenger (websocket-proxy ≥ 1.4.0).
2303
- try { client.sendByPubkey(pub, { type: MSG.ADMIN_EVENT, body, seal }, { app: 'vault' }) }
2343
+ const ring = await ringFor(pub, record, { ...body, ctx: pend.ctx || null })
2344
+ try { client.sendByPubkey(pub, { type: MSG.ADMIN_EVENT, body, seal, ...(ring ? { ring } : {}) }, { app: 'vault' }) }
2304
2345
  catch (e) { log(`[vault] could not ring ${pub.slice(0, 24)}… about ${pend.ns}: ${e.message}`) }
2305
2346
  }
2306
2347
  log(`[vault] ${pend.ns}: rang ${who.length} approver(s) for ${pend.id}`)
@@ -2331,9 +2372,12 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2331
2372
  const { id, ev, ts, ...rest } = notice
2332
2373
  const body = { ev, id, ...rest, ts }
2333
2374
  const seal = await sealOrFail(body)
2375
+ // Lo que calla no timbra: no lleva asunto. Lo que suena, sí (ver `ringFor`).
2376
+ const record = quiet ? null : await refreshActa()
2334
2377
  let sent = 0
2335
2378
  for (const pub of who) {
2336
- try { client.sendByPubkey(pub, { type: MSG.ADMIN_EVENT, body, seal }, { app: 'vault', ...(quiet ? { quiet: true } : {}) }); sent++ }
2379
+ const ring = quiet ? null : await ringFor(pub, record, { ev, id, ts, kind: rest.kind || null, ns: rest.ns || null, deviceId: rest.deviceId || null, label: rest.label || null, product: rest.product || null, version: rest.version || null, from: rest.from || null })
2380
+ try { client.sendByPubkey(pub, { type: MSG.ADMIN_EVENT, body, seal, ...(ring ? { ring } : {}) }, { app: 'vault', ...(quiet ? { quiet: true } : {}) }); sent++ }
2337
2381
  catch (e) { log(`[vault] could not tell ${pub.slice(0, 24)}… about ${what}: ${e.message}`) }
2338
2382
  }
2339
2383
  return sent
@@ -2402,6 +2446,39 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2402
2446
  return { approvers: who.length, sent, notice }
2403
2447
  }
2404
2448
 
2449
+ /**
2450
+ * «SE LLEVÓ CLAVES SIN PEDIR», a quien aprueba (dueño, 2026-11-04). Un aparato con
2451
+ * `unattended` no pide aprobación —para eso se le dio—, pero que lo haga en silencio deja al
2452
+ * dueño sin saber qué máquina se llevó qué. Se cuenta como aviso (`delivered`), no como pedido.
2453
+ *
2454
+ * UNO POR APARATO, CAJÓN Y HORA: un servicio pide su cajón en cada arranque y el gestor una
2455
+ * contraseña en cada relleno; timbrar cada vez enseña a ignorar el timbre. Solo cuando de
2456
+ * verdad no se pidió por `unattended`: sin aprobadores no hay a quién contar, y lo aprobado
2457
+ * ya lo vio quien aprobó.
2458
+ */
2459
+ const DELIVERED_EVERY_MS = 60 * 60 * 1000
2460
+ const deliveredAt = new Map()
2461
+ async function announceDelivered ({ device, ns, kind }) {
2462
+ try {
2463
+ const record = await refreshActa()
2464
+ if (!record || !Acta.memberCan(record, device, 'unattended')) return
2465
+ const who = (record.members || []).filter((m) => Acta.memberCan(record, m.pub, 'approve')).map((m) => m.pub)
2466
+ if (!who.length) return
2467
+ const key = `${device}|${kind}|${ns}`
2468
+ const now = Date.now()
2469
+ if (now - (deliveredAt.get(key) || 0) < DELIVERED_EVERY_MS) return
2470
+ deliveredAt.set(key, now)
2471
+ for (const [k, t] of deliveredAt) if (now - t >= DELIVERED_EVERY_MS) deliveredAt.delete(k)
2472
+ const deviceId = await deviceIdOf(device).catch(() => null)
2473
+ if (!deviceId) return log(`[vault] delivered: could not name the device that took ${kind} of ${ns}, so nobody is told`)
2474
+ const label = (record.members || []).find((m) => m.pub === device)?.label || ''
2475
+ const notice = notices.add('delivered', { kind, ns, deviceId, label })
2476
+ const sent = await sendNotice(notice, who, `the delivery of ${kind} of ${ns} to ${deviceId}`)
2477
+ audit('delivered.announced', { device: deviceId, ns, kind, approvers: who.length, sent })
2478
+ log(`[vault] delivered: told ${sent} of ${who.length} approver(s) that ${deviceId} took ${kind} of ${ns} without approval (unattended)`)
2479
+ } catch (e) { log(`[vault] delivered: could not tell the approvers (${e.code || 'error'}: ${e.message})`) }
2480
+ }
2481
+
2405
2482
  /**
2406
2483
  * UN INCIDENTE: un agente de la cuenta dice que OTRO aparato de la cuenta se equivocó de
2407
2484
  * clave tres veces seguidas (la terminal, `dotrino-terminal lock`). No se decide aquí
@@ -2676,6 +2753,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2676
2753
  // el permiso se seguía sirviendo solo.
2677
2754
  needsApproval: passwordsNeedApproval,
2678
2755
  approve: approvePasswordRequest,
2756
+ onDelivered: (pub) => announceDelivered({ device: pub, ns: 'passwords', kind: 'passwords' }),
2679
2757
  audit,
2680
2758
  log,
2681
2759
  }).start()
@@ -3019,6 +3097,14 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
3019
3097
  for (const m of members) notify(m.pub)
3020
3098
  for (const d of issued || []) notify(d.sub)
3021
3099
  log(`[vault] notified ${seen.size} member(s) of "${ev}" (record #${acta?.seq ?? '?'})`)
3100
+ // Y SE DEJA EN LA CACHÉ DEL PROXIO (websocket-proxy ≥ 1.10.0): así un aparato que va
3101
+ // atrás se pone al día sin despertar a la bóveda (una ventana de Terminal esperaba 4-17 s
3102
+ // por esto, 2026-11-04). El proxio solo guarda; quien la toma la adopta si encadena.
3103
+ if (acta) {
3104
+ Promise.resolve().then(() => client.putActa(acta)).then(
3105
+ (r) => log(`[vault] record #${acta.seq} left on the proxy cache${r.stored ? '' : ' (it already had it)'}`),
3106
+ (e) => log(`[vault] could not leave record #${acta.seq} on the proxy cache: ${e.code || 'error'} · ${e.message}`))
3107
+ }
3022
3108
  } catch (e) { log('[vault] could not notify members of the change:', e.message) }
3023
3109
  // Y a los replicadores, que no quieren un aviso sino el CONTENIDO: sin esto se
3024
3110
  // quedarían con el acta de ayer y repartiendo sobres de un aparato ya revocado.
@@ -3440,6 +3526,13 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
3440
3526
  deviceIdOf,
3441
3527
  audit,
3442
3528
  blocked: { list: () => blocked.list(), set: setBlocked },
3529
+ grants: {
3530
+ list: async (device) => {
3531
+ const record = (await identity.profileActa?.().catch(() => null))?.acta
3532
+ return { items: await withSealedContext(grants.list(), device, record), ttlMs: GRANT_TTL_MS }
3533
+ },
3534
+ revoke: async (id, { by }) => revokeGrantBy(id, by)
3535
+ },
3443
3536
  // Abrir a distancia. Va inyectado porque `admin.js` es puro y esto necesita cripto y
3444
3537
  // disco; `null` si este perfil no lo soporta, y entonces la operación contesta que no.
3445
3538
  unlockDesk,
@@ -4721,8 +4814,17 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
4721
4814
  }
4722
4815
  }
4723
4816
  } catch (_) { /* comprobar es un extra: si falla, no rompe el cambio */ }
4724
- const devices = await Promise.all(changes.map(async ({ pub, caps }) => ({ deviceId: await deviceIdOf(pub).catch(() => null), caps })))
4725
- for (const d of devices) audit('caps', { device: d.deviceId, caps: d.caps })
4817
+ // DISPOSITIVO O SERVICIO (`cn`, identity ≥ 0.135.0). Un pilar viejo ignora la clave y
4818
+ // sella el acta sin tocarlo: eso no es «listo», y se dice.
4819
+ for (const { pub, cn } of changes) {
4820
+ if (cn === undefined) continue
4821
+ const m = await memberOf(pub)
4822
+ if ((m?.cn ?? null) !== cn) {
4823
+ throw Object.assign(new Error(`the device is still ${m?.cn ? `the "${m.cn}" service` : 'a device'}: this build's @dotrino/identity cannot change it (needs 0.135.0)`), { code: 'cn-unavailable' })
4824
+ }
4825
+ }
4826
+ const devices = await Promise.all(changes.map(async ({ pub, caps, cn }) => ({ deviceId: await deviceIdOf(pub).catch(() => null), caps, ...(cn !== undefined ? { service: cn } : {}) })))
4827
+ for (const d of devices) audit('caps', { device: d.deviceId, caps: d.caps, ...(d.service !== undefined ? { service: d.service } : {}) })
4726
4828
  // El acta acaba de cambiar QUIÉN debe tener envoltura de qué: se repasa antes de
4727
4829
  // avisar, para que el aviso salga con el llavero ya al día.
4728
4830
  await refreshWraps('caps')