@lumoauth/react 1.4.1 → 1.4.2

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.mjs CHANGED
@@ -24,36 +24,7 @@ function injectStyles() {
24
24
  document.head.appendChild(style);
25
25
  injected = true;
26
26
  }
27
- var CSS_CONTENT = `
28
- /* \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
29
- @lumoauth/react \u2014 Self-contained component styles
30
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 */
31
-
32
- :root {
33
- --la-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
34
- --la-font-size-sm: 0.8125rem;
35
- --la-font-size-base: 0.875rem;
36
- --la-font-size-lg: 1rem;
37
- --la-font-size-xl: 1.25rem;
38
- --la-font-size-2xl: 1.5rem;
39
- --la-font-weight-normal: 400;
40
- --la-font-weight-medium: 500;
41
- --la-font-weight-semibold: 600;
42
-
43
- --la-radius-sm: 6px;
44
- --la-radius-md: 8px;
45
- --la-radius-lg: 12px;
46
- --la-radius-xl: 16px;
47
- --la-radius-full: 9999px;
48
-
49
- --la-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
50
- --la-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
51
- --la-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
52
- --la-shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
53
-
54
- --la-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
55
-
56
- /* Light theme (default) */
27
+ var LIGHT_THEME = `
57
28
  --la-bg: #ffffff;
58
29
  --la-bg-subtle: #f8f9fb;
59
30
  --la-bg-muted: #f1f3f5;
@@ -73,11 +44,13 @@ var CSS_CONTENT = `
73
44
  --la-link: #7c5cfc;
74
45
  --la-overlay: rgba(0,0,0,0.5);
75
46
  --la-card-shadow: var(--la-shadow-xl);
76
- }
77
-
78
- /* Dark theme */
79
- [data-lumoauth-theme="dark"],
80
- .la-dark {
47
+ --la-badge-success-bg: #dcfce7;
48
+ --la-badge-success-text: #166534;
49
+ --la-badge-warning-bg: #fef9c3;
50
+ --la-badge-warning-text: #854d0e;
51
+ --la-badge-muted-bg: var(--la-bg-muted);
52
+ `;
53
+ var DARK_THEME = `
81
54
  --la-bg: #1a1a2e;
82
55
  --la-bg-subtle: #16213e;
83
56
  --la-bg-muted: #0f3460;
@@ -97,32 +70,71 @@ var CSS_CONTENT = `
97
70
  --la-link: #9d85f7;
98
71
  --la-overlay: rgba(0,0,0,0.7);
99
72
  --la-card-shadow: 0 20px 25px -5px rgba(0,0,0,0.3), 0 10px 10px -5px rgba(0,0,0,0.2);
73
+ --la-badge-success-bg: rgba(22, 163, 74, 0.15);
74
+ --la-badge-success-text: #4ade80;
75
+ --la-badge-warning-bg: rgba(234, 179, 8, 0.15);
76
+ --la-badge-warning-text: #facc15;
77
+ --la-badge-muted-bg: rgba(255, 255, 255, 0.08);
78
+ `;
79
+ var CSS_CONTENT = `
80
+ /* \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
81
+ @lumoauth/react \u2014 Self-contained component styles
82
+ \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 */
83
+
84
+ :root {
85
+ --la-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
86
+ --la-font-size-sm: 0.8125rem;
87
+ --la-font-size-base: 0.875rem;
88
+ --la-font-size-lg: 1rem;
89
+ --la-font-size-xl: 1.25rem;
90
+ --la-font-size-2xl: 1.5rem;
91
+ --la-font-weight-normal: 400;
92
+ --la-font-weight-medium: 500;
93
+ --la-font-weight-semibold: 600;
94
+
95
+ --la-radius-sm: 6px;
96
+ --la-radius-md: 8px;
97
+ --la-radius-lg: 12px;
98
+ --la-radius-xl: 16px;
99
+ --la-radius-full: 9999px;
100
+
101
+ --la-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
102
+ --la-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
103
+ --la-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
104
+ --la-shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
105
+
106
+ --la-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
107
+ }
108
+
109
+ /*
110
+ * Colours. Three ways choose the theme, from weakest to strongest:
111
+ *
112
+ * 1. the operating system (prefers-color-scheme), when nothing else is set;
113
+ * 2. a class or attribute on an ancestor or on the component itself:
114
+ * .la-light / .la-dark, or data-lumoauth-theme="light" | "dark"
115
+ * (the appearance.theme prop sets the class on the component);
116
+ * 3. appearance.variables, which is inline style on the component.
117
+ *
118
+ * The light values are repeated under .la-light so that a component can be
119
+ * light on a page that the operating system made dark.
120
+ */
121
+ :root,
122
+ .la-light,
123
+ [data-lumoauth-theme="light"] {
124
+ ${LIGHT_THEME}
100
125
  }
