@dotrino/identity 0.121.4 → 0.121.6

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.121.4",
3
+ "version": "0.121.6",
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",
@@ -1,4 +1,4 @@
1
- Copia vendorizada de @dotrino/proxy-client@0.38.2 (dotrino-proxy-client/src/{binpack,canonical,client,encpub,errors,index,parts,sealing,signature,stats-log,stats,webrtc}.js).
1
+ Copia vendorizada de @dotrino/proxy-client@0.38.4 (dotrino-proxy-client/src/{binpack,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.
@@ -23,6 +23,8 @@
23
23
  * El proxio lee la cabecera para enrutar y no mira el cuerpo, que va sellado.
24
24
  */
25
25
 
26
+ import { errorWithCode } from './errors.js'
27
+
26
28
  export const BIN_TAG = '__dotrino_bin'
27
29
  const PACK_MAGIC = 0xB1
28
30
  const FRAME_VERSION = 0x01
@@ -30,10 +32,6 @@ const FRAME_VERSION = 0x01
30
32
  const enc = new TextEncoder()
31
33
  const dec = new TextDecoder()
32
34
 
33
- function withCode (message, code) {
34
- return Object.assign(new Error(message), { code })
35
- }
36
-
37
35
  /** Bytes, sin importar de qué vista vengan (`Buffer`, `ArrayBuffer`, `Uint8Array`). */
38
36
  export function asBytes (v) {
39
37
  if (v instanceof Uint8Array) return v
@@ -84,12 +82,12 @@ export const isPacked = (b) => b instanceof Uint8Array && b.length >= 5 && b[0]
84
82
  */
85
83
  export function unpack (bytes) {
86
84
  const b = asBytes(bytes)
87
- if (!isPacked(b)) throw withCode('not a packed message', 'bad-pack')
85
+ if (!isPacked(b)) throw errorWithCode('not a packed message', 'bad-pack')
88
86
  const len = new DataView(b.buffer, b.byteOffset, b.byteLength).getUint32(1)
89
- if (5 + len > b.length) throw withCode('packed message is shorter than its header says', 'bad-pack')
87
+ if (5 + len > b.length) throw errorWithCode('packed message is shorter than its header says', 'bad-pack')
90
88
  const area = b.subarray(5 + len)
91
89
  let obj
92
- try { obj = JSON.parse(dec.decode(b.subarray(5, 5 + len))) } catch (_) { throw withCode('packed message header is not JSON', 'bad-pack') }
90
+ try { obj = JSON.parse(dec.decode(b.subarray(5, 5 + len))) } catch (_) { throw errorWithCode('packed message header is not JSON', 'bad-pack') }
93
91
  const revive = (v) => {
94
92
  if (Array.isArray(v)) return v.map(revive)
95
93
  if (!v || typeof v !== 'object') return v
@@ -97,7 +95,7 @@ export function unpack (bytes) {
97
95
  if (ref !== undefined) {
98
96
  if (!Array.isArray(ref) || ref.length !== 2 || !Number.isInteger(ref[0]) || !Number.isInteger(ref[1]) ||
99
97
  ref[0] < 0 || ref[1] < 0 || ref[0] + ref[1] > area.length) {
100
- throw withCode('packed message points outside itself', 'bad-pack')
98
+ throw errorWithCode('packed message points outside itself', 'bad-pack')
101
99
  }
102
100
  return area.subarray(ref[0], ref[0] + ref[1])
103
101
  }
@@ -130,11 +128,11 @@ export function encodeFrame (header, body) {
130
128
  /** El inverso: `{ header, body }`. Lanza con `code: 'bad-frame'` si no es una trama válida. */
131
129
  export function decodeFrame (data) {
132
130
  const b = asBytes(data)
133
- if (!b || b.length < 5 || b[0] !== FRAME_VERSION) throw withCode('not a binary frame of a known version', 'bad-frame')
131
+ if (!b || b.length < 5 || b[0] !== FRAME_VERSION) throw errorWithCode('not a binary frame of a known version', 'bad-frame')
134
132
  const len = new DataView(b.buffer, b.byteOffset, b.byteLength).getUint32(1)
135
- if (5 + len > b.length) throw withCode('binary frame is shorter than its header says', 'bad-frame')
133
+ if (5 + len > b.length) throw errorWithCode('binary frame is shorter than its header says', 'bad-frame')
136
134
  let header
137
- try { header = JSON.parse(dec.decode(b.subarray(5, 5 + len))) } catch (_) { throw withCode('binary frame header is not JSON', 'bad-frame') }
138
- if (!header || typeof header !== 'object' || Array.isArray(header)) throw withCode('binary frame header is not an object', 'bad-frame')
135
+ try { header = JSON.parse(dec.decode(b.subarray(5, 5 + len))) } catch (_) { throw errorWithCode('binary frame header is not JSON', 'bad-frame') }
136
+ if (!header || typeof header !== 'object' || Array.isArray(header)) throw errorWithCode('binary frame header is not an object', 'bad-frame')
139
137
  return { header, body: b.subarray(5 + len) }
140
138
  }
@@ -50,7 +50,7 @@ const APP_RE = /^[a-z0-9][a-z0-9-]{0,31}$/
50
50
  function checkApp (app) {
51
51
  if (app == null) return null
52
52
  if (typeof app !== 'string' || !APP_RE.test(app)) {
53
- throw Object.assign(new Error(`app: "${app}" is not a valid app name (a-z, 0-9, -; up to 32)`), { code: 'bad-app' })
53
+ throw errorWithCode(`app: "${app}" is not a valid app name (a-z, 0-9, -; up to 32)`, 'bad-app')
54
54
  }
55
55
  return app
56
56
  }
@@ -309,7 +309,7 @@ export class WebSocketProxyClient {
309
309
  if (options.app != null) {
310
310
  const app = checkApp(options.app)
311
311
  if (this.app && this.app !== app) {
312
- throw Object.assign(new Error(`app: this client is already "${this.app}", not "${app}"`), { code: 'app-conflict' })
312
+ throw errorWithCode(`app: this client is already "${this.app}", not "${app}"`, 'app-conflict')
313
313
  }
314
314
  this.app = app
315
315
  }
@@ -1155,7 +1155,7 @@ export class WebSocketProxyClient {
1155
1155
  // `code`: la bóveda usa esto para saber si su llave de comunicación firma todavía, y
1156
1156
  // tragarse un fallo de red como si fuera lo primero la mandaría al camino equivocado.
1157
1157
  if (typeof signature !== 'string') {
1158
- throw Object.assign(new Error('identifyAs: sign() returned no signature'), { code: 'no-signature' })
1158
+ throw errorWithCode('identifyAs: sign() returned no signature', 'no-signature')
1159
1159
  }
1160
1160
  return this.identify({ data, signature, cert, acta, sign })
1161
1161
  }
@@ -23,6 +23,7 @@
23
23
  */
24
24
 
25
25
  import { pack, unpack, concatBytes } from './binpack.js'
26
+ import { errorWithCode } from './errors.js'
26
27
 
27
28
  export const PART_TAG = '__dotrino_part'
28
29
 
@@ -107,7 +108,7 @@ export class Reassembler {
107
108
  if (!p || typeof p.id !== 'string' || p.id.length > 64 ||
108
109
  !Number.isInteger(p.n) || !Number.isInteger(p.i) || p.n < 2 || p.n > MAX_PARTS ||
109
110
  p.i < 0 || p.i >= p.n || (typeof d !== 'string' && !(d instanceof Uint8Array))) {
110
- throw Object.assign(new Error('malformed message part'), { code: 'bad-part' })
111
+ throw errorWithCode('malformed message part', 'bad-part')
111
112
  }
112
113
  const key = `${sender}|${p.id}`
113
114
  let a = this._open.get(key)
@@ -117,12 +118,12 @@ export class Reassembler {
117
118
  }
118
119
  if (a.n !== p.n || a.bin !== (d instanceof Uint8Array)) {
119
120
  this._drop(key)
120
- throw Object.assign(new Error('message parts disagree on their count or kind'), { code: 'bad-part' })
121
+ throw errorWithCode('message parts disagree on their count or kind', 'bad-part')
121
122
  }
122
123
  if (a.got[p.i] === undefined) {
123
124
  if (this._chars + d.length > RECV_MAX_CHARS) {
124
125
  this._drop(key)
125
- throw Object.assign(new Error('too much of a message in parts is pending'), { code: 'parts-too-big' })
126
+ throw errorWithCode('too much of a message in parts is pending', 'parts-too-big')
126
127
  }
127
128
  // Una copia: `d` es una vista sobre la trama entera, y guardarla retendría la trama.
128
129
  a.got[p.i] = a.bin ? d.slice() : d
@@ -134,7 +135,7 @@ export class Reassembler {
134
135
  if (a.count === a.n) {
135
136
  this._drop(key)
136
137
  try { return a.bin ? unpack(concatBytes(a.got)) : JSON.parse(a.got.join('')) }
137
- catch (_) { throw Object.assign(new Error('a message in parts did not join into a message'), { code: 'bad-part' }) }
138
+ catch (_) { throw errorWithCode('a message in parts did not join into a message', 'bad-part') }
138
139
  }
139
140
  a.timer = setTimeout(() => {
140
141
  const missing = a.n - a.count
@@ -342,6 +342,14 @@ export class WebRTCManager {
342
342
  if (self && self > peer.remote && !peer.dc) {
343
343
  const dc = peer.pc.createDataChannel('cc', { ordered: true })
344
344
  this._attachDC(peer, dc)
345
+ } else if (self && self < peer.remote && !peer.dc) {
346
+ // EL QUE NO CREA EL CANAL TIENE QUE PEDIRLO. Sin un canal nuevo no hay nada que
347
+ // negociar (`onnegotiationneeded` no salta), así que si el que quiere ir directo
348
+ // era el del token menor, el otro nunca se enteraba y el canal no se abría jamás:
349
+ // la mitad de las parejas se quedaban en el proxio según cómo cayera el sorteo de
350
+ // tokens. Se le pide al otro que arranque; el que crea el canal sigue siendo uno
351
+ // solo, así que no hay ofertas cruzadas.
352
+ this._signal(peer, { kind: 'start' })
345
353
  }
346
354
  } catch (e) {
347
355
  this.emit('error', { type: 'webrtc_start', error: e, peer: peer.remote })
@@ -398,6 +406,17 @@ export class WebRTCManager {
398
406
  if (!peer.pc) this._createPC(peer)
399
407
  const pc = peer.pc
400
408
 
409
+ if (msg.kind === 'start') {
410
+ // El otro quiere ir directo y el canal lo creamos nosotros (ver `_startNegotiation`).
411
+ // Solo lo atiende el del token mayor: así un `start` nunca rebota.
412
+ const self = this.getSelfToken()
413
+ if (self && self > peer.remote && !peer.dc) {
414
+ peer.negotiating = false
415
+ await this._startNegotiation(peer)
416
+ }
417
+ return
418
+ }
419
+
401
420
  if (msg.kind === 'sdp' && msg.sdp) {
402
421
  const offerCollision = msg.sdp.type === 'offer' &&
403
422
  (peer.makingOffer || pc.signalingState !== 'stable')
@@ -1,3 +1,3 @@
1
- Copia vendorizada de @dotrino/roadmap@0.4.35 (dotrino-roadmap/src/{index,manifests}.js).
1
+ Copia vendorizada de @dotrino/roadmap@0.4.38 (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,30 +8,30 @@
8
8
  export const MANIFESTS = Object.freeze({
9
9
  "dotrino": {
10
10
  "manifest": "dotrino",
11
- "seq": 32,
11
+ "seq": 33,
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": {
15
15
  "compat": {
16
16
  "repo": "imdotrino/dotrino-compat",
17
17
  "npm": "@dotrino/compat",
18
- "current": "0.4.0",
18
+ "current": "0.4.1",
19
19
  "protocol": 1,
20
20
  "requires": {}
21
21
  },
22
22
  "env": {
23
23
  "repo": "imdotrino/dotrino-vault",
24
24
  "npm": "@dotrino/env",
25
- "current": "0.92.0",
25
+ "current": "0.93.0",
26
26
  "protocol": 1,
27
27
  "requires": {
28
- "vault": ">=0.92.0"
28
+ "vault": ">=0.93.0"
29
29
  }
30
30
  },
31
31
  "identity": {
32
32
  "repo": "imdotrino/dotrino-identity",
33
33
  "npm": "@dotrino/identity",
34
- "current": "0.121.3",
34
+ "current": "0.121.5",
35
35
  "protocol": 1,
36
36
  "requires": {
37
37
  "proxy-client": ">=0.13.1"
@@ -85,7 +85,7 @@ export const MANIFESTS = Object.freeze({
85
85
  "notifications": {
86
86
  "repo": "imdotrino/dotrino-notifications",
87
87
  "npm": "@dotrino/notifications",
88
- "current": "0.7.1",
88
+ "current": "0.7.2",
89
89
  "protocol": 2,
90
90
  "requires": {
91
91
  "proxy-client": ">=0.20.0"
@@ -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.2",
124
+ "current": "0.38.3",
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.2",
134
+ "current": "0.22.3",
135
135
  "protocol": 1,
136
136
  "requires": {
137
- "identity": ">=0.120.0",
137
+ "identity": ">=0.121.4",
138
138
  "vault": ">=0.85.0",
139
139
  "proxy-client": ">=0.36.1",
140
140
  "vaultd": ">=0.154.0"
@@ -181,7 +181,7 @@ export const MANIFESTS = Object.freeze({
181
181
  "repo": "imdotrino/dotrino-ia",
182
182
  "npm": "@dotrino/ia-agent",
183
183
  "deprecated": "2026-10-07: retired, replaced by terminal-agent (dotrino-terminal)",
184
- "current": "0.9.0",
184
+ "current": "0.9.1",
185
185
  "protocol": 1,
186
186
  "requires": {
187
187
  "remote-agent": ">=0.20.1",
@@ -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.7",
196
+ "current": "0.6.8",
197
197
  "protocol": 1,
198
198
  "requires": {
199
199
  "remote-agent": ">=0.22.2",
@@ -205,7 +205,7 @@ export const MANIFESTS = Object.freeze({
205
205
  "sealers": {
206
206
  "repo": "imdotrino/dotrino-sealers",
207
207
  "npm": "@dotrino/sealers",
208
- "current": "0.10.1",
208
+ "current": "0.10.2",
209
209
  "protocol": 1,
210
210
  "requires": {
211
211
  "remote-agent": ">=0.20.1",
@@ -243,7 +243,7 @@ export const MANIFESTS = Object.freeze({
243
243
  "topbar": {
244
244
  "repo": "imdotrino/dotrino-topbar",
245
245
  "npm": "@dotrino/topbar",
246
- "current": "0.16.2",
246
+ "current": "0.16.3",
247
247
  "protocol": 1,
248
248
  "requires": {
249
249
  "identity": ">=0.96.1",
@@ -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.92.0",
256
+ "current": "0.93.0",
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.164.1",
272
+ "current": "0.165.0",
273
273
  "protocol": 1,
274
274
  "requires": {
275
275
  "identity": ">=0.118.0",
@@ -371,6 +371,13 @@ export const MANIFESTS = Object.freeze({
371
371
  "remote-agent": ">=0.19.0",
372
372
  "vault": ">=0.92.0"
373
373
  }
374
+ },
375
+ "ai": {
376
+ "repo": "imdotrino/dotrino-ai",
377
+ "npm": "@dotrino/ai",
378
+ "current": "0.1.1",
379
+ "protocol": 1,
380
+ "requires": {}
374
381
  }
375
382
  },
376
383
  "broken": [
@@ -1,4 +1,4 @@
1
- Copia vendorizada de @dotrino/vault@0.92.0 (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).
1
+ Copia vendorizada de @dotrino/vault@0.93.0 (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
@@ -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.92.0'
8
+ export const LIB_VERSION = '0.93.0'
@@ -75,12 +75,12 @@ export function openSubacta (disk) {
75
75
  * aparatos se cuentan lo mismo.
76
76
  */
77
77
  async add (e) {
78
- if (!(await isAcceptable(e))) return { ok: false, reason: 'no-aceptable' }
78
+ if (!(await isAcceptable(e))) return { ok: false, reason: 'not-acceptable' }
79
79
  const id = idOf(e)
80
- if (data.entries.some((x) => idOf(x) === id)) return { ok: false, reason: 'ya-estaba' }
80
+ if (data.entries.some((x) => idOf(x) === id)) return { ok: false, reason: 'already-present' }
81
81
  data.entries = [...data.entries, e]
82
82
  guardar()
83
- return { ok: true, reason: 'nueva' }
83
+ return { ok: true, reason: 'new' }
84
84
  },
85
85
 
86
86
  /**
@@ -872,13 +872,13 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
872
872
  // acta falta justo cuando algo se rompió (un archivo a medias, un `catch` que devolvió
873
873
  // null), que es cuando menos hay que fiarse. Toda cuenta tiene acta desde hace versiones.
874
874
  if (!record) {
875
- audit('rejected', { what, reason: 'sin-acta' })
875
+ audit('rejected', { what, reason: 'no-record' })
876
876
  reply(from, { type: MSG.ERROR, error: 'unauthorized: this vault has no record to decide with' })
877
877
  return false
878
878
  }
879
879
  if (Acta.memberCanScope(record, chk.device, scope)) return true
880
- audit('rejected', { what, reason: 'acta' })
881
- reply(from, { type: MSG.ERROR, error: 'unauthorized: acta — this member no longer has that permission' })
880
+ audit('rejected', { what, reason: 'record' })
881
+ reply(from, { type: MSG.ERROR, error: 'unauthorized: record — this member no longer has that permission' })
882
882
  return false
883
883
  }
884
884
 
@@ -976,14 +976,14 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
976
976
  const t = Date.now()
977
977
  for (const [n, v] of aperturas) if (v.exp <= t) aperturas.delete(n)
978
978
  const eph = await makeEphemeralKey()
979
- aperturas.set('pendiente', { privateKey: eph.privateKey, exp: t + EPHEMERAL_TTL_MS })
979
+ aperturas.set('pending', { privateKey: eph.privateKey, exp: t + EPHEMERAL_TTL_MS })
980
980
  audit('unlock.begin', { by })
981
981
  return { ...params, ek: eph.ek }
982
982
  },
983
983
 
984
984
  async open ({ nonce, enc, by }) {
985
- const guardada = aperturas.get('pendiente')
986
- aperturas.delete('pendiente')
985
+ const guardada = aperturas.get('pending')
986
+ aperturas.delete('pending')
987
987
  if (!guardada || guardada.exp <= Date.now()) {
988
988
  return { ok: false, error: 'unlock: ask for a key first, and use it within a minute' }
989
989
  }
@@ -992,7 +992,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
992
992
  // EL NONCE VA DENTRO DEL SOBRE. Si fuera solo por fuera, un sobre capturado se
993
993
  // reenvía con un nonce nuevo y el candado del nonce no sirve de nada.
994
994
  if (!payload || payload.nonce !== nonce || typeof payload.key !== 'string') {
995
- audit('rejected', { what: 'unlock', by, reason: 'sobre' })
995
+ audit('rejected', { what: 'unlock', by, reason: 'envelope' })
996
996
  return { ok: false, error: 'unlock: the envelope does not check out' }
997
997
  }
998
998
  const derivada = b64ToBytes(payload.key)
@@ -1314,10 +1314,10 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
1314
1314
  const { issued, revoked } = await identity.listDelegations()
1315
1315
  if (!puedeVerTodo) {
1316
1316
  if (!record) {
1317
- audit('rejected', { what: 'devices', reason: 'sin-acta' })
1317
+ audit('rejected', { what: 'devices', reason: 'no-record' })
1318
1318
  return reply(from, { type: MSG.ERROR, error: 'unauthorized: this vault has no record to decide with' })
1319
1319
  }
1320
- audit('devices', { device: await deviceIdOf(chk.device).catch(() => null), solo: 'revocaciones' })
1320
+ audit('devices', { device: await deviceIdOf(chk.device).catch(() => null), only: 'revocations' })
1321
1321
  return reply(from, { type: MSG.DEVICES_RESULT, devices: [], revoked, blocked: blocked.pubs(), acta: record, sealerChain: await sealerChainOf() })
1322
1322
  }
1323
1323
  // El acta viaja con la lista: así cada dispositivo se entera de los cambios de
@@ -1401,7 +1401,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
1401
1401
  // Sin acta no se renueva: caer al scope del papel viejo es reconceder a ciegas lo que
1402
1402
  // el acta ya no dice. Un repliegue así no protege de nada, tapa.
1403
1403
  if (!record) {
1404
- audit('rejected', { what: 'renew', device: await deviceIdOf(p.cert.sub), reason: 'sin-acta' })
1404
+ audit('rejected', { what: 'renew', device: await deviceIdOf(p.cert.sub), reason: 'no-record' })
1405
1405
  return reply(from, { type: MSG.ERROR, error: 'unauthorized: this vault has no record to decide with' })
1406
1406
  }
1407
1407
  const scope = Acta.memberScopes(record, p.cert.sub)
@@ -1460,7 +1460,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
1460
1460
  // que se cerró en `handleSign`, en otro mostrador.
1461
1461
  const record = (await identity.profileActa?.().catch(() => null))?.acta
1462
1462
  if (!record || !Acta.memberCanReadSecrets(record, chk.device, ns)) {
1463
- audit('rejected', { what: 'enckey', ns, reason: record ? 'cn' : 'sin-acta' })
1463
+ audit('rejected', { what: 'enckey', ns, reason: record ? 'cn' : 'no-record' })
1464
1464
  return reply(from, { type: MSG.ERROR, error: `unauthorized: cn — the record does not recognise this member as the "${ns}" service` })
1465
1465
  }
1466
1466
  try {
@@ -1545,7 +1545,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
1545
1545
  if (!chk.ok) return denyChain(from, chk, p, 'digest')
1546
1546
  const record = (await identity.profileActa?.().catch(() => null))?.acta
1547
1547
  if (!record || !Acta.memberCanReadSecrets(record, chk.device, ns)) {
1548
- audit('rejected', { what: 'digest', ns, reason: record ? 'cn' : 'sin-acta' })
1548
+ audit('rejected', { what: 'digest', ns, reason: record ? 'cn' : 'no-record' })
1549
1549
  return reply(from, { type: MSG.ERROR, error: `unauthorized: cn — the record does not recognise this member as the "${ns}" service` })
1550
1550
  }
1551
1551
  const body = { op: 'secrets.digest', ns, digest: drawerDigest(ns, chk.device), ts: Date.now() }
@@ -1578,8 +1578,8 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
1578
1578
  if (!chk.ok) return denyChain(from, chk, p, 'update-ask')
1579
1579
  const record = (await identity.profileActa?.().catch(() => null))?.acta
1580
1580
  if (!record || !(record.members || []).some((m) => m.pub === chk.device)) {
1581
- audit('rejected', { what: 'update-ask', reason: record ? 'acta' : 'sin-acta' })
1582
- return reply(from, { type: MSG.ERROR, error: 'unauthorized: acta — this device is not in the record' })
1581
+ audit('rejected', { what: 'update-ask', reason: record ? 'record' : 'no-record' })
1582
+ return reply(from, { type: MSG.ERROR, error: 'unauthorized: record — this device is not in the record' })
1583
1583
  }
1584
1584
  const product = cut(p.data?.product, 128)
1585
1585
  const version = cut(p.data?.version, 64)
@@ -1656,8 +1656,8 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
1656
1656
  const record = (await identity.profileActa?.().catch(() => null))?.acta
1657
1657
  const member = (record?.members || []).find((m) => m.pub === chk.device)
1658
1658
  if (!member) {
1659
- audit('rejected', { what: op, reason: record ? 'acta' : 'sin-acta' })
1660
- return reply(from, { type: MSG.ERROR, error: 'unauthorized: acta — this device is not in the record' })
1659
+ audit('rejected', { what: op, reason: record ? 'record' : 'no-record' })
1660
+ return reply(from, { type: MSG.ERROR, error: 'unauthorized: record — this device is not in the record' })
1661
1661
  }
1662
1662
  const product = cut(p.data?.product, 128)
1663
1663
  const version = cut(p.data?.version, 64)
@@ -1685,7 +1685,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
1685
1685
  if (!chk.ok) return denyChain(from, chk, p, op)
1686
1686
  const record = (await identity.profileActa?.().catch(() => null))?.acta
1687
1687
  if (!record || !Acta.memberCanReadSecrets(record, chk.device, ns)) {
1688
- audit('rejected', { what: op, ns, reason: record ? 'cn' : 'sin-acta' })
1688
+ audit('rejected', { what: op, ns, reason: record ? 'cn' : 'no-record' })
1689
1689
  return reply(from, { type: MSG.ERROR, error: `unauthorized: cn — the record does not recognise this member as the "${ns}" service` })
1690
1690
  }
1691
1691
  const deviceId = await deviceIdOf(chk.device).catch(() => null)
@@ -1756,7 +1756,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
1756
1756
  // llave del proxy no ve nada que no sea del proxy, y está escrito donde se puede comprobar.
1757
1757
  const record = (await identity.profileActa?.().catch(() => null))?.acta
1758
1758
  if (!record || !Acta.memberCanReadSecrets(record, chk.device, ns)) {
1759
- audit('rejected', { what: 'secrets', ns, reason: record ? 'cn' : 'sin-acta' })
1759
+ audit('rejected', { what: 'secrets', ns, reason: record ? 'cn' : 'no-record' })
1760
1760
  return reply(from, { type: MSG.ERROR, error: `unauthorized: cn — the record does not recognise this member as the "${ns}" service` })
1761
1761
  }
1762
1762
  // APROBACIÓN: si este APARATO está marcado (`dotrino-vault approval <ID> on`), liberarle
@@ -1908,8 +1908,8 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
1908
1908
  if (!chk.ok) return denyChain(from, chk, p, 'approval')
1909
1909
  const record = (await identity.profileActa?.().catch(() => null))?.acta
1910
1910
  if (!record || !Acta.memberCan(record, chk.device, 'approve')) {
1911
- audit('rejected', { what: 'approval', reason: record ? 'acta' : 'sin-acta' })
1912
- return reply(from, { type: MSG.ERROR, error: 'unauthorized: acta — this member does not approve' })
1911
+ audit('rejected', { what: 'approval', reason: record ? 'record' : 'no-record' })
1912
+ return reply(from, { type: MSG.ERROR, error: 'unauthorized: record — this member does not approve' })
1913
1913
  }
1914
1914
  const by = await deviceIdOf(chk.device).catch(() => null)
1915
1915
  const answer = async (body) => {
@@ -2157,8 +2157,8 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2157
2157
  if (!chk.ok) return denyChain(from, chk, p, 'incident')
2158
2158
  const record = await refreshActa()
2159
2159
  if (!record || !Acta.memberCan(record, chk.device, 'sign')) {
2160
- audit('rejected', { what: 'incident', reason: record ? 'acta' : 'sin-acta' })
2161
- return reply(from, { type: MSG.ERROR, error: 'unauthorized: acta — this member cannot report incidents' })
2160
+ audit('rejected', { what: 'incident', reason: record ? 'record' : 'no-record' })
2161
+ return reply(from, { type: MSG.ERROR, error: 'unauthorized: record — this member cannot report incidents' })
2162
2162
  }
2163
2163
  const d = p.data || {}
2164
2164
  const kind = typeof d.kind === 'string' ? d.kind.slice(0, 32) : ''
@@ -2913,7 +2913,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2913
2913
  return chk
2914
2914
  }
2915
2915
  const record = (await identity.profileActa?.().catch(() => null))?.acta
2916
- if (!record || !Acta.memberCan(record, chk.device, 'admin')) return { ok: false, reason: record ? 'acta' : 'sin-acta' }
2916
+ if (!record || !Acta.memberCan(record, chk.device, 'admin')) return { ok: false, reason: record ? 'record' : 'no-record' }
2917
2917
  return chk
2918
2918
  }
2919
2919
  })
@@ -2949,12 +2949,12 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2949
2949
  // la fecha de la última renuncia por miembro y rechace las que no sean posteriores.
2950
2950
  const actual = (await identity.profileActa?.().catch(() => null))?.acta || null
2951
2951
  if (!actual) {
2952
- audit('rejected', { what: 'renounce', reason: 'sin-acta' })
2952
+ audit('rejected', { what: 'renounce', reason: 'no-record' })
2953
2953
  return reply(from, { type: MSG.ERROR, error: 'renounce: this vault has no record to apply it to' })
2954
2954
  }
2955
2955
  const tiene = new Set(Acta.effectiveCaps(actual, record.member) || [])
2956
2956
  if (!(record.caps || []).some((c) => tiene.has(c))) {
2957
- audit('rejected', { what: 'renounce', reason: 'nada-que-quitar' })
2957
+ audit('rejected', { what: 'renounce', reason: 'nothing-to-remove' })
2958
2958
  return reply(from, { type: MSG.ERROR, error: 'renounce: that member no longer holds any of those capabilities' })
2959
2959
  }
2960
2960
  try {
@@ -2963,8 +2963,8 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2963
2963
  // de la maestra, y con el perfil cerrado la renuncia se perdía con un error — en el
2964
2964
  // único momento en que de verdad hace falta.
2965
2965
  const guardada = await subacta.add(record)
2966
- if (!guardada.ok && guardada.reason === 'no-aceptable') {
2967
- audit('rejected', { what: 'renounce', reason: 'no-aceptable' })
2966
+ if (!guardada.ok && guardada.reason === 'not-acceptable') {
2967
+ audit('rejected', { what: 'renounce', reason: 'not-acceptable' })
2968
2968
  return reply(from, { type: MSG.ERROR, error: 'renounce: the entry is not one this vault accepts' })
2969
2969
  }
2970
2970
  const device = await deviceIdOf(record.member).catch(() => null)
@@ -272,7 +272,7 @@ export function createEnrollDesk ({
272
272
  return { ignored: true }
273
273
  }
274
274
  if (!pend || Date.now() > pend.exp) {
275
- audit('rejected', { what: 'hello', reason: 'sin-sesion' })
275
+ audit('rejected', { what: 'hello', reason: 'no-session' })
276
276
  return fail(from, 'no pairing session open for that code', String(p?.sn || ''))
277
277
  }
278
278
  // La respuesta va FIRMADA por la maestra y el `sn` va dentro de lo firmado. Eso ata
@@ -261,7 +261,7 @@ export async function startDeviceVault (identity, { proxyUrl, client: injectedCl
261
261
  if (expectedScope) {
262
262
  const record = (await identity.profileActa?.().catch(() => null))?.acta || null
263
263
  if (record && !memberCanScope(record, chk.device, expectedScope)) {
264
- send(from, { type: MSG.ERROR, error: 'unauthorized: acta — this member no longer has that permission' })
264
+ send(from, { type: MSG.ERROR, error: 'unauthorized: record — this member no longer has that permission' })
265
265
  return null
266
266
  }
267
267
  }
@@ -356,7 +356,7 @@ export async function startDeviceVault (identity, { proxyUrl, client: injectedCl
356
356
  if (p.type === MSG.HELLO) handle('hello', desk.handleHello(_from, p), _from)
357
357
  else if (p.type === MSG.ENROLL) handle('enroll', desk.handleEnroll(_from, p), _from)
358
358
  // Camino A: el aparato devuelve su acta sellada admitiendo a esta bóveda.
359
- else if (p.type === MSG.ACTA_SEALED) handle('acta', desk.handleActaSealed(_from, p), _from)
359
+ else if (p.type === MSG.ACTA_SEALED) handle('record-sealed', desk.handleActaSealed(_from, p), _from)
360
360
  else if (p.type === MSG.RENEW) handle('renew', handleRenew(_from, p), _from)
361
361
  else if (p.type === MSG.DEVICES) handle('devices', handleDevices(_from, p), _from)
362
362
  // Lo que faltaba para que un aparato enrolado aquí pueda hacer lo mismo que contra
@@ -67,7 +67,7 @@ export const loginAddress = (user, fingerprint) => `${user}@${accountCode(finger
67
67
  */
68
68
  export async function accountFingerprint (identity) {
69
69
  const pid = (await identity?.profileActa?.().catch(() => null))?.acta?.profileId
70
- if (!pid) throw err('no-acta', 'this vault has no account record yet: there is no address to build')
70
+ if (!pid) throw err('no-record', 'this vault has no account record yet: there is no address to build')
71
71
  return (await pubkeyId(pid)).slice(0, 16)
72
72
  }
73
73