@prson/login-sdk-ui 0.0.0-stage → 0.1.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.
@@ -0,0 +1,351 @@
1
+ /**
2
+ * The sign-in card. The base SDK calls
3
+ * `window.__prsonLoginQrRenderer(url, mount, theme, context?)` and gets
4
+ * back `{ dispose, update }`. The card shows:
5
+ *
6
+ * * the site being signed in to, large, with a monogram — the main cue
7
+ * against QR relay phishing, with "Only scan codes shown on <site>";
8
+ * * on computers: a large, always dark-on-white QR in a branded frame
9
+ * whose border is the countdown ring; on phones: one "Open Prson"
10
+ * button (the same universal link) and a way to show the code anyway;
11
+ * * exactly what the site will get, read from the code's own request;
12
+ * * the progress the SDK reports (`update`): phone connected, receiving
13
+ * the proof, checking it, signed in (a check that draws itself; still
14
+ * under reduced motion), or an error with "Try again";
15
+ * * expiry with a one-tap "Get a new code".
16
+ *
17
+ * Nothing on the card is a secret or a reusable code: the QR is single-use,
18
+ * bound to this browser's key and expires in minutes. The URL is never
19
+ * printed as text or offered for copying.
20
+ *
21
+ * Renderers from 0.1 took three arguments and returned `{ dispose }`; the
22
+ * SDK still accepts those, and this one still works with a 0.1 SDK (no
23
+ * `context`: inline layout, refresh by DOM event only).
24
+ */
25
+ import QRCode from "qrcode";
26
+ import { prsonMarkSvg } from "./button.js";
27
+ import { describeCode, monogram } from "./describe.js";
28
+ /**
29
+ * Draft TTL in seconds — must mirror `DRAFT_TTL_SECONDS` in the
30
+ * signaling Worker. The countdown runs from the server-stamped `serverTs`
31
+ * in the URL's `t=` query param, so it matches what the Worker accepts.
32
+ */
33
+ const DRAFT_TTL_SECONDS = 180;
34
+ /** The ring and the time turn amber-600 for the last 30 seconds. */
35
+ const COUNTDOWN_WARN_SECONDS = 30;
36
+ const svg = (body, cls = "") => `<svg${cls ? ` class="${cls}"` : ""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${body}</svg>`;
37
+ const ICONS = {
38
+ shield: svg('<path d="M12 3l8 4v5c0 5-3.5 8.5-8 9-4.5-.5-8-4-8-9V7l8-4z"/><path d="M9 12l2 2 4-4"/>'),
39
+ user: svg('<circle cx="12" cy="8" r="4"/><path d="M6 21v-1a6 6 0 0 1 12 0v1"/>'),
40
+ calendar: svg('<rect x="4" y="5" width="16" height="16" rx="2"/><path d="M16 3v4M8 3v4M4 11h16"/>'),
41
+ id: svg('<rect x="3" y="5" width="18" height="14" rx="2"/><circle cx="9" cy="11" r="2"/><path d="M15 9h2M15 13h2M7 16h4"/>'),
42
+ mail: svg('<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/>'),
43
+ phone: svg('<rect x="7" y="3" width="10" height="18" rx="2"/><path d="M11 18h2"/>'),
44
+ device: svg('<rect x="7" y="3" width="10" height="18" rx="2"/><path d="M11 18h2"/>'),
45
+ home: svg('<path d="M5 12H3l9-9 9 9h-2"/><path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-7"/>'),
46
+ building: svg('<path d="M3 21h18M5 21V7l8-4v18M19 21V11l-6-4M9 9v.01M9 12v.01M9 15v.01"/>'),
47
+ key: svg('<circle cx="8" cy="15" r="4"/><path d="M10.85 12.15L19 4M18 5l2 2M15 8l2 2"/>'),
48
+ flag: svg('<path d="M5 5a5 5 0 0 1 7 0 5 5 0 0 0 7 0v9a5 5 0 0 1-7 0 5 5 0 0 0-7 0V5z"/><path d="M5 21v-7"/>'),
49
+ check: svg('<path d="M5 12l5 5L20 7"/>'),
50
+ close: svg('<path d="M18 6L6 18M6 6l12 12"/>'),
51
+ lock: svg('<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/>'),
52
+ clock: svg('<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 3"/>'),
53
+ alert: svg('<circle cx="12" cy="12" r="9"/><path d="M12 8v4M12 16h.01"/>'),
54
+ refresh: svg('<path d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4"/><path d="M4 13a8.1 8.1 0 0 0 15.5 2M20 19v-4h-4"/>'),
55
+ };
56
+ const SPINNER = svg('<path d="M12 3a9 9 0 1 0 9 9" />', "prson-spinner");
57
+ const CHECK = `<svg class="prson-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>`;
58
+ /** Soft tiles with ink text (≥ 12:1), picked by the domain so a site always looks the same. */
59
+ const MONO_TINTS = ["#FEF3C7", "#E0F2FE", "#DCFCE7", "#EDE9FE", "#FCE7F3", "#E2E8F0", "#FFEDD5"];
60
+ function tintFor(domain) {
61
+ let h = 0;
62
+ for (let i = 0; i < domain.length; i++)
63
+ h = (h * 31 + domain.charCodeAt(i)) >>> 0;
64
+ return MONO_TINTS[h % MONO_TINTS.length];
65
+ }
66
+ function fmtSeconds(seconds) {
67
+ const s = Math.max(0, seconds);
68
+ return Math.floor(s / 60) + ":" + String(s % 60).padStart(2, "0");
69
+ }
70
+ function prefersReducedMotion() {
71
+ return typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
72
+ }
73
+ /** A phone or small tablet, where the Prson app is (or would be) on this device. */
74
+ function isPhone() {
75
+ const ua = navigator.userAgent || "";
76
+ if (/iPhone|iPod|Android.+Mobile|Windows Phone|Mobile Safari/i.test(ua))
77
+ return true;
78
+ return (typeof window.matchMedia === "function" &&
79
+ window.matchMedia("(pointer: coarse)").matches &&
80
+ window.matchMedia("(max-width: 820px)").matches);
81
+ }
82
+ function el(tag, cls, html) {
83
+ const e = document.createElement(tag);
84
+ if (cls)
85
+ e.className = cls;
86
+ if (html !== undefined)
87
+ e.innerHTML = html;
88
+ return e;
89
+ }
90
+ /**
91
+ * Render the sign-in card into [mount]. Returns the handle the SDK uses
92
+ * to report progress and tear it down.
93
+ */
94
+ export function renderQrCard(url, mount, theme, context) {
95
+ // A host page that calls this directly, or stale DOM from a session
96
+ // whose dispose() never ran, could stack two cards: drop older ones.
97
+ Array.from(mount.querySelectorAll(".prson-card, .prson-qr-card")).forEach((orphan) => orphan.remove());
98
+ const info = describeCode(url);
99
+ const domain = context?.domain || info.domain || window.location.host;
100
+ const mode = context?.mode ?? "inline";
101
+ const titleId = context?.titleId ?? `prson-login-title-${Math.random().toString(36).slice(2, 10)}`;
102
+ const getAppUrl = context?.getAppUrl ?? "https://app.prson.net/";
103
+ const phone = isPhone();
104
+ const sheet = mode === "modal" && typeof window.matchMedia === "function" && window.matchMedia("(max-width: 480px)").matches;
105
+ const card = el("section", "prson-card");
106
+ card.setAttribute("data-prson-login-ui", "1");
107
+ card.dataset.theme = theme === "light" || theme === "dark" ? theme : "auto";
108
+ card.dataset.mode = mode;
109
+ card.dataset.device = phone ? "phone" : "desktop";
110
+ card.dataset.state = "waiting";
111
+ if (sheet)
112
+ card.dataset.sheet = "1";
113
+ card.setAttribute("aria-labelledby", titleId);
114
+ // Kept for hosts that styled the 0.1 card.
115
+ card.classList.add("prson-qr-card");
116
+ // Header: brand + close (dialog only).
117
+ const head = el("div", "prson-head");
118
+ const brand = el("span", "prson-brand", prsonMarkSvg({ size: 22 }));
119
+ brand.append(document.createTextNode("Sign in with Prson"));
120
+ head.append(brand);
121
+ if (mode === "modal" && context?.cancel) {
122
+ const close = el("button", "prson-close", ICONS.close);
123
+ close.type = "button";
124
+ close.setAttribute("aria-label", "Close");
125
+ close.addEventListener("click", () => context.cancel?.());
126
+ head.append(close);
127
+ }
128
+ // The site, big.
129
+ const site = el("div", "prson-site");
130
+ const mono = el("div", "prson-monogram");
131
+ mono.textContent = monogram(domain);
132
+ mono.style.setProperty("--prson-mono-bg", tintFor(domain));
133
+ mono.setAttribute("aria-hidden", "true");
134
+ const siteText = el("div", "prson-site-text");
135
+ const eyebrow = el("p", "prson-eyebrow");
136
+ eyebrow.textContent = "Sign in to";
137
+ const title = el("h2", "prson-domain");
138
+ title.id = titleId;
139
+ title.textContent = domain;
140
+ // "Sign in to shop.example.com" for screen readers in one go.
141
+ title.setAttribute("aria-label", `Sign in to ${domain}`);
142
+ siteText.append(eyebrow, title);
143
+ site.append(mono, siteText);
144
+ // The stage: the code (computers) or the Open Prson button (phones), with
145
+ // the state overlay on top.
146
+ const stage = el("div", "prson-stage");
147
+ const frame = el("div", "prson-frame");
148
+ const ring = document.createElementNS("http://www.w3.org/2000/svg", "svg");
149
+ ring.setAttribute("class", "prson-ring");
150
+ ring.setAttribute("viewBox", "0 0 272 272");
151
+ ring.setAttribute("aria-hidden", "true");
152
+ ring.innerHTML =
153
+ '<rect class="prson-ring-track" x="2" y="2" width="268" height="268" rx="24" pathLength="100"/>' +
154
+ '<rect class="prson-ring-fill" x="2" y="2" width="268" height="268" rx="24" pathLength="100"/>';
155
+ const ringFill = ring.querySelector(".prson-ring-fill");
156
+ const code = el("div", "prson-code");
157
+ code.setAttribute("role", "img");
158
+ code.setAttribute("aria-label", `Sign-in code for ${domain}. Scan it with the Prson app.`);
159
+ QRCode.toString(url, { type: "svg", errorCorrectionLevel: "H", margin: 0, color: { dark: "#0A0A0A", light: "#FFFFFF" } }, (err, svgString) => {
160
+ if (err) {
161
+ code.textContent = "The code couldn't be drawn. Use Get a new code.";
162
+ return;
163
+ }
164
+ code.innerHTML = svgString.replace("<svg ", '<svg class="prson-qr" aria-hidden="true" focusable="false" ');
165
+ const logo = el("span", "prson-code-logo", prsonMarkSvg({ size: 36 }));
166
+ code.append(logo);
167
+ });
168
+ frame.append(ring, code);
169
+ const open = el("div", "prson-open");
170
+ const openBtn = el("a", "prson-btn prson-btn--big", prsonMarkSvg({ size: 26, square: "#0A0A0A", glyph: "#FBBF24" }));
171
+ openBtn.href = url;
172
+ openBtn.append(document.createTextNode("Open Prson"));
173
+ const showCode = el("button", "prson-linkish");
174
+ showCode.type = "button";
175
+ showCode.textContent = "Scan with another phone instead";
176
+ showCode.setAttribute("aria-expanded", "false");
177
+ showCode.addEventListener("click", () => {
178
+ const on = card.dataset.showCode !== "1";
179
+ card.dataset.showCode = on ? "1" : "";
180
+ showCode.setAttribute("aria-expanded", String(on));
181
+ showCode.textContent = on ? "Hide the code" : "Scan with another phone instead";
182
+ });
183
+ open.append(openBtn, showCode);
184
+ const overlay = el("div", "prson-overlay");
185
+ const overlayIcon = el("div", "prson-overlay-icon");
186
+ const overlayTitle = el("p", "prson-overlay-title");
187
+ const overlayText = el("p", "prson-overlay-text");
188
+ overlay.append(overlayIcon, overlayTitle, overlayText);
189
+ // Over the code on computers, over the Open Prson button on phones.
190
+ (phone ? open : frame).append(overlay);
191
+ const timer = el("p", "prson-timer");
192
+ stage.append(frame, open);
193
+ if (!phone)
194
+ stage.append(el("p", "prson-hint", "Open <b>Prson</b> on your phone and scan this code."));
195
+ stage.append(timer);
196
+ // What the site gets.
197
+ const share = el("div", "prson-share");
198
+ const shareTitle = el("p", "prson-share-title");
199
+ shareTitle.textContent = `${domain} will get`;
200
+ const list = el("ul");
201
+ list.setAttribute("aria-label", `What ${domain} will get`);
202
+ for (const item of info.shares) {
203
+ const li = el("li", "", ICONS[item.icon]);
204
+ const text = el("span");
205
+ text.textContent = item.label;
206
+ if (item.detail) {
207
+ const small = el("small");
208
+ small.textContent = item.detail;
209
+ text.append(small);
210
+ }
211
+ li.append(text);
212
+ list.append(li);
213
+ }
214
+ share.append(shareTitle, list);
215
+ if (info.anonymousAllowed) {
216
+ const note = el("p", "prson-share-note");
217
+ note.textContent = "You can also choose to sign in anonymously in the app.";
218
+ share.append(note);
219
+ }
220
+ // The anti-relay cue.
221
+ const guard = el("p", "prson-guard", ICONS.lock);
222
+ const guardText = el("span");
223
+ guardText.append(document.createTextNode("Only scan codes shown on "));
224
+ const guardDomain = el("b");
225
+ guardDomain.textContent = domain;
226
+ guardText.append(guardDomain, document.createTextNode(". Never scan one someone sent you."));
227
+ guard.append(guardText);
228
+ const foot = el("p", "prson-foot");
229
+ foot.append(document.createTextNode("Don't have Prson? "));
230
+ const get = el("a");
231
+ get.href = getAppUrl;
232
+ get.target = "_blank";
233
+ get.rel = "noopener";
234
+ get.textContent = "Get the app";
235
+ foot.append(get);
236
+ const live = el("div", "prson-sr");
237
+ live.setAttribute("aria-live", "polite");
238
+ live.setAttribute("role", "status");
239
+ card.append(head, site, stage, share, guard, foot, live);
240
+ mount.append(card);
241
+ const announce = (text) => {
242
+ live.textContent = "";
243
+ // A tick later, so the same text twice is still read.
244
+ setTimeout(() => (live.textContent = text), 50);
245
+ };
246
+ announce(phone ? `Sign in to ${domain}. Open Prson to continue.` : `Sign in to ${domain}. Scan the code with the Prson app.`);
247
+ // ── Countdown ────────────────────────────────────────────────
248
+ // From the server's own timestamp, unless this computer's clock is
249
+ // clearly off (then from now).
250
+ const nowS = Date.now() / 1000;
251
+ const startS = info.serverTs && Math.abs(nowS - info.serverTs) < 60 ? info.serverTs : nowS;
252
+ const deadlineMs = (startS + DRAFT_TTL_SECONDS) * 1000;
253
+ let tickHandle = null;
254
+ let expired = false;
255
+ let warned = false;
256
+ let settled = false; // success or error: the countdown no longer matters
257
+ const timers = [];
258
+ function action(label, icon, onClick) {
259
+ const b = el("button", "prson-btn", icon);
260
+ b.type = "button";
261
+ b.append(document.createTextNode(label));
262
+ b.addEventListener("click", onClick);
263
+ return b;
264
+ }
265
+ /** Ask for a fresh code: the 0.1 DOM event first, then the SDK (a no-op if the host already re-called signIn()). */
266
+ function requestRefresh() {
267
+ card.dispatchEvent(new CustomEvent("prson-login-refresh-requested", { bubbles: true }));
268
+ context?.refresh?.();
269
+ }
270
+ function setOverlay(icon, titleText, text, button, pulse = false) {
271
+ overlayIcon.innerHTML = icon;
272
+ overlayIcon.classList.toggle("prson-pulse", pulse);
273
+ overlayTitle.textContent = titleText;
274
+ overlayText.textContent = text;
275
+ overlay.querySelector(".prson-btn")?.remove();
276
+ if (button) {
277
+ overlay.append(button);
278
+ // Move focus to the one thing to do next (the dialog keeps it inside).
279
+ if (mount.contains(document.activeElement) || mode === "modal")
280
+ setTimeout(() => button.focus(), 30);
281
+ }
282
+ }
283
+ function tick() {
284
+ if (settled)
285
+ return;
286
+ const remainingMs = deadlineMs - Date.now();
287
+ const remaining = Math.max(0, Math.ceil(remainingMs / 1000));
288
+ const ratio = Math.max(0, Math.min(1, remainingMs / (DRAFT_TTL_SECONDS * 1000)));
289
+ ringFill.style.strokeDashoffset = String(100 - ratio * 100);
290
+ if (remaining > 0) {
291
+ timer.innerHTML = `Code expires in <b>${fmtSeconds(remaining)}</b>`;
292
+ card.dataset.urgency = remaining <= COUNTDOWN_WARN_SECONDS ? "warn" : "";
293
+ if (remaining <= COUNTDOWN_WARN_SECONDS && !warned) {
294
+ warned = true;
295
+ announce("30 seconds left on this code.");
296
+ }
297
+ }
298
+ else if (!expired && card.dataset.state === "waiting") {
299
+ expired = true;
300
+ card.dataset.state = "expired";
301
+ timer.textContent = "";
302
+ setOverlay(ICONS.clock, "This code expired", "Codes last 3 minutes, so a copied one is useless.", action("Get a new code", ICONS.refresh, requestRefresh));
303
+ announce("The code expired. Get a new code to continue.");
304
+ }
305
+ }
306
+ tick();
307
+ tickHandle = window.setInterval(tick, 1000);
308
+ return {
309
+ dispose() {
310
+ if (tickHandle != null)
311
+ window.clearInterval(tickHandle);
312
+ tickHandle = null;
313
+ timers.forEach((t) => window.clearTimeout(t));
314
+ card.remove();
315
+ },
316
+ update(s) {
317
+ if (!card.isConnected)
318
+ return;
319
+ card.dataset.state = s.state;
320
+ switch (s.state) {
321
+ case "waiting":
322
+ return;
323
+ case "scanned":
324
+ setOverlay(ICONS.device, "Phone connected", "Finishing on your phone…", undefined, true);
325
+ announce("Phone connected. Finishing on your phone.");
326
+ return;
327
+ case "approving":
328
+ setOverlay(SPINNER, "Receiving your proof", "Your phone is sending a signed, encrypted proof.");
329
+ return;
330
+ case "verifying":
331
+ setOverlay(SPINNER, "Checking the proof", "Almost there.");
332
+ announce("Checking the proof.");
333
+ return;
334
+ case "success": {
335
+ settled = true;
336
+ setOverlay(CHECK, "Signed in", `You're signed in to ${s.domain || domain}.`);
337
+ announce(`You're signed in to ${s.domain || domain}.`);
338
+ // Long enough to see the check; short when motion is reduced.
339
+ const hold = prefersReducedMotion() ? 450 : 1000;
340
+ return new Promise((resolve) => timers.push(window.setTimeout(resolve, hold)));
341
+ }
342
+ case "error":
343
+ settled = true;
344
+ timer.textContent = "";
345
+ setOverlay(ICONS.alert, "Sign-in didn't finish", s.message, action("Try again", ICONS.refresh, requestRefresh));
346
+ announce(`Sign-in didn't finish. ${s.message}`);
347
+ return;
348
+ }
349
+ },
350
+ };
351
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * CSS bundled with the UI package and injected at import-time via a
3
+ * single `<style data-prson-login-ui>` tag.
4
+ *
5
+ * Embedding the stylesheet in JS rather than shipping a sidecar
6
+ * `.css` file is deliberate — the goal of `@prson/login-sdk-ui` is
7
+ * "drop one script tag and get a working sign-in". A separate
8
+ * stylesheet adds a second HTTP fetch + a partner-side concatenation
9
+ * step we don't want.
10
+ *
11
+ * Two parts:
12
+ * * the sign-in card (`.prson-card`, under `[data-prson-login-ui]`),
13
+ * themed with `--prson-*` custom properties: override them on
14
+ * `[data-prson-login-ui]` with higher specificity;
15
+ * * the "Sign in with Prson" button (`.prson-signin-btn`), which lives
16
+ * on the host page.
17
+ *
18
+ * Brand: ink #0A0A0A, muted #52525B, amber #FBBF24 with ink text for the
19
+ * primary action, Inter. Light first; dark follows `prefers-color-scheme`
20
+ * for `theme: "auto"` or is forced with `theme: "dark"`. Every animation
21
+ * stops under `prefers-reduced-motion: reduce`.
22
+ */
23
+ export declare const PRSON_LOGIN_UI_CSS = "\n[data-prson-login-ui] {\n --prson-bg: #FFFFFF;\n --prson-fg: #0A0A0A;\n --prson-muted: #52525B;\n --prson-soft: #FAFAF9;\n --prson-line: rgba(10, 10, 10, 0.08);\n --prson-line-strong: rgba(10, 10, 10, 0.16);\n --prson-amber: #FBBF24;\n --prson-amber-hover: #F59E0B;\n --prson-accent-text: #B45309;\n --prson-focus: #0A0A0A;\n --prson-danger: #B91C1C;\n --prson-danger-soft: #FEF2F2;\n --prson-ring-track: rgba(10, 10, 10, 0.08);\n --prson-shadow: 0 24px 64px rgba(10, 10, 10, 0.18), 0 2px 6px rgba(10, 10, 10, 0.06);\n --prson-radius: 24px;\n --prson-font: \"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, system-ui, sans-serif;\n --prson-spring: cubic-bezier(0.16, 1, 0.3, 1);\n}\n[data-prson-login-ui][data-theme=\"dark\"] {\n --prson-bg: #18181B;\n --prson-fg: #FAFAFA;\n --prson-muted: #A1A1AA;\n --prson-soft: #232327;\n --prson-line: rgba(255, 255, 255, 0.10);\n --prson-line-strong: rgba(255, 255, 255, 0.20);\n --prson-accent-text: #FBBF24;\n --prson-focus: #FBBF24;\n --prson-danger: #FCA5A5;\n --prson-danger-soft: rgba(248, 113, 113, 0.14);\n --prson-ring-track: rgba(255, 255, 255, 0.12);\n --prson-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);\n}\n@media (prefers-color-scheme: dark) {\n [data-prson-login-ui][data-theme=\"auto\"] {\n --prson-bg: #18181B;\n --prson-fg: #FAFAFA;\n --prson-muted: #A1A1AA;\n --prson-soft: #232327;\n --prson-line: rgba(255, 255, 255, 0.10);\n --prson-line-strong: rgba(255, 255, 255, 0.20);\n --prson-accent-text: #FBBF24;\n --prson-focus: #FBBF24;\n --prson-danger: #FCA5A5;\n --prson-danger-soft: rgba(248, 113, 113, 0.14);\n --prson-ring-track: rgba(255, 255, 255, 0.12);\n --prson-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);\n }\n}\n\n/* \u2500\u2500 The card \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.prson-card {\n box-sizing: border-box;\n position: relative;\n width: 400px;\n max-width: 100%;\n padding: 20px 24px 20px;\n background: var(--prson-bg);\n color: var(--prson-fg);\n border: 1px solid var(--prson-line);\n border-radius: var(--prson-radius);\n box-shadow: var(--prson-shadow);\n font-family: var(--prson-font);\n font-size: 14px;\n line-height: 1.45;\n text-align: left;\n -webkit-font-smoothing: antialiased;\n animation: prson-enter 320ms var(--prson-spring);\n}\n.prson-card *, .prson-card *::before, .prson-card *::after { box-sizing: border-box; }\n.prson-card[data-mode=\"inline\"] { margin-top: 24px; box-shadow: 0 8px 24px rgba(10, 10, 10, 0.06), 0 1px 3px rgba(10, 10, 10, 0.05); }\n.prson-card[data-sheet=\"1\"] {\n width: 100%;\n border-radius: var(--prson-radius) var(--prson-radius) 0 0;\n border-bottom: 0;\n padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));\n animation-name: prson-sheet;\n}\n@keyframes prson-enter { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }\n@keyframes prson-sheet { from { transform: translateY(100%); } to { transform: none; } }\n\n.prson-card button, .prson-card a { font-family: inherit; }\n.prson-card :focus-visible { outline: 3px solid var(--prson-focus); outline-offset: 2px; border-radius: 10px; }\n\n.prson-head { display: flex; align-items: center; gap: 8px; min-height: 44px; margin: -4px -8px 4px 0; }\n.prson-brand { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--prson-muted); letter-spacing: -0.1px; }\n.prson-brand .prson-mark { display: block; }\n.prson-close {\n margin-left: auto; width: 44px; height: 44px; display: inline-grid; place-items: center;\n border: 0; border-radius: 12px; background: transparent; color: var(--prson-muted); cursor: pointer;\n}\n.prson-close:hover { background: var(--prson-soft); color: var(--prson-fg); }\n.prson-close svg { width: 20px; height: 20px; }\n\n.prson-site { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; min-width: 0; }\n.prson-monogram {\n flex: none; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;\n font-size: 22px; font-weight: 700; letter-spacing: -0.5px; color: #0A0A0A;\n background: var(--prson-mono-bg, #FEF3C7);\n box-shadow: inset 0 0 0 1px rgba(10, 10, 10, 0.06);\n}\n.prson-site-text { min-width: 0; }\n.prson-eyebrow { margin: 0; font-size: 13px; color: var(--prson-muted); }\n.prson-domain {\n margin: 0; font-size: 24px; line-height: 1.15; font-weight: 700; letter-spacing: -0.6px;\n color: var(--prson-fg); overflow-wrap: anywhere;\n}\n\n/* \u2500\u2500 The code, its frame and the countdown ring \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.prson-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; }\n.prson-frame { position: relative; width: 272px; height: 272px; max-width: 100%; aspect-ratio: 1; }\n.prson-ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }\n.prson-ring rect { fill: none; stroke-width: 4; }\n.prson-ring .prson-ring-track { stroke: var(--prson-ring-track); }\n.prson-ring .prson-ring-fill {\n stroke: var(--prson-amber); stroke-linecap: round;\n stroke-dasharray: 100 100; transition: stroke-dashoffset 1s linear, stroke 300ms ease;\n}\n.prson-card[data-urgency=\"warn\"] .prson-ring-fill { stroke: #D97706; }\n.prson-code {\n position: absolute; inset: 10px; border-radius: 18px; background: #FFFFFF; /* always white: cameras need contrast */\n display: grid; place-items: center; padding: 12px;\n box-shadow: inset 0 0 0 1px rgba(10, 10, 10, 0.06);\n transition: filter 300ms ease, opacity 300ms ease;\n}\n.prson-code svg.prson-qr { display: block; width: 100%; height: 100%; }\n.prson-code-logo {\n position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;\n border-radius: 12px; background: #FFFFFF; display: grid; place-items: center;\n}\n.prson-code-logo .prson-mark { width: 36px; height: 36px; }\n.prson-card[data-state]:not([data-state=\"waiting\"]) .prson-code { filter: blur(3px); opacity: 0.25; }\n.prson-card[data-state=\"waiting\"] .prson-code { filter: none; opacity: 1; }\n\n.prson-overlay {\n position: absolute; inset: 10px; border-radius: 18px; display: none;\n flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 18px; text-align: center;\n background: var(--prson-bg);\n background: color-mix(in srgb, var(--prson-bg) 82%, transparent);\n animation: prson-fade 220ms ease;\n}\n.prson-card:not([data-state=\"waiting\"]) .prson-overlay { display: flex; }\n@keyframes prson-fade { from { opacity: 0; } to { opacity: 1; } }\n.prson-overlay-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 6px; background: var(--prson-soft); color: var(--prson-fg); }\n.prson-overlay-icon svg { width: 28px; height: 28px; }\n.prson-overlay-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.3px; color: var(--prson-fg); }\n.prson-overlay-text { margin: 0; font-size: 13.5px; color: var(--prson-muted); max-width: 230px; }\n.prson-overlay .prson-btn { margin-top: 10px; }\n.prson-card[data-state=\"error\"] .prson-overlay-icon { background: var(--prson-danger-soft); color: var(--prson-danger); }\n\n.prson-spinner { width: 28px; height: 28px; animation: prson-spin 900ms linear infinite; }\n@keyframes prson-spin { to { transform: rotate(360deg); } }\n.prson-pulse { animation: prson-pulse 1.6s ease-in-out infinite; }\n@keyframes prson-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.45); } 50% { box-shadow: 0 0 0 10px rgba(251, 191, 36, 0); } }\n\n/* Success: an amber disc pops in and the check draws itself. */\n.prson-card[data-state=\"success\"] .prson-overlay-icon { background: var(--prson-amber); color: #0A0A0A; width: 72px; height: 72px; animation: prson-pop 420ms var(--prson-spring); }\n.prson-card[data-state=\"success\"] .prson-overlay-icon svg { width: 36px; height: 36px; }\n.prson-check path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: prson-draw 380ms 160ms ease-out forwards; }\n@keyframes prson-pop { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }\n@keyframes prson-draw { to { stroke-dashoffset: 0; } }\n.prson-card[data-state=\"success\"] .prson-ring-fill { stroke: var(--prson-amber); stroke-dashoffset: 0 !important; }\n\n.prson-timer { margin: 0; min-height: 20px; font-size: 13px; color: var(--prson-muted); font-variant-numeric: tabular-nums; }\n.prson-timer b { color: var(--prson-fg); font-weight: 600; }\n.prson-card[data-urgency=\"warn\"] .prson-timer b { color: var(--prson-accent-text); }\n.prson-card[data-state=\"success\"] .prson-timer, .prson-card[data-state=\"error\"] .prson-timer { visibility: hidden; }\n.prson-hint { margin: 0; font-size: 13px; color: var(--prson-muted); text-align: center; }\n.prson-card:not([data-state=\"waiting\"]) .prson-hint { visibility: hidden; }\n.prson-hint b { color: var(--prson-fg); font-weight: 600; }\n\n/* \u2500\u2500 Phones: one big \"Open Prson\" button \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.prson-open { position: relative; display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 10px; width: 100%; }\n.prson-card[data-device=\"phone\"] .prson-frame { display: none; }\n.prson-card[data-device=\"phone\"][data-show-code=\"1\"] .prson-frame { display: block; }\n.prson-card[data-device=\"desktop\"] .prson-open { display: none; }\n.prson-card[data-device=\"phone\"] .prson-overlay { inset: 0; }\n.prson-card[data-device=\"phone\"]:not([data-state=\"waiting\"]) .prson-open { min-height: 236px; }\n.prson-card[data-device=\"phone\"]:not([data-state=\"waiting\"]) .prson-open > :not(.prson-overlay) { visibility: hidden; }\n.prson-linkish {\n min-height: 44px; border: 0; background: transparent; color: var(--prson-fg); cursor: pointer;\n font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; padding: 0 8px;\n}\n\n/* \u2500\u2500 Buttons inside the card \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.prson-btn {\n display: inline-flex; align-items: center; justify-content: center; gap: 10px;\n min-height: 48px; padding: 0 20px; border-radius: 14px; border: 0; cursor: pointer;\n font-size: 15px; font-weight: 600; letter-spacing: -0.1px; text-decoration: none;\n background: var(--prson-amber); color: #0A0A0A;\n transition: background-color 150ms ease, transform 80ms ease;\n}\n.prson-btn:hover { background: var(--prson-amber-hover); }\n.prson-btn:active { transform: translateY(1px); }\n.prson-btn--big { min-height: 56px; font-size: 16px; border-radius: 16px; }\n.prson-btn .prson-mark { flex: none; }\n.prson-btn { white-space: nowrap; }\n.prson-btn svg:not(.prson-mark) { flex: none; width: 20px; height: 20px; }\n\n/* \u2500\u2500 What the site gets \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.prson-share { margin: 18px 0 0; padding: 14px 16px; border-radius: 16px; background: var(--prson-soft); border: 1px solid var(--prson-line); }\n.prson-share-title { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--prson-muted); letter-spacing: 0.1px; }\n.prson-share ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }\n.prson-share li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--prson-fg); }\n.prson-share li svg { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--prson-fg); opacity: 0.8; }\n.prson-share li small { display: block; font-size: 12.5px; color: var(--prson-muted); }\n.prson-share-note { margin: 10px 0 0; font-size: 12.5px; color: var(--prson-muted); }\n\n/* \u2500\u2500 Anti-relay cue and footer \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.prson-guard { display: flex; gap: 8px; align-items: flex-start; margin: 14px 2px 0; font-size: 12.5px; color: var(--prson-muted); }\n.prson-guard svg { flex: none; width: 16px; height: 16px; margin-top: 1px; }\n.prson-guard b { color: var(--prson-fg); font-weight: 600; overflow-wrap: anywhere; }\n.prson-foot { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--prson-line); font-size: 13px; color: var(--prson-muted); text-align: center; }\n.prson-foot a { color: var(--prson-fg); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; display: inline-block; padding: 12px 4px; margin: -12px 0; }\n\n.prson-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }\n\n@media (max-width: 380px) {\n .prson-card { padding: 16px 16px 18px; }\n .prson-frame { width: 248px; height: 248px; }\n .prson-domain { font-size: 21px; }\n}\n\n/* \u2500\u2500 \"Sign in with Prson\" button (host page) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.prson-signin-btn {\n box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 10px;\n min-height: 44px; padding: 0 18px 0 12px; border-radius: 12px; cursor: pointer;\n font-family: \"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, system-ui, sans-serif;\n font-size: 15px; font-weight: 600; line-height: 1; letter-spacing: -0.1px; white-space: nowrap;\n border: 1px solid transparent; text-decoration: none; -webkit-font-smoothing: antialiased;\n transition: background-color 150ms ease, border-color 150ms ease, transform 80ms ease;\n}\n.prson-signin-btn .prson-mark { flex: none; display: block; }\n.prson-signin-btn:focus-visible { outline: 3px solid #0A0A0A; outline-offset: 2px; }\n.prson-signin-btn:active:not(:disabled) { transform: translateY(1px); }\n.prson-signin-btn:disabled { opacity: 0.55; cursor: not-allowed; }\n.prson-signin-btn--lg { min-height: 52px; padding: 0 22px 0 14px; font-size: 16px; border-radius: 14px; }\n.prson-signin-btn--block { display: flex; width: 100%; }\n.prson-signin-btn--amber { background: #FBBF24; color: #0A0A0A; }\n.prson-signin-btn--amber:hover:not(:disabled) { background: #F59E0B; }\n.prson-signin-btn--dark { background: #0A0A0A; color: #FFFFFF; }\n.prson-signin-btn--dark:hover:not(:disabled) { background: #27272A; }\n.prson-signin-btn--dark:focus-visible { outline-color: #D97706; }\n.prson-signin-btn--light { background: #FFFFFF; color: #0A0A0A; border-color: rgba(10, 10, 10, 0.16); }\n.prson-signin-btn--light:hover:not(:disabled) { background: #FAFAF9; border-color: rgba(10, 10, 10, 0.28); }\n.prson-signin-btn--light:focus-visible { outline-color: #FBBF24; }\n.prson-signin-btn--outline { background: transparent; color: inherit; border: 1.5px solid currentColor; }\n.prson-signin-btn--outline:hover:not(:disabled) { background: rgba(127, 127, 127, 0.10); }\n.prson-signin-btn--outline:focus-visible { outline-color: currentColor; }\n.prson-signin-btn--busy { cursor: progress; }\n.prson-signin-btn--busy .prson-mark { animation: prson-busy 1s ease-in-out infinite; }\n@keyframes prson-busy { 50% { opacity: 0.35; } }\nprson-signin-button { display: inline-block; }\n\n@media (prefers-reduced-motion: reduce) {\n .prson-card, .prson-card *, .prson-signin-btn, .prson-signin-btn * {\n animation: none !important;\n transition: none !important;\n }\n .prson-check path { stroke-dashoffset: 0; }\n .prson-signin-btn:active:not(:disabled), .prson-btn:active { transform: none; }\n}\n";
24
+ /**
25
+ * Inject the stylesheet exactly once per page. Subsequent imports
26
+ * (e.g. multi-tab dev tooling that ends up loading the bundle
27
+ * twice) are no-ops thanks to the dedupe attribute.
28
+ */
29
+ export declare function injectStylesOnce(): void;