@dotrino/identity 0.137.0 → 0.138.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/identity",
3
- "version": "0.137.0",
3
+ "version": "0.138.0",
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/types/avatar.d.ts CHANGED
@@ -11,6 +11,28 @@
11
11
  export function avatarSvg(seed: unknown, { size }?: {
12
12
  size?: number;
13
13
  }): string;
14
+ /**
15
+ * El mismo identicon, pintado en un canvas 2D (`CanvasRenderingContext2D` u
16
+ * `OffscreenCanvasRenderingContext2D`). Existe para donde no se puede rasterizar un SVG:
17
+ * un service worker no decodifica `image/svg+xml`, y el icono de una extensión
18
+ * (`chrome.action.setIcon`) pide píxeles. Pinta en `[0, size]` desde el origen.
19
+ *
20
+ * @param {{ fillStyle: unknown, beginPath (): void, arc (x: number, y: number, r: number, a0: number, a1: number): void, fill (): void, fillRect (x: number, y: number, w: number, h: number): void, createLinearGradient (x0: number, y0: number, x1: number, y1: number): { addColorStop (o: number, c: string): void } }} ctx
21
+ * @param {unknown} seed
22
+ * @param {{ size?: number }} [opts]
23
+ */
24
+ export function avatarPaint(ctx: {
25
+ fillStyle: unknown;
26
+ beginPath(): void;
27
+ arc(x: number, y: number, r: number, a0: number, a1: number): void;
28
+ fill(): void;
29
+ fillRect(x: number, y: number, w: number, h: number): void;
30
+ createLinearGradient(x0: number, y0: number, x1: number, y1: number): {
31
+ addColorStop(o: number, c: string): void;
32
+ };
33
+ }, seed: unknown, { size }?: {
34
+ size?: number;
35
+ }): void;
14
36
  /**
15
37
  * El avatar como data-URI listo para `<img src>` o `background-image`.
16
38
  * @param {unknown} seed
package/vault/avatar.js CHANGED
@@ -30,6 +30,29 @@ function _hashSeed (s) {
30
30
  return { h: h >>> 0, bytes }
31
31
  }
32
32
 
33
+ /**
34
+ * La GEOMETRÍA del identicon: colores y celdas de la rejilla 5×5. Es la única fuente: el SVG
35
+ * y el canvas (`avatarPaint`) se dibujan de aquí, así que no pueden salir distintos.
36
+ *
37
+ * @param {unknown} seed
38
+ * @returns {{ h: number, fg: string, bg1: string, bg2: string, cells: Array<[number, number]> }}
39
+ * `cells`: pares `[columna, fila]` encendidos, en una rejilla de 5×5.
40
+ */
41
+ function _avatarModel (seed) {
42
+ const { h, bytes } = _hashSeed(String(seed || 'dotrino'))
43
+ const hue = h % 360
44
+ const hue2 = (hue + 40) % 360
45
+ /** @type {Array<[number, number]>} */
46
+ const cells = []
47
+ for (let col = 0; col < 3; col++) {
48
+ for (let row = 0; row < 5; row++) {
49
+ if (!(bytes[col * 5 + row] & 1)) continue
50
+ for (const c of (col === 2 ? [2] : [col, 4 - col])) cells.push([c, row])
51
+ }
52
+ }
53
+ return { h, fg: `hsl(${hue} 62% 46%)`, bg1: `hsl(${hue} 48% 95%)`, bg2: `hsl(${hue2} 48% 90%)`, cells }
54
+ }
55
+
33
56
  /**
34
57
  * Identicon determinista de una semilla (normalmente el pubkey): así cada perfil
35
58
  * nace con imagen sin que el usuario tenga que subir nada. Síncrono → usable
@@ -41,22 +64,11 @@ function _hashSeed (s) {
41
64
  * @returns {string}
42
65
  */