101
126
 
102
127
  @media (prefers-color-scheme: dark) {
103
128
  :root:not([data-lumoauth-theme="light"]):not(.la-light) {
104
- --la-bg: #1a1a2e;
105
- --la-bg-subtle: #16213e;
106
- --la-bg-muted: #0f3460;
107
- --la-bg-hover: #1a3a6a;
108
- --la-border: #2a2a4a;
109
- --la-border-focus: #9d85f7;
110
- --la-text: #e8e8f0;
111
- --la-text-secondary: #a0a0b8;
112
- --la-text-muted: #6a6a88;
113
- --la-primary: #9d85f7;
114
- --la-primary-hover: #b39dff;
115
- --la-primary-text: #1a1a2e;
116
- --la-danger: #ff6b6b;
117
- --la-danger-bg: #2d1b1b;
118
- --la-success: #51cf66;
119
- --la-success-bg: #1b2d1b;
120
- --la-link: #9d85f7;
121
- --la-overlay: rgba(0,0,0,0.7);
122
- --la-card-shadow: 0 20px 25px -5px rgba(0,0,0,0.3), 0 10px 10px -5px rgba(0,0,0,0.2);
129
+ ${DARK_THEME}
123
130
  }
124
131
  }
125
132
 
133
+ .la-dark,
134
+ [data-lumoauth-theme="dark"] {
135
+ ${DARK_THEME}
136
+ }
137
+
126
138
  /* \u2500\u2500\u2500 Card Container \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 */
127
139
 
128
140
  .la-card {
@@ -612,7 +624,7 @@ var CSS_CONTENT = `
612
624
  justify-content: center;
613
625
  font-family: var(--la-font-family);
614
626
  font-weight: var(--la-font-weight-semibold);
615
- color: #fff;
627
+ color: var(--la-primary-text);
616
628
  background: var(--la-primary);
617
629
  overflow: hidden;
618
630
  flex-shrink: 0;
@@ -636,6 +648,9 @@ var CSS_CONTENT = `
636
648
 
637
649
  /* \u2500\u2500\u2500 UserProfile 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 */
638
650
 
651
+ /* --la-text-primary is an optional override that older apps set. It has no
652
+ default: the text colour is --la-text. */
653
+
639
654
  .la-profile-card {
640
655
  max-width: 420px;
641
656
  }
@@ -669,7 +684,7 @@ var CSS_CONTENT = `
669
684
  .la-profile-name {
670
685
  font-size: var(--la-font-size-lg);
671
686
  font-weight: var(--la-font-weight-semibold);
672
- color: var(--la-text-primary);
687
+ color: var(--la-text-primary, var(--la-text));
673
688
  line-height: 1.3;
674
689
  overflow: hidden;
675
690
  text-overflow: ellipsis;
@@ -703,7 +718,7 @@ var CSS_CONTENT = `
703
718
  gap: 0.625rem;
704
719
  padding: 0.5rem 0;
705
720
  font-size: var(--la-font-size-base);
706
- color: var(--la-text-primary);
721
+ color: var(--la-text-primary, var(--la-text));
707
722
  }
708
723
 
