@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,59 @@
1
+ /**
2
+ * `@prson/login-sdk-ui` — optional batteries-included UI for the
3
+ * sign-in-with-Prson flow.
4
+ *
5
+ * What this package is for
6
+ * ------------------------
7
+ * The base SDK (`@prson/login-sdk`) is intentionally headless: it
8
+ * does the crypto, talks to the signaling Worker, and delegates QR
9
+ * rendering to whatever the host page assigns to
10
+ * `window.__prsonLoginQrRenderer`. That keeps the base bundle
11
+ * small (~25 KB gzipped) and lets enterprise partners drop their
12
+ * own design-system QR card in.
13
+ *
14
+ * This companion package is the opposite end: import it once and
15
+ * you get a styled QR card with a TTL countdown + refresh
16
+ * affordance — zero configuration. Partners can use it on a demo
17
+ * site or for a quick deployment; production deployments that
18
+ * already have a design system can either keep using it (the card
19
+ * is themeable via CSS variables under `[data-prson-login-ui]`) or
20
+ * skip it entirely.
21
+ *
22
+ * Usage
23
+ * -----
24
+ * Via `<script>`:
25
+ *
26
+ * <script type="module" src="path/to/prson-login.js"></script>
27
+ * <script type="module" src="path/to/prson-login-ui.js"></script>
28
+ * <!-- now signIn() uses the styled card by default -->
29
+ *
30
+ * Via npm:
31
+ *
32
+ * import "@prson/login-sdk-ui"; // side-effect register
33
+ * import { PrsonLogin } from "@prson/login-sdk";
34
+ * await PrsonLogin.signIn({ ... });
35
+ *
36
+ * If you want to opt out of just the auto-registration but still use
37
+ * the renderer manually:
38
+ *
39
+ * import { renderQrCard } from "@prson/login-sdk-ui/render";
40
+ * window.__prsonLoginQrRenderer = renderQrCard;
41
+ *
42
+ * Refresh contract
43
+ * ----------------
44
+ * When the QR's TTL expires, the card swaps to a "Generate a new
45
+ * code" button. Clicking it dispatches a bubbling `CustomEvent`
46
+ * called `prson-login-refresh-requested` so the host page can
47
+ * decide what to do — most callers want to re-invoke `signIn()`.
48
+ * Example listener:
49
+ *
50
+ * document.addEventListener("prson-login-refresh-requested", () => {
51
+ * document.querySelector("#signin")?.click();
52
+ * });
53
+ */
54
+ import { renderQrCard, type LoginQrContext, type LoginQrHandle, type LoginUiState, type Theme } from "./qr-renderer.js";
55
+ export { renderQrCard };
56
+ export type { LoginQrContext, LoginQrHandle, LoginUiState, Theme };
57
+ export { PRSON_LOGIN_UI_CSS, injectStylesOnce } from "./styles.js";
58
+ export { createSignInButton, defineSignInButtonElement, prsonMarkSvg, type SignInButtonOptions, type SignInButtonSize, type SignInButtonVariant, } from "./button.js";
59
+ export { describeCode, describeShares, monogram, type CodeDescription, type ShareItem } from "./describe.js";