@dotrino/identity 0.135.0 → 0.136.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.
@@ -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