@poly-x/react 0.1.0-alpha.1 → 0.1.0-alpha.11

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/dist/index.cjs CHANGED
@@ -300,31 +300,188 @@ function PolyXProvider({ publishableKey, baseUrl, signInUrl, children }) {
300
300
  });
301
301
  }
302
302
  //#endregion
303
+ //#region src/bff-session.ts
304
+ /**
305
+ * Client session under BFF custody (ADR-0004).
306
+ *
307
+ * `@poly-x/next` seals the tokens in an httpOnly cookie, so a consuming app mounts no
308
+ * `<PolyXProvider>` and there is no client engine to read — there is nothing for it to own.
309
+ * The hooks still have to work there, so they fall back to this: a single module-level store
310
+ * that reads server truth from the `session` route handler once and feeds the *same*
311
+ * `SessionState` machine the engine drives. That is what ADR-0004 meant by custody being
312
+ * "invisible to the consumer API surface".
313
+ *
314
+ * It follows `<SignIn/>`'s precedent — work without a provider, degrade quietly — rather than
315
+ * asking BFF apps to adopt a provider whose whole purpose is holding tokens they don't have.
316
+ */
317
+ const SESSION_ENDPOINT = "/api/polyx/session";
318
+ const SIGNOUT_ENDPOINT = "/api/polyx/signout";
319
+ var BffSessionStore = class {
320
+ state = { status: "resolving" };
321
+ listeners = /* @__PURE__ */ new Set();
322
+ loading = false;
323
+ watching = false;
324
+ getState = () => this.state;
325
+ /** SSR has no session to read; render the resolving branch and settle on the client. */
326
+ getServerState = () => ({ status: "resolving" });
327
+ subscribe = (listener) => {
328
+ this.listeners.add(listener);
329
+ this.load();
330
+ this.watchFocus();
331
+ return () => {
332
+ this.listeners.delete(listener);
333
+ };
334
+ };
335
+ /**
336
+ * The platform revokes every session for a user when an admin changes their permission,
337
+ * suspends them, or resets their password — and it pushes nothing, so a revoked user keeps
338
+ * looking signed in until they happen to make a request. Re-checking when the tab regains
339
+ * focus is the cheapest way to notice: come back to the tab, discover you're signed out.
340
+ *
341
+ * It is not a replacement for the 401 the next request will get; it just moves the discovery
342
+ * to a moment the user is actually looking at the screen.
343
+ */
344
+ watchFocus() {
345
+ if (this.watching || typeof window === "undefined") return;
346
+ this.watching = true;
347
+ const recheck = () => {
348
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
349
+ this.revalidate();
350
+ };
351
+ window.addEventListener("focus", recheck);
352
+ document?.addEventListener?.("visibilitychange", recheck);
353
+ }
354
+ /**
355
+ * Re-read the session without passing through `resolving` — a confirmed session must not
356
+ * flicker the UI back to a loading state. Only a definite signed-out answer signs the user
357
+ * out: an unreachable server is a blip, not a revocation.
358
+ */
359
+ async revalidate() {
360
+ if (this.loading || this.state.status === "resolving") return;
361
+ this.loading = true;
362
+ try {
363
+ const response = await fetch(SESSION_ENDPOINT, {
364
+ credentials: "same-origin",
365
+ headers: { accept: "application/json" }
366
+ });
367
+ const body = response.ok ? await response.json() : null;
368
+ const signedIn = Boolean(body?.isSignedIn && body.claims);
369
+ if (!signedIn && this.state.status !== "signed-out") this.set({
370
+ status: "signed-out",
371
+ reason: "revoked"
372
+ });
373
+ else if (signedIn && body?.claims) this.set({
374
+ status: "authenticated",
375
+ session: { claims: body.claims }
376
+ });
377
+ } catch {} finally {
378
+ this.loading = false;
379
+ }
380
+ }
381
+ /**
382
+ * Reading the session is a one-shot per page load, shared by every component that asks —
383
+ * a user menu and three gates must not mean four round-trips.
384
+ */
385
+ async load() {
386
+ if (this.loading || this.state.status !== "resolving") return;
387
+ this.loading = true;
388
+ try {
389
+ const response = await fetch(SESSION_ENDPOINT, {
390
+ credentials: "same-origin",
391
+ headers: { accept: "application/json" }
392
+ });
393
+ const body = response.ok ? await response.json() : null;
394
+ this.set(body?.isSignedIn && body.claims ? {
395
+ status: "authenticated",
396
+ session: { claims: body.claims }
397
+ } : {
398
+ status: "signed-out",
399
+ reason: "signed-out"
400
+ });
401
+ } catch {
402
+ this.set({
403
+ status: "signed-out",
404
+ reason: "signed-out"
405
+ });
406
+ } finally {
407
+ this.loading = false;
408
+ }
409
+ }
410
+ set(next) {
411
+ this.state = next;
412
+ for (const listener of this.listeners) listener();
413
+ }
414
+ /**
415
+ * Sign-out has to reach the server — only it can unseal an httpOnly cookie, and only it
416
+ * holds the token needed to revoke the session upstream (X002).
417
+ *
418
+ * A same-origin fetch, not a navigation: the response's Set-Cookie still applies, and it
419
+ * leaves the destination to the caller. That is why the handler is content-negotiated —
420
+ * a server-side redirect target would be an open redirect on the auth path, and the client
421
+ * already knows where it wants to land.
422
+ */
423
+ signOut = async (options) => {
424
+ const query = options?.scope === "everywhere" ? "?scope=everywhere" : "";
425
+ try {
426
+ await fetch(`${SIGNOUT_ENDPOINT}${query}`, {
427
+ method: "POST",
428
+ credentials: "same-origin",
429
+ headers: { accept: "application/json" }
430
+ });
431
+ } catch {}
432
+ this.set({
433
+ status: "signed-out",
434
+ reason: "signed-out"
435
+ });
436
+ window.location.assign(options?.redirectTo ?? "/");
437
+ };
438
+ /** Null by design: under BFF custody the token never reaches the browser (FR-SES-3). */
439
+ getToken = async () => null;
440
+ };
441
+ let store = new BffSessionStore();
442
+ function getBffSessionStore() {
443
+ return store;
444
+ }
445
+ //#endregion
303
446
  //#region src/hooks.ts