709
724
  .la-profile-row svg {
@@ -737,32 +752,17 @@ var CSS_CONTENT = `
737
752
  }
738
753
 
739
754
  .la-badge-success {
740
- background: #dcfce7;
741
- color: #166534;
755
+ background: var(--la-badge-success-bg);
756
+ color: var(--la-badge-success-text);
742
757
  }
743
758
 
744
759
  .la-badge-warning {
745
- background: #fef9c3;
746
- color: #854d0e;
760
+ background: var(--la-badge-warning-bg);
761
+ color: var(--la-badge-warning-text);
747
762
  }
748
763
 
749
764
  .la-badge-muted {
750
- background: var(--la-bg-muted);
751
- color: var(--la-text-secondary);
752
- }
753
-
754
- .la-dark .la-badge-success {
755
- background: rgba(22, 163, 74, 0.15);
756
- color: #4ade80;
757
- }
758
-
759
- .la-dark .la-badge-warning {
760
- background: rgba(234, 179, 8, 0.15);
761
- color: #facc15;
762
- }
763
-
764
- .la-dark .la-badge-muted {
765
- background: rgba(255, 255, 255, 0.08);
765
+ background: var(--la-badge-muted-bg);
766
766
  color: var(--la-text-secondary);
767
767
  }
768
768
 
@@ -801,7 +801,7 @@ var CSS_CONTENT = `
801
801
  .la-btn-outline {
802
802
  background: transparent;
803
803
  border: 1px solid var(--la-border);
804
- color: var(--la-text-primary);
804
+ color: var(--la-text-primary, var(--la-text));
805
805
  padding: 0.625rem 1rem;
806
806
  border-radius: var(--la-radius-md);
807
807
  font-size: var(--la-font-size-base);
@@ -1132,7 +1132,7 @@ function LumoAuthProvider({
1132
1132
  params.set("id_token_hint", idToken);
1133
1133
  }
1134
1134
  const logoutUrl = `${domain.replace(/\/+$/, "")}/orgs/${safeOrgId}/api/v1/oauth/logout?${params.toString()}`;
1135
- if (accessToken) {
1135
+ if (accessToken && !storage?.serverManaged) {
1136
1136
  authModule.revokeToken(accessToken, accessToken).catch(() => {
1137
1137
  });
1138
1138
  }
@@ -1141,7 +1141,7 @@ function LumoAuthProvider({
1141
1141
  window.location.replace(logoutUrl);
1142
1142
  await new Promise(() => {
1143
1143
  });
1144
- }, [authModule, domain, orgId, afterSignOutUrl, session, dispatch]);
1144
+ }, [authModule, domain, orgId, afterSignOutUrl, session, storage, dispatch]);
1145
1145
  useEffect(() => {
1146
1146
  let cancelled = false;
1147
1147
  async function init() {
@@ -1881,11 +1881,12 @@ function UserAvatar({
1881
1881
  appearance
1882
1882
  }) {
1883
1883
  const { user, isSignedIn } = useLumoAuthContext();
1884
+ const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
1884
1885
  if (!isSignedIn || !user) {
1885
1886
  return /* @__PURE__ */ jsx6(
1886
1887
  "span",
1887
1888
  {
1888
- className: `la-avatar la-avatar-${shape} ${appearance?.className || ""}`,
1889
+ className: `la-avatar la-avatar-${shape} ${themeClass} ${appearance?.className || ""}`,
1889
1890
  style: {
1890
1891
  width: size,
1891
1892
  height: size,
@@ -1900,7 +1901,6 @@ function UserAvatar({
1900
1901
  );
1901
1902
  }
1902
1903
  const initials = [user.firstName, user.lastName].filter(Boolean).map((n) => n.charAt(0).toUpperCase()).join("") || user.email.charAt(0).toUpperCase();
1903
- const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
1904
1904
  return /* @__PURE__ */ jsx6(
1905
1905
  "span",
1906
1906
  {
@@ -1949,6 +1949,9 @@ var ICONS = {
1949
1949
  /* @__PURE__ */ jsx7("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
1950
1950
  ] })
1951
1951
  };
1952
+ function hasMfaStatus(user) {
1953
+ return typeof user.claims?.mfa_enabled === "boolean";
1954
+ }
1952
1955
  function UserProfile({
1953
1956
  afterSignOutUrl,
1954
1957
  mode = "full",
@@ -2000,7 +2003,7 @@ function UserProfile({
2000
2003
  ] })
2001
2004
  ] }),
2002
2005
  mode === "full" && /* @__PURE__ */ jsxs6(Fragment2, { children: [
2003
- /* @__PURE__ */ jsxs6("div", { className: "la-profile-section", children: [
2006
+ hasMfaStatus(user) && /* @__PURE__ */ jsxs6("div", { className: "la-profile-section", children: [
2004
2007
  /* @__PURE__ */ jsx7("div", { className: "la-profile-section-title", children: "Security" }),
2005
2008
  /* @__PURE__ */ jsxs6("div", { className: "la-profile-row", children: [
2006
2009
  ICONS.shield,