43
66
  export function avatarSvg (seed, { size = 80 } = {}) {
44
- const { h, bytes } = _hashSeed(String(seed || 'dotrino'))
45
- const hue = h % 360
46
- const hue2 = (hue + 40) % 360
47
- const fg = `hsl(${hue} 62% 46%)`
48
- const bg1 = `hsl(${hue} 48% 95%)`
49
- const bg2 = `hsl(${hue2} 48% 90%)`
50
- const cells = 5
51
- const unit = size / cells
67
+ const { h, fg, bg1, bg2, cells } = _avatarModel(seed)
68
+ const unit = size / 5
52
69
  let rects = ''
53
- for (let col = 0; col < 3; col++) {
54
- for (let row = 0; row < cells; row++) {
55
- if (!(bytes[col * cells + row] & 1)) continue
56
- for (const c of (col === 2 ? [2] : [col, cells - 1 - col])) {
57
- rects += `<rect x="${(c * unit).toFixed(2)}" y="${(row * unit).toFixed(2)}" width="${unit.toFixed(2)}" height="${unit.toFixed(2)}"/>`
58
- }
59
- }
70
+ for (const [c, row] of cells) {
71
+ rects += `<rect x="${(c * unit).toFixed(2)}" y="${(row * unit).toFixed(2)}" width="${unit.toFixed(2)}" height="${unit.toFixed(2)}"/>`
60
72
  }
61
73
  const id = 'g' + (h % 100000)
62
74
  return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${size} ${size}" width="${size}" height="${size}">` +
@@ -65,6 +77,31 @@ export function avatarSvg (seed, { size = 80 } = {}) {
65
77
  `<g fill="${fg}" transform="translate(${(size * 0.12).toFixed(2)} ${(size * 0.12).toFixed(2)}) scale(0.76)">${rects}</g></svg>`
66
78
  }
67
79
 
80
+ /**
81
+ * El mismo identicon, pintado en un canvas 2D (`CanvasRenderingContext2D` u
82
+ * `OffscreenCanvasRenderingContext2D`). Existe para donde no se puede rasterizar un SVG:
83
+ * un service worker no decodifica `image/svg+xml`, y el icono de una extensión
84
+ * (`chrome.action.setIcon`) pide píxeles. Pinta en `[0, size]` desde el origen.
85
+ *
86
+ * @param {{ fillStyle: unknown, beginPath (): void, arc (x: number, y: number, r: number, a0: number, a1: number): void, fill (): void, fillRect (x: number, y: number, w: number, h: number): void, createLinearGradient (x0: number, y0: number, x1: number, y1: number): { addColorStop (o: number, c: string): void } }} ctx
87
+ * @param {unknown} seed
88
+ * @param {{ size?: number }} [opts]
89
+ */
90
+ export function avatarPaint (ctx, seed, { size = 80 } = {}) {
91
+ const { fg, bg1, bg2, cells } = _avatarModel(seed)
92
+ const grad = ctx.createLinearGradient(0, 0, size, size)
93
+ grad.addColorStop(0, bg1)
94
+ grad.addColorStop(1, bg2)
95
+ ctx.fillStyle = grad
96
+ ctx.beginPath()
97
+ ctx.arc(size / 2, size / 2, size / 2, 0, Math.PI * 2)
98
+ ctx.fill()
99
+ ctx.fillStyle = fg
100
+ const unit = (size / 5) * 0.76
101
+ const off = size * 0.12
102
+ for (const [c, row] of cells) ctx.fillRect(off + c * unit, off + row * unit, unit, unit)
103
+ }
104
+
68
105
  /**
69
106
  * El avatar como data-URI listo para `<img src>` o `background-image`.
70
107
  * @param {unknown} seed
@@ -22,7 +22,7 @@ export const MANIFESTS = Object.freeze({
22
22
  "env": {
23
23
  "repo": "imdotrino/dotrino-vault",
24
24
  "npm": "@dotrino/env",
25
- "current": "0.120.1",
25
+ "current": "0.121.2",
26
26
  "protocol": 1,
27
27
  "requires": {
28
28
  "vault": ">=0.118.0"
@@ -31,7 +31,7 @@ export const MANIFESTS = Object.freeze({
31
31
  "identity": {
32
32
  "repo": "imdotrino/dotrino-identity",
33
33
  "npm": "@dotrino/identity",
34
- "current": "0.136.3",
34
+ "current": "0.137.1",
35
35
  "protocol": 1,
36
36
  "requires": {
37
37
  "proxy-client": ">=0.20.0"
@@ -273,7 +273,7 @@ export const MANIFESTS = Object.freeze({
273
273
  "vault": {
274
274
  "repo": "imdotrino/dotrino-vault",
275
275
  "npm": "@dotrino/vault",
276
- "current": "0.120.1",
276
+ "current": "0.121.2",
277
277
  "protocol": 1,
278
278
  "requires": {
279
279
  "vaultd": ">=0.105.0",
@@ -289,7 +289,7 @@ export const MANIFESTS = Object.freeze({
289
289
  "vaultd": {
290
290
  "repo": "imdotrino/dotrino-vault",
291
291
  "npm": "@dotrino/vaultd",
292
- "current": "0.192.1",
292
+ "current": "0.193.2",
293
293
  "protocol": 1,
294
294
  "requires": {
295
295
  "identity": ">=0.136.0",
@@ -342,19 +342,19 @@ export const MANIFESTS = Object.freeze({
342
342
  },
343
343
  "passmanager-extension": {
344
344
  "repo": "imdotrino/dotrino-passmanager",
345
- "current": "0.58.5",
345
+ "current": "0.58.6",
346
346
  "protocol": 1,
347
347
  "requires": {
348
348
  "identity": ">=0.136.0",
349
349
  "proxy-client": ">=0.47.0",
350
- "vault": ">=0.120.0",
350
+ "vault": ">=0.120.1",
351
351
  "proxy": "1.1.0+",
352
352
  "vaultd": ">=0.160.2"
353
353
  }
354
354
  },
355
355
  "app": {
356
356
  "repo": "imdotrino/dotrino-app",
357
- "current": "0.4.30",
357
+ "current": "0.4.33",
358
358
  "protocol": 1,
359
359
  "requires": {
360
360
  "proxy": "1.6.0+",
@@ -364,7 +364,7 @@ export const MANIFESTS = Object.freeze({
364
364
  },
365
365
  "app-ios": {
366
366
  "repo": "imdotrino/dotrino-app",
367
- "current": "0.4.19",
367
+ "current": "0.4.33",
368
368
  "protocol": 1,
369
369
  "requires": {
370
370
  "proxy": "1.6.0+",
@@ -1,4 +1,4 @@
1
- Copia vendorizada de @dotrino/vault@0.121.1 (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.121.2 (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
@@ -126,11 +126,12 @@ export function createApprovals ({ now = Date.now, pendingTtlMs = PENDING_TTL_MS
126
126
  * La llave es cajón + aparato + huella del comando. Nada de esto se escribe en disco.
127
127
  */
128
128
  export function createGrants ({ now = Date.now, ttlMs = GRANT_TTL_MS } = {}) {
129
- /** key → { id, ns, device, deviceId, fp, ctx, by, grantedAt, lastAt, exp, uses } */
129
+ /** key → { id, ns, device, deviceId, label, fp, ctx, by, grantedAt, lastAt, exp, uses } */
130
130
  const grants = new Map()
131
131
  const keyOf = (ns, device, fp) => ns + SEP + device + SEP + fp
132
132
  const publicOf = (g) => ({
133
- id: g.id, ns: g.ns, deviceId: g.deviceId, fp: g.fp, ctx: g.ctx,
133
+ // El aparato con su ALIAS además del ID (dueño, 2026-11-05: «debe mostrar el ID y el alias, ambos»).
134
+ id: g.id, ns: g.ns, deviceId: g.deviceId, label: g.label || '', fp: g.fp, ctx: g.ctx,
134
135
  by: g.by, grantedAt: g.grantedAt, lastAt: g.lastAt, exp: g.exp, uses: g.uses
135
136
  })
136
137
 
@@ -140,11 +141,11 @@ export function createGrants ({ now = Date.now, ttlMs = GRANT_TTL_MS } = {}) {
140
141
  * traía comando: sin huella no hay nada que recordar, y el próximo pedido volverá a
141
142
  * timbrar. Que eso se diga en el log es cosa de quien llama.
142
143
  */
143
- grant ({ ns, device, deviceId = null, ctx = null, by = null }) {
144
+ grant ({ ns, device, deviceId = null, label = '', ctx = null, by = null }) {
144
145
  const fp = commandFingerprint(ctx)
145
146
  if (!fp) return null
146
147
  const t = now()
147
- const g = { id: rnd(), ns, device, deviceId, fp, ctx, by, grantedAt: t, lastAt: t, exp: t + ttlMs, uses: 0 }
148
+ const g = { id: rnd(), ns, device, deviceId, label, fp, ctx, by, grantedAt: t, lastAt: t, exp: t + ttlMs, uses: 0 }
148
149
  grants.set(keyOf(ns, device, fp), g)
149
150
  return publicOf(g)
150
151
  },
@@ -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.121.1'
8
+ export const LIB_VERSION = '0.121.2'
@@ -2285,7 +2285,7 @@ export async function startVault ({ platform, proxyUrl, log = console.log, onEnr
2285
2285
  // las siguientes veces que lo pida ESE MISMO comando desde ESA MISMA carpeta. Un pedido
2286
2286
  // que no dijo qué corría no deja nada anotado, y se dice por qué: si no, el dueño vería
2287
2287
  // que unos pedidos dejan de timbrar y otros no, sin ninguna explicación a mano.
2288
- const grant = grants.grant({ ns: pend.ns, device: pend.device, deviceId: pend.deviceId, ctx: pend.ctx, by })
2288
+ const grant = grants.grant({ ns: pend.ns, device: pend.device, deviceId: pend.deviceId, label: pend.label || '', ctx: pend.ctx, by })
2289
2289
  audit('secrets.approved', { device: pend.deviceId, ns: pend.ns, id, by, ...(grant ? { grant: grant.id } : {}) })
2290
2290
  noteAnswered(pend, 'approved', by, chk.device)
2291
2291
  log(`[vault] ${pend.ns}: request of ${pend.deviceId} approved by ${by}`)