304
- function usePolyX() {
447
+ function useSessionSource() {
305
448
  const ctx = (0, react.useContext)(PolyXContext);
306
- if (!ctx) throw new Error("PolyX hooks (useAuth/useUser/useSession) must be used within a <PolyXProvider>.");
307
- return ctx;
449
+ if (!ctx) return {
450
+ source: getBffSessionStore(),
451
+ canSignIn: false
452
+ };
453
+ const { engine, controller } = ctx;
454
+ return {
455
+ source: {
456
+ getState: () => engine.getState(),
457
+ subscribe: (listener) => engine.subscribe(listener),
458
+ signOut: () => engine.signOut(),
459
+ getToken: async () => {
460
+ try {
461
+ return await engine.getAccessToken();
462
+ } catch {
463
+ return null;
464
+ }
465
+ }
466
+ },
467
+ canSignIn: Boolean(controller)
468
+ };
308
469
  }
309
470
  /** The raw session state machine value — tearing-free under concurrent React. */
310
471
  function useSession() {
311
- const { engine } = usePolyX();
312
- const subscribe = (0, react.useCallback)((onChange) => engine.subscribe(onChange), [engine]);
313
- const getSnapshot = (0, react.useCallback)(() => engine.getState(), [engine]);
314
- return (0, react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
472
+ const { source } = useSessionSource();
473
+ return (0, react.useSyncExternalStore)((0, react.useCallback)((onChange) => source.subscribe(onChange), [source]), (0, react.useCallback)(() => source.getState(), [source]), (0, react.useCallback)(() => (source.getServerState ?? source.getState)(), [source]));
315
474
  }
316
475
  function useAuth() {
317
- const { engine, controller } = usePolyX();
476
+ const ctx = (0, react.useContext)(PolyXContext);
477
+ const { source } = useSessionSource();
318
478
  const state = useSession();
319
- const signIn = (0, react.useCallback)((options) => controller.signIn(options), [controller]);
320
- const signOut = (0, react.useCallback)(() => engine.signOut(), [engine]);
321
- const getToken = (0, react.useCallback)(async () => {
322
- try {
323
- return await engine.getAccessToken();
324
- } catch {
325
- return null;
326
- }
327
- }, [engine]);
479
+ const signIn = (0, react.useCallback)(async (options) => {
480
+ if (!ctx) throw new Error("PolyX: signIn() needs a <PolyXProvider> (it owns the publishable key and the popup flow). Under BFF custody, render <SignIn/> or link to your sign-in route instead.");
481
+ return ctx.controller.signIn(options);
482
+ }, [ctx]);
483
+ const signOut = (0, react.useCallback)((options) => source.signOut(options), [source]);
484
+ const getToken = (0, react.useCallback)(() => source.getToken(), [source]);
328
485
  return {
329
486
  isLoaded: state.status !== "resolving",
330
487
  isSignedIn: state.status === "authenticated" || state.status === "refreshing",
@@ -335,8 +492,11 @@ function useAuth() {
335
492
  }
336
493
  /** Run this on your callback route to complete a sign-in (see `<AuthCallback>`). */
337
494
  function useAuthCallback() {
338
- const { controller } = usePolyX();
339
- return (0, react.useCallback)(() => controller.handleCallback(), [controller]);
495
+ const ctx = (0, react.useContext)(PolyXContext);
496
+ return (0, react.useCallback)(() => {
497
+ if (!ctx) throw new Error("PolyX: <AuthCallback> / useAuthCallback() must be used within a <PolyXProvider>.");
498
+ return ctx.controller.handleCallback();
499
+ }, [ctx]);
340
500
  }
341
501
  function useUser() {
342
502
  const state = useSession();
@@ -352,14 +512,890 @@ function Protected({ children, fallback = null, loading = null }) {
352
512
  }
353
513
  //#endregion
354
514
  //#region src/components/sign-in.tsx
355
- /** Minimal sign-in trigger — popup by default. Style via `className`/children. */
356
- function SignIn({ children, className, ...options }) {
357
- const { signIn } = useAuth();
358
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
359
- type: "button",
360
- className,
361
- onClick: () => void signIn(options),
362
- children: children ?? "Sign in"
515
+ const DEFAULT_LABELS$3 = {
516
+ heading: "Sign in",
517
+ subheading: "Enter your credentials to continue.",
518
+ tagline: "",
519
+ emailLabel: "Email",
520
+ emailPlaceholder: "you@company.com",
521
+ passwordLabel: "Password",
522
+ passwordPlaceholder: "••••••••",
523
+ showPassword: "Show password",
524
+ hidePassword: "Hide password",
525
+ submit: "Sign in",
526
+ submitting: "Signing in…",
527
+ forgotPassword: "Forgot password?",
528
+ chooseWorkspace: "Choose a workspace",
529
+ chooseWorkspaceSubheading: "You have access to more than one workspace.",
530
+ securedBy: "Secured by PolyX",
531
+ setPasswordHeading: "Choose a new password",
532
+ setPasswordSubheading: "Your temporary password must be replaced before you continue.",
533
+ newPasswordLabel: "New password",
534
+ confirmPasswordLabel: "Confirm new password",
535
+ setPasswordSubmit: "Set password and sign in",
536
+ passwordMismatch: "Those passwords don't match.",
537
+ weakPassword: "Password must be at least 6 characters.",
538
+ invalidCredentials: "Invalid email or password.",
539
+ noAccess: "You don't have access to this application.",
540
+ passwordChangeRequired: "You must reset your password before you can sign in.",
541
+ genericError: "Something went wrong. Please try again."
542
+ };
543
+ /** Mirrors poly-auth's own floor (Joi: min 6). */
544
+ const MIN_PASSWORD_LENGTH = 6;
545
+ function EyeIcon() {
546
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
547
+ viewBox: "0 0 24 24",
548
+ fill: "none",
549
+ stroke: "currentColor",
550
+ strokeWidth: "2",
551
+ strokeLinecap: "round",
552
+ strokeLinejoin: "round",
553
+ "aria-hidden": "true",
554
+ focusable: "false",
555
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
556
+ cx: "12",
557
+ cy: "12",
558
+ r: "3"
559
+ })]
560
+ });
561
+ }
562
+ function EyeOffIcon() {
563
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
564
+ viewBox: "0 0 24 24",
565
+ fill: "none",
566
+ stroke: "currentColor",
567
+ strokeWidth: "2",
568
+ strokeLinecap: "round",
569
+ strokeLinejoin: "round",
570
+ "aria-hidden": "true",
571
+ focusable: "false",
572
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M9.88 4.24A9.1 9.1 0 0 1 12 4c6.5 0 10 7 10 7a13.2 13.2 0 0 1-1.67 2.68M6.61 6.61A13.5 13.5 0 0 0 2 12s3.5 7 10 7a9.7 9.7 0 0 0 5.39-1.61" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
573
+ x1: "2",
574
+ y1: "2",
575
+ x2: "22",
576
+ y2: "22"
577
+ })]
578
+ });
579
+ }
580
+ /** A password input with an accessible show/hide reveal toggle (own visibility state). */
581
+ function PasswordField(props) {
582
+ const [visible, setVisible] = (0, react.useState)(false);
583
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
584
+ className: "polyx-signin__field",
585
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
586
+ className: "polyx-signin__label",
587
+ htmlFor: props.id,
588
+ children: props.label
589
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
590
+ className: "polyx-signin__input-wrap",
591
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
592
+ id: props.id,
593
+ className: "polyx-signin__input polyx-signin__input--has-reveal",
594
+ type: visible ? "text" : "password",
595
+ name: props.name,
596
+ autoComplete: props.autoComplete,
597
+ placeholder: props.placeholder,
598
+ required: true,
599
+ minLength: props.minLength,
600
+ value: props.value,
601
+ disabled: props.disabled,
602
+ onChange: (event) => props.onChange(event.target.value)
603
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
604
+ type: "button",
605
+ className: "polyx-signin__reveal",
606
+ "aria-pressed": visible,
607
+ "aria-label": visible ? props.hideLabel : props.showLabel,
608
+ title: visible ? props.hideLabel : props.showLabel,
609
+ disabled: props.disabled,
610
+ onClick: () => setVisible((value) => !value),
611
+ children: visible ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EyeOffIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EyeIcon, {})
612
+ })]
613
+ })]
614
+ });
615
+ }
616
+ /**
617
+ * The embedded, Clerk-style sign-in form (D2b). Renders email/password inside the
618
+ * consuming app and POSTs to the SDK's BFF (`@poly-x/next` `authenticate`), which
619
+ * runs the credential authorize server-side and seals an httpOnly session — no
620
+ * redirect to a hosted PolyX login page, no tokens or credentials in the browser
621
+ * after submit. Handles the workspace picker (select_tenant) inline.
622
+ *
623
+ * Ships styled: `import "@poly-x/react/styles.css"` once, then theme it by
624
+ * overriding the `--polyx-*` custom properties on any ancestor.
625
+ */
626
+ function SignIn(props) {
627
+ const action = props.action ?? "/api/polyx/authenticate";
628
+ const variant = props.variant ?? "card";
629
+ const labels = {
630
+ ...DEFAULT_LABELS$3,
631
+ ...props.labels
632
+ };
633
+ const [email, setEmail] = (0, react.useState)("");
634
+ const [password, setPassword] = (0, react.useState)("");
635
+ const [newPassword, setNewPassword] = (0, react.useState)("");
636
+ const [confirmPassword, setConfirmPassword] = (0, react.useState)("");
637
+ const [mustSetPassword, setMustSetPassword] = (0, react.useState)(false);
638
+ const [tenants, setTenants] = (0, react.useState)(null);
639
+ const [submitting, setSubmitting] = (0, react.useState)(false);
640
+ const [error, setError] = (0, react.useState)(null);
641
+ const polyx = (0, react.useContext)(PolyXContext);
642
+ const [branding, setBranding] = (0, react.useState)({});
643
+ (0, react.useEffect)(() => {
644
+ if (!polyx) return;
645
+ let active = true;
646
+ polyx.authClient.fetchBranding(props.organizationCode ? { organizationCode: props.organizationCode } : {}).then((tokens) => {
647
+ if (active) setBranding(tokens);
648
+ });
649
+ return () => {
650
+ active = false;
651
+ };
652
+ }, [polyx, props.organizationCode]);
653
+ const brandingStyle = {};
654
+ if (branding.primaryColor) brandingStyle["--polyx-brand"] = branding.primaryColor;
655
+ if (branding.backgroundColor) {
656
+ brandingStyle["--polyx-bg"] = branding.backgroundColor;
657
+ brandingStyle["--polyx-page-bg"] = branding.backgroundColor;
658
+ }
659
+ const brandingLogo = props.logo ?? (branding.logoUrl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
660
+ className: "polyx-signin__brand-logo",
661
+ src: branding.logoUrl,
662
+ alt: branding.displayName ?? ""
663
+ }) : void 0);
664
+ /**
665
+ * One round-trip to the BFF. `tenantId` picks a workspace; `passwords` completes
666
+ * the temp-password flow (the BFF re-verifies the temporary password, sets the
667
+ * new one, and signs the user straight in).
668
+ */
669
+ async function authenticate(options = {}) {
670
+ setSubmitting(true);
671
+ setError(null);
672
+ try {
673
+ const body = await (await fetch(action, {
674
+ method: "POST",
675
+ headers: { "content-type": "application/json" },
676
+ body: JSON.stringify({
677
+ email,
678
+ password,
679
+ organizationCode: props.organizationCode,
680
+ tenantId: options.tenantId,
681
+ ...options.passwords
682
+ })
683
+ })).json().catch(() => ({}));
684
+ switch (body.status) {
685
+ case "success":
686
+ window.location.assign(props.afterSignInPath ?? body.redirectTo ?? "/");
687
+ return;
688
+ case "select_tenant":
689
+ setTenants(body.tenants ?? []);
690
+ return;
691
+ case "password_change_required":
692
+ setMustSetPassword(true);
693
+ if (body.userId) props.onPasswordChangeRequired?.(body.userId);
694
+ return;
695
+ case "password_mismatch":
696
+ setError(labels.passwordMismatch);
697
+ return;
698
+ case "weak_password":
699
+ setError(labels.weakPassword);
700
+ return;
701
+ case "invalid_credentials":
702
+ setError(labels.invalidCredentials);
703
+ return;
704
+ case "no_access":
705
+ setError(labels.noAccess);
706
+ return;
707
+ default:
708
+ setError(labels.genericError);
709
+ return;
710
+ }
711
+ } catch {
712
+ setError(labels.genericError);
713
+ } finally {
714
+ setSubmitting(false);
715
+ }
716
+ }
717
+ function onSubmit(event) {
718
+ event.preventDefault();
719
+ authenticate();
720
+ }
721
+ function onSetPasswordSubmit(event) {
722
+ event.preventDefault();
723
+ if (newPassword !== confirmPassword) {
724
+ setError(labels.passwordMismatch);
725
+ return;
726
+ }
727
+ authenticate({ passwords: {
728
+ newPassword,
729
+ confirmPassword
730
+ } });
731
+ }
732
+ const picking = tenants !== null;
733
+ const showHeaderLogo = Boolean(brandingLogo) && !(variant === "page");
734
+ const rootClass = [
735
+ "polyx-signin",
736
+ `polyx-signin--${variant}`,
737
+ props.className
738
+ ].filter(Boolean).join(" ");
739
+ const step = picking ? "select_tenant" : mustSetPassword ? "set_password" : "credentials";
740
+ const HEADINGS = {
741
+ credentials: {
742
+ heading: labels.heading,
743
+ subheading: labels.subheading
744
+ },
745
+ select_tenant: {
746
+ heading: labels.chooseWorkspace,
747
+ subheading: labels.chooseWorkspaceSubheading
748
+ },
749
+ set_password: {
750
+ heading: labels.setPasswordHeading,
751
+ subheading: labels.setPasswordSubheading
752
+ }
753
+ };
754
+ const header = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
755
+ className: "polyx-signin__header",
756
+ children: [
757
+ showHeaderLogo ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
758
+ className: "polyx-signin__logo",
759
+ children: brandingLogo
760
+ }) : null,
761
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
762
+ className: "polyx-signin__heading",
763
+ children: HEADINGS[step].heading
764
+ }),
765
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
766
+ className: "polyx-signin__subheading",
767
+ children: HEADINGS[step].subheading
768
+ })
769
+ ]
770
+ });
771
+ const errorNode = error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
772
+ role: "alert",
773
+ className: "polyx-signin__error",
774
+ children: error
775
+ }) : null;
776
+ const footer = props.showSecuredBy === false ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
777
+ className: "polyx-signin__footer",
778
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
779
+ className: "polyx-signin__shield",
780
+ viewBox: "0 0 16 16",
781
+ fill: "currentColor",
782
+ "aria-hidden": "true",
783
+ focusable: "false",
784
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M8 0.5 2 3v4.2c0 3.5 2.5 6.7 6 7.8 3.5-1.1 6-4.3 6-7.8V3L8 .5Zm2.9 5.6-3.4 3.4a.7.7 0 0 1-1 0L5.1 8.1a.7.7 0 1 1 1-1l.9.9 2.9-2.9a.7.7 0 0 1 1 1Z" })
785
+ }), labels.securedBy]
786
+ });
787
+ const tenantPicker = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
788
+ className: "polyx-signin__form",
789
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
790
+ className: "polyx-signin__tenants",
791
+ children: (tenants ?? []).map((tenant) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
792
+ type: "button",
793
+ className: "polyx-signin__tenant",
794
+ disabled: submitting,
795
+ onClick: () => void authenticate({ tenantId: tenant.tenantId }),
796
+ children: tenant.name ?? tenant.slug ?? tenant.organizationCode ?? tenant.tenantId
797
+ }) }, tenant.tenantId))
798
+ }), errorNode]
799
+ });
800
+ const setPasswordForm = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
801
+ className: "polyx-signin__form",
802
+ onSubmit: onSetPasswordSubmit,
803
+ children: [
804
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordField, {
805
+ id: "polyx-signin-new-password",
806
+ label: labels.newPasswordLabel,
807
+ name: "newPassword",
808
+ autoComplete: "new-password",
809
+ placeholder: labels.passwordPlaceholder,
810
+ minLength: MIN_PASSWORD_LENGTH,
811
+ value: newPassword,
812
+ disabled: submitting,
813
+ onChange: setNewPassword,
814
+ showLabel: labels.showPassword,
815
+ hideLabel: labels.hidePassword
816
+ }),
817
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordField, {
818
+ id: "polyx-signin-confirm-password",
819
+ label: labels.confirmPasswordLabel,
820
+ name: "confirmPassword",
821
+ autoComplete: "new-password",
822
+ placeholder: labels.passwordPlaceholder,
823
+ minLength: MIN_PASSWORD_LENGTH,
824
+ value: confirmPassword,
825
+ disabled: submitting,
826
+ onChange: setConfirmPassword,
827
+ showLabel: labels.showPassword,
828
+ hideLabel: labels.hidePassword
829
+ }),
830
+ errorNode,
831
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
832
+ type: "submit",
833
+ className: "polyx-signin__submit",
834
+ disabled: submitting,
835
+ children: submitting ? labels.submitting : labels.setPasswordSubmit
836
+ })
837
+ ]
838
+ });
839
+ const card = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
840
+ className: "polyx-signin__card",
841
+ children: [
842
+ header,
843
+ step === "select_tenant" ? tenantPicker : step === "set_password" ? setPasswordForm : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
844
+ className: "polyx-signin__form",
845
+ onSubmit,
846
+ children: [
847
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
848
+ className: "polyx-signin__field",
849
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
850
+ className: "polyx-signin__label",
851
+ children: labels.emailLabel
852
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
853
+ className: "polyx-signin__input",
854
+ type: "email",
855
+ name: "email",
856
+ autoComplete: "username",
857
+ placeholder: labels.emailPlaceholder,
858
+ required: true,
859
+ value: email,
860
+ disabled: submitting,
861
+ onChange: (event) => setEmail(event.target.value)
862
+ })]
863
+ }),
864
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordField, {
865
+ id: "polyx-signin-password",
866
+ label: labels.passwordLabel,
867
+ name: "password",
868
+ autoComplete: "current-password",
869
+ placeholder: labels.passwordPlaceholder,
870
+ value: password,
871
+ disabled: submitting,
872
+ onChange: setPassword,
873
+ showLabel: labels.showPassword,
874
+ hideLabel: labels.hidePassword
875
+ }),
876
+ props.forgotPasswordUrl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
877
+ className: "polyx-signin__forgot",
878
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
879
+ className: "polyx-signin__link",
880
+ href: props.forgotPasswordUrl,
881
+ children: labels.forgotPassword
882
+ })
883
+ }) : null,
884
+ errorNode,
885
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
886
+ type: "submit",
887
+ className: "polyx-signin__submit",
888
+ disabled: submitting,
889
+ children: submitting ? labels.submitting : labels.submit
890
+ })
891
+ ]
892
+ }),
893
+ footer
894
+ ]
895
+ });
896
+ if (variant === "page") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
897
+ className: rootClass,
898
+ "data-polyx-signin": step,
899
+ style: brandingStyle,
900
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
901
+ className: "polyx-signin__panel",
902
+ children: props.panel ?? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [brandingLogo ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
903
+ className: "polyx-signin__panel-logo",
904
+ children: brandingLogo
905
+ }) : null, labels.tagline ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
906
+ className: "polyx-signin__tagline",
907
+ children: labels.tagline
908
+ }) : null] })
909
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
910
+ className: "polyx-signin__main",
911
+ children: card
912
+ })]
913
+ });
914
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
915
+ className: rootClass,
916
+ "data-polyx-signin": step,
917
+ style: brandingStyle,
918
+ children: card
919
+ });
920
+ }
921
+ //#endregion
922
+ //#region src/components/_recovery-status.tsx
923
+ const ICONS = {
924
+ mail: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
925
+ viewBox: "0 0 24 24",
926
+ fill: "none",
927
+ stroke: "currentColor",
928
+ strokeWidth: "1.75",
929
+ "aria-hidden": "true",
930
+ focusable: "false",
931
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
932
+ x: "3",
933
+ y: "5",
934
+ width: "18",
935
+ height: "14",
936
+ rx: "2.5"
937
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
938
+ d: "m4 7 8 6 8-6",
939
+ strokeLinecap: "round",
940
+ strokeLinejoin: "round"
941
+ })]
942
+ }),
943
+ check: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
944
+ viewBox: "0 0 24 24",
945
+ fill: "none",
946
+ stroke: "currentColor",
947
+ strokeWidth: "2",
948
+ "aria-hidden": "true",
949
+ focusable: "false",
950
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
951
+ d: "m5 12.5 4.5 4.5L19 7",
952
+ strokeLinecap: "round",
953
+ strokeLinejoin: "round"
954
+ })
955
+ }),
956
+ warning: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
957
+ viewBox: "0 0 24 24",
958
+ fill: "none",
959
+ stroke: "currentColor",
960
+ strokeWidth: "1.75",
961
+ "aria-hidden": "true",
962
+ focusable: "false",
963
+ children: [
964
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
965
+ cx: "12",
966
+ cy: "12",
967
+ r: "9"
968
+ }),
969
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
970
+ d: "M12 7.5v5",
971
+ strokeLinecap: "round"
972
+ }),
973
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
974
+ cx: "12",
975
+ cy: "16",
976
+ r: "0.6",
977
+ fill: "currentColor",
978
+ stroke: "none"
979
+ })
980
+ ]
981
+ })
982
+ };
983
+ /**
984
+ * A centered, icon-topped confirmation card — the shape every recovery terminal
985
+ * state shares (link sent, password updated, link expired). Reuses the `<SignIn/>`
986
+ * class anatomy so it themes from the same `--polyx-*` custom properties.
987
+ */
988
+ function RecoveryStatus(props) {
989
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
990
+ className: "polyx-signin__card",
991
+ children: [
992
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
993
+ className: "polyx-signin__header polyx-signin__header--center",
994
+ children: [
995
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
996
+ className: `polyx-signin__status-icon polyx-signin__status-icon--${props.tone ?? "brand"}`,
997
+ children: ICONS[props.icon]
998
+ }),
999
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
1000
+ className: "polyx-signin__heading",
1001
+ children: props.heading
1002
+ }),
1003
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1004
+ className: "polyx-signin__subheading",
1005
+ children: props.children
1006
+ })
1007
+ ]
1008
+ }),
1009
+ props.actions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1010
+ className: "polyx-signin__actions",
1011
+ children: props.actions
1012
+ }) : null,
1013
+ props.footer
1014
+ ]
1015
+ });
1016
+ }
1017
+ //#endregion
1018
+ //#region src/components/forgot-password.tsx
1019
+ const DEFAULT_LABELS$2 = {
1020
+ heading: "Reset your password",
1021
+ subheading: "Enter your email and we'll send you a reset link.",
1022
+ emailLabel: "Email",
1023
+ emailPlaceholder: "you@company.com",
1024
+ submit: "Send reset link",
1025
+ submitting: "Sending…",
1026
+ sentHeading: "Check your email",
1027
+ sentSubheading: "If an account exists for {email}, a password reset link is on its way. It expires in 30 minutes.",
1028
+ differentEmail: "Use a different email",
1029
+ backToSignIn: "Back to sign in",
1030
+ securedBy: "Secured by PolyX",
1031
+ genericError: "Something went wrong. Please try again."
1032
+ };
1033
+ /** Splits a label on `{email}` and drops the entered address in, emphasized. */
1034
+ function withEmail(template, email) {
1035
+ return template.split("{email}").map((chunk, index, all) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [chunk, index < all.length - 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1036
+ className: "polyx-signin__email",
1037
+ children: email || "that address"
1038
+ }) : null] }, index));
1039
+ }
1040
+ /**
1041
+ * The self-service "forgot password" form (poly-x v5 / F040). Renders an email field
1042
+ * inside the consuming app and POSTs to the SDK's BFF (`@poly-x/next` `forgotPassword`),
1043
+ * which asks poly-auth to email a single-use reset link SERVER-SIDE. The response is
1044
+ * always the same — no token, no account-existence signal — so after submit the form
1045
+ * shows an identical "check your email" state whether or not the account exists.
1046
+ *
1047
+ * Reuses the `<SignIn/>` styling: `import "@poly-x/react/styles.css"` once, then theme
1048
+ * via the `--polyx-*` custom properties. Target `.polyx-forgot` for form-specific tweaks.
1049
+ */
1050
+ function ForgotPassword(props) {
1051
+ const action = props.action ?? "/api/polyx/forgot-password";
1052
+ const signInPath = props.signInPath ?? "/sign-in";
1053
+ const labels = {
1054
+ ...DEFAULT_LABELS$2,
1055
+ ...props.labels
1056
+ };
1057
+ const [email, setEmail] = (0, react.useState)("");
1058
+ const [submitting, setSubmitting] = (0, react.useState)(false);
1059
+ const [sent, setSent] = (0, react.useState)(false);
1060
+ const [error, setError] = (0, react.useState)(null);
1061
+ async function onSubmit(event) {
1062
+ event.preventDefault();
1063
+ setSubmitting(true);
1064
+ setError(null);
1065
+ try {
1066
+ if ((await (await fetch(action, {
1067
+ method: "POST",
1068
+ headers: { "content-type": "application/json" },
1069
+ body: JSON.stringify({ email })
1070
+ })).json().catch(() => ({}))).status === "accepted") {
1071
+ setSent(true);
1072
+ return;
1073
+ }
1074
+ setError(labels.genericError);
1075
+ } catch {
1076
+ setError(labels.genericError);
1077
+ } finally {
1078
+ setSubmitting(false);
1079
+ }
1080
+ }
1081
+ const rootClass = [
1082
+ "polyx-signin",
1083
+ "polyx-forgot",
1084
+ props.className
1085
+ ].filter(Boolean).join(" ");
1086
+ const footer = props.showSecuredBy === false ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
1087
+ className: "polyx-signin__footer",
1088
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1089
+ className: "polyx-signin__shield",
1090
+ viewBox: "0 0 16 16",
1091
+ fill: "currentColor",
1092
+ "aria-hidden": "true",
1093
+ focusable: "false",
1094
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M8 0.5 2 3v4.2c0 3.5 2.5 6.7 6 7.8 3.5-1.1 6-4.3 6-7.8V3L8 .5Zm2.9 5.6-3.4 3.4a.7.7 0 0 1-1 0L5.1 8.1a.7.7 0 1 1 1-1l.9.9 2.9-2.9a.7.7 0 0 1 1 1Z" })
1095
+ }), labels.securedBy]
1096
+ });
1097
+ const header = (heading, subheading) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1098
+ className: "polyx-signin__header",
1099
+ children: [
1100
+ props.logo ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1101
+ className: "polyx-signin__logo",
1102
+ children: props.logo
1103
+ }) : null,
1104
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
1105
+ className: "polyx-signin__heading",
1106
+ children: heading
1107
+ }),
1108
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1109
+ className: "polyx-signin__subheading",
1110
+ children: subheading
1111
+ })
1112
+ ]
1113
+ });
1114
+ if (sent) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1115
+ className: rootClass,
1116
+ "data-polyx-forgot": "sent",
1117
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RecoveryStatus, {
1118
+ icon: "mail",
1119
+ heading: labels.sentHeading,
1120
+ footer,
1121
+ actions: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1122
+ type: "button",
1123
+ className: "polyx-signin__link",
1124
+ onClick: () => setSent(false),
1125
+ children: labels.differentEmail
1126
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1127
+ className: "polyx-signin__link",
1128
+ href: signInPath,
1129
+ children: labels.backToSignIn
1130
+ })] }),
1131
+ children: withEmail(labels.sentSubheading, email)
1132
+ })
1133
+ });
1134
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1135
+ className: rootClass,
1136
+ "data-polyx-forgot": "request",
1137
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1138
+ className: "polyx-signin__card",
1139
+ children: [
1140
+ header(labels.heading, labels.subheading),
1141
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
1142
+ className: "polyx-signin__form",
1143
+ onSubmit,
1144
+ children: [
1145
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1146
+ className: "polyx-signin__field",
1147
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1148
+ className: "polyx-signin__label",
1149
+ children: labels.emailLabel
1150
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1151
+ className: "polyx-signin__input",
1152
+ type: "email",
1153
+ name: "email",
1154
+ autoComplete: "username",
1155
+ placeholder: labels.emailPlaceholder,
1156
+ required: true,
1157
+ value: email,
1158
+ disabled: submitting,
1159
+ onChange: (event) => setEmail(event.target.value)
1160
+ })]
1161
+ }),
1162
+ error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1163
+ role: "alert",
1164
+ className: "polyx-signin__error",
1165
+ children: error
1166
+ }) : null,
1167
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1168
+ type: "submit",
1169
+ className: "polyx-signin__submit",
1170
+ disabled: submitting,
1171
+ children: submitting ? labels.submitting : labels.submit
1172
+ })
1173
+ ]
1174
+ }),
1175
+ footer
1176
+ ]
1177
+ })
1178
+ });
1179
+ }
1180
+ //#endregion
1181
+ //#region src/components/reset-password.tsx
1182
+ const DEFAULT_LABELS$1 = {
1183
+ heading: "Choose a new password",
1184
+ subheading: "Enter and confirm your new password.",
1185
+ newPasswordLabel: "New password",
1186
+ confirmPasswordLabel: "Confirm new password",
1187
+ passwordPlaceholder: "••••••••",
1188
+ submit: "Reset password",
1189
+ submitting: "Resetting…",
1190
+ successHeading: "Password updated",
1191
+ successSubheading: "You can now sign in with your new password.",
1192
+ invalidHeading: "This link is invalid or expired",
1193
+ invalidSubheading: "Password reset links can be used once and expire quickly. Request a new one.",
1194
+ requestNewLink: "Request a new link",
1195
+ backToSignIn: "Back to sign in",
1196
+ securedBy: "Secured by PolyX",
1197
+ passwordMismatch: "Those passwords don't match.",
1198
+ weakPassword: "Password must be at least 8 characters.",
1199
+ genericError: "Something went wrong. Please try again."
1200
+ };
1201
+ /** Matches poly-auth's v5 reset floor (F040). */
1202
+ const DEFAULT_MIN_LENGTH = 8;
1203
+ /**
1204
+ * The reset-completion form (poly-x v5 / F040). Reads the opaque token from the URL,
1205
+ * collects a new password, and POSTs to the SDK's BFF (`@poly-x/next` `resetPassword`),
1206
+ * which redeems the token single-use server-side. The token is never decoded in the
1207
+ * browser — identity, validity, and expiry are all enforced by the backend.
1208
+ *
1209
+ * Reuses the `<SignIn/>` styling: `import "@poly-x/react/styles.css"` once, then theme
1210
+ * via the `--polyx-*` custom properties. Target `.polyx-reset` for form-specific tweaks.
1211
+ */
1212
+ function ResetPassword(props) {
1213
+ const action = props.action ?? "/api/polyx/reset-password";
1214
+ const minLength = props.minLength ?? DEFAULT_MIN_LENGTH;
1215
+ const signInPath = props.signInPath ?? "/sign-in";
1216
+ const forgotPasswordPath = props.forgotPasswordPath ?? "/forgot-password";
1217
+ const labels = {
1218
+ ...DEFAULT_LABELS$1,
1219
+ ...props.labels
1220
+ };
1221
+ const [token] = (0, react.useState)(() => props.token ?? (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") ?? "" : ""));
1222
+ const [newPassword, setNewPassword] = (0, react.useState)("");
1223
+ const [confirmPassword, setConfirmPassword] = (0, react.useState)("");
1224
+ const [submitting, setSubmitting] = (0, react.useState)(false);
1225
+ const [error, setError] = (0, react.useState)(null);
1226
+ const [step, setStep] = (0, react.useState)(token ? "form" : "invalid");
1227
+ async function onSubmit(event) {
1228
+ event.preventDefault();
1229
+ if (newPassword !== confirmPassword) {
1230
+ setError(labels.passwordMismatch);
1231
+ return;
1232
+ }
1233
+ setSubmitting(true);
1234
+ setError(null);
1235
+ try {
1236
+ switch ((await (await fetch(action, {
1237
+ method: "POST",
1238
+ headers: { "content-type": "application/json" },
1239
+ body: JSON.stringify({
1240
+ token,
1241
+ newPassword,
1242
+ confirmPassword
1243
+ })
1244
+ })).json().catch(() => ({}))).status) {
1245
+ case "success":
1246
+ setStep("success");
1247
+ if (props.afterResetPath) window.location.assign(props.afterResetPath);
1248
+ return;
1249
+ case "weak_password":
1250
+ setError(labels.weakPassword);
1251
+ return;
1252
+ case "password_mismatch":
1253
+ setError(labels.passwordMismatch);
1254
+ return;
1255
+ case "invalid_or_expired":
1256
+ setStep("invalid");
1257
+ return;
1258
+ default:
1259
+ setError(labels.genericError);
1260
+ return;
1261
+ }
1262
+ } catch {
1263
+ setError(labels.genericError);
1264
+ } finally {
1265
+ setSubmitting(false);
1266
+ }
1267
+ }
1268
+ const rootClass = [
1269
+ "polyx-signin",
1270
+ "polyx-reset",
1271
+ props.className
1272
+ ].filter(Boolean).join(" ");
1273
+ const footer = props.showSecuredBy === false ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
1274
+ className: "polyx-signin__footer",
1275
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1276
+ className: "polyx-signin__shield",
1277
+ viewBox: "0 0 16 16",
1278
+ fill: "currentColor",
1279
+ "aria-hidden": "true",
1280
+ focusable: "false",
1281
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M8 0.5 2 3v4.2c0 3.5 2.5 6.7 6 7.8 3.5-1.1 6-4.3 6-7.8V3L8 .5Zm2.9 5.6-3.4 3.4a.7.7 0 0 1-1 0L5.1 8.1a.7.7 0 1 1 1-1l.9.9 2.9-2.9a.7.7 0 0 1 1 1Z" })
1282
+ }), labels.securedBy]
1283
+ });
1284
+ const header = (heading, subheading) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1285
+ className: "polyx-signin__header",
1286
+ children: [
1287
+ props.logo ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1288
+ className: "polyx-signin__logo",
1289
+ children: props.logo
1290
+ }) : null,
1291
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
1292
+ className: "polyx-signin__heading",
1293
+ children: heading
1294
+ }),
1295
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1296
+ className: "polyx-signin__subheading",
1297
+ children: subheading
1298
+ })
1299
+ ]
1300
+ });
1301
+ if (step === "success") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1302
+ className: rootClass,
1303
+ "data-polyx-reset": "success",
1304
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RecoveryStatus, {
1305
+ icon: "check",
1306
+ heading: labels.successHeading,
1307
+ footer,
1308
+ actions: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1309
+ className: "polyx-signin__link",
1310
+ href: signInPath,
1311
+ children: labels.backToSignIn
1312
+ }),
1313
+ children: labels.successSubheading
1314
+ })
1315
+ });
1316
+ if (step === "invalid") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1317
+ className: rootClass,
1318
+ "data-polyx-reset": "invalid",
1319
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RecoveryStatus, {
1320
+ icon: "warning",
1321
+ tone: "danger",
1322
+ heading: labels.invalidHeading,
1323
+ footer,
1324
+ actions: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1325
+ className: "polyx-signin__link",
1326
+ href: forgotPasswordPath,
1327
+ children: labels.requestNewLink
1328
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1329
+ className: "polyx-signin__link",
1330
+ href: signInPath,
1331
+ children: labels.backToSignIn
1332
+ })] }),
1333
+ children: labels.invalidSubheading
1334
+ })
1335
+ });
1336
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1337
+ className: rootClass,
1338
+ "data-polyx-reset": step,
1339
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1340
+ className: "polyx-signin__card",
1341
+ children: [
1342
+ header(labels.heading, labels.subheading),
1343
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
1344
+ className: "polyx-signin__form",
1345
+ onSubmit,
1346
+ children: [
1347
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1348
+ className: "polyx-signin__field",
1349
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1350
+ className: "polyx-signin__label",
1351
+ children: labels.newPasswordLabel
1352
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1353
+ className: "polyx-signin__input",
1354
+ type: "password",
1355
+ name: "newPassword",
1356
+ autoComplete: "new-password",
1357
+ placeholder: labels.passwordPlaceholder,
1358
+ required: true,
1359
+ minLength,
1360
+ value: newPassword,
1361
+ disabled: submitting,
1362
+ onChange: (event) => setNewPassword(event.target.value)
1363
+ })]
1364
+ }),
1365
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1366
+ className: "polyx-signin__field",
1367
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1368
+ className: "polyx-signin__label",
1369
+ children: labels.confirmPasswordLabel
1370
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1371
+ className: "polyx-signin__input",
1372
+ type: "password",
1373
+ name: "confirmPassword",
1374
+ autoComplete: "new-password",
1375
+ placeholder: labels.passwordPlaceholder,
1376
+ required: true,
1377
+ minLength,
1378
+ value: confirmPassword,
1379
+ disabled: submitting,
1380
+ onChange: (event) => setConfirmPassword(event.target.value)
1381
+ })]
1382
+ }),
1383
+ error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1384
+ role: "alert",
1385
+ className: "polyx-signin__error",
1386
+ children: error
1387
+ }) : null,
1388
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1389
+ type: "submit",
1390
+ className: "polyx-signin__submit",
1391
+ disabled: submitting,
1392
+ children: submitting ? labels.submitting : labels.submit
1393
+ })
1394
+ ]
1395
+ }),
1396
+ footer
1397
+ ]
1398
+ })
363
1399
  });
