@dotrino/identity 0.86.0 → 0.86.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/vault/vault.js +20 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/identity",
3
- "version": "0.86.0",
3
+ "version": "0.86.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/vault.js CHANGED
@@ -77,6 +77,24 @@ import { pubkeyId } from './capabilities.js'
77
77
  : { 'profile:name': 'tu nombre', 'profile:avatar': 'tu foto', 'profile:email': 'tu correo', 'profile:social': 'tus enlaces', 'id:whoami': 'quién eres' }
78
78
  })()
79
79
 
80
+ /**
81
+ * CÓMO SE LLAMA QUIEN PIDE. Una dirección cruda no dice nada —y quien la lee deprisa no
82
+ * distingue `chat.dotrino.com` de `chat.dotrlno.com`—, así que se enseña el nombre y
83
+ * DEBAJO la dirección entera, que es lo que de verdad identifica.
84
+ *
85
+ * No se importa el catálogo de aplicaciones: eso ataría este iframe al repositorio del
86
+ * home y habría que subirlo cada vez que nace una app. El subdominio ya es el nombre.
87
+ */
88
+ function nombreDeOrigen (origin) {
89
+ try {
90
+ const h = new URL(origin).hostname
91
+ if (h === 'dotrino.com' || h === 'www.dotrino.com') return 'Dotrino'
92
+ const m = /^([a-z0-9-]+)\.dotrino\.com$/.exec(h)
93
+ if (m) return m[1].charAt(0).toUpperCase() + m[1].slice(1)
94
+ return h
95
+ } catch (_) { return String(origin) }
96
+ }
97
+
80
98
  let consentAbierto = null
81
99
  function askConsent ({ origin, scopes }) {
82
100
  if (consentAbierto) return Promise.resolve(false) // una pregunta a la vez
@@ -86,7 +104,8 @@ import { pubkeyId } from './capabilities.js'
86
104
  const lista = scopes.map((x) => `<li>${SCOPE_TXT[x] || x}</li>`).join('')
87
105
  host.innerHTML = `<div style="background:#171331;border:1px solid #2a2350;border-radius:16px;padding:22px;min-width:min(320px,90vw);max-width:90vw;color:#e7e3ff">
88
106
  <div style="opacity:.7;font-size:13px">${T_CONSENT.who}</div>
89
- <div style="font-weight:700;margin:8px 0 4px">${String(origin).replace(/^https?:\/\//, '')} ${T_CONSENT.title}:</div>
107
+ <div style="font-weight:700;margin:8px 0 4px">${nombreDeOrigen(origin)} ${T_CONSENT.title}:</div>
108
+ <div style="opacity:.55;font-size:12px;margin-bottom:6px">${String(origin).replace(/^https?:\/\//, '')}</div>
90
109
  <ul style="margin:6px 0 12px 18px;padding:0">${lista}</ul>
91
110
  <div style="opacity:.7;font-size:12px;margin-bottom:12px">${T_CONSENT.once}</div>
92
111
  <div style="display:flex;gap:8px">