@dotrino/identity 0.126.1 → 0.126.2

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.126.1",
3
+ "version": "0.126.2",
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/core.js CHANGED
@@ -3322,7 +3322,8 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
3322
3322
  // El acta es la nuestra: no hay nada que adoptar.
3323
3323
  if ((!v?.cert || !device) && adminLink()?.self) {
3324
3324
  const self = adminLink()
3325
- return remoteDevices({ master: self.v.master, proxy: self.v.proxy, device: self.device, cert: self.v.cert, sinceSeq: loadActa()?.seq ?? 0 })
3325
+ const res = await remoteDevices({ master: self.v.master, proxy: self.v.proxy, device: self.device, cert: self.v.cert, sinceSeq: loadActa()?.seq ?? 0 })
3326
+ return { ...res, acta: loadActa() }
3326
3327
  }
3327
3328
  if (!v?.cert || !device) {
3328
3329
  // SOLO SE AVISA SI ES RARO. Un aparato que manda en su propia cuenta —o que aún no
@@ -3350,7 +3351,11 @@ export async function createIdentityCore ({ kv: hostKv, peers, makeSync = null,
3350
3351
  // comprobación de arriba corrió ANTES de tenerla, así que sin esto haría falta una
3351
3352
  // segunda visita para estrenar un permiso recién concedido.
3352
3353
  maybeRenewVaultCert()
3353
- return res
3354
+ // EL ACTA QUE SE DEVUELVE ES LA ADOPTADA, no la que llegó: la respuesta no trae
3355
+ // remitente comprobable, y quien llama decide con ella quién es de la cuenta (la
3356
+ // terminal, a qué máquina le abre una consola). Si la recibida no se pudo adoptar,
3357
+ // vale la que ya se tenía comprobada.
3358
+ return { ...res, acta: loadActa() }
3354
3359
  } catch (e) { return handleVaultError(e) }
3355
3360
  },
3356
3361
 
@@ -1,4 +1,4 @@
1
- Copia vendorizada de @dotrino/proxy-client@0.41.0 (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.42.1 (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.
@@ -454,9 +454,12 @@ export class BluetoothManager {
454
454
  this._scanListeners.add(listener)
455
455
  if (this._stopScan) return
456
456
  if (!this._scanStarting) {
457
- this._scanStarting = this.adapter.scan((dev) => {
457
+ // Una búsqueda que se está parando todavía ocupa el adaptador: BlueZ contesta `InProgress`
458
+ // a la siguiente si no se espera a que acabe (dos `discover` seguidos).
459
+ const stopping = this._scanStopping || Promise.resolve()
460
+ this._scanStarting = stopping.then(() => this.adapter.scan((dev) => {
458
461
  for (const l of [...this._scanListeners]) l(dev)
459
- }).then((stop) => {
462
+ })).then((stop) => {
460
463
  this._stopScan = stop
461
464
  this._scanStarting = null
462
465
  if (!this._scanListeners.size) this._removeScan(null)
@@ -470,6 +473,8 @@ export class BluetoothManager {
470
473
  if (this._scanListeners.size || !this._stopScan) return
471
474
  const stop = this._stopScan
472
475
  this._stopScan = null
473
- stop().catch(() => {})
476
+ const stopping = this._scanStopping = stop().catch(() => {}).then(() => {
477
+ if (this._scanStopping === stopping) this._scanStopping = null
478
+ })
474
479
  }
475
480
  }
@@ -88,6 +88,53 @@ export function decodeBeacon (bytes) {
88
88
  } catch (_) { return null }
89
89
  }
90
90
 
91
+ export const KIND_PAIR = 'pair'
92
+ export const KIND_CONTACT = 'contact'
93
+ export const CONTACT_NICK_MAX = 40
94
+ export const CONTACT_NICK_MAX_BYTES = 60
95
+
96
+ /** El apodo recortado a 40 unidades UTF-16 y 60 bytes UTF-8, por puntos de código enteros: así cabe en el beacon. */
97
+ export function trimNick (nickname) {
98
+ let out = ''
99
+ let bytes = 0
100
+ for (const ch of String(nickname)) {
101
+ const b = enc.encode(ch).length
102
+ if (out.length + ch.length > CONTACT_NICK_MAX || bytes + b > CONTACT_NICK_MAX_BYTES) break
103
+ out += ch
104
+ bytes += b
105
+ }
106
+ return out
107
+ }
108
+
109
+ /**
110
+ * La tarjeta de contacto que se anuncia (`kind: 'contact'`): el mismo fragmento que el enlace
111
+ * `#to=` del messenger, `to=<publickey en base64url>&nick=<apodo>`. La `publickey` es la cadena
112
+ * JWK tal cual la escribe la identidad. El apodo va recortado con `trimNick` y codificado como
113
+ * `encodeURIComponent` (lo que no es `A-Za-z0-9-_.!~*'()` va en %XX de sus bytes UTF-8).
114
+ */
115
+ export function encodeContact ({ publickey, nickname = '' }) {
116
+ if (typeof publickey !== 'string' || !publickey) {
117
+ throw Object.assign(new Error('bluetooth: a contact needs its publickey'), { code: 'bad-contact' })
118
+ }
119
+ const nick = trimNick(nickname)
120
+ return 'to=' + b64u(enc.encode(publickey)) + (nick ? '&nick=' + encodeURIComponent(nick) : '')
121
+ }
122
+
123
+ /** `{ publickey, nickname }` de una tarjeta anunciada, o null si no se entiende. */
124
+ export function decodeContact (data) {
125
+ if (typeof data !== 'string') return null
126
+ const param = (k) => { const m = data.match(new RegExp('(?:^|&)' + k + '=([^&]*)')); return m ? m[1] : null }
127
+ try {
128
+ const to = param('to')
129
+ if (!to) return null
130
+ const publickey = dec.decode(unb64u(to))
131
+ const jwk = JSON.parse(publickey)
132
+ if (!jwk || typeof jwk !== 'object' || typeof jwk.x !== 'string' || typeof jwk.y !== 'string') return null
133
+ const nick = param('nick')
134
+ return { publickey, nickname: nick ? trimNick(decodeURIComponent(nick)) : '' }
135
+ } catch (_) { return null }
136
+ }
137
+
91
138
  // ---------- llave del canal ----------
92
139
 
93
140
  export async function makeEphemeral () {
@@ -14,6 +14,7 @@ export { listTransports, routeOf } from './stats.js'
14
14
  export { PART_TAG, DIRECT_PART_CHARS, PROXY_PART_CHARS, QUEUE_MAX_CHARS, RELAY_MAX_CHARS, DIRECT_PART_BYTES, PROXY_PART_BYTES, QUEUE_MAX_BYTES, RELAY_MAX_BYTES } from './parts.js'
15
15
  export { pack, unpack, hasBinary, encodeFrame, decodeFrame } from './binpack.js'
16
16
  export { logStats, formatStats, netReport, splitPeers } from './stats-log.js'
17
+ export { encodeContact, decodeContact, KIND_PAIR, KIND_CONTACT } from './ble/wire.js'
17
18
 
18
19
  import { WebSocketProxyClient } from './client.js'
19
20
 
@@ -1,3 +1,3 @@
1
- Copia vendorizada de @dotrino/roadmap@0.4.55 (dotrino-roadmap/src/{index,manifests}.js).
1
+ Copia vendorizada de @dotrino/roadmap@0.4.57 (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.
@@ -31,7 +31,7 @@ export const MANIFESTS = Object.freeze({
31
31
  "identity": {
32
32
  "repo": "imdotrino/dotrino-identity",
33
33
  "npm": "@dotrino/identity",
34
- "current": "0.126.0",
34
+ "current": "0.126.1",
35
35
  "protocol": 1,
36
36
  "requires": {
37
37
  "proxy-client": ">=0.13.1"
@@ -121,7 +121,7 @@ export const MANIFESTS = Object.freeze({
121
121
  "proxy-client": {
122
122
  "repo": "imdotrino/dotrino-proxy-client",
123
123
  "npm": "@dotrino/proxy-client",
124
- "current": "0.40.0",
124
+ "current": "0.42.1",
125
125
  "protocol": 2,
126
126
  "requires": {
127
127
  "identity": ">=0.53.0",
@@ -253,11 +253,11 @@ export const MANIFESTS = Object.freeze({
253
253
  "vault": {
254
254
  "repo": "imdotrino/dotrino-vault",
255
255
  "npm": "@dotrino/vault",
256
- "current": "0.99.0",
256
+ "current": "0.100.0",
257
257
  "protocol": 1,
258
258
  "requires": {
259
259
  "vaultd": ">=0.105.0",
260
- "proxy-client": ">=0.39.0",
260
+ "proxy-client": ">=0.41.0",
261
261
  "identity": ">=0.126.0",
262
262
  "opaque": ">=0.1.0",
263
263
  "compat": ">=0.4.0",
@@ -269,11 +269,11 @@ export const MANIFESTS = Object.freeze({
269
269
  "vaultd": {
270
270
  "repo": "imdotrino/dotrino-vault",
271
271
  "npm": "@dotrino/vaultd",
272
- "current": "0.171.0",
272
+ "current": "0.172.0",
273
273
  "protocol": 1,
274
274
  "requires": {
275
275
  "identity": ">=0.126.0",
276
- "proxy-client": ">=0.39.0",
276
+ "proxy-client": ">=0.41.0",
277
277
  "store": ">=0.11.0",
278
278
  "passmanager": ">=0.18.4",
279
279
  "compat": ">=0.4.0",
@@ -320,7 +320,7 @@ export const MANIFESTS = Object.freeze({
320
320
  },
321
321
  "passmanager-extension": {
322
322
  "repo": "imdotrino/dotrino-passmanager",
323
- "current": "0.56.2",
323
+ "current": "0.57.0",
324
324
  "protocol": 1,
325
325
  "requires": {
326
326
  "identity": ">=0.118.0",
@@ -332,7 +332,7 @@ export const MANIFESTS = Object.freeze({
332
332
  },
333
333
  "app": {
334
334
  "repo": "imdotrino/dotrino-app",
335
- "current": "0.4.25",
335
+ "current": "0.4.26",
336
336
  "protocol": 1,
337
337
  "requires": {
338
338
  "proxy": "1.6.0+",
@@ -342,7 +342,7 @@ export const MANIFESTS = Object.freeze({
342
342
  },
343
343
  "app-ios": {
344
344
  "repo": "imdotrino/dotrino-app",
345
- "current": "0.4.15",
345
+ "current": "0.4.16",
346
346
  "protocol": 1,
347
347
  "requires": {
348
348
  "proxy": "1.6.0+",
@@ -406,6 +406,13 @@ export const MANIFESTS = Object.freeze({
406
406
  "current": "0.2.0",
407
407
  "protocol": 1,
408
408
  "requires": {}
409
+ },
410
+ "update": {
411
+ "repo": "imdotrino/dotrino-update",
412
+ "npm": "@dotrino/update",
413
+ "current": "0.9.2",
414
+ "protocol": 1,
415
+ "requires": {}
409
416
  }
410
417
  },
411
418
  "broken": [