364
1400
  }
365
1401
  //#endregion
@@ -373,6 +1409,442 @@ function AuthCallback({ children = null }) {
373
1409
  return children;
374
1410
  }
375
1411
  //#endregion
1412
+ //#region src/components/placement.ts
1413
+ const OPPOSITE = {
1414
+ top: "bottom",
1415
+ bottom: "top",
1416
+ left: "right",
1417
+ right: "left"
1418
+ };
1419
+ /** Preference order when nothing is requested: vertical reads better for a menu than sideways. */
1420
+ const AUTO_ORDER = [
1421
+ "bottom",
1422
+ "top",
1423
+ "right",
1424
+ "left"
1425
+ ];
1426
+ /** Room between the trigger and each viewport edge. */
1427
+ function spaceAround(trigger, viewport) {
1428
+ return {
1429
+ top: trigger.top,
1430
+ bottom: viewport.height - trigger.bottom,
1431
+ left: trigger.left,
1432
+ right: viewport.width - trigger.right
1433
+ };
1434
+ }
1435
+ function required(menu, gap) {
1436
+ return {
1437
+ top: menu.height + gap,
1438
+ bottom: menu.height + gap,
1439
+ left: menu.width + gap,
1440
+ right: menu.width + gap
1441
+ };
1442
+ }
1443
+ /**
1444
+ * Which side the menu should open on.
1445
+ *
1446
+ * An explicit side is honoured when it fits and flipped to its opposite when it doesn't — a
1447
+ * requested side that runs off-screen is a worse answer than the one that doesn't. `auto` takes
1448
+ * the first side that fits, and if none do, the roomiest: something has to be chosen, and the
1449
+ * least-bad option beats an arbitrary default.
1450
+ */
1451
+ function resolveSide(preferred, trigger, menu, viewport, gap = 8) {
1452
+ const space = spaceAround(trigger, viewport);
1453
+ const need = required(menu, gap);
1454
+ const fits = (side) => space[side] >= need[side];
1455
+ if (preferred !== "auto") {
1456
+ if (fits(preferred)) return preferred;
1457
+ const opposite = OPPOSITE[preferred];
1458
+ return fits(opposite) ? opposite : preferred;
1459
+ }
1460
+ const firstFitting = AUTO_ORDER.find(fits);
1461
+ if (firstFitting) return firstFitting;
1462
+ return AUTO_ORDER.reduce((best, side) => space[side] > space[best] ? side : best, AUTO_ORDER[0]);
1463
+ }
1464
+ //#endregion
1465
+ //#region src/components/user-avatar.tsx
1466
+ /**
1467
+ * Up to two initials from a display name. Handles the shapes the platform actually
1468
+ * produces — "Ali Ikram", a bare username, an email address.
1469
+ */
1470
+ function initialsFrom(name) {
1471
+ const source = (name ?? "").trim();
1472
+ if (source.length === 0) return "?";
1473
+ const words = (source.includes("@") ? source.split("@")[0] : source).split(/[\s._-]+/).filter(Boolean);
1474
+ if (words.length === 0) return "?";
1475
+ return (words.length === 1 ? [words[0][0]] : [words[0][0], words[words.length - 1][0]]).join("").toUpperCase();
1476
+ }
1477
+ /**
1478
+ * The user's picture, or their initials. A missing avatar is the ordinary case rather than
1479
+ * an error, so initials are a first-class state, not a broken image.
1480
+ */
1481
+ function UserAvatar({ src, name, size = 32, className }) {
1482
+ const rootClass = ["polyx-userbutton__avatar", className].filter(Boolean).join(" ");
1483
+ const style = {
1484
+ width: `${size}px`,
1485
+ height: `${size}px`
1486
+ };
1487
+ if (src) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
1488
+ className: rootClass,
1489
+ style,
1490
+ src,
1491
+ alt: name ?? ""
1492
+ });
1493
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1494
+ className: rootClass,
1495
+ style,
1496
+ "aria-hidden": "true",
1497
+ children: initialsFrom(name)
1498
+ });
1499
+ }
1500
+ //#endregion
1501
+ //#region src/components/user-button.tsx
1502
+ const DEFAULT_LABELS = {
1503
+ trigger: "Account menu",
1504
+ manageAccount: "Manage account",
1505
+ signOut: "Sign out",
1506
+ signOutEverywhere: "Sign out everywhere"
1507
+ };
1508
+ const BUILT_INS = [
1509
+ "manageAccount",
1510
+ "signOut",
1511
+ "signOutEverywhere"
1512
+ ];
1513
+ function isBuiltIn(label) {
1514
+ return BUILT_INS.includes(label);
1515
+ }
1516
+ /**
1517
+ * Declarative markers. `<UserButton/>` reads their props off the element tree and renders the
1518
+ * menu itself, so these never render anything. Their public prop types come from the signatures
1519
+ * declared on the exported object below.
1520
+ *
1521
+ * `Custom` and `Header` take arbitrary nodes on purpose: an app adopting this component in place
1522
+ * of its own user menu has to be able to bring its own UI, or it won't adopt it. That is
1523
+ * composition, not the style injection FR-BRAND-1 guards against — a consumer renders their own
1524
+ * subtree in a slot; they still cannot restyle the SDK's own chrome.
1525
+ */
1526
+ function MenuItems() {
1527
+ return null;
1528
+ }
1529
+ function Action() {
1530
+ return null;
1531
+ }
1532
+ function Link() {
1533
+ return null;
1534
+ }
1535
+ function Custom() {
1536
+ return null;
1537
+ }
1538
+ function Header() {
1539
+ return null;
1540
+ }
1541
+ /**
1542
+ * Read the declarative children into a flat item list. A custom entry naming a built-in
1543
+ * *moves* it; unnamed built-ins keep their default order at the end. This is the whole reason
1544
+ * the API is declarative rather than a config array: it composes without letting a consumer
1545
+ * inject arbitrary markup or styles into the menu (FR-BRAND-1).
1546
+ */
1547
+ function resolveItems(children, builtIns) {
1548
+ const supplied = [];
1549
+ const placed = /* @__PURE__ */ new Set();
1550
+ react.Children.forEach(children, (child) => {
1551
+ if (!(0, react.isValidElement)(child) || child.type !== MenuItems) return;
1552
+ react.Children.forEach(child.props.children, (item, index) => {
1553
+ if (!(0, react.isValidElement)(item)) return;
1554
+ if (item.type === Action) {
1555
+ const props = item.props;
1556
+ if (isBuiltIn(props.label)) {
1557
+ const builtIn = builtIns.get(props.label);
1558
+ if (builtIn) {
1559
+ supplied.push(builtIn);
1560
+ placed.add(props.label);
1561
+ }
1562
+ return;
1563
+ }
1564
+ supplied.push({
1565
+ key: `action-${index}`,
1566
+ label: props.label,
1567
+ labelIcon: props.labelIcon,
1568
+ onClick: props.onClick
1569
+ });
1570
+ return;
1571
+ }
1572
+ if (item.type === Link) {
1573
+ const props = item.props;
1574
+ supplied.push({
1575
+ key: `link-${index}`,
1576
+ label: props.label,
1577
+ labelIcon: props.labelIcon,
1578
+ href: props.href
1579
+ });
1580
+ return;
1581
+ }
1582
+ if (item.type === Custom) supplied.push({
1583
+ key: `custom-${index}`,
1584
+ custom: item.props.children
1585
+ });
1586
+ });
1587
+ });
1588
+ const remaining = [...builtIns.entries()].filter(([name]) => !placed.has(name)).map(([, item]) => item);
1589
+ return [...supplied, ...remaining];
1590
+ }
1591
+ /** The consumer's replacement for the identity block, if they supplied one. */
1592
+ function findHeader(children) {
1593
+ let header;
1594
+ react.Children.forEach(children, (child) => {
1595
+ if ((0, react.isValidElement)(child) && child.type === Header) header = child.props.children;
1596
+ });
1597
+ return header;
1598
+ }
1599
+ function UserButtonRoot(props) {
1600
+ const labels = {
1601
+ ...DEFAULT_LABELS,
1602
+ ...props.labels
1603
+ };
1604
+ const { isLoaded, isSignedIn, signOut } = useAuth();
1605
+ const user = useUser();
1606
+ const [open, setOpen] = (0, react.useState)(props.defaultOpen ?? false);
1607
+ const [focused, setFocused] = (0, react.useState)(0);
1608
+ const [side, setSide] = (0, react.useState)(props.side && props.side !== "auto" ? props.side : "bottom");
1609
+ const triggerRef = (0, react.useRef)(null);
1610
+ const menuRef = (0, react.useRef)(null);
1611
+ const itemRefs = (0, react.useRef)([]);
1612
+ const menuId = (0, react.useId)();
1613
+ const align = props.align ?? "end";
1614
+ const close = (0, react.useCallback)((returnFocus) => {
1615
+ setOpen(false);
1616
+ if (returnFocus) triggerRef.current?.focus();
1617
+ }, []);
1618
+ (0, react.useEffect)(() => {
1619
+ if (!open) return;
1620
+ const onKeyDown = (event) => {
1621
+ if (event.key === "Escape") close(true);
1622
+ };
1623
+ const onPointerDown = (event) => {
1624
+ const root = triggerRef.current?.closest(".polyx-userbutton");
1625
+ if (root && !root.contains(event.target)) close(false);
1626
+ };
1627
+ document.addEventListener("keydown", onKeyDown);
1628
+ document.addEventListener("mousedown", onPointerDown);
1629
+ return () => {
1630
+ document.removeEventListener("keydown", onKeyDown);
1631
+ document.removeEventListener("mousedown", onPointerDown);
1632
+ };
1633
+ }, [open, close]);
1634
+ (0, react.useEffect)(() => {
1635
+ if (open) itemRefs.current[focused]?.focus();
1636
+ }, [open, focused]);
1637
+ /**
1638
+ * Choose the side once the menu exists and can be measured. `useLayoutEffect` runs before
1639
+ * paint, so the correction never shows as a jump — the menu is only ever painted where it
1640
+ * belongs. Re-measured on resize and on scroll, since either can invalidate the choice.
1641
+ */
1642
+ (0, react.useLayoutEffect)(() => {
1643
+ if (!open) return;
1644
+ const place = () => {
1645
+ const trigger = triggerRef.current?.getBoundingClientRect();
1646
+ const menu = menuRef.current?.getBoundingClientRect();
1647
+ if (!trigger || !menu) return;
1648
+ setSide(resolveSide(props.side ?? "auto", trigger, {
1649
+ width: menu.width,
1650
+ height: menu.height
1651
+ }, {
1652
+ width: window.innerWidth,
1653
+ height: window.innerHeight
1654
+ }));
1655
+ };
1656
+ place();
1657
+ window.addEventListener("resize", place);
1658
+ window.addEventListener("scroll", place, true);
1659
+ return () => {
1660
+ window.removeEventListener("resize", place);
1661
+ window.removeEventListener("scroll", place, true);
1662
+ };
1663
+ }, [open, props.side]);
1664
+ if (!isLoaded) return props.fallback ?? null;
1665
+ if (!isSignedIn || !user) return null;
1666
+ const name = user.displayName ?? user.email ?? "";
1667
+ const builtIns = /* @__PURE__ */ new Map();
1668
+ if (props.manageAccountUrl) builtIns.set("manageAccount", {
1669
+ key: "manageAccount",
1670
+ label: labels.manageAccount,
1671
+ labelIcon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GearIcon, {}),
1672
+ href: props.manageAccountUrl
1673
+ });
1674
+ builtIns.set("signOut", {
1675
+ key: "signOut",
1676
+ label: labels.signOut,
1677
+ labelIcon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExitIcon, {}),
1678
+ onClick: () => void signOut({ redirectTo: props.afterSignOutUrl })
1679
+ });
1680
+ if (props.showSignOutEverywhere) builtIns.set("signOutEverywhere", {
1681
+ key: "signOutEverywhere",
1682
+ label: labels.signOutEverywhere,
1683
+ labelIcon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExitIcon, {}),
1684
+ onClick: () => void signOut({
1685
+ scope: "everywhere",
1686
+ redirectTo: props.afterSignOutUrl
1687
+ })
1688
+ });
1689
+ const items = resolveItems(props.children, builtIns);
1690
+ const customHeader = findHeader(props.children);
1691
+ const navigable = items.map((item, index) => ({
1692
+ item,
1693
+ index
1694
+ })).filter(({ item }) => !item.custom);
1695
+ const onMenuKeyDown = (event) => {
1696
+ if (navigable.length === 0) return;
1697
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
1698
+ event.preventDefault();
1699
+ const next = (navigable.findIndex(({ index }) => index === focused) + (event.key === "ArrowDown" ? 1 : -1) + navigable.length) % navigable.length;
1700
+ setFocused(navigable[next].index);
1701
+ };
1702
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1703
+ className: [
1704
+ "polyx-signin",
1705
+ "polyx-userbutton",
1706
+ props.className
1707
+ ].filter(Boolean).join(" "),
1708
+ "data-polyx-userbutton": open ? "open" : "closed",
1709
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1710
+ ref: triggerRef,
1711
+ type: "button",
1712
+ className: "polyx-userbutton__trigger",
1713
+ "aria-haspopup": "menu",
1714
+ "aria-expanded": open,
1715
+ "aria-controls": open ? menuId : void 0,
1716
+ "aria-label": labels.trigger,
1717
+ onClick: () => {
1718
+ setFocused(0);
1719
+ setOpen((current) => !current);
1720
+ },
1721
+ children: props.trigger ?? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UserAvatar, {
1722
+ src: user.avatarUrl,
1723
+ name,
1724
+ size: props.avatarSize
1725
+ }), props.showName ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1726
+ className: "polyx-userbutton__trigger-name",
1727
+ children: name
1728
+ }) : null] })
1729
+ }), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1730
+ ref: menuRef,
1731
+ id: menuId,
1732
+ role: "menu",
1733
+ className: "polyx-userbutton__menu",
1734
+ "data-polyx-side": side,
1735
+ "data-polyx-align": align,
1736
+ onKeyDown: onMenuKeyDown,
1737
+ children: [customHeader ?? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1738
+ className: "polyx-userbutton__identity",
1739
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UserAvatar, {
1740
+ src: user.avatarUrl,
1741
+ name,
1742
+ size: 36
1743
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1744
+ className: "polyx-userbutton__identity-text",
1745
+ children: [user.displayName ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1746
+ className: "polyx-userbutton__name",
1747
+ children: user.displayName
1748
+ }) : null, user.email ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1749
+ className: "polyx-userbutton__email",
1750
+ children: user.email
1751
+ }) : null]
1752
+ })]
1753
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
1754
+ className: "polyx-userbutton__items",
1755
+ children: items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: item.custom ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1756
+ className: "polyx-userbutton__custom",
1757
+ children: item.custom
1758
+ }) : item.href ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
1759
+ ref: (node) => {
1760
+ itemRefs.current[index] = node;
1761
+ },
1762
+ role: "menuitem",
1763
+ tabIndex: index === focused ? 0 : -1,
1764
+ className: "polyx-userbutton__item",
1765
+ href: item.href,
1766
+ onClick: () => close(false),
1767
+ children: [item.labelIcon, item.label]
1768
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1769
+ ref: (node) => {
1770
+ itemRefs.current[index] = node;
1771
+ },
1772
+ role: "menuitem",
1773
+ tabIndex: index === focused ? 0 : -1,
1774
+ type: "button",
1775
+ className: "polyx-userbutton__item",
1776
+ onClick: () => {
1777
+ close(false);
1778
+ item.onClick?.();
1779
+ },
1780
+ children: [item.labelIcon, item.label]
1781
+ }) }, item.key))
1782
+ })]
1783
+ }) : null]
1784
+ });
1785
+ }
1786
+ function GearIcon() {
1787
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
1788
+ className: "polyx-userbutton__icon",
1789
+ viewBox: "0 0 16 16",
1790
+ fill: "none",
1791
+ "aria-hidden": "true",
1792
+ focusable: "false",
1793
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
1794
+ cx: "8",
1795
+ cy: "8",
1796
+ r: "2.25",
1797
+ stroke: "currentColor",
1798
+ strokeWidth: "1.3"
1799
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1800
+ d: "M8 1.75v1.5M8 12.75v1.5M14.25 8h-1.5M3.25 8h-1.5M12.42 3.58l-1.06 1.06M4.64 11.36l-1.06 1.06M12.42 12.42l-1.06-1.06M4.64 4.64L3.58 3.58",
1801
+ stroke: "currentColor",
1802
+ strokeWidth: "1.3",
1803
+ strokeLinecap: "round"
1804
+ })]
1805
+ });
1806
+ }
1807
+ function ExitIcon() {
1808
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1809
+ className: "polyx-userbutton__icon",
1810
+ viewBox: "0 0 16 16",
1811
+ fill: "none",
1812
+ "aria-hidden": "true",
1813
+ focusable: "false",
1814
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1815
+ d: "M6 2.75H3.75a1 1 0 0 0-1 1v8.5a1 1 0 0 0 1 1H6M10.5 10.5 13 8l-2.5-2.5M13 8H6",
1816
+ stroke: "currentColor",
1817
+ strokeWidth: "1.3",
1818
+ strokeLinecap: "round",
1819
+ strokeLinejoin: "round"
1820
+ })
1821
+ });
1822
+ }
1823
+ /**
1824
+ * The signed-in user surface: avatar trigger + a menu with their identity and sign-out
1825
+ * (FR-SIGNIN-6). Reads only the hooks, so it behaves identically under either custody model
1826
+ * — an httpOnly BFF session or an in-memory SPA one — and needs no provider in a
1827
+ * `@poly-x/next` app.
1828
+ *
1829
+ * Custom entries compose declaratively:
1830
+ *
1831
+ * ```tsx
1832
+ * <UserButton manageAccountUrl="/account">
1833
+ * <UserButton.MenuItems>
1834
+ * <UserButton.Action label="signOut" /> // reposition a built-in
1835
+ * <UserButton.Link label="Docs" href="/docs" />
1836
+ * </UserButton.MenuItems>
1837
+ * </UserButton>
1838
+ * ```
1839
+ */
1840
+ const UserButton = Object.assign(UserButtonRoot, {
1841
+ MenuItems,
1842
+ Action,
1843
+ Link,
1844
+ Custom,
1845
+ Header
1846
+ });
1847
+ //#endregion
376
1848
  //#region src/index.ts
