@lumoauth/react 0.0.0-stage → 1.0.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.
- package/LICENSE +21 -0
- package/README.md +790 -2
- package/dist/index.d.mts +678 -0
- package/dist/index.d.ts +678 -0
- package/dist/index.js +2472 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2424 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -5
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2424 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { LumoAuth as LumoAuth2 } from "@lumoauth/client";
|
|
5
|
+
|
|
6
|
+
// src/provider.tsx
|
|
7
|
+
import { createContext, useContext, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
8
|
+
import { LumoAuthSession } from "@lumoauth/client";
|
|
9
|
+
import { AuthModule } from "@lumoauth/client";
|
|
10
|
+
|
|
11
|
+
// src/styles.ts
|
|
12
|
+
var STYLE_ID = "lumoauth-react-styles";
|
|
13
|
+
var injected = false;
|
|
14
|
+
function injectStyles() {
|
|
15
|
+
if (injected) return;
|
|
16
|
+
if (typeof document === "undefined") return;
|
|
17
|
+
if (document.getElementById(STYLE_ID)) {
|
|
18
|
+
injected = true;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const style = document.createElement("style");
|
|
22
|
+
style.id = STYLE_ID;
|
|
23
|
+
style.textContent = CSS_CONTENT;
|
|
24
|
+
document.head.appendChild(style);
|
|
25
|
+
injected = true;
|
|
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) */
|
|
57
|
+
--la-bg: #ffffff;
|
|
58
|
+
--la-bg-subtle: #f8f9fb;
|
|
59
|
+
--la-bg-muted: #f1f3f5;
|
|
60
|
+
--la-bg-hover: #e9ecef;
|
|
61
|
+
--la-border: #dee2e6;
|
|
62
|
+
--la-border-focus: #7c5cfc;
|
|
63
|
+
--la-text: #1a1a2e;
|
|
64
|
+
--la-text-secondary: #6c757d;
|
|
65
|
+
--la-text-muted: #adb5bd;
|
|
66
|
+
--la-primary: #7c5cfc;
|
|
67
|
+
--la-primary-hover: #6a4ce0;
|
|
68
|
+
--la-primary-text: #ffffff;
|
|
69
|
+
--la-danger: #e74c3c;
|
|
70
|
+
--la-danger-bg: #fef2f2;
|
|
71
|
+
--la-success: #27ae60;
|
|
72
|
+
--la-success-bg: #f0fdf4;
|
|
73
|
+
--la-link: #7c5cfc;
|
|
74
|
+
--la-overlay: rgba(0,0,0,0.5);
|
|
75
|
+
--la-card-shadow: var(--la-shadow-xl);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Dark theme */
|
|
79
|
+
[data-lumoauth-theme="dark"],
|
|
80
|
+
.la-dark {
|
|
81
|
+
--la-bg: #1a1a2e;
|
|
82
|
+
--la-bg-subtle: #16213e;
|
|
83
|
+
--la-bg-muted: #0f3460;
|
|
84
|
+
--la-bg-hover: #1a3a6a;
|
|
85
|
+
--la-border: #2a2a4a;
|
|
86
|
+
--la-border-focus: #9d85f7;
|
|
87
|
+
--la-text: #e8e8f0;
|
|
88
|
+
--la-text-secondary: #a0a0b8;
|
|
89
|
+
--la-text-muted: #6a6a88;
|
|
90
|
+
--la-primary: #9d85f7;
|
|
91
|
+
--la-primary-hover: #b39dff;
|
|
92
|
+
--la-primary-text: #1a1a2e;
|
|
93
|
+
--la-danger: #ff6b6b;
|
|
94
|
+
--la-danger-bg: #2d1b1b;
|
|
95
|
+
--la-success: #51cf66;
|
|
96
|
+
--la-success-bg: #1b2d1b;
|
|
97
|
+
--la-link: #9d85f7;
|
|
98
|
+
--la-overlay: rgba(0,0,0,0.7);
|
|
99
|
+
--la-card-shadow: 0 20px 25px -5px rgba(0,0,0,0.3), 0 10px 10px -5px rgba(0,0,0,0.2);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@media (prefers-color-scheme: dark) {
|
|
103
|
+
: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);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* \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
|
+
|
|
128
|
+
.la-card {
|
|
129
|
+
font-family: var(--la-font-family);
|
|
130
|
+
background: var(--la-bg);
|
|
131
|
+
border: 1px solid var(--la-border);
|
|
132
|
+
border-radius: var(--la-radius-xl);
|
|
133
|
+
box-shadow: var(--la-card-shadow);
|
|
134
|
+
width: 100%;
|
|
135
|
+
max-width: 400px;
|
|
136
|
+
padding: 2rem;
|
|
137
|
+
box-sizing: border-box;
|
|
138
|
+
color: var(--la-text);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.la-card * {
|
|
142
|
+
box-sizing: border-box;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.la-card-header {
|
|
146
|
+
text-align: center;
|
|
147
|
+
margin-bottom: 1.5rem;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.la-card-title {
|
|
151
|
+
font-size: var(--la-font-size-2xl);
|
|
152
|
+
font-weight: var(--la-font-weight-semibold);
|
|
153
|
+
color: var(--la-text);
|
|
154
|
+
margin: 0 0 0.25rem 0;
|
|
155
|
+
line-height: 1.3;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.la-card-subtitle {
|
|
159
|
+
font-size: var(--la-font-size-base);
|
|
160
|
+
color: var(--la-text-secondary);
|
|
161
|
+
margin: 0;
|
|
162
|
+
line-height: 1.5;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* \u2500\u2500\u2500 Form Elements \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 */
|
|
166
|
+
|
|
167
|
+
.la-form-group {
|
|
168
|
+
margin-bottom: 1rem;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.la-label {
|
|
172
|
+
display: block;
|
|
173
|
+
font-size: var(--la-font-size-sm);
|
|
174
|
+
font-weight: var(--la-font-weight-medium);
|
|
175
|
+
color: var(--la-text);
|
|
176
|
+
margin-bottom: 0.375rem;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.la-input {
|
|
180
|
+
display: block;
|
|
181
|
+
width: 100%;
|
|
182
|
+
padding: 0.625rem 0.75rem;
|
|
183
|
+
font-family: var(--la-font-family);
|
|
184
|
+
font-size: var(--la-font-size-base);
|
|
185
|
+
color: var(--la-text);
|
|
186
|
+
background: var(--la-bg-subtle);
|
|
187
|
+
border: 1px solid var(--la-border);
|
|
188
|
+
border-radius: var(--la-radius-md);
|
|
189
|
+
outline: none;
|
|
190
|
+
transition: border-color var(--la-transition), box-shadow var(--la-transition);
|
|
191
|
+
line-height: 1.5;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.la-input::placeholder {
|
|
195
|
+
color: var(--la-text-muted);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.la-input:focus {
|
|
199
|
+
border-color: var(--la-border-focus);
|
|
200
|
+
box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.15);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.la-input:disabled {
|
|
204
|
+
opacity: 0.6;
|
|
205
|
+
cursor: not-allowed;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* \u2500\u2500\u2500 Buttons \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\u2500\u2500\u2500\u2500\u2500 */
|
|
209
|
+
|
|
210
|
+
.la-btn {
|
|
211
|
+
display: inline-flex;
|
|
212
|
+
align-items: center;
|
|
213
|
+
justify-content: center;
|
|
214
|
+
gap: 0.5rem;
|
|
215
|
+
width: 100%;
|
|
216
|
+
padding: 0.625rem 1rem;
|
|
217
|
+
font-family: var(--la-font-family);
|
|
218
|
+
font-size: var(--la-font-size-base);
|
|
219
|
+
font-weight: var(--la-font-weight-medium);
|
|
220
|
+
line-height: 1.5;
|
|
221
|
+
border-radius: var(--la-radius-md);
|
|
222
|
+
border: 1px solid transparent;
|
|
223
|
+
cursor: pointer;
|
|
224
|
+
transition: all var(--la-transition);
|
|
225
|
+
text-decoration: none;
|
|
226
|
+
outline: none;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.la-btn:focus-visible {
|
|
230
|
+
box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.25);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.la-btn:disabled {
|
|
234
|
+
opacity: 0.6;
|
|
235
|
+
cursor: not-allowed;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.la-btn-primary {
|
|
239
|
+
background: var(--la-primary);
|
|
240
|
+
color: var(--la-primary-text);
|
|
241
|
+
border-color: var(--la-primary);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.la-btn-primary:hover:not(:disabled) {
|
|
245
|
+
background: var(--la-primary-hover);
|
|
246
|
+
border-color: var(--la-primary-hover);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.la-btn-outline {
|
|
250
|
+
background: transparent;
|
|
251
|
+
color: var(--la-text);
|
|
252
|
+
border-color: var(--la-border);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.la-btn-outline:hover:not(:disabled) {
|
|
256
|
+
background: var(--la-bg-hover);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.la-btn-ghost {
|
|
260
|
+
background: transparent;
|
|
261
|
+
color: var(--la-text-secondary);
|
|
262
|
+
border: none;
|
|
263
|
+
padding: 0.375rem 0.5rem;
|
|
264
|
+
width: auto;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.la-btn-ghost:hover:not(:disabled) {
|
|
268
|
+
color: var(--la-text);
|
|
269
|
+
background: var(--la-bg-hover);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.la-btn-danger {
|
|
273
|
+
background: transparent;
|
|
274
|
+
color: var(--la-danger);
|
|
275
|
+
border: none;
|
|
276
|
+
width: auto;
|
|
277
|
+
padding: 0.375rem 0.5rem;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.la-btn-danger:hover:not(:disabled) {
|
|
281
|
+
background: var(--la-danger-bg);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/* \u2500\u2500\u2500 Spinner \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\u2500\u2500\u2500\u2500\u2500 */
|
|
285
|
+
|
|
286
|
+
.la-spinner {
|
|
287
|
+
display: inline-block;
|
|
288
|
+
width: 1rem;
|
|
289
|
+
height: 1rem;
|
|
290
|
+
border: 2px solid var(--la-border);
|
|
291
|
+
border-top-color: var(--la-primary);
|
|
292
|
+
border-radius: 50%;
|
|
293
|
+
animation: la-spin 0.6s linear infinite;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.la-spinner-sm {
|
|
297
|
+
width: 0.75rem;
|
|
298
|
+
height: 0.75rem;
|
|
299
|
+
border-width: 1.5px;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
@keyframes la-spin {
|
|
303
|
+
to { transform: rotate(360deg); }
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/* \u2500\u2500\u2500 Alert / Error \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 */
|
|
307
|
+
|
|
308
|
+
.la-alert {
|
|
309
|
+
padding: 0.625rem 0.75rem;
|
|
310
|
+
border-radius: var(--la-radius-md);
|
|
311
|
+
font-size: var(--la-font-size-sm);
|
|
312
|
+
line-height: 1.5;
|
|
313
|
+
margin-bottom: 1rem;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.la-alert-error {
|
|
317
|
+
background: var(--la-danger-bg);
|
|
318
|
+
color: var(--la-danger);
|
|
319
|
+
border: 1px solid rgba(231, 76, 60, 0.15);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.la-alert-success {
|
|
323
|
+
background: var(--la-success-bg);
|
|
324
|
+
color: var(--la-success);
|
|
325
|
+
border: 1px solid rgba(39, 174, 96, 0.15);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/* \u2500\u2500\u2500 Divider \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\u2500\u2500\u2500\u2500\u2500 */
|
|
329
|
+
|
|
330
|
+
.la-divider {
|
|
331
|
+
display: flex;
|
|
332
|
+
align-items: center;
|
|
333
|
+
gap: 0.75rem;
|
|
334
|
+
margin: 1.25rem 0;
|
|
335
|
+
color: var(--la-text-muted);
|
|
336
|
+
font-size: var(--la-font-size-sm);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.la-divider::before,
|
|
340
|
+
.la-divider::after {
|
|
341
|
+
content: '';
|
|
342
|
+
flex: 1;
|
|
343
|
+
height: 1px;
|
|
344
|
+
background: var(--la-border);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/* \u2500\u2500\u2500 Social 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\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 */
|
|
348
|
+
|
|
349
|
+
.la-social-btn {
|
|
350
|
+
display: flex;
|
|
351
|
+
align-items: center;
|
|
352
|
+
justify-content: center;
|
|
353
|
+
gap: 0.5rem;
|
|
354
|
+
width: 100%;
|
|
355
|
+
padding: 0.5rem 0.75rem;
|
|
356
|
+
font-family: var(--la-font-family);
|
|
357
|
+
font-size: var(--la-font-size-sm);
|
|
358
|
+
font-weight: var(--la-font-weight-medium);
|
|
359
|
+
color: var(--la-text);
|
|
360
|
+
background: var(--la-bg);
|
|
361
|
+
border: 1px solid var(--la-border);
|
|
362
|
+
border-radius: var(--la-radius-md);
|
|
363
|
+
cursor: pointer;
|
|
364
|
+
transition: all var(--la-transition);
|
|
365
|
+
outline: none;
|
|
366
|
+
line-height: 1.5;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.la-social-btn:hover {
|
|
370
|
+
background: var(--la-bg-hover);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.la-social-btn:focus-visible {
|
|
374
|
+
box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.15);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.la-social-buttons {
|
|
378
|
+
display: flex;
|
|
379
|
+
flex-direction: column;
|
|
380
|
+
gap: 0.5rem;
|
|
381
|
+
margin-bottom: 0.25rem;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.la-social-icon {
|
|
385
|
+
width: 1.125rem;
|
|
386
|
+
height: 1.125rem;
|
|
387
|
+
flex-shrink: 0;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/* \u2500\u2500\u2500 Footer Link \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\u2500 */
|
|
391
|
+
|
|
392
|
+
.la-footer {
|
|
393
|
+
text-align: center;
|
|
394
|
+
margin-top: 1.25rem;
|
|
395
|
+
font-size: var(--la-font-size-sm);
|
|
396
|
+
color: var(--la-text-secondary);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
.la-footer a,
|
|
400
|
+
.la-link {
|
|
401
|
+
color: var(--la-link);
|
|
402
|
+
text-decoration: none;
|
|
403
|
+
font-weight: var(--la-font-weight-medium);
|
|
404
|
+
cursor: pointer;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.la-footer a:hover,
|
|
408
|
+
.la-link:hover {
|
|
409
|
+
text-decoration: underline;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/* \u2500\u2500\u2500 Password Strength \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 */
|
|
413
|
+
|
|
414
|
+
.la-password-strength {
|
|
415
|
+
margin-top: 0.375rem;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.la-password-bar {
|
|
419
|
+
height: 3px;
|
|
420
|
+
border-radius: 2px;
|
|
421
|
+
background: var(--la-bg-muted);
|
|
422
|
+
overflow: hidden;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.la-password-fill {
|
|
426
|
+
height: 100%;
|
|
427
|
+
border-radius: 2px;
|
|
428
|
+
transition: width var(--la-transition), background var(--la-transition);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.la-password-fill[data-strength="0"] { width: 0%; }
|
|
432
|
+
.la-password-fill[data-strength="1"] { width: 25%; background: var(--la-danger); }
|
|
433
|
+
.la-password-fill[data-strength="2"] { width: 50%; background: #f39c12; }
|
|
434
|
+
.la-password-fill[data-strength="3"] { width: 75%; background: #3498db; }
|
|
435
|
+
.la-password-fill[data-strength="4"] { width: 100%; background: var(--la-success); }
|
|
436
|
+
|
|
437
|
+
.la-password-label {
|
|
438
|
+
font-size: 0.6875rem;
|
|
439
|
+
color: var(--la-text-muted);
|
|
440
|
+
margin-top: 0.25rem;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/* \u2500\u2500\u2500 UserButton \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\u2500\u2500 */
|
|
444
|
+
|
|
445
|
+
.la-user-button {
|
|
446
|
+
position: relative;
|
|
447
|
+
display: inline-flex;
|
|
448
|
+
font-family: var(--la-font-family);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.la-user-trigger {
|
|
452
|
+
display: flex;
|
|
453
|
+
align-items: center;
|
|
454
|
+
gap: 0.5rem;
|
|
455
|
+
padding: 0.25rem;
|
|
456
|
+
background: none;
|
|
457
|
+
border: none;
|
|
458
|
+
cursor: pointer;
|
|
459
|
+
border-radius: var(--la-radius-full);
|
|
460
|
+
transition: all var(--la-transition);
|
|
461
|
+
outline: none;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.la-user-trigger:hover {
|
|
465
|
+
background: var(--la-bg-hover);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.la-user-trigger:focus-visible {
|
|
469
|
+
box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.25);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.la-user-avatar {
|
|
473
|
+
width: 2rem;
|
|
474
|
+
height: 2rem;
|
|
475
|
+
border-radius: 50%;
|
|
476
|
+
background: var(--la-primary);
|
|
477
|
+
color: var(--la-primary-text);
|
|
478
|
+
display: flex;
|
|
479
|
+
align-items: center;
|
|
480
|
+
justify-content: center;
|
|
481
|
+
font-size: var(--la-font-size-sm);
|
|
482
|
+
font-weight: var(--la-font-weight-semibold);
|
|
483
|
+
overflow: hidden;
|
|
484
|
+
flex-shrink: 0;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.la-user-avatar img {
|
|
488
|
+
width: 100%;
|
|
489
|
+
height: 100%;
|
|
490
|
+
object-fit: cover;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.la-user-name {
|
|
494
|
+
font-size: var(--la-font-size-sm);
|
|
495
|
+
font-weight: var(--la-font-weight-medium);
|
|
496
|
+
color: var(--la-text);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
.la-user-dropdown {
|
|
500
|
+
position: absolute;
|
|
501
|
+
top: calc(100% + 0.5rem);
|
|
502
|
+
right: 0;
|
|
503
|
+
min-width: 220px;
|
|
504
|
+
background: var(--la-bg);
|
|
505
|
+
border: 1px solid var(--la-border);
|
|
506
|
+
border-radius: var(--la-radius-lg);
|
|
507
|
+
box-shadow: var(--la-shadow-lg);
|
|
508
|
+
padding: 0.375rem;
|
|
509
|
+
z-index: 9999;
|
|
510
|
+
animation: la-dropdown-in 0.15s ease-out;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
@keyframes la-dropdown-in {
|
|
514
|
+
from {
|
|
515
|
+
opacity: 0;
|
|
516
|
+
transform: translateY(-4px) scale(0.97);
|
|
517
|
+
}
|
|
518
|
+
to {
|
|
519
|
+
opacity: 1;
|
|
520
|
+
transform: translateY(0) scale(1);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.la-user-dropdown-header {
|
|
525
|
+
padding: 0.5rem 0.625rem;
|
|
526
|
+
border-bottom: 1px solid var(--la-border);
|
|
527
|
+
margin-bottom: 0.25rem;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.la-user-dropdown-email {
|
|
531
|
+
font-size: var(--la-font-size-sm);
|
|
532
|
+
color: var(--la-text-secondary);
|
|
533
|
+
overflow: hidden;
|
|
534
|
+
text-overflow: ellipsis;
|
|
535
|
+
white-space: nowrap;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.la-user-dropdown-name {
|
|
539
|
+
font-size: var(--la-font-size-sm);
|
|
540
|
+
font-weight: var(--la-font-weight-medium);
|
|
541
|
+
color: var(--la-text);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
.la-dropdown-item {
|
|
545
|
+
display: flex;
|
|
546
|
+
align-items: center;
|
|
547
|
+
gap: 0.5rem;
|
|
548
|
+
width: 100%;
|
|
549
|
+
padding: 0.5rem 0.625rem;
|
|
550
|
+
font-family: var(--la-font-family);
|
|
551
|
+
font-size: var(--la-font-size-sm);
|
|
552
|
+
color: var(--la-text);
|
|
553
|
+
background: none;
|
|
554
|
+
border: none;
|
|
555
|
+
border-radius: var(--la-radius-sm);
|
|
556
|
+
cursor: pointer;
|
|
557
|
+
transition: background var(--la-transition);
|
|
558
|
+
text-align: left;
|
|
559
|
+
outline: none;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.la-dropdown-item:hover {
|
|
563
|
+
background: var(--la-bg-hover);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.la-dropdown-item-danger {
|
|
567
|
+
color: var(--la-danger);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
.la-dropdown-item-danger:hover {
|
|
571
|
+
background: var(--la-danger-bg);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.la-dropdown-divider {
|
|
575
|
+
height: 1px;
|
|
576
|
+
background: var(--la-border);
|
|
577
|
+
margin: 0.25rem 0;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/* \u2500\u2500\u2500 Protect Loading \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 */
|
|
581
|
+
|
|
582
|
+
.la-protect-loading {
|
|
583
|
+
display: flex;
|
|
584
|
+
align-items: center;
|
|
585
|
+
justify-content: center;
|
|
586
|
+
padding: 1rem;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/* \u2500\u2500\u2500 Forgot Password Link \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 */
|
|
590
|
+
|
|
591
|
+
.la-forgot {
|
|
592
|
+
text-align: right;
|
|
593
|
+
margin-top: -0.5rem;
|
|
594
|
+
margin-bottom: 1rem;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
.la-forgot a {
|
|
598
|
+
font-size: var(--la-font-size-sm);
|
|
599
|
+
color: var(--la-link);
|
|
600
|
+
text-decoration: none;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.la-forgot a:hover {
|
|
604
|
+
text-decoration: underline;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/* \u2500\u2500\u2500 UserAvatar (standalone) \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 */
|
|
608
|
+
|
|
609
|
+
.la-avatar {
|
|
610
|
+
display: inline-flex;
|
|
611
|
+
align-items: center;
|
|
612
|
+
justify-content: center;
|
|
613
|
+
font-family: var(--la-font-family);
|
|
614
|
+
font-weight: var(--la-font-weight-semibold);
|
|
615
|
+
color: #fff;
|
|
616
|
+
background: var(--la-primary);
|
|
617
|
+
overflow: hidden;
|
|
618
|
+
flex-shrink: 0;
|
|
619
|
+
user-select: none;
|
|
620
|
+
line-height: 1;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
.la-avatar img {
|
|
624
|
+
width: 100%;
|
|
625
|
+
height: 100%;
|
|
626
|
+
object-fit: cover;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.la-avatar-circle {
|
|
630
|
+
border-radius: var(--la-radius-full);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.la-avatar-square {
|
|
634
|
+
border-radius: var(--la-radius-md);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/* \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
|
+
|
|
639
|
+
.la-profile-card {
|
|
640
|
+
max-width: 420px;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
.la-profile-header {
|
|
644
|
+
display: flex;
|
|
645
|
+
align-items: center;
|
|
646
|
+
gap: 1rem;
|
|
647
|
+
padding-bottom: 1.25rem;
|
|
648
|
+
border-bottom: 1px solid var(--la-border);
|
|
649
|
+
margin-bottom: 1rem;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
.la-profile-avatar {
|
|
653
|
+
width: 56px;
|
|
654
|
+
height: 56px;
|
|
655
|
+
font-size: 1.25rem;
|
|
656
|
+
flex-shrink: 0;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
.la-profile-avatar img {
|
|
660
|
+
width: 100%;
|
|
661
|
+
height: 100%;
|
|
662
|
+
object-fit: cover;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
.la-profile-header-info {
|
|
666
|
+
min-width: 0;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
.la-profile-name {
|
|
670
|
+
font-size: var(--la-font-size-lg);
|
|
671
|
+
font-weight: var(--la-font-weight-semibold);
|
|
672
|
+
color: var(--la-text-primary);
|
|
673
|
+
line-height: 1.3;
|
|
674
|
+
overflow: hidden;
|
|
675
|
+
text-overflow: ellipsis;
|
|
676
|
+
white-space: nowrap;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
.la-profile-email {
|
|
680
|
+
font-size: var(--la-font-size-sm);
|
|
681
|
+
color: var(--la-text-secondary);
|
|
682
|
+
overflow: hidden;
|
|
683
|
+
text-overflow: ellipsis;
|
|
684
|
+
white-space: nowrap;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.la-profile-section {
|
|
688
|
+
margin-bottom: 1rem;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
.la-profile-section-title {
|
|
692
|
+
font-size: var(--la-font-size-sm);
|
|
693
|
+
font-weight: var(--la-font-weight-semibold);
|
|
694
|
+
color: var(--la-text-secondary);
|
|
695
|
+
text-transform: uppercase;
|
|
696
|
+
letter-spacing: 0.05em;
|
|
697
|
+
margin-bottom: 0.625rem;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
.la-profile-row {
|
|
701
|
+
display: flex;
|
|
702
|
+
align-items: center;
|
|
703
|
+
gap: 0.625rem;
|
|
704
|
+
padding: 0.5rem 0;
|
|
705
|
+
font-size: var(--la-font-size-base);
|
|
706
|
+
color: var(--la-text-primary);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
.la-profile-row svg {
|
|
710
|
+
color: var(--la-text-secondary);
|
|
711
|
+
flex-shrink: 0;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
.la-profile-row-label {
|
|
715
|
+
color: var(--la-text-secondary);
|
|
716
|
+
min-width: 3.5rem;
|
|
717
|
+
flex-shrink: 0;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
.la-profile-row-value {
|
|
721
|
+
flex: 1;
|
|
722
|
+
min-width: 0;
|
|
723
|
+
overflow: hidden;
|
|
724
|
+
text-overflow: ellipsis;
|
|
725
|
+
white-space: nowrap;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
.la-profile-badge {
|
|
729
|
+
display: inline-flex;
|
|
730
|
+
align-items: center;
|
|
731
|
+
gap: 0.25rem;
|
|
732
|
+
font-size: 0.75rem;
|
|
733
|
+
font-weight: var(--la-font-weight-medium);
|
|
734
|
+
padding: 0.125rem 0.5rem;
|
|
735
|
+
border-radius: var(--la-radius-full);
|
|
736
|
+
flex-shrink: 0;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.la-badge-success {
|
|
740
|
+
background: #dcfce7;
|
|
741
|
+
color: #166534;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.la-badge-warning {
|
|
745
|
+
background: #fef9c3;
|
|
746
|
+
color: #854d0e;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
.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);
|
|
766
|
+
color: var(--la-text-secondary);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
.la-profile-tags {
|
|
770
|
+
display: flex;
|
|
771
|
+
flex-wrap: wrap;
|
|
772
|
+
gap: 0.375rem;
|
|
773
|
+
flex: 1;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
.la-profile-tag {
|
|
777
|
+
display: inline-block;
|
|
778
|
+
font-size: 0.75rem;
|
|
779
|
+
font-weight: var(--la-font-weight-medium);
|
|
780
|
+
padding: 0.125rem 0.5rem;
|
|
781
|
+
border-radius: var(--la-radius-full);
|
|
782
|
+
background: var(--la-bg-muted);
|
|
783
|
+
color: var(--la-text-secondary);
|
|
784
|
+
border: 1px solid var(--la-border);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
.la-profile-actions {
|
|
788
|
+
padding-top: 0.5rem;
|
|
789
|
+
border-top: 1px solid var(--la-border);
|
|
790
|
+
margin-top: 0.5rem;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
.la-profile-signout-btn {
|
|
794
|
+
width: 100%;
|
|
795
|
+
display: flex;
|
|
796
|
+
align-items: center;
|
|
797
|
+
justify-content: center;
|
|
798
|
+
gap: 0.5rem;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
.la-btn-outline {
|
|
802
|
+
background: transparent;
|
|
803
|
+
border: 1px solid var(--la-border);
|
|
804
|
+
color: var(--la-text-primary);
|
|
805
|
+
padding: 0.625rem 1rem;
|
|
806
|
+
border-radius: var(--la-radius-md);
|
|
807
|
+
font-size: var(--la-font-size-base);
|
|
808
|
+
font-weight: var(--la-font-weight-medium);
|
|
809
|
+
cursor: pointer;
|
|
810
|
+
transition: background var(--la-transition), border-color var(--la-transition);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.la-btn-outline:hover {
|
|
814
|
+
background: var(--la-bg-hover);
|
|
815
|
+
border-color: var(--la-text-secondary);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
.la-btn-outline:disabled {
|
|
819
|
+
opacity: 0.5;
|
|
820
|
+
cursor: not-allowed;
|
|
821
|
+
}
|
|
822
|
+
`;
|
|
823
|
+
|
|
824
|
+
// src/provider.tsx
|
|
825
|
+
import { jsx } from "react/jsx-runtime";
|
|
826
|
+
var LumoAuthContext = createContext(null);
|
|
827
|
+
LumoAuthContext.displayName = "LumoAuthContext";
|
|
828
|
+
function useLumoAuthContext() {
|
|
829
|
+
const ctx = useContext(LumoAuthContext);
|
|
830
|
+
if (!ctx) {
|
|
831
|
+
throw new Error(
|
|
832
|
+
'useLumoAuthContext must be used within <LumoAuthProvider>. Wrap your application with <LumoAuthProvider domain="..." orgId="..." clientId="...">.'
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
return ctx;
|
|
836
|
+
}
|
|
837
|
+
var PKCE_VERIFIER_KEY = "lumoauth_pkce_verifier";
|
|
838
|
+
var PKCE_STATE_KEY = "lumoauth_pkce_state";
|
|
839
|
+
function savePkceParams(codeVerifier, state) {
|
|
840
|
+
try {
|
|
841
|
+
if (typeof window !== "undefined") {
|
|
842
|
+
sessionStorage.setItem(PKCE_VERIFIER_KEY, codeVerifier);
|
|
843
|
+
sessionStorage.setItem(PKCE_STATE_KEY, state);
|
|
844
|
+
}
|
|
845
|
+
} catch {
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
function loadPkceParams() {
|
|
849
|
+
try {
|
|
850
|
+
if (typeof window !== "undefined") {
|
|
851
|
+
return {
|
|
852
|
+
codeVerifier: sessionStorage.getItem(PKCE_VERIFIER_KEY),
|
|
853
|
+
state: sessionStorage.getItem(PKCE_STATE_KEY)
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
} catch {
|
|
857
|
+
}
|
|
858
|
+
return { codeVerifier: null, state: null };
|
|
859
|
+
}
|
|
860
|
+
function clearPkceParams() {
|
|
861
|
+
try {
|
|
862
|
+
if (typeof window !== "undefined") {
|
|
863
|
+
sessionStorage.removeItem(PKCE_VERIFIER_KEY);
|
|
864
|
+
sessionStorage.removeItem(PKCE_STATE_KEY);
|
|
865
|
+
}
|
|
866
|
+
} catch {
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
function parseUserFromUserInfo(data) {
|
|
870
|
+
const firstName = data.given_name || data.first_name || "";
|
|
871
|
+
const lastName = data.family_name || data.last_name || "";
|
|
872
|
+
const email = data.email || "";
|
|
873
|
+
const displayName = data.name || [firstName, lastName].filter(Boolean).join(" ") || email;
|
|
874
|
+
return {
|
|
875
|
+
id: data.sub || data.id || "",
|
|
876
|
+
email,
|
|
877
|
+
firstName: firstName || void 0,
|
|
878
|
+
lastName: lastName || void 0,
|
|
879
|
+
displayName,
|
|
880
|
+
avatarUrl: data.picture || void 0,
|
|
881
|
+
emailVerified: data.email_verified ?? false,
|
|
882
|
+
mfaEnabled: data.mfa_enabled ?? false,
|
|
883
|
+
roles: Array.isArray(data.roles) ? data.roles : [],
|
|
884
|
+
groups: Array.isArray(data.groups) ? data.groups : [],
|
|
885
|
+
sub: data.sub || void 0,
|
|
886
|
+
claims: data
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
function LumoAuthProvider({
|
|
890
|
+
domain,
|
|
891
|
+
orgId,
|
|
892
|
+
clientId,
|
|
893
|
+
authStrategy = "pkce",
|
|
894
|
+
redirectUri,
|
|
895
|
+
afterSignInUrl,
|
|
896
|
+
afterSignUpUrl,
|
|
897
|
+
afterSignOutUrl,
|
|
898
|
+
storage,
|
|
899
|
+
crossTab = true,
|
|
900
|
+
children
|
|
901
|
+
}) {
|
|
902
|
+
const [user, setUser] = useState(null);
|
|
903
|
+
const tokensRef = useRef({ accessToken: null, refreshToken: null, expiresAt: null, idToken: null });
|
|
904
|
+
const callbackHandledRef = useRef(false);
|
|
905
|
+
const callbackInflightRef = useRef(null);
|
|
906
|
+
useEffect(() => {
|
|
907
|
+
injectStyles();
|
|
908
|
+
}, []);
|
|
909
|
+
const authModule = useMemo(
|
|
910
|
+
() => new AuthModule({
|
|
911
|
+
baseUrl: domain,
|
|
912
|
+
orgId,
|
|
913
|
+
clientId
|
|
914
|
+
}),
|
|
915
|
+
[domain, orgId, clientId]
|
|
916
|
+
);
|
|
917
|
+
const resolvedRedirectUri = useMemo(() => {
|
|
918
|
+
if (redirectUri) return redirectUri;
|
|
919
|
+
if (typeof window !== "undefined") {
|
|
920
|
+
return `${window.location.origin}/auth/callback`;
|
|
921
|
+
}
|
|
922
|
+
return "";
|
|
923
|
+
}, [redirectUri]);
|
|
924
|
+
const session = useMemo(
|
|
925
|
+
() => new LumoAuthSession({
|
|
926
|
+
auth: authModule,
|
|
927
|
+
redirectUri: resolvedRedirectUri,
|
|
928
|
+
storage,
|
|
929
|
+
crossTab,
|
|
930
|
+
// Mirror the store's tokens into the ref the flow code below
|
|
931
|
+
// still reads, so signOut can build id_token_hint and the
|
|
932
|
+
// callback path can inspect what was persisted.
|
|
933
|
+
onTokens: (t) => {
|
|
934
|
+
tokensRef.current = {
|
|
935
|
+
accessToken: t.accessToken,
|
|
936
|
+
refreshToken: t.refreshToken,
|
|
937
|
+
idToken: t.idToken,
|
|
938
|
+
expiresAt: t.expiresAt
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
}),
|
|
942
|
+
[authModule, resolvedRedirectUri, storage, crossTab]
|
|
943
|
+
);
|
|
944
|
+
useEffect(() => () => session.dispose(), [session]);
|
|
945
|
+
const sessionState = useSyncExternalStore(
|
|
946
|
+
session.subscribe,
|
|
947
|
+
session.getSnapshot,
|
|
948
|
+
session.getServerSnapshot
|
|
949
|
+
);
|
|
950
|
+
const state = useMemo(
|
|
951
|
+
() => ({
|
|
952
|
+
status: sessionState.status,
|
|
953
|
+
user: sessionState.isSignedIn ? user : null,
|
|
954
|
+
isLoaded: sessionState.isLoaded,
|
|
955
|
+
isSignedIn: sessionState.isSignedIn
|
|
956
|
+
}),
|
|
957
|
+
[sessionState, user]
|
|
958
|
+
);
|
|
959
|
+
const dispatch = useCallback(
|
|
960
|
+
(action) => {
|
|
961
|
+
if (action.type === "AUTHENTICATED") setUser(action.user);
|
|
962
|
+
else if (action.type === "UNAUTHENTICATED" || action.type === "ERROR") setUser(null);
|
|
963
|
+
},
|
|
964
|
+
[]
|
|
965
|
+
);
|
|
966
|
+
const fetchUser = useCallback(async (accessToken) => {
|
|
967
|
+
const data = await authModule.getUserInfo(accessToken);
|
|
968
|
+
return parseUserFromUserInfo(data);
|
|
969
|
+
}, [authModule]);
|
|
970
|
+
const refreshAccessToken = useCallback(
|
|
971
|
+
() => session.refresh(),
|
|
972
|
+
[session]
|
|
973
|
+
);
|
|
974
|
+
const getToken = useCallback(
|
|
975
|
+
() => session.getToken(),
|
|
976
|
+
[session]
|
|
977
|
+
);
|
|
978
|
+
const signInWithRedirect = useCallback(() => {
|
|
979
|
+
authModule.buildAuthorizationUrl({
|
|
980
|
+
redirectUri: resolvedRedirectUri,
|
|
981
|
+
scope: "openid profile email"
|
|
982
|
+
}).then(({ url, codeVerifier, state: stateParam }) => {
|
|
983
|
+
savePkceParams(codeVerifier, stateParam);
|
|
984
|
+
if (typeof window !== "undefined") {
|
|
985
|
+
window.location.href = url;
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
}, [authModule, resolvedRedirectUri]);
|
|
989
|
+
const signInWithSocial = useCallback((provider) => {
|
|
990
|
+
authModule.buildAuthorizationUrl({
|
|
991
|
+
redirectUri: resolvedRedirectUri,
|
|
992
|
+
scope: "openid profile email",
|
|
993
|
+
extraParams: { provider }
|
|
994
|
+
}).then(({ url, codeVerifier, state: stateParam }) => {
|
|
995
|
+
savePkceParams(codeVerifier, stateParam);
|
|
996
|
+
if (typeof window !== "undefined") {
|
|
997
|
+
window.location.href = url;
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
}, [authModule, resolvedRedirectUri]);
|
|
1001
|
+
const signIn = useCallback(async (email, password) => {
|
|
1002
|
+
if (authStrategy === "pkce" || !email && !password) {
|
|
1003
|
+
signInWithRedirect();
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
if (!email || !password) {
|
|
1007
|
+
throw new Error("Email and password are required for password-based sign-in");
|
|
1008
|
+
}
|
|
1009
|
+
dispatch({ type: "LOADING" });
|
|
1010
|
+
try {
|
|
1011
|
+
const data = await authModule.passwordGrant(
|
|
1012
|
+
email,
|
|
1013
|
+
password,
|
|
1014
|
+
"openid profile email",
|
|
1015
|
+
redirectUri
|
|
1016
|
+
);
|
|
1017
|
+
await session.adopt(data);
|
|
1018
|
+
const user2 = await fetchUser(data.access_token);
|
|
1019
|
+
dispatch({ type: "AUTHENTICATED", user: user2 });
|
|
1020
|
+
} catch (err) {
|
|
1021
|
+
dispatch({ type: "ERROR", error: err instanceof Error ? err.message : "Sign in failed" });
|
|
1022
|
+
throw err;
|
|
1023
|
+
}
|
|
1024
|
+
}, [authStrategy, authModule, redirectUri, fetchUser, session, signInWithRedirect, dispatch]);
|
|
1025
|
+
const handleCallback = useCallback(async () => {
|
|
1026
|
+
if (typeof window === "undefined") return;
|
|
1027
|
+
const params = new URLSearchParams(window.location.search);
|
|
1028
|
+
const code = params.get("code");
|
|
1029
|
+
if (code && callbackInflightRef.current?.code === code) {
|
|
1030
|
+
return callbackInflightRef.current.promise;
|
|
1031
|
+
}
|
|
1032
|
+
const promise = (async () => {
|
|
1033
|
+
const returnedState = params.get("state");
|
|
1034
|
+
const error = params.get("error");
|
|
1035
|
+
const errorDescription = params.get("error_description");
|
|
1036
|
+
if (error) {
|
|
1037
|
+
dispatch({ type: "ERROR", error: errorDescription || error });
|
|
1038
|
+
throw new Error(errorDescription || error);
|
|
1039
|
+
}
|
|
1040
|
+
if (!code) {
|
|
1041
|
+
dispatch({ type: "ERROR", error: "No authorization code found in callback URL" });
|
|
1042
|
+
throw new Error("No authorization code found in callback URL");
|
|
1043
|
+
}
|
|
1044
|
+
const { codeVerifier, state: savedState } = loadPkceParams();
|
|
1045
|
+
if (!savedState || savedState !== returnedState) {
|
|
1046
|
+
clearPkceParams();
|
|
1047
|
+
dispatch({ type: "ERROR", error: "Invalid state parameter \u2014 possible CSRF attack" });
|
|
1048
|
+
throw new Error("Invalid state parameter \u2014 possible CSRF attack");
|
|
1049
|
+
}
|
|
1050
|
+
if (!codeVerifier) {
|
|
1051
|
+
clearPkceParams();
|
|
1052
|
+
dispatch({ type: "ERROR", error: "No PKCE code verifier found" });
|
|
1053
|
+
throw new Error("No PKCE code verifier found");
|
|
1054
|
+
}
|
|
1055
|
+
dispatch({ type: "LOADING" });
|
|
1056
|
+
try {
|
|
1057
|
+
const data = await authModule.exchangeCodeForTokens({
|
|
1058
|
+
code,
|
|
1059
|
+
codeVerifier,
|
|
1060
|
+
redirectUri: resolvedRedirectUri
|
|
1061
|
+
});
|
|
1062
|
+
clearPkceParams();
|
|
1063
|
+
await session.adopt(data);
|
|
1064
|
+
const user2 = await fetchUser(data.access_token);
|
|
1065
|
+
dispatch({ type: "AUTHENTICATED", user: user2 });
|
|
1066
|
+
} catch (err) {
|
|
1067
|
+
clearPkceParams();
|
|
1068
|
+
dispatch({ type: "ERROR", error: err instanceof Error ? err.message : "Token exchange failed" });
|
|
1069
|
+
throw err;
|
|
1070
|
+
}
|
|
1071
|
+
})();
|
|
1072
|
+
if (code) {
|
|
1073
|
+
callbackInflightRef.current = { code, promise };
|
|
1074
|
+
promise.catch(() => {
|
|
1075
|
+
if (callbackInflightRef.current?.promise === promise) {
|
|
1076
|
+
callbackInflightRef.current = null;
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
return promise;
|
|
1081
|
+
}, [authModule, resolvedRedirectUri, fetchUser, session, dispatch]);
|
|
1082
|
+
const signUp = useCallback(async (_params) => {
|
|
1083
|
+
if (authStrategy === "pkce") {
|
|
1084
|
+
const safeOrgId = encodeURIComponent(orgId);
|
|
1085
|
+
const signUpUrl = `${domain.replace(/\/+$/, "")}/orgs/${safeOrgId}/register?` + new URLSearchParams({
|
|
1086
|
+
client_id: clientId,
|
|
1087
|
+
redirect_uri: resolvedRedirectUri,
|
|
1088
|
+
response_type: "code",
|
|
1089
|
+
scope: "openid profile email"
|
|
1090
|
+
}).toString();
|
|
1091
|
+
if (typeof window !== "undefined") {
|
|
1092
|
+
window.location.href = signUpUrl;
|
|
1093
|
+
}
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
dispatch({
|
|
1097
|
+
type: "ERROR",
|
|
1098
|
+
error: "inline_registration_unsupported"
|
|
1099
|
+
});
|
|
1100
|
+
throw new Error(
|
|
1101
|
+
`Inline registration is not supported by this LumoAuth server: there is no JSON registration endpoint. Use redirectToSignUp() to send the user to the hosted registration page (${domain.replace(/\/+$/, "")}/orgs/${encodeURIComponent(orgId)}/register), or set authStrategy: "pkce".`
|
|
1102
|
+
);
|
|
1103
|
+
}, [authStrategy, domain, orgId, clientId, resolvedRedirectUri, signIn]);
|
|
1104
|
+
const sendMagicLink = useCallback(async (email, redirectUri2) => {
|
|
1105
|
+
await authModule.requestMagicLink({ email, redirectUri: redirectUri2 });
|
|
1106
|
+
}, [authModule]);
|
|
1107
|
+
const checkEmail = useCallback(
|
|
1108
|
+
(email) => authModule.checkEmailExists(email),
|
|
1109
|
+
[authModule]
|
|
1110
|
+
);
|
|
1111
|
+
const signOut = useCallback(async (options) => {
|
|
1112
|
+
const { accessToken, idToken } = tokensRef.current;
|
|
1113
|
+
if (typeof window === "undefined") {
|
|
1114
|
+
if (accessToken) {
|
|
1115
|
+
authModule.revokeToken(accessToken, accessToken).catch(() => {
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
tokensRef.current = { accessToken: null, refreshToken: null, expiresAt: null, idToken: null };
|
|
1119
|
+
await session.clearSession();
|
|
1120
|
+
dispatch({ type: "UNAUTHENTICATED" });
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
const targetUrl = options?.afterSignOutUrl || afterSignOutUrl || "/";
|
|
1124
|
+
const postLogoutRedirectUri = new URL(targetUrl, window.location.origin).toString();
|
|
1125
|
+
const safeOrgId = encodeURIComponent(orgId);
|
|
1126
|
+
const params = new URLSearchParams({
|
|
1127
|
+
post_logout_redirect_uri: postLogoutRedirectUri
|
|
1128
|
+
});
|
|
1129
|
+
if (idToken) {
|
|
1130
|
+
params.set("id_token_hint", idToken);
|
|
1131
|
+
}
|
|
1132
|
+
const logoutUrl = `${domain.replace(/\/+$/, "")}/orgs/${safeOrgId}/api/v1/oauth/logout?${params.toString()}`;
|
|
1133
|
+
if (accessToken) {
|
|
1134
|
+
authModule.revokeToken(accessToken, accessToken).catch(() => {
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
tokensRef.current = { accessToken: null, refreshToken: null, expiresAt: null, idToken: null };
|
|
1138
|
+
await session.clearSession(null, { emit: false });
|
|
1139
|
+
window.location.replace(logoutUrl);
|
|
1140
|
+
await new Promise(() => {
|
|
1141
|
+
});
|
|
1142
|
+
}, [authModule, domain, orgId, afterSignOutUrl, session, dispatch]);
|
|
1143
|
+
useEffect(() => {
|
|
1144
|
+
let cancelled = false;
|
|
1145
|
+
async function init() {
|
|
1146
|
+
if (typeof window === "undefined") return;
|
|
1147
|
+
const params = new URLSearchParams(window.location.search);
|
|
1148
|
+
const code = params.get("code");
|
|
1149
|
+
const returnedState = params.get("state");
|
|
1150
|
+
if (code && returnedState) {
|
|
1151
|
+
if (callbackHandledRef.current) return;
|
|
1152
|
+
callbackHandledRef.current = true;
|
|
1153
|
+
try {
|
|
1154
|
+
await handleCallback();
|
|
1155
|
+
if (cancelled) return;
|
|
1156
|
+
params.delete("code");
|
|
1157
|
+
params.delete("state");
|
|
1158
|
+
params.delete("iss");
|
|
1159
|
+
const cleanUrl = params.toString() ? `${window.location.pathname}?${params}` : window.location.pathname;
|
|
1160
|
+
window.history.replaceState({}, "", cleanUrl);
|
|
1161
|
+
return;
|
|
1162
|
+
} catch {
|
|
1163
|
+
callbackHandledRef.current = false;
|
|
1164
|
+
if (!cancelled) dispatch({ type: "UNAUTHENTICATED" });
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
init().then(() => {
|
|
1170
|
+
if (!cancelled) void session.hydrate();
|
|
1171
|
+
});
|
|
1172
|
+
return () => {
|
|
1173
|
+
cancelled = true;
|
|
1174
|
+
};
|
|
1175
|
+
}, [fetchUser, handleCallback, refreshAccessToken, session]);
|
|
1176
|
+
useEffect(() => {
|
|
1177
|
+
let cancelled = false;
|
|
1178
|
+
if (!sessionState.isSignedIn) {
|
|
1179
|
+
setUser(null);
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
if (user) return;
|
|
1183
|
+
void (async () => {
|
|
1184
|
+
const token = await session.getToken().catch(() => null);
|
|
1185
|
+
if (cancelled || !token) return;
|
|
1186
|
+
try {
|
|
1187
|
+
const fetched = await fetchUser(token);
|
|
1188
|
+
if (!cancelled) setUser(fetched);
|
|
1189
|
+
} catch {
|
|
1190
|
+
}
|
|
1191
|
+
})();
|
|
1192
|
+
return () => {
|
|
1193
|
+
cancelled = true;
|
|
1194
|
+
};
|
|
1195
|
+
}, [sessionState.isSignedIn, user, session, fetchUser]);
|
|
1196
|
+
const contextValue = useMemo(() => ({
|
|
1197
|
+
...state,
|
|
1198
|
+
signIn,
|
|
1199
|
+
signInWithRedirect,
|
|
1200
|
+
signInWithSocial,
|
|
1201
|
+
signUp,
|
|
1202
|
+
signOut,
|
|
1203
|
+
getToken,
|
|
1204
|
+
handleCallback,
|
|
1205
|
+
sendMagicLink,
|
|
1206
|
+
checkEmail,
|
|
1207
|
+
authStrategy,
|
|
1208
|
+
config: {
|
|
1209
|
+
domain,
|
|
1210
|
+
orgId,
|
|
1211
|
+
clientId,
|
|
1212
|
+
redirectUri: resolvedRedirectUri,
|
|
1213
|
+
afterSignInUrl,
|
|
1214
|
+
afterSignUpUrl,
|
|
1215
|
+
afterSignOutUrl
|
|
1216
|
+
}
|
|
1217
|
+
}), [state, signIn, signInWithRedirect, signInWithSocial, signUp, signOut, getToken, handleCallback, sendMagicLink, checkEmail, authStrategy, domain, orgId, clientId, resolvedRedirectUri, afterSignInUrl, afterSignUpUrl, afterSignOutUrl]);
|
|
1218
|
+
return /* @__PURE__ */ jsx(LumoAuthContext.Provider, { value: contextValue, children });
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
// src/components/SignIn.tsx
|
|
1222
|
+
import { useState as useState2, useCallback as useCallback2 } from "react";
|
|
1223
|
+
|
|
1224
|
+
// src/utils/url.ts
|
|
1225
|
+
function sanitizeRedirectUrl(url, defaultUrl = "/") {
|
|
1226
|
+
if (!url || typeof url !== "string") {
|
|
1227
|
+
return defaultUrl;
|
|
1228
|
+
}
|
|
1229
|
+
let sanitizedUrl = url.trim().replace(/[\x00-\x1F\x7F]/g, "");
|
|
1230
|
+
try {
|
|
1231
|
+
const parsedUrl = new URL(sanitizedUrl, typeof window !== "undefined" ? window.location.origin : "http://localhost");
|
|
1232
|
+
if (sanitizedUrl.startsWith("/") && !sanitizedUrl.startsWith("//")) {
|
|
1233
|
+
return sanitizedUrl;
|
|
1234
|
+
}
|
|
1235
|
+
const dangerousSchemes = ["javascript:", "data:", "vbscript:", "file:"];
|
|
1236
|
+
if (dangerousSchemes.includes(parsedUrl.protocol.toLowerCase())) {
|
|
1237
|
+
return defaultUrl;
|
|
1238
|
+
}
|
|
1239
|
+
if (typeof window !== "undefined" && parsedUrl.origin !== window.location.origin) {
|
|
1240
|
+
return defaultUrl;
|
|
1241
|
+
}
|
|
1242
|
+
return parsedUrl.href;
|
|
1243
|
+
} catch {
|
|
1244
|
+
return defaultUrl;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
// src/components/SignIn.tsx
|
|
1249
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
1250
|
+
var SOCIAL_ICONS = {
|
|
1251
|
+
google: /* @__PURE__ */ jsxs("svg", { className: "la-social-icon", viewBox: "0 0 24 24", fill: "none", children: [
|
|
1252
|
+
/* @__PURE__ */ jsx2("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z", fill: "#4285F4" }),
|
|
1253
|
+
/* @__PURE__ */ jsx2("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z", fill: "#34A853" }),
|
|
1254
|
+
/* @__PURE__ */ jsx2("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z", fill: "#FBBC05" }),
|
|
1255
|
+
/* @__PURE__ */ jsx2("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })
|
|
1256
|
+
] }),
|
|
1257
|
+
github: /* @__PURE__ */ jsx2("svg", { className: "la-social-icon", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx2("path", { d: "M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" }) }),
|
|
1258
|
+
microsoft: /* @__PURE__ */ jsxs("svg", { className: "la-social-icon", viewBox: "0 0 24 24", fill: "none", children: [
|
|
1259
|
+
/* @__PURE__ */ jsx2("rect", { x: "1", y: "1", width: "10", height: "10", fill: "#F25022" }),
|
|
1260
|
+
/* @__PURE__ */ jsx2("rect", { x: "13", y: "1", width: "10", height: "10", fill: "#7FBA00" }),
|
|
1261
|
+
/* @__PURE__ */ jsx2("rect", { x: "1", y: "13", width: "10", height: "10", fill: "#00A4EF" }),
|
|
1262
|
+
/* @__PURE__ */ jsx2("rect", { x: "13", y: "13", width: "10", height: "10", fill: "#FFB900" })
|
|
1263
|
+
] }),
|
|
1264
|
+
apple: /* @__PURE__ */ jsx2("svg", { className: "la-social-icon", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx2("path", { d: "M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z" }) })
|
|
1265
|
+
};
|
|
1266
|
+
function getSocialLabel(provider) {
|
|
1267
|
+
const names = {
|
|
1268
|
+
google: "Google",
|
|
1269
|
+
github: "GitHub",
|
|
1270
|
+
microsoft: "Microsoft",
|
|
1271
|
+
apple: "Apple",
|
|
1272
|
+
facebook: "Facebook",
|
|
1273
|
+
linkedin: "LinkedIn",
|
|
1274
|
+
twitter: "X (Twitter)",
|
|
1275
|
+
gitlab: "GitLab"
|
|
1276
|
+
};
|
|
1277
|
+
return names[provider] || provider.charAt(0).toUpperCase() + provider.slice(1);
|
|
1278
|
+
}
|
|
1279
|
+
function SignIn({
|
|
1280
|
+
afterSignInUrl,
|
|
1281
|
+
signUpUrl,
|
|
1282
|
+
appearance,
|
|
1283
|
+
socialProviders = []
|
|
1284
|
+
}) {
|
|
1285
|
+
const { signIn, signInWithSocial, config, status, authStrategy } = useLumoAuthContext();
|
|
1286
|
+
const resolvedAfterSignInUrl = afterSignInUrl || config.afterSignInUrl || "/";
|
|
1287
|
+
const resolvedSignUpUrl = signUpUrl || config.afterSignUpUrl || "/sign-up";
|
|
1288
|
+
const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
|
|
1289
|
+
if (status === "authenticated") {
|
|
1290
|
+
return null;
|
|
1291
|
+
}
|
|
1292
|
+
if (authStrategy === "pkce") {
|
|
1293
|
+
return /* @__PURE__ */ jsx2(
|
|
1294
|
+
SignInPkce,
|
|
1295
|
+
{
|
|
1296
|
+
signIn,
|
|
1297
|
+
signInWithSocial,
|
|
1298
|
+
socialProviders,
|
|
1299
|
+
resolvedSignUpUrl,
|
|
1300
|
+
themeClass,
|
|
1301
|
+
appearance
|
|
1302
|
+
}
|
|
1303
|
+
);
|
|
1304
|
+
}
|
|
1305
|
+
return /* @__PURE__ */ jsx2(
|
|
1306
|
+
SignInPassword,
|
|
1307
|
+
{
|
|
1308
|
+
signIn,
|
|
1309
|
+
signInWithSocial,
|
|
1310
|
+
socialProviders,
|
|
1311
|
+
config,
|
|
1312
|
+
resolvedAfterSignInUrl,
|
|
1313
|
+
resolvedSignUpUrl,
|
|
1314
|
+
themeClass,
|
|
1315
|
+
appearance
|
|
1316
|
+
}
|
|
1317
|
+
);
|
|
1318
|
+
}
|
|
1319
|
+
function SignInPkce({
|
|
1320
|
+
signIn,
|
|
1321
|
+
signInWithSocial,
|
|
1322
|
+
socialProviders,
|
|
1323
|
+
resolvedSignUpUrl,
|
|
1324
|
+
themeClass,
|
|
1325
|
+
appearance
|
|
1326
|
+
}) {
|
|
1327
|
+
const handleSocialLogin = useCallback2((provider) => {
|
|
1328
|
+
signInWithSocial(provider);
|
|
1329
|
+
}, [signInWithSocial]);
|
|
1330
|
+
return /* @__PURE__ */ jsxs(
|
|
1331
|
+
"div",
|
|
1332
|
+
{
|
|
1333
|
+
className: `la-card ${themeClass} ${appearance?.className || ""}`,
|
|
1334
|
+
style: appearance?.variables,
|
|
1335
|
+
children: [
|
|
1336
|
+
/* @__PURE__ */ jsxs("div", { className: "la-card-header", children: [
|
|
1337
|
+
/* @__PURE__ */ jsx2("h2", { className: "la-card-title", children: "Sign in" }),
|
|
1338
|
+
/* @__PURE__ */ jsx2("p", { className: "la-card-subtitle", children: "Welcome back! Please sign in to continue." })
|
|
1339
|
+
] }),
|
|
1340
|
+
socialProviders.length > 0 && /* @__PURE__ */ jsx2("div", { className: "la-social-buttons", children: socialProviders.map((provider) => /* @__PURE__ */ jsxs(
|
|
1341
|
+
"button",
|
|
1342
|
+
{
|
|
1343
|
+
type: "button",
|
|
1344
|
+
className: "la-social-btn",
|
|
1345
|
+
onClick: () => handleSocialLogin(provider),
|
|
1346
|
+
children: [
|
|
1347
|
+
SOCIAL_ICONS[provider] || null,
|
|
1348
|
+
"Continue with ",
|
|
1349
|
+
getSocialLabel(provider)
|
|
1350
|
+
]
|
|
1351
|
+
},
|
|
1352
|
+
provider
|
|
1353
|
+
)) }),
|
|
1354
|
+
socialProviders.length > 0 && /* @__PURE__ */ jsx2("div", { className: "la-divider", children: "or" }),
|
|
1355
|
+
/* @__PURE__ */ jsx2(
|
|
1356
|
+
"button",
|
|
1357
|
+
{
|
|
1358
|
+
type: "button",
|
|
1359
|
+
className: "la-btn la-btn-primary",
|
|
1360
|
+
onClick: () => signIn(),
|
|
1361
|
+
children: "Sign in with email"
|
|
1362
|
+
}
|
|
1363
|
+
),
|
|
1364
|
+
/* @__PURE__ */ jsxs("div", { className: "la-footer", children: [
|
|
1365
|
+
"Don't have an account?",
|
|
1366
|
+
" ",
|
|
1367
|
+
/* @__PURE__ */ jsx2("a", { href: resolvedSignUpUrl, children: "Sign up" })
|
|
1368
|
+
] })
|
|
1369
|
+
]
|
|
1370
|
+
}
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1373
|
+
function SignInPassword({
|
|
1374
|
+
signIn,
|
|
1375
|
+
signInWithSocial,
|
|
1376
|
+
socialProviders,
|
|
1377
|
+
config,
|
|
1378
|
+
resolvedAfterSignInUrl,
|
|
1379
|
+
resolvedSignUpUrl,
|
|
1380
|
+
themeClass,
|
|
1381
|
+
appearance
|
|
1382
|
+
}) {
|
|
1383
|
+
const [email, setEmail] = useState2("");
|
|
1384
|
+
const [password, setPassword] = useState2("");
|
|
1385
|
+
const [error, setError] = useState2(null);
|
|
1386
|
+
const [loading, setLoading] = useState2(false);
|
|
1387
|
+
const handleSubmit = useCallback2(async (e) => {
|
|
1388
|
+
e.preventDefault();
|
|
1389
|
+
setError(null);
|
|
1390
|
+
setLoading(true);
|
|
1391
|
+
try {
|
|
1392
|
+
await signIn(email, password);
|
|
1393
|
+
if (typeof window !== "undefined") {
|
|
1394
|
+
window.location.href = sanitizeRedirectUrl(resolvedAfterSignInUrl);
|
|
1395
|
+
}
|
|
1396
|
+
} catch (err) {
|
|
1397
|
+
setError(err instanceof Error ? err.message : "Sign in failed. Please try again.");
|
|
1398
|
+
} finally {
|
|
1399
|
+
setLoading(false);
|
|
1400
|
+
}
|
|
1401
|
+
}, [signIn, email, password, resolvedAfterSignInUrl]);
|
|
1402
|
+
const handleSocialLogin = useCallback2((provider) => {
|
|
1403
|
+
signInWithSocial(provider);
|
|
1404
|
+
}, [signInWithSocial]);
|
|
1405
|
+
return /* @__PURE__ */ jsxs(
|
|
1406
|
+
"div",
|
|
1407
|
+
{
|
|
1408
|
+
className: `la-card ${themeClass} ${appearance?.className || ""}`,
|
|
1409
|
+
style: appearance?.variables,
|
|
1410
|
+
children: [
|
|
1411
|
+
/* @__PURE__ */ jsxs("div", { className: "la-card-header", children: [
|
|
1412
|
+
/* @__PURE__ */ jsx2("h2", { className: "la-card-title", children: "Sign in" }),
|
|
1413
|
+
/* @__PURE__ */ jsx2("p", { className: "la-card-subtitle", children: "Welcome back! Please sign in to continue." })
|
|
1414
|
+
] }),
|
|
1415
|
+
socialProviders.length > 0 && /* @__PURE__ */ jsx2("div", { className: "la-social-buttons", children: socialProviders.map((provider) => /* @__PURE__ */ jsxs(
|
|
1416
|
+
"button",
|
|
1417
|
+
{
|
|
1418
|
+
type: "button",
|
|
1419
|
+
className: "la-social-btn",
|
|
1420
|
+
onClick: () => handleSocialLogin(provider),
|
|
1421
|
+
disabled: loading,
|
|
1422
|
+
children: [
|
|
1423
|
+
SOCIAL_ICONS[provider] || null,
|
|
1424
|
+
"Continue with ",
|
|
1425
|
+
getSocialLabel(provider)
|
|
1426
|
+
]
|
|
1427
|
+
},
|
|
1428
|
+
provider
|
|
1429
|
+
)) }),
|
|
1430
|
+
socialProviders.length > 0 && /* @__PURE__ */ jsx2("div", { className: "la-divider", children: "or" }),
|
|
1431
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
1432
|
+
error && /* @__PURE__ */ jsx2("div", { className: "la-alert la-alert-error", role: "alert", children: error }),
|
|
1433
|
+
/* @__PURE__ */ jsxs("div", { className: "la-form-group", children: [
|
|
1434
|
+
/* @__PURE__ */ jsx2("label", { className: "la-label", htmlFor: "la-signin-email", children: "Email address" }),
|
|
1435
|
+
/* @__PURE__ */ jsx2(
|
|
1436
|
+
"input",
|
|
1437
|
+
{
|
|
1438
|
+
id: "la-signin-email",
|
|
1439
|
+
className: "la-input",
|
|
1440
|
+
type: "email",
|
|
1441
|
+
placeholder: "name@example.com",
|
|
1442
|
+
value: email,
|
|
1443
|
+
onChange: (e) => setEmail(e.target.value),
|
|
1444
|
+
required: true,
|
|
1445
|
+
autoComplete: "email",
|
|
1446
|
+
disabled: loading
|
|
1447
|
+
}
|
|
1448
|
+
)
|
|
1449
|
+
] }),
|
|
1450
|
+
/* @__PURE__ */ jsxs("div", { className: "la-form-group", children: [
|
|
1451
|
+
/* @__PURE__ */ jsx2("label", { className: "la-label", htmlFor: "la-signin-password", children: "Password" }),
|
|
1452
|
+
/* @__PURE__ */ jsx2(
|
|
1453
|
+
"input",
|
|
1454
|
+
{
|
|
1455
|
+
id: "la-signin-password",
|
|
1456
|
+
className: "la-input",
|
|
1457
|
+
type: "password",
|
|
1458
|
+
placeholder: "Enter your password",
|
|
1459
|
+
value: password,
|
|
1460
|
+
onChange: (e) => setPassword(e.target.value),
|
|
1461
|
+
required: true,
|
|
1462
|
+
autoComplete: "current-password",
|
|
1463
|
+
disabled: loading
|
|
1464
|
+
}
|
|
1465
|
+
)
|
|
1466
|
+
] }),
|
|
1467
|
+
/* @__PURE__ */ jsx2("div", { className: "la-forgot", children: /* @__PURE__ */ jsx2("a", { href: `${config.domain}/account/forgot-password`, children: "Forgot password?" }) }),
|
|
1468
|
+
/* @__PURE__ */ jsxs(
|
|
1469
|
+
"button",
|
|
1470
|
+
{
|
|
1471
|
+
type: "submit",
|
|
1472
|
+
className: "la-btn la-btn-primary",
|
|
1473
|
+
disabled: loading || !email || !password,
|
|
1474
|
+
children: [
|
|
1475
|
+
loading ? /* @__PURE__ */ jsx2("span", { className: "la-spinner la-spinner-sm" }) : null,
|
|
1476
|
+
loading ? "Signing in\u2026" : "Sign in"
|
|
1477
|
+
]
|
|
1478
|
+
}
|
|
1479
|
+
)
|
|
1480
|
+
] }),
|
|
1481
|
+
/* @__PURE__ */ jsxs("div", { className: "la-footer", children: [
|
|
1482
|
+
"Don't have an account?",
|
|
1483
|
+
" ",
|
|
1484
|
+
/* @__PURE__ */ jsx2("a", { href: resolvedSignUpUrl, children: "Sign up" })
|
|
1485
|
+
] })
|
|
1486
|
+
]
|
|
1487
|
+
}
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
// src/components/SignUp.tsx
|
|
1492
|
+
import { useState as useState3, useCallback as useCallback3, useMemo as useMemo2 } from "react";
|
|
1493
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1494
|
+
function getPasswordStrength(password) {
|
|
1495
|
+
if (!password) return { score: 0, label: "" };
|
|
1496
|
+
let score = 0;
|
|
1497
|
+
if (password.length >= 8) score++;
|
|
1498
|
+
if (password.length >= 12) score++;
|
|
1499
|
+
if (/[A-Z]/.test(password) && /[a-z]/.test(password)) score++;
|
|
1500
|
+
if (/\d/.test(password)) score++;
|
|
1501
|
+
if (/[^A-Za-z0-9]/.test(password)) score++;
|
|
1502
|
+
const capped = Math.min(score, 4);
|
|
1503
|
+
const labels = ["", "Weak", "Fair", "Good", "Strong"];
|
|
1504
|
+
return { score: capped, label: labels[capped] };
|
|
1505
|
+
}
|
|
1506
|
+
function SignUp({
|
|
1507
|
+
afterSignUpUrl,
|
|
1508
|
+
signInUrl,
|
|
1509
|
+
appearance
|
|
1510
|
+
}) {
|
|
1511
|
+
const { signUp, config, status, authStrategy } = useLumoAuthContext();
|
|
1512
|
+
const resolvedSignInUrl = signInUrl || "/sign-in";
|
|
1513
|
+
const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
|
|
1514
|
+
if (status === "authenticated") {
|
|
1515
|
+
return null;
|
|
1516
|
+
}
|
|
1517
|
+
if (authStrategy === "pkce") {
|
|
1518
|
+
return /* @__PURE__ */ jsxs2(
|
|
1519
|
+
"div",
|
|
1520
|
+
{
|
|
1521
|
+
className: `la-card ${themeClass} ${appearance?.className || ""}`,
|
|
1522
|
+
style: appearance?.variables,
|
|
1523
|
+
children: [
|
|
1524
|
+
/* @__PURE__ */ jsxs2("div", { className: "la-card-header", children: [
|
|
1525
|
+
/* @__PURE__ */ jsx3("h2", { className: "la-card-title", children: "Create your account" }),
|
|
1526
|
+
/* @__PURE__ */ jsx3("p", { className: "la-card-subtitle", children: "Get started \u2014 it only takes a minute." })
|
|
1527
|
+
] }),
|
|
1528
|
+
/* @__PURE__ */ jsx3(
|
|
1529
|
+
"button",
|
|
1530
|
+
{
|
|
1531
|
+
type: "button",
|
|
1532
|
+
className: "la-btn la-btn-primary",
|
|
1533
|
+
onClick: () => signUp({ email: "", password: "" }),
|
|
1534
|
+
children: "Create account"
|
|
1535
|
+
}
|
|
1536
|
+
),
|
|
1537
|
+
/* @__PURE__ */ jsxs2("div", { className: "la-footer", children: [
|
|
1538
|
+
"Already have an account?",
|
|
1539
|
+
" ",
|
|
1540
|
+
/* @__PURE__ */ jsx3("a", { href: resolvedSignInUrl, children: "Sign in" })
|
|
1541
|
+
] })
|
|
1542
|
+
]
|
|
1543
|
+
}
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
return /* @__PURE__ */ jsx3(
|
|
1547
|
+
SignUpPasswordForm,
|
|
1548
|
+
{
|
|
1549
|
+
signUp,
|
|
1550
|
+
resolvedAfterSignUpUrl: afterSignUpUrl || config.afterSignUpUrl || "/",
|
|
1551
|
+
resolvedSignInUrl,
|
|
1552
|
+
themeClass,
|
|
1553
|
+
appearance
|
|
1554
|
+
}
|
|
1555
|
+
);
|
|
1556
|
+
}
|
|
1557
|
+
function SignUpPasswordForm({
|
|
1558
|
+
signUp,
|
|
1559
|
+
resolvedAfterSignUpUrl,
|
|
1560
|
+
resolvedSignInUrl,
|
|
1561
|
+
themeClass,
|
|
1562
|
+
appearance
|
|
1563
|
+
}) {
|
|
1564
|
+
const [firstName, setFirstName] = useState3("");
|
|
1565
|
+
const [lastName, setLastName] = useState3("");
|
|
1566
|
+
const [email, setEmail] = useState3("");
|
|
1567
|
+
const [password, setPassword] = useState3("");
|
|
1568
|
+
const [error, setError] = useState3(null);
|
|
1569
|
+
const [loading, setLoading] = useState3(false);
|
|
1570
|
+
const passwordStrength = useMemo2(() => getPasswordStrength(password), [password]);
|
|
1571
|
+
const handleSubmit = useCallback3(async (e) => {
|
|
1572
|
+
e.preventDefault();
|
|
1573
|
+
setError(null);
|
|
1574
|
+
setLoading(true);
|
|
1575
|
+
try {
|
|
1576
|
+
await signUp({
|
|
1577
|
+
email,
|
|
1578
|
+
password,
|
|
1579
|
+
firstName: firstName || void 0,
|
|
1580
|
+
lastName: lastName || void 0
|
|
1581
|
+
});
|
|
1582
|
+
if (typeof window !== "undefined") {
|
|
1583
|
+
window.location.href = sanitizeRedirectUrl(resolvedAfterSignUpUrl);
|
|
1584
|
+
}
|
|
1585
|
+
} catch (err) {
|
|
1586
|
+
setError(err instanceof Error ? err.message : "Registration failed. Please try again.");
|
|
1587
|
+
} finally {
|
|
1588
|
+
setLoading(false);
|
|
1589
|
+
}
|
|
1590
|
+
}, [signUp, email, password, firstName, lastName, resolvedAfterSignUpUrl]);
|
|
1591
|
+
return /* @__PURE__ */ jsxs2(
|
|
1592
|
+
"div",
|
|
1593
|
+
{
|
|
1594
|
+
className: `la-card ${themeClass} ${appearance?.className || ""}`,
|
|
1595
|
+
style: appearance?.variables,
|
|
1596
|
+
children: [
|
|
1597
|
+
/* @__PURE__ */ jsxs2("div", { className: "la-card-header", children: [
|
|
1598
|
+
/* @__PURE__ */ jsx3("h2", { className: "la-card-title", children: "Create your account" }),
|
|
1599
|
+
/* @__PURE__ */ jsx3("p", { className: "la-card-subtitle", children: "Get started \u2014 it only takes a minute." })
|
|
1600
|
+
] }),
|
|
1601
|
+
/* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit, children: [
|
|
1602
|
+
error && /* @__PURE__ */ jsx3("div", { className: "la-alert la-alert-error", role: "alert", children: error }),
|
|
1603
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: "0.75rem" }, children: [
|
|
1604
|
+
/* @__PURE__ */ jsxs2("div", { className: "la-form-group", style: { flex: 1 }, children: [
|
|
1605
|
+
/* @__PURE__ */ jsx3("label", { className: "la-label", htmlFor: "la-signup-firstname", children: "First name" }),
|
|
1606
|
+
/* @__PURE__ */ jsx3(
|
|
1607
|
+
"input",
|
|
1608
|
+
{
|
|
1609
|
+
id: "la-signup-firstname",
|
|
1610
|
+
className: "la-input",
|
|
1611
|
+
type: "text",
|
|
1612
|
+
placeholder: "Jane",
|
|
1613
|
+
value: firstName,
|
|
1614
|
+
onChange: (e) => setFirstName(e.target.value),
|
|
1615
|
+
autoComplete: "given-name",
|
|
1616
|
+
disabled: loading
|
|
1617
|
+
}
|
|
1618
|
+
)
|
|
1619
|
+
] }),
|
|
1620
|
+
/* @__PURE__ */ jsxs2("div", { className: "la-form-group", style: { flex: 1 }, children: [
|
|
1621
|
+
/* @__PURE__ */ jsx3("label", { className: "la-label", htmlFor: "la-signup-lastname", children: "Last name" }),
|
|
1622
|
+
/* @__PURE__ */ jsx3(
|
|
1623
|
+
"input",
|
|
1624
|
+
{
|
|
1625
|
+
id: "la-signup-lastname",
|
|
1626
|
+
className: "la-input",
|
|
1627
|
+
type: "text",
|
|
1628
|
+
placeholder: "Doe",
|
|
1629
|
+
value: lastName,
|
|
1630
|
+
onChange: (e) => setLastName(e.target.value),
|
|
1631
|
+
autoComplete: "family-name",
|
|
1632
|
+
disabled: loading
|
|
1633
|
+
}
|
|
1634
|
+
)
|
|
1635
|
+
] })
|
|
1636
|
+
] }),
|
|
1637
|
+
/* @__PURE__ */ jsxs2("div", { className: "la-form-group", children: [
|
|
1638
|
+
/* @__PURE__ */ jsx3("label", { className: "la-label", htmlFor: "la-signup-email", children: "Email address" }),
|
|
1639
|
+
/* @__PURE__ */ jsx3(
|
|
1640
|
+
"input",
|
|
1641
|
+
{
|
|
1642
|
+
id: "la-signup-email",
|
|
1643
|
+
className: "la-input",
|
|
1644
|
+
type: "email",
|
|
1645
|
+
placeholder: "name@example.com",
|
|
1646
|
+
value: email,
|
|
1647
|
+
onChange: (e) => setEmail(e.target.value),
|
|
1648
|
+
required: true,
|
|
1649
|
+
autoComplete: "email",
|
|
1650
|
+
disabled: loading
|
|
1651
|
+
}
|
|
1652
|
+
)
|
|
1653
|
+
] }),
|
|
1654
|
+
/* @__PURE__ */ jsxs2("div", { className: "la-form-group", children: [
|
|
1655
|
+
/* @__PURE__ */ jsx3("label", { className: "la-label", htmlFor: "la-signup-password", children: "Password" }),
|
|
1656
|
+
/* @__PURE__ */ jsx3(
|
|
1657
|
+
"input",
|
|
1658
|
+
{
|
|
1659
|
+
id: "la-signup-password",
|
|
1660
|
+
className: "la-input",
|
|
1661
|
+
type: "password",
|
|
1662
|
+
placeholder: "Create a strong password",
|
|
1663
|
+
value: password,
|
|
1664
|
+
onChange: (e) => setPassword(e.target.value),
|
|
1665
|
+
required: true,
|
|
1666
|
+
minLength: 8,
|
|
1667
|
+
autoComplete: "new-password",
|
|
1668
|
+
disabled: loading
|
|
1669
|
+
}
|
|
1670
|
+
),
|
|
1671
|
+
password && /* @__PURE__ */ jsxs2("div", { className: "la-password-strength", children: [
|
|
1672
|
+
/* @__PURE__ */ jsx3("div", { className: "la-password-bar", children: /* @__PURE__ */ jsx3(
|
|
1673
|
+
"div",
|
|
1674
|
+
{
|
|
1675
|
+
className: "la-password-fill",
|
|
1676
|
+
"data-strength": passwordStrength.score
|
|
1677
|
+
}
|
|
1678
|
+
) }),
|
|
1679
|
+
passwordStrength.label && /* @__PURE__ */ jsx3("div", { className: "la-password-label", children: passwordStrength.label })
|
|
1680
|
+
] })
|
|
1681
|
+
] }),
|
|
1682
|
+
/* @__PURE__ */ jsxs2(
|
|
1683
|
+
"button",
|
|
1684
|
+
{
|
|
1685
|
+
type: "submit",
|
|
1686
|
+
className: "la-btn la-btn-primary",
|
|
1687
|
+
disabled: loading || !email || !password,
|
|
1688
|
+
style: { marginTop: "0.5rem" },
|
|
1689
|
+
children: [
|
|
1690
|
+
loading ? /* @__PURE__ */ jsx3("span", { className: "la-spinner la-spinner-sm" }) : null,
|
|
1691
|
+
loading ? "Creating account\u2026" : "Create account"
|
|
1692
|
+
]
|
|
1693
|
+
}
|
|
1694
|
+
)
|
|
1695
|
+
] }),
|
|
1696
|
+
/* @__PURE__ */ jsxs2("div", { className: "la-footer", children: [
|
|
1697
|
+
"Already have an account?",
|
|
1698
|
+
" ",
|
|
1699
|
+
/* @__PURE__ */ jsx3("a", { href: resolvedSignInUrl, children: "Sign in" })
|
|
1700
|
+
] })
|
|
1701
|
+
]
|
|
1702
|
+
}
|
|
1703
|
+
);
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
// src/components/AuthCallback.tsx
|
|
1707
|
+
import { useEffect as useEffect2, useState as useState4 } from "react";
|
|
1708
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1709
|
+
function AuthCallback({
|
|
1710
|
+
afterSignInUrl,
|
|
1711
|
+
loading,
|
|
1712
|
+
error: errorComponent
|
|
1713
|
+
}) {
|
|
1714
|
+
const { handleCallback, config } = useLumoAuthContext();
|
|
1715
|
+
const [error, setError] = useState4(null);
|
|
1716
|
+
const resolvedAfterSignInUrl = afterSignInUrl || config.afterSignInUrl || "/";
|
|
1717
|
+
useEffect2(() => {
|
|
1718
|
+
let cancelled = false;
|
|
1719
|
+
handleCallback().then(() => {
|
|
1720
|
+
if (!cancelled && typeof window !== "undefined") {
|
|
1721
|
+
window.location.href = sanitizeRedirectUrl(resolvedAfterSignInUrl);
|
|
1722
|
+
}
|
|
1723
|
+
}).catch((err) => {
|
|
1724
|
+
if (!cancelled) {
|
|
1725
|
+
setError(err instanceof Error ? err.message : "Authentication failed");
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1728
|
+
return () => {
|
|
1729
|
+
cancelled = true;
|
|
1730
|
+
};
|
|
1731
|
+
}, [handleCallback, resolvedAfterSignInUrl]);
|
|
1732
|
+
if (error) {
|
|
1733
|
+
if (errorComponent) {
|
|
1734
|
+
return typeof errorComponent === "function" ? /* @__PURE__ */ jsx4(Fragment, { children: errorComponent(error) }) : /* @__PURE__ */ jsx4(Fragment, { children: errorComponent });
|
|
1735
|
+
}
|
|
1736
|
+
return /* @__PURE__ */ jsxs3("div", { className: "la-card", children: [
|
|
1737
|
+
/* @__PURE__ */ jsx4("div", { className: "la-card-header", children: /* @__PURE__ */ jsx4("h2", { className: "la-card-title", children: "Authentication Error" }) }),
|
|
1738
|
+
/* @__PURE__ */ jsx4("div", { className: "la-alert la-alert-error", role: "alert", children: error }),
|
|
1739
|
+
/* @__PURE__ */ jsx4(
|
|
1740
|
+
"button",
|
|
1741
|
+
{
|
|
1742
|
+
type: "button",
|
|
1743
|
+
className: "la-btn la-btn-primary",
|
|
1744
|
+
onClick: () => {
|
|
1745
|
+
if (typeof window !== "undefined") {
|
|
1746
|
+
window.location.href = "/";
|
|
1747
|
+
}
|
|
1748
|
+
},
|
|
1749
|
+
children: "Return home"
|
|
1750
|
+
}
|
|
1751
|
+
)
|
|
1752
|
+
] });
|
|
1753
|
+
}
|
|
1754
|
+
if (loading) {
|
|
1755
|
+
return /* @__PURE__ */ jsx4(Fragment, { children: loading });
|
|
1756
|
+
}
|
|
1757
|
+
return /* @__PURE__ */ jsxs3("div", { className: "la-card", style: { textAlign: "center" }, children: [
|
|
1758
|
+
/* @__PURE__ */ jsx4("span", { className: "la-spinner" }),
|
|
1759
|
+
/* @__PURE__ */ jsx4("p", { style: { marginTop: "1rem", color: "var(--la-text-secondary)" }, children: "Completing sign-in\u2026" })
|
|
1760
|
+
] });
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
// src/components/UserButton.tsx
|
|
1764
|
+
import { useState as useState5, useCallback as useCallback4, useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
1765
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1766
|
+
function UserButton({
|
|
1767
|
+
afterSignOutUrl,
|
|
1768
|
+
showName = false,
|
|
1769
|
+
appearance
|
|
1770
|
+
}) {
|
|
1771
|
+
const { user, isSignedIn, signOut, config } = useLumoAuthContext();
|
|
1772
|
+
const [isOpen, setIsOpen] = useState5(false);
|
|
1773
|
+
const containerRef = useRef2(null);
|
|
1774
|
+
const resolvedSignOutUrl = afterSignOutUrl || config.afterSignOutUrl || "/";
|
|
1775
|
+
useEffect3(() => {
|
|
1776
|
+
function handleClickOutside(e) {
|
|
1777
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
1778
|
+
setIsOpen(false);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
if (isOpen) {
|
|
1782
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
1783
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1784
|
+
}
|
|
1785
|
+
}, [isOpen]);
|
|
1786
|
+
useEffect3(() => {
|
|
1787
|
+
function handleEscape(e) {
|
|
1788
|
+
if (e.key === "Escape") setIsOpen(false);
|
|
1789
|
+
}
|
|
1790
|
+
if (isOpen) {
|
|
1791
|
+
document.addEventListener("keydown", handleEscape);
|
|
1792
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
1793
|
+
}
|
|
1794
|
+
}, [isOpen]);
|
|
1795
|
+
const handleSignOut = useCallback4(async () => {
|
|
1796
|
+
setIsOpen(false);
|
|
1797
|
+
await signOut({ afterSignOutUrl: sanitizeRedirectUrl(resolvedSignOutUrl) });
|
|
1798
|
+
}, [signOut, resolvedSignOutUrl]);
|
|
1799
|
+
if (!isSignedIn || !user) {
|
|
1800
|
+
return null;
|
|
1801
|
+
}
|
|
1802
|
+
const initials = [user.firstName, user.lastName].filter(Boolean).map((n) => n.charAt(0).toUpperCase()).join("") || user.email.charAt(0).toUpperCase();
|
|
1803
|
+
const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
|
|
1804
|
+
return /* @__PURE__ */ jsxs4(
|
|
1805
|
+
"div",
|
|
1806
|
+
{
|
|
1807
|
+
ref: containerRef,
|
|
1808
|
+
className: `la-user-button ${themeClass} ${appearance?.className || ""}`,
|
|
1809
|
+
style: appearance?.variables,
|
|
1810
|
+
children: [
|
|
1811
|
+
/* @__PURE__ */ jsxs4(
|
|
1812
|
+
"button",
|
|
1813
|
+
{
|
|
1814
|
+
type: "button",
|
|
1815
|
+
className: "la-user-trigger",
|
|
1816
|
+
onClick: () => setIsOpen(!isOpen),
|
|
1817
|
+
"aria-expanded": isOpen,
|
|
1818
|
+
"aria-haspopup": "menu",
|
|
1819
|
+
"aria-label": "User menu",
|
|
1820
|
+
children: [
|
|
1821
|
+
/* @__PURE__ */ jsx5("span", { className: "la-user-avatar", children: user.avatarUrl ? /* @__PURE__ */ jsx5("img", { src: user.avatarUrl, alt: user.displayName }) : initials }),
|
|
1822
|
+
showName && /* @__PURE__ */ jsx5("span", { className: "la-user-name", children: user.displayName })
|
|
1823
|
+
]
|
|
1824
|
+
}
|
|
1825
|
+
),
|
|
1826
|
+
isOpen && /* @__PURE__ */ jsxs4("div", { className: "la-user-dropdown", role: "menu", children: [
|
|
1827
|
+
/* @__PURE__ */ jsxs4("div", { className: "la-user-dropdown-header", children: [
|
|
1828
|
+
/* @__PURE__ */ jsx5("div", { className: "la-user-dropdown-name", children: user.displayName }),
|
|
1829
|
+
/* @__PURE__ */ jsx5("div", { className: "la-user-dropdown-email", children: user.email })
|
|
1830
|
+
] }),
|
|
1831
|
+
/* @__PURE__ */ jsxs4(
|
|
1832
|
+
"button",
|
|
1833
|
+
{
|
|
1834
|
+
type: "button",
|
|
1835
|
+
className: "la-dropdown-item",
|
|
1836
|
+
role: "menuitem",
|
|
1837
|
+
onClick: () => {
|
|
1838
|
+
setIsOpen(false);
|
|
1839
|
+
window.location.href = `${config.domain}/account/profile`;
|
|
1840
|
+
},
|
|
1841
|
+
children: [
|
|
1842
|
+
/* @__PURE__ */ jsxs4("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1843
|
+
/* @__PURE__ */ jsx5("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),
|
|
1844
|
+
/* @__PURE__ */ jsx5("circle", { cx: "12", cy: "7", r: "4" })
|
|
1845
|
+
] }),
|
|
1846
|
+
"Manage account"
|
|
1847
|
+
]
|
|
1848
|
+
}
|
|
1849
|
+
),
|
|
1850
|
+
/* @__PURE__ */ jsx5("div", { className: "la-dropdown-divider" }),
|
|
1851
|
+
/* @__PURE__ */ jsxs4(
|
|
1852
|
+
"button",
|
|
1853
|
+
{
|
|
1854
|
+
type: "button",
|
|
1855
|
+
className: "la-dropdown-item la-dropdown-item-danger",
|
|
1856
|
+
role: "menuitem",
|
|
1857
|
+
onClick: handleSignOut,
|
|
1858
|
+
children: [
|
|
1859
|
+
/* @__PURE__ */ jsxs4("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1860
|
+
/* @__PURE__ */ jsx5("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
|
|
1861
|
+
/* @__PURE__ */ jsx5("polyline", { points: "16 17 21 12 16 7" }),
|
|
1862
|
+
/* @__PURE__ */ jsx5("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
|
|
1863
|
+
] }),
|
|
1864
|
+
"Sign out"
|
|
1865
|
+
]
|
|
1866
|
+
}
|
|
1867
|
+
)
|
|
1868
|
+
] })
|
|
1869
|
+
]
|
|
1870
|
+
}
|
|
1871
|
+
);
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
// src/components/UserAvatar.tsx
|
|
1875
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1876
|
+
function UserAvatar({
|
|
1877
|
+
size = 32,
|
|
1878
|
+
shape = "circle",
|
|
1879
|
+
appearance
|
|
1880
|
+
}) {
|
|
1881
|
+
const { user, isSignedIn } = useLumoAuthContext();
|
|
1882
|
+
if (!isSignedIn || !user) {
|
|
1883
|
+
return /* @__PURE__ */ jsx6(
|
|
1884
|
+
"span",
|
|
1885
|
+
{
|
|
1886
|
+
className: `la-avatar la-avatar-${shape} ${appearance?.className || ""}`,
|
|
1887
|
+
style: {
|
|
1888
|
+
width: size,
|
|
1889
|
+
height: size,
|
|
1890
|
+
fontSize: size * 0.4,
|
|
1891
|
+
...appearance?.variables
|
|
1892
|
+
},
|
|
1893
|
+
children: /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", width: size * 0.5, height: size * 0.5, children: [
|
|
1894
|
+
/* @__PURE__ */ jsx6("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),
|
|
1895
|
+
/* @__PURE__ */ jsx6("circle", { cx: "12", cy: "7", r: "4" })
|
|
1896
|
+
] })
|
|
1897
|
+
}
|
|
1898
|
+
);
|
|
1899
|
+
}
|
|
1900
|
+
const initials = [user.firstName, user.lastName].filter(Boolean).map((n) => n.charAt(0).toUpperCase()).join("") || user.email.charAt(0).toUpperCase();
|
|
1901
|
+
const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
|
|
1902
|
+
return /* @__PURE__ */ jsx6(
|
|
1903
|
+
"span",
|
|
1904
|
+
{
|
|
1905
|
+
className: `la-avatar la-avatar-${shape} ${themeClass} ${appearance?.className || ""}`,
|
|
1906
|
+
style: {
|
|
1907
|
+
width: size,
|
|
1908
|
+
height: size,
|
|
1909
|
+
fontSize: size * 0.4,
|
|
1910
|
+
...appearance?.variables
|
|
1911
|
+
},
|
|
1912
|
+
title: user.displayName,
|
|
1913
|
+
children: user.avatarUrl ? /* @__PURE__ */ jsx6(
|
|
1914
|
+
"img",
|
|
1915
|
+
{
|
|
1916
|
+
src: user.avatarUrl,
|
|
1917
|
+
alt: user.displayName,
|
|
1918
|
+
style: { width: "100%", height: "100%", objectFit: "cover" }
|
|
1919
|
+
}
|
|
1920
|
+
) : initials
|
|
1921
|
+
}
|
|
1922
|
+
);
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
// src/components/UserProfile.tsx
|
|
1926
|
+
import { useState as useState6, useCallback as useCallback5 } from "react";
|
|
1927
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1928
|
+
var ICONS = {
|
|
1929
|
+
user: /* @__PURE__ */ jsxs6("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1930
|
+
/* @__PURE__ */ jsx7("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),
|
|
1931
|
+
/* @__PURE__ */ jsx7("circle", { cx: "12", cy: "7", r: "4" })
|
|
1932
|
+
] }),
|
|
1933
|
+
mail: /* @__PURE__ */ jsxs6("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1934
|
+
/* @__PURE__ */ jsx7("rect", { x: "2", y: "4", width: "20", height: "16", rx: "2" }),
|
|
1935
|
+
/* @__PURE__ */ jsx7("path", { d: "m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7" })
|
|
1936
|
+
] }),
|
|
1937
|
+
shield: /* @__PURE__ */ jsx7("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx7("path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" }) }),
|
|
1938
|
+
key: /* @__PURE__ */ jsx7("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx7("path", { d: "m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4" }) }),
|
|
1939
|
+
check: /* @__PURE__ */ jsx7("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx7("polyline", { points: "20 6 9 17 4 12" }) }),
|
|
1940
|
+
x: /* @__PURE__ */ jsxs6("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1941
|
+
/* @__PURE__ */ jsx7("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1942
|
+
/* @__PURE__ */ jsx7("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1943
|
+
] }),
|
|
1944
|
+
signOut: /* @__PURE__ */ jsxs6("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1945
|
+
/* @__PURE__ */ jsx7("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
|
|
1946
|
+
/* @__PURE__ */ jsx7("polyline", { points: "16 17 21 12 16 7" }),
|
|
1947
|
+
/* @__PURE__ */ jsx7("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
|
|
1948
|
+
] })
|
|
1949
|
+
};
|
|
1950
|
+
function UserProfile({
|
|
1951
|
+
afterSignOutUrl,
|
|
1952
|
+
mode = "full",
|
|
1953
|
+
appearance
|
|
1954
|
+
}) {
|
|
1955
|
+
const { user, isSignedIn, isLoaded, signOut, config } = useLumoAuthContext();
|
|
1956
|
+
const [signingOut, setSigningOut] = useState6(false);
|
|
1957
|
+
const resolvedSignOutUrl = afterSignOutUrl || config.afterSignOutUrl || "/";
|
|
1958
|
+
const handleSignOut = useCallback5(async () => {
|
|
1959
|
+
setSigningOut(true);
|
|
1960
|
+
await signOut({ afterSignOutUrl: resolvedSignOutUrl });
|
|
1961
|
+
}, [signOut, resolvedSignOutUrl]);
|
|
1962
|
+
if (!isLoaded) {
|
|
1963
|
+
return /* @__PURE__ */ jsx7("div", { className: "la-card", style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ jsx7("span", { className: "la-spinner" }) });
|
|
1964
|
+
}
|
|
1965
|
+
if (!isSignedIn || !user) {
|
|
1966
|
+
return null;
|
|
1967
|
+
}
|
|
1968
|
+
const initials = [user.firstName, user.lastName].filter(Boolean).map((n) => n.charAt(0).toUpperCase()).join("") || user.email.charAt(0).toUpperCase();
|
|
1969
|
+
const themeClass = appearance?.theme === "dark" ? "la-dark" : appearance?.theme === "light" ? "la-light" : "";
|
|
1970
|
+
return /* @__PURE__ */ jsxs6(
|
|
1971
|
+
"div",
|
|
1972
|
+
{
|
|
1973
|
+
className: `la-card la-profile-card ${themeClass} ${appearance?.className || ""}`,
|
|
1974
|
+
style: appearance?.variables,
|
|
1975
|
+
children: [
|
|
1976
|
+
/* @__PURE__ */ jsxs6("div", { className: "la-profile-header", children: [
|
|
1977
|
+
/* @__PURE__ */ jsx7("span", { className: "la-avatar la-avatar-circle la-profile-avatar", children: user.avatarUrl ? /* @__PURE__ */ jsx7("img", { src: user.avatarUrl, alt: user.displayName }) : initials }),
|
|
1978
|
+
/* @__PURE__ */ jsxs6("div", { className: "la-profile-header-info", children: [
|
|
1979
|
+
/* @__PURE__ */ jsx7("div", { className: "la-profile-name", children: user.displayName }),
|
|
1980
|
+
/* @__PURE__ */ jsx7("div", { className: "la-profile-email", children: user.email })
|
|
1981
|
+
] })
|
|
1982
|
+
] }),
|
|
1983
|
+
/* @__PURE__ */ jsxs6("div", { className: "la-profile-section", children: [
|
|
1984
|
+
/* @__PURE__ */ jsx7("div", { className: "la-profile-section-title", children: "Account" }),
|
|
1985
|
+
/* @__PURE__ */ jsxs6("div", { className: "la-profile-row", children: [
|
|
1986
|
+
ICONS.mail,
|
|
1987
|
+
/* @__PURE__ */ jsx7("span", { className: "la-profile-row-label", children: "Email" }),
|
|
1988
|
+
/* @__PURE__ */ jsx7("span", { className: "la-profile-row-value", children: user.email }),
|
|
1989
|
+
/* @__PURE__ */ jsxs6("span", { className: `la-profile-badge ${user.emailVerified ? "la-badge-success" : "la-badge-warning"}`, children: [
|
|
1990
|
+
user.emailVerified ? ICONS.check : ICONS.x,
|
|
1991
|
+
user.emailVerified ? "Verified" : "Unverified"
|
|
1992
|
+
] })
|
|
1993
|
+
] }),
|
|
1994
|
+
user.firstName && /* @__PURE__ */ jsxs6("div", { className: "la-profile-row", children: [
|
|
1995
|
+
ICONS.user,
|
|
1996
|
+
/* @__PURE__ */ jsx7("span", { className: "la-profile-row-label", children: "Name" }),
|
|
1997
|
+
/* @__PURE__ */ jsx7("span", { className: "la-profile-row-value", children: [user.firstName, user.lastName].filter(Boolean).join(" ") })
|
|
1998
|
+
] })
|
|
1999
|
+
] }),
|
|
2000
|
+
mode === "full" && /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
2001
|
+
/* @__PURE__ */ jsxs6("div", { className: "la-profile-section", children: [
|
|
2002
|
+
/* @__PURE__ */ jsx7("div", { className: "la-profile-section-title", children: "Security" }),
|
|
2003
|
+
/* @__PURE__ */ jsxs6("div", { className: "la-profile-row", children: [
|
|
2004
|
+
ICONS.shield,
|
|
2005
|
+
/* @__PURE__ */ jsx7("span", { className: "la-profile-row-label", children: "MFA" }),
|
|
2006
|
+
/* @__PURE__ */ jsxs6("span", { className: `la-profile-badge ${user.mfaEnabled ? "la-badge-success" : "la-badge-muted"}`, children: [
|
|
2007
|
+
user.mfaEnabled ? ICONS.check : ICONS.x,
|
|
2008
|
+
user.mfaEnabled ? "Enabled" : "Disabled"
|
|
2009
|
+
] })
|
|
2010
|
+
] })
|
|
2011
|
+
] }),
|
|
2012
|
+
(user.roles.length > 0 || user.groups.length > 0) && /* @__PURE__ */ jsxs6("div", { className: "la-profile-section", children: [
|
|
2013
|
+
/* @__PURE__ */ jsx7("div", { className: "la-profile-section-title", children: "Roles & Groups" }),
|
|
2014
|
+
user.roles.length > 0 && /* @__PURE__ */ jsxs6("div", { className: "la-profile-row", children: [
|
|
2015
|
+
ICONS.key,
|
|
2016
|
+
/* @__PURE__ */ jsx7("span", { className: "la-profile-row-label", children: "Roles" }),
|
|
2017
|
+
/* @__PURE__ */ jsx7("div", { className: "la-profile-tags", children: user.roles.map((role) => /* @__PURE__ */ jsx7("span", { className: "la-profile-tag", children: role }, role)) })
|
|
2018
|
+
] }),
|
|
2019
|
+
user.groups.length > 0 && /* @__PURE__ */ jsxs6("div", { className: "la-profile-row", children: [
|
|
2020
|
+
ICONS.user,
|
|
2021
|
+
/* @__PURE__ */ jsx7("span", { className: "la-profile-row-label", children: "Groups" }),
|
|
2022
|
+
/* @__PURE__ */ jsx7("div", { className: "la-profile-tags", children: user.groups.map((group) => /* @__PURE__ */ jsx7("span", { className: "la-profile-tag", children: group }, group)) })
|
|
2023
|
+
] })
|
|
2024
|
+
] })
|
|
2025
|
+
] }),
|
|
2026
|
+
/* @__PURE__ */ jsx7("div", { className: "la-profile-section la-profile-actions", children: /* @__PURE__ */ jsxs6(
|
|
2027
|
+
"button",
|
|
2028
|
+
{
|
|
2029
|
+
type: "button",
|
|
2030
|
+
className: "la-btn la-btn-outline la-profile-signout-btn",
|
|
2031
|
+
onClick: handleSignOut,
|
|
2032
|
+
disabled: signingOut,
|
|
2033
|
+
children: [
|
|
2034
|
+
signingOut ? /* @__PURE__ */ jsx7("span", { className: "la-spinner la-spinner-sm" }) : ICONS.signOut,
|
|
2035
|
+
signingOut ? "Signing out\u2026" : "Sign out"
|
|
2036
|
+
]
|
|
2037
|
+
}
|
|
2038
|
+
) })
|
|
2039
|
+
]
|
|
2040
|
+
}
|
|
2041
|
+
);
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
// src/hooks.ts
|
|
2045
|
+
import { useState as useState7, useEffect as useEffect4, useCallback as useCallback6, useMemo as useMemo3 } from "react";
|
|
2046
|
+
import { LumoAuth } from "@lumoauth/client";
|
|
2047
|
+
function useAuth() {
|
|
2048
|
+
return useLumoAuthContext();
|
|
2049
|
+
}
|
|
2050
|
+
function useUser() {
|
|
2051
|
+
const { user } = useLumoAuthContext();
|
|
2052
|
+
return user;
|
|
2053
|
+
}
|
|
2054
|
+
function useSignIn() {
|
|
2055
|
+
const { signIn, signInWithRedirect, status } = useLumoAuthContext();
|
|
2056
|
+
return {
|
|
2057
|
+
signIn,
|
|
2058
|
+
signInWithRedirect,
|
|
2059
|
+
isLoading: status === "loading"
|
|
2060
|
+
};
|
|
2061
|
+
}
|
|
2062
|
+
function useSession() {
|
|
2063
|
+
const { isSignedIn, isLoaded, getToken, status } = useLumoAuthContext();
|
|
2064
|
+
return {
|
|
2065
|
+
isActive: isSignedIn,
|
|
2066
|
+
isLoaded,
|
|
2067
|
+
getToken,
|
|
2068
|
+
status
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
function useLumoAuth() {
|
|
2072
|
+
const { getToken, config } = useLumoAuthContext();
|
|
2073
|
+
const client = useMemo3(
|
|
2074
|
+
() => new LumoAuth({
|
|
2075
|
+
baseUrl: config.domain,
|
|
2076
|
+
orgId: config.orgId,
|
|
2077
|
+
clientId: config.clientId,
|
|
2078
|
+
token: () => getToken().then((t) => t || "")
|
|
2079
|
+
}),
|
|
2080
|
+
[config.domain, config.orgId, config.clientId, getToken]
|
|
2081
|
+
);
|
|
2082
|
+
return client;
|
|
2083
|
+
}
|
|
2084
|
+
function usePermission(slug) {
|
|
2085
|
+
const client = useLumoAuth();
|
|
2086
|
+
const { isSignedIn, isLoaded } = useLumoAuthContext();
|
|
2087
|
+
const [allowed, setAllowed] = useState7(false);
|
|
2088
|
+
const [isLoading, setIsLoading] = useState7(true);
|
|
2089
|
+
useEffect4(() => {
|
|
2090
|
+
if (!isLoaded || !isSignedIn) {
|
|
2091
|
+
setAllowed(false);
|
|
2092
|
+
setIsLoading(!isLoaded);
|
|
2093
|
+
return;
|
|
2094
|
+
}
|
|
2095
|
+
let cancelled = false;
|
|
2096
|
+
setIsLoading(true);
|
|
2097
|
+
client.permissions.check(slug).then((result) => {
|
|
2098
|
+
if (!cancelled) {
|
|
2099
|
+
setAllowed(result);
|
|
2100
|
+
setIsLoading(false);
|
|
2101
|
+
}
|
|
2102
|
+
}).catch(() => {
|
|
2103
|
+
if (!cancelled) {
|
|
2104
|
+
setAllowed(false);
|
|
2105
|
+
setIsLoading(false);
|
|
2106
|
+
}
|
|
2107
|
+
});
|
|
2108
|
+
return () => {
|
|
2109
|
+
cancelled = true;
|
|
2110
|
+
};
|
|
2111
|
+
}, [client, slug, isSignedIn, isLoaded]);
|
|
2112
|
+
return { allowed, isLoading };
|
|
2113
|
+
}
|
|
2114
|
+
function useZanzibar(request) {
|
|
2115
|
+
const client = useLumoAuth();
|
|
2116
|
+
const { isSignedIn, isLoaded } = useLumoAuthContext();
|
|
2117
|
+
const [allowed, setAllowed] = useState7(false);
|
|
2118
|
+
const [isLoading, setIsLoading] = useState7(true);
|
|
2119
|
+
const requestKey = `${request.object}:${request.relation}:${request.subject}`;
|
|
2120
|
+
useEffect4(() => {
|
|
2121
|
+
if (!isLoaded || !isSignedIn) {
|
|
2122
|
+
setAllowed(false);
|
|
2123
|
+
setIsLoading(!isLoaded);
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
let cancelled = false;
|
|
2127
|
+
setIsLoading(true);
|
|
2128
|
+
client.zanzibar.check(request).then((result) => {
|
|
2129
|
+
if (!cancelled) {
|
|
2130
|
+
setAllowed(result);
|
|
2131
|
+
setIsLoading(false);
|
|
2132
|
+
}
|
|
2133
|
+
}).catch(() => {
|
|
2134
|
+
if (!cancelled) {
|
|
2135
|
+
setAllowed(false);
|
|
2136
|
+
setIsLoading(false);
|
|
2137
|
+
}
|
|
2138
|
+
});
|
|
2139
|
+
return () => {
|
|
2140
|
+
cancelled = true;
|
|
2141
|
+
};
|
|
2142
|
+
}, [client, requestKey, isSignedIn, isLoaded]);
|
|
2143
|
+
return { allowed, isLoading };
|
|
2144
|
+
}
|
|
2145
|
+
function useAbac(request) {
|
|
2146
|
+
const client = useLumoAuth();
|
|
2147
|
+
const { isSignedIn, isLoaded } = useLumoAuthContext();
|
|
2148
|
+
const [allowed, setAllowed] = useState7(false);
|
|
2149
|
+
const [isLoading, setIsLoading] = useState7(true);
|
|
2150
|
+
const requestKey = `${request.resourceType}:${request.action}:${request.resourceId || ""}`;
|
|
2151
|
+
useEffect4(() => {
|
|
2152
|
+
if (!isLoaded || !isSignedIn) {
|
|
2153
|
+
setAllowed(false);
|
|
2154
|
+
setIsLoading(!isLoaded);
|
|
2155
|
+
return;
|
|
2156
|
+
}
|
|
2157
|
+
let cancelled = false;
|
|
2158
|
+
setIsLoading(true);
|
|
2159
|
+
client.abac.check(request).then((res) => {
|
|
2160
|
+
if (!cancelled) {
|
|
2161
|
+
setAllowed(res.allowed);
|
|
2162
|
+
setIsLoading(false);
|
|
2163
|
+
}
|
|
2164
|
+
}).catch(() => {
|
|
2165
|
+
if (!cancelled) {
|
|
2166
|
+
setAllowed(false);
|
|
2167
|
+
setIsLoading(false);
|
|
2168
|
+
}
|
|
2169
|
+
});
|
|
2170
|
+
return () => {
|
|
2171
|
+
cancelled = true;
|
|
2172
|
+
};
|
|
2173
|
+
}, [client, requestKey, isSignedIn, isLoaded]);
|
|
2174
|
+
return { allowed, isLoading };
|
|
2175
|
+
}
|
|
2176
|
+
function useMagicLink() {
|
|
2177
|
+
const { sendMagicLink: sendMagicLinkCtx } = useLumoAuthContext();
|
|
2178
|
+
const [isLoading, setIsLoading] = useState7(false);
|
|
2179
|
+
const [isSent, setIsSent] = useState7(false);
|
|
2180
|
+
const [error, setError] = useState7(null);
|
|
2181
|
+
const sendMagicLink = useCallback6(async (email, redirectUri) => {
|
|
2182
|
+
setIsLoading(true);
|
|
2183
|
+
setError(null);
|
|
2184
|
+
try {
|
|
2185
|
+
await sendMagicLinkCtx(email, redirectUri);
|
|
2186
|
+
setIsSent(true);
|
|
2187
|
+
} catch (err) {
|
|
2188
|
+
setError(err instanceof Error ? err.message : "Failed to send magic link");
|
|
2189
|
+
} finally {
|
|
2190
|
+
setIsLoading(false);
|
|
2191
|
+
}
|
|
2192
|
+
}, [sendMagicLinkCtx]);
|
|
2193
|
+
const reset = useCallback6(() => {
|
|
2194
|
+
setIsSent(false);
|
|
2195
|
+
setError(null);
|
|
2196
|
+
setIsLoading(false);
|
|
2197
|
+
}, []);
|
|
2198
|
+
return { sendMagicLink, isLoading, isSent, error, reset };
|
|
2199
|
+
}
|
|
2200
|
+
function useEmailFirst() {
|
|
2201
|
+
const { checkEmail: checkEmailCtx } = useLumoAuthContext();
|
|
2202
|
+
const [isLoading, setIsLoading] = useState7(false);
|
|
2203
|
+
const [result, setResult] = useState7(null);
|
|
2204
|
+
const checkEmail = useCallback6(async (email) => {
|
|
2205
|
+
setIsLoading(true);
|
|
2206
|
+
try {
|
|
2207
|
+
const res = await checkEmailCtx(email);
|
|
2208
|
+
setResult(res);
|
|
2209
|
+
return res;
|
|
2210
|
+
} finally {
|
|
2211
|
+
setIsLoading(false);
|
|
2212
|
+
}
|
|
2213
|
+
}, [checkEmailCtx]);
|
|
2214
|
+
const reset = useCallback6(() => {
|
|
2215
|
+
setResult(null);
|
|
2216
|
+
setIsLoading(false);
|
|
2217
|
+
}, []);
|
|
2218
|
+
return { checkEmail, isLoading, result, exists: result?.exists ?? null, reset };
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
// src/components/Protect.tsx
|
|
2222
|
+
import { Fragment as Fragment3, jsx as jsx8 } from "react/jsx-runtime";
|
|
2223
|
+
function Protect({
|
|
2224
|
+
permission,
|
|
2225
|
+
zanzibar,
|
|
2226
|
+
abac,
|
|
2227
|
+
fallback = null,
|
|
2228
|
+
children
|
|
2229
|
+
}) {
|
|
2230
|
+
const { isLoaded, isSignedIn } = useLumoAuthContext();
|
|
2231
|
+
if (permission) {
|
|
2232
|
+
return /* @__PURE__ */ jsx8(
|
|
2233
|
+
ProtectWithPermission,
|
|
2234
|
+
{
|
|
2235
|
+
permission,
|
|
2236
|
+
fallback,
|
|
2237
|
+
isLoaded,
|
|
2238
|
+
isSignedIn,
|
|
2239
|
+
children
|
|
2240
|
+
}
|
|
2241
|
+
);
|
|
2242
|
+
}
|
|
2243
|
+
if (zanzibar) {
|
|
2244
|
+
return /* @__PURE__ */ jsx8(
|
|
2245
|
+
ProtectWithZanzibar,
|
|
2246
|
+
{
|
|
2247
|
+
zanzibar,
|
|
2248
|
+
fallback,
|
|
2249
|
+
isLoaded,
|
|
2250
|
+
isSignedIn,
|
|
2251
|
+
children
|
|
2252
|
+
}
|
|
2253
|
+
);
|
|
2254
|
+
}
|
|
2255
|
+
if (abac) {
|
|
2256
|
+
return /* @__PURE__ */ jsx8(
|
|
2257
|
+
ProtectWithAbac,
|
|
2258
|
+
{
|
|
2259
|
+
abac,
|
|
2260
|
+
fallback,
|
|
2261
|
+
isLoaded,
|
|
2262
|
+
isSignedIn,
|
|
2263
|
+
children
|
|
2264
|
+
}
|
|
2265
|
+
);
|
|
2266
|
+
}
|
|
2267
|
+
if (!isLoaded) {
|
|
2268
|
+
return /* @__PURE__ */ jsx8("div", { className: "la-protect-loading", children: /* @__PURE__ */ jsx8("span", { className: "la-spinner" }) });
|
|
2269
|
+
}
|
|
2270
|
+
return isSignedIn ? /* @__PURE__ */ jsx8(Fragment3, { children }) : /* @__PURE__ */ jsx8(Fragment3, { children: fallback });
|
|
2271
|
+
}
|
|
2272
|
+
function ProtectWithPermission({
|
|
2273
|
+
permission,
|
|
2274
|
+
fallback,
|
|
2275
|
+
isLoaded,
|
|
2276
|
+
isSignedIn,
|
|
2277
|
+
children
|
|
2278
|
+
}) {
|
|
2279
|
+
const { allowed, isLoading } = usePermission(permission);
|
|
2280
|
+
if (!isLoaded || isLoading) {
|
|
2281
|
+
return /* @__PURE__ */ jsx8("div", { className: "la-protect-loading", children: /* @__PURE__ */ jsx8("span", { className: "la-spinner" }) });
|
|
2282
|
+
}
|
|
2283
|
+
if (!isSignedIn || !allowed) {
|
|
2284
|
+
return /* @__PURE__ */ jsx8(Fragment3, { children: fallback });
|
|
2285
|
+
}
|
|
2286
|
+
return /* @__PURE__ */ jsx8(Fragment3, { children });
|
|
2287
|
+
}
|
|
2288
|
+
function ProtectWithZanzibar({
|
|
2289
|
+
zanzibar,
|
|
2290
|
+
fallback,
|
|
2291
|
+
isLoaded,
|
|
2292
|
+
isSignedIn,
|
|
2293
|
+
children
|
|
2294
|
+
}) {
|
|
2295
|
+
const { allowed, isLoading } = useZanzibar({
|
|
2296
|
+
object: zanzibar.object,
|
|
2297
|
+
relation: zanzibar.relation,
|
|
2298
|
+
subject: zanzibar.subject || "user:me"
|
|
2299
|
+
});
|
|
2300
|
+
if (!isLoaded || isLoading) {
|
|
2301
|
+
return /* @__PURE__ */ jsx8("div", { className: "la-protect-loading", children: /* @__PURE__ */ jsx8("span", { className: "la-spinner" }) });
|
|
2302
|
+
}
|
|
2303
|
+
if (!isSignedIn || !allowed) {
|
|
2304
|
+
return /* @__PURE__ */ jsx8(Fragment3, { children: fallback });
|
|
2305
|
+
}
|
|
2306
|
+
return /* @__PURE__ */ jsx8(Fragment3, { children });
|
|
2307
|
+
}
|
|
2308
|
+
function ProtectWithAbac({
|
|
2309
|
+
abac,
|
|
2310
|
+
fallback,
|
|
2311
|
+
isLoaded,
|
|
2312
|
+
isSignedIn,
|
|
2313
|
+
children
|
|
2314
|
+
}) {
|
|
2315
|
+
const { allowed, isLoading } = useAbac({
|
|
2316
|
+
resourceType: abac.resourceType,
|
|
2317
|
+
action: abac.action,
|
|
2318
|
+
resourceId: abac.resourceId
|
|
2319
|
+
});
|
|
2320
|
+
if (!isLoaded || isLoading) {
|
|
2321
|
+
return /* @__PURE__ */ jsx8("div", { className: "la-protect-loading", children: /* @__PURE__ */ jsx8("span", { className: "la-spinner" }) });
|
|
2322
|
+
}
|
|
2323
|
+
if (!isSignedIn || !allowed) {
|
|
2324
|
+
return /* @__PURE__ */ jsx8(Fragment3, { children: fallback });
|
|
2325
|
+
}
|
|
2326
|
+
return /* @__PURE__ */ jsx8(Fragment3, { children });
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
// src/components/Control.tsx
|
|
2330
|
+
import { useEffect as useEffect5 } from "react";
|
|
2331
|
+
import { Fragment as Fragment4, jsx as jsx9 } from "react/jsx-runtime";
|
|
2332
|
+
function SignedIn({ children }) {
|
|
2333
|
+
const { isLoaded, isSignedIn } = useLumoAuthContext();
|
|
2334
|
+
if (!isLoaded || !isSignedIn) return null;
|
|
2335
|
+
return /* @__PURE__ */ jsx9(Fragment4, { children });
|
|
2336
|
+
}
|
|
2337
|
+
function SignedOut({ children }) {
|
|
2338
|
+
const { isLoaded, isSignedIn } = useLumoAuthContext();
|
|
2339
|
+
if (!isLoaded || isSignedIn) return null;
|
|
2340
|
+
return /* @__PURE__ */ jsx9(Fragment4, { children });
|
|
2341
|
+
}
|
|
2342
|
+
function SignInButton({ children, signInUrl, className }) {
|
|
2343
|
+
const { signIn, authStrategy, config } = useLumoAuthContext();
|
|
2344
|
+
const handleClick = () => {
|
|
2345
|
+
if (authStrategy === "pkce") {
|
|
2346
|
+
signIn();
|
|
2347
|
+
} else if (signInUrl) {
|
|
2348
|
+
window.location.href = sanitizeRedirectUrl(signInUrl);
|
|
2349
|
+
} else {
|
|
2350
|
+
window.location.href = sanitizeRedirectUrl(config.afterSignInUrl || "/sign-in");
|
|
2351
|
+
}
|
|
2352
|
+
};
|
|
2353
|
+
if (children) {
|
|
2354
|
+
return /* @__PURE__ */ jsx9("span", { onClick: handleClick, role: "button", tabIndex: 0, onKeyDown: (e) => {
|
|
2355
|
+
if (e.key === "Enter" || e.key === " ") handleClick();
|
|
2356
|
+
}, children });
|
|
2357
|
+
}
|
|
2358
|
+
return /* @__PURE__ */ jsx9("button", { type: "button", className, onClick: handleClick, children: "Sign in" });
|
|
2359
|
+
}
|
|
2360
|
+
function SignUpButton({ children, signUpUrl, className }) {
|
|
2361
|
+
const { config } = useLumoAuthContext();
|
|
2362
|
+
const handleClick = () => {
|
|
2363
|
+
const url = signUpUrl || config.afterSignUpUrl || "/sign-up";
|
|
2364
|
+
window.location.href = sanitizeRedirectUrl(url);
|
|
2365
|
+
};
|
|
2366
|
+
if (children) {
|
|
2367
|
+
return /* @__PURE__ */ jsx9("span", { onClick: handleClick, role: "button", tabIndex: 0, onKeyDown: (e) => {
|
|
2368
|
+
if (e.key === "Enter" || e.key === " ") handleClick();
|
|
2369
|
+
}, children });
|
|
2370
|
+
}
|
|
2371
|
+
return /* @__PURE__ */ jsx9("button", { type: "button", className, onClick: handleClick, children: "Sign up" });
|
|
2372
|
+
}
|
|
2373
|
+
function SignOutButton({ children, afterSignOutUrl, className }) {
|
|
2374
|
+
const { signOut, config } = useLumoAuthContext();
|
|
2375
|
+
const handleClick = async () => {
|
|
2376
|
+
const redirectUrl = afterSignOutUrl || config.afterSignOutUrl || "/";
|
|
2377
|
+
await signOut({ afterSignOutUrl: sanitizeRedirectUrl(redirectUrl) });
|
|
2378
|
+
};
|
|
2379
|
+
if (children) {
|
|
2380
|
+
return /* @__PURE__ */ jsx9("span", { onClick: handleClick, role: "button", tabIndex: 0, onKeyDown: (e) => {
|
|
2381
|
+
if (e.key === "Enter" || e.key === " ") handleClick();
|
|
2382
|
+
}, children });
|
|
2383
|
+
}
|
|
2384
|
+
return /* @__PURE__ */ jsx9("button", { type: "button", className, onClick: handleClick, children: "Sign out" });
|
|
2385
|
+
}
|
|
2386
|
+
function RedirectToSignIn({ signInUrl }) {
|
|
2387
|
+
const { signIn, authStrategy } = useLumoAuthContext();
|
|
2388
|
+
useEffect5(() => {
|
|
2389
|
+
if (authStrategy === "pkce") {
|
|
2390
|
+
signIn();
|
|
2391
|
+
} else if (signInUrl && typeof window !== "undefined") {
|
|
2392
|
+
window.location.href = sanitizeRedirectUrl(signInUrl);
|
|
2393
|
+
}
|
|
2394
|
+
}, [signIn, authStrategy, signInUrl]);
|
|
2395
|
+
return null;
|
|
2396
|
+
}
|
|
2397
|
+
export {
|
|
2398
|
+
AuthCallback,
|
|
2399
|
+
LumoAuth2 as LumoAuth,
|
|
2400
|
+
LumoAuthProvider,
|
|
2401
|
+
Protect,
|
|
2402
|
+
RedirectToSignIn,
|
|
2403
|
+
SignIn,
|
|
2404
|
+
SignInButton,
|
|
2405
|
+
SignOutButton,
|
|
2406
|
+
SignUp,
|
|
2407
|
+
SignUpButton,
|
|
2408
|
+
SignedIn,
|
|
2409
|
+
SignedOut,
|
|
2410
|
+
UserAvatar,
|
|
2411
|
+
UserButton,
|
|
2412
|
+
UserProfile,
|
|
2413
|
+
useAbac,
|
|
2414
|
+
useAuth,
|
|
2415
|
+
useEmailFirst,
|
|
2416
|
+
useLumoAuth,
|
|
2417
|
+
useMagicLink,
|
|
2418
|
+
usePermission,
|
|
2419
|
+
useSession,
|
|
2420
|
+
useSignIn,
|
|
2421
|
+
useUser,
|
|
2422
|
+
useZanzibar
|
|
2423
|
+
};
|
|
2424
|
+
//# sourceMappingURL=index.mjs.map
|