377
1849
  /**
378
1850
  * @poly-x/react — PolyX SDK for React SPAs. Sign-in UI + orchestration land in
@@ -384,16 +1856,22 @@ const version = "0.0.0";
384
1856
  exports.AuthCallback = AuthCallback;
385
1857
  exports.BroadcastAuthChannel = BroadcastAuthChannel;
386
1858
  exports.BroadcastChannelSessionChannel = BroadcastChannelSessionChannel;
1859
+ exports.ForgotPassword = ForgotPassword;
387
1860
  exports.PACKAGE_NAME = PACKAGE_NAME;
388
1861
  exports.PolyXContext = PolyXContext;
389
1862
  exports.PolyXProvider = PolyXProvider;
390
1863
  exports.PopupCancelledError = PopupCancelledError;
391
1864
  exports.Protected = Protected;
1865
+ exports.ResetPassword = ResetPassword;
392
1866
  exports.SessionStoragePkceStore = SessionStoragePkceStore;
393
1867
  exports.SignIn = SignIn;
1868
+ exports.UserAvatar = UserAvatar;
1869
+ exports.UserButton = UserButton;
394
1870
  exports.WebLocksLock = WebLocksLock;
395
1871
  exports.WindowBrowserBridge = WindowBrowserBridge;
396
1872
  exports.createLoginController = createLoginController;
1873
+ exports.initialsFrom = initialsFrom;
1874
+ exports.resolveSide = resolveSide;
397
1875
  exports.useAuth = useAuth;
398
1876
  exports.useAuthCallback = useAuthCallback;
399
1877
  exports.useSession = useSession;