@thetechfossil/auth2 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.NEW.md +365 -0
- package/dist/index.components.d.ts +112 -2
- package/dist/index.components.js +1995 -19
- package/dist/index.components.js.map +1 -1
- package/dist/index.components.mjs +1986 -21
- package/dist/index.components.mjs.map +1 -1
- package/dist/index.d.ts +250 -13
- package/dist/index.js +2392 -132
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2376 -134
- package/dist/index.mjs.map +1 -1
- package/dist/index.next.d.ts +253 -4
- package/dist/index.next.js +2514 -133
- package/dist/index.next.js.map +1 -1
- package/dist/index.next.mjs +2494 -134
- package/dist/index.next.mjs.map +1 -1
- package/dist/index.next.server.d.ts +68 -2
- package/dist/index.next.server.js +184 -18
- package/dist/index.next.server.js.map +1 -1
- package/dist/index.next.server.mjs +184 -18
- package/dist/index.next.server.mjs.map +1 -1
- package/dist/index.node.d.ts +68 -2
- package/dist/index.node.js +184 -18
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +184 -18
- package/dist/index.node.mjs.map +1 -1
- package/package.json +40 -18
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import { createContext, useState, useCallback, useEffect, useContext, useRef } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -10,6 +10,7 @@ var __export = (target, all) => {
|
|
|
10
10
|
var HttpClient = class {
|
|
11
11
|
constructor(baseUrl, defaultHeaders = {}) {
|
|
12
12
|
this.csrfToken = null;
|
|
13
|
+
this.frontendBaseUrl = null;
|
|
13
14
|
this.axiosInstance = axios.create({
|
|
14
15
|
baseURL: baseUrl.replace(/\/$/, ""),
|
|
15
16
|
headers: {
|
|
@@ -26,6 +27,9 @@ var HttpClient = class {
|
|
|
26
27
|
if (this.csrfToken && ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "")) {
|
|
27
28
|
config.headers["x-csrf-token"] = this.csrfToken;
|
|
28
29
|
}
|
|
30
|
+
if (this.frontendBaseUrl) {
|
|
31
|
+
config.headers["X-Frontend-URL"] = this.frontendBaseUrl;
|
|
32
|
+
}
|
|
29
33
|
return config;
|
|
30
34
|
},
|
|
31
35
|
(error) => Promise.reject(error)
|
|
@@ -81,6 +85,15 @@ var HttpClient = class {
|
|
|
81
85
|
removeCsrfToken() {
|
|
82
86
|
this.csrfToken = null;
|
|
83
87
|
}
|
|
88
|
+
setFrontendBaseUrl(url) {
|
|
89
|
+
this.frontendBaseUrl = url;
|
|
90
|
+
}
|
|
91
|
+
getFrontendBaseUrl() {
|
|
92
|
+
return this.frontendBaseUrl;
|
|
93
|
+
}
|
|
94
|
+
removeFrontendBaseUrl() {
|
|
95
|
+
this.frontendBaseUrl = null;
|
|
96
|
+
}
|
|
84
97
|
async refreshCsrfToken() {
|
|
85
98
|
try {
|
|
86
99
|
const response = await this.axiosInstance.get("/api/v1/auth/csrf-token");
|
|
@@ -103,6 +116,12 @@ var AuthService = class {
|
|
|
103
116
|
};
|
|
104
117
|
this.httpClient = new HttpClient(this.config.baseUrl);
|
|
105
118
|
this.loadTokenFromStorage();
|
|
119
|
+
if (typeof window !== "undefined") {
|
|
120
|
+
const frontendBaseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || process.env.NEXT_PUBLIC_APP_URL || window.location.origin;
|
|
121
|
+
if (frontendBaseUrl) {
|
|
122
|
+
this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
106
125
|
if (this.config.csrfEnabled && typeof window !== "undefined") {
|
|
107
126
|
this.refreshCsrfToken();
|
|
108
127
|
}
|
|
@@ -219,11 +238,7 @@ var AuthService = class {
|
|
|
219
238
|
throw new Error(response.message || "Login failed");
|
|
220
239
|
}
|
|
221
240
|
async register(data) {
|
|
222
|
-
const
|
|
223
|
-
if (!registerData.frontendBaseUrl && typeof window !== "undefined") {
|
|
224
|
-
registerData.frontendBaseUrl = process.env.FRONTEND_BASE_URL || process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || process.env.NEXT_PUBLIC_APP_URL || window.location.origin;
|
|
225
|
-
}
|
|
226
|
-
const response = await this.httpClient.post("/api/v1/auth/register", registerData);
|
|
241
|
+
const response = await this.httpClient.post("/api/v1/auth/register", data);
|
|
227
242
|
if (response.success && response.message === "Registration data saved. Verification email sent. Please check your inbox.") {
|
|
228
243
|
return response;
|
|
229
244
|
}
|
|
@@ -239,15 +254,33 @@ var AuthService = class {
|
|
|
239
254
|
return response;
|
|
240
255
|
}
|
|
241
256
|
async verifyEmailToken(token) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
257
|
+
try {
|
|
258
|
+
const response = await this.httpClient.get(`/api/v1/auth/verify-email?token=${token}`);
|
|
259
|
+
if (response.success && response.token) {
|
|
260
|
+
this.token = response.token;
|
|
261
|
+
this.httpClient.setAuthToken(response.token);
|
|
262
|
+
this.saveTokenToStorage(response.token);
|
|
263
|
+
}
|
|
264
|
+
return response;
|
|
265
|
+
} catch (error) {
|
|
266
|
+
if (error.response?.data) {
|
|
267
|
+
return {
|
|
268
|
+
success: false,
|
|
269
|
+
message: error.response.data.message || "Email verification failed"
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
success: false,
|
|
274
|
+
message: error.message || "Network error occurred"
|
|
275
|
+
};
|
|
247
276
|
}
|
|
248
|
-
return response;
|
|
249
277
|
}
|
|
250
278
|
async logout() {
|
|
279
|
+
try {
|
|
280
|
+
await this.httpClient.post("/api/v1/auth/logout", {});
|
|
281
|
+
} catch (error) {
|
|
282
|
+
console.warn("Failed to call logout endpoint:", error);
|
|
283
|
+
}
|
|
251
284
|
this.token = null;
|
|
252
285
|
this.httpClient.removeAuthToken();
|
|
253
286
|
this.httpClient.removeCsrfToken();
|
|
@@ -284,9 +317,6 @@ var AuthService = class {
|
|
|
284
317
|
return response.user;
|
|
285
318
|
}
|
|
286
319
|
async forgotPassword(email) {
|
|
287
|
-
if (typeof window !== "undefined") {
|
|
288
|
-
process.env.FRONTEND_BASE_URL || process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || process.env.NEXT_PUBLIC_APP_URL || window.location.origin;
|
|
289
|
-
}
|
|
290
320
|
const response = await this.httpClient.post("/api/v1/auth/forgot-password", { email });
|
|
291
321
|
return response;
|
|
292
322
|
}
|
|
@@ -294,70 +324,208 @@ var AuthService = class {
|
|
|
294
324
|
const response = await this.httpClient.post("/api/v1/auth/reset-password", { token, password });
|
|
295
325
|
return response;
|
|
296
326
|
}
|
|
327
|
+
async changePassword(oldPassword, newPassword) {
|
|
328
|
+
if (!this.token) {
|
|
329
|
+
throw new Error("Not authenticated");
|
|
330
|
+
}
|
|
331
|
+
const response = await this.httpClient.post("/api/v1/user/change-password", {
|
|
332
|
+
oldPassword,
|
|
333
|
+
newPassword
|
|
334
|
+
});
|
|
335
|
+
return response;
|
|
336
|
+
}
|
|
337
|
+
async updateAvatar(avatar) {
|
|
338
|
+
if (!this.token) {
|
|
339
|
+
throw new Error("Not authenticated");
|
|
340
|
+
}
|
|
341
|
+
const response = await this.httpClient.post("/api/v1/user/update/avatar", { avatar });
|
|
342
|
+
if (response.success && response.token) {
|
|
343
|
+
this.token = response.token;
|
|
344
|
+
this.httpClient.setAuthToken(response.token);
|
|
345
|
+
this.saveTokenToStorage(response.token);
|
|
346
|
+
}
|
|
347
|
+
return response;
|
|
348
|
+
}
|
|
349
|
+
async requestEmailChange(newEmail) {
|
|
350
|
+
if (!this.token) {
|
|
351
|
+
throw new Error("Not authenticated");
|
|
352
|
+
}
|
|
353
|
+
const response = await this.httpClient.post("/api/v1/user/request-email-change", {
|
|
354
|
+
newEmail
|
|
355
|
+
});
|
|
356
|
+
return response;
|
|
357
|
+
}
|
|
358
|
+
async verifyEmailChange(token) {
|
|
359
|
+
const response = await this.httpClient.get(`/api/v1/user/verify-email-change?token=${token}`);
|
|
360
|
+
if (response.success && response.token) {
|
|
361
|
+
this.token = response.token;
|
|
362
|
+
this.httpClient.setAuthToken(response.token);
|
|
363
|
+
this.saveTokenToStorage(response.token);
|
|
364
|
+
}
|
|
365
|
+
return response;
|
|
366
|
+
}
|
|
367
|
+
// 2FA / MFA Methods
|
|
368
|
+
async generate2FA() {
|
|
369
|
+
if (!this.token) {
|
|
370
|
+
throw new Error("Not authenticated");
|
|
371
|
+
}
|
|
372
|
+
const response = await this.httpClient.post(
|
|
373
|
+
"/api/v1/mfa/generate",
|
|
374
|
+
{}
|
|
375
|
+
);
|
|
376
|
+
return response;
|
|
377
|
+
}
|
|
378
|
+
async enable2FA(token) {
|
|
379
|
+
if (!this.token) {
|
|
380
|
+
throw new Error("Not authenticated");
|
|
381
|
+
}
|
|
382
|
+
const response = await this.httpClient.post("/api/v1/mfa/enable", { token });
|
|
383
|
+
return response;
|
|
384
|
+
}
|
|
385
|
+
async disable2FA(token) {
|
|
386
|
+
if (!this.token) {
|
|
387
|
+
throw new Error("Not authenticated");
|
|
388
|
+
}
|
|
389
|
+
const response = await this.httpClient.post("/api/v1/mfa/disable", { token });
|
|
390
|
+
return response;
|
|
391
|
+
}
|
|
392
|
+
async validate2FA(token) {
|
|
393
|
+
if (!this.token) {
|
|
394
|
+
throw new Error("Not authenticated");
|
|
395
|
+
}
|
|
396
|
+
const response = await this.httpClient.post("/api/v1/mfa/validate", { token });
|
|
397
|
+
return response;
|
|
398
|
+
}
|
|
399
|
+
// Session Management Methods
|
|
400
|
+
async getSessions() {
|
|
401
|
+
if (!this.token) {
|
|
402
|
+
throw new Error("Not authenticated");
|
|
403
|
+
}
|
|
404
|
+
const response = await this.httpClient.get("/api/v1/session");
|
|
405
|
+
return response;
|
|
406
|
+
}
|
|
407
|
+
async revokeSession(sessionId) {
|
|
408
|
+
if (!this.token) {
|
|
409
|
+
throw new Error("Not authenticated");
|
|
410
|
+
}
|
|
411
|
+
const response = await this.httpClient.delete(`/api/v1/session/${sessionId}`);
|
|
412
|
+
return response;
|
|
413
|
+
}
|
|
414
|
+
async revokeAllSessions() {
|
|
415
|
+
if (!this.token) {
|
|
416
|
+
throw new Error("Not authenticated");
|
|
417
|
+
}
|
|
418
|
+
const response = await this.httpClient.delete("/api/v1/session/revoke/all");
|
|
419
|
+
this.token = null;
|
|
420
|
+
this.httpClient.removeAuthToken();
|
|
421
|
+
this.removeTokenFromStorage();
|
|
422
|
+
return response;
|
|
423
|
+
}
|
|
424
|
+
// Admin Methods
|
|
425
|
+
async getAuditLogs(filters) {
|
|
426
|
+
if (!this.token) {
|
|
427
|
+
throw new Error("Not authenticated");
|
|
428
|
+
}
|
|
429
|
+
const response = await this.httpClient.get(
|
|
430
|
+
"/api/v1/admin/audit-logs",
|
|
431
|
+
filters
|
|
432
|
+
);
|
|
433
|
+
return response;
|
|
434
|
+
}
|
|
435
|
+
async adminVerifyUser(userId) {
|
|
436
|
+
if (!this.token) {
|
|
437
|
+
throw new Error("Not authenticated");
|
|
438
|
+
}
|
|
439
|
+
const response = await this.httpClient.post(`/api/v1/admin/verify-user/${userId}`, {});
|
|
440
|
+
return response;
|
|
441
|
+
}
|
|
442
|
+
async adminForcePasswordReset(userId) {
|
|
443
|
+
if (!this.token) {
|
|
444
|
+
throw new Error("Not authenticated");
|
|
445
|
+
}
|
|
446
|
+
const response = await this.httpClient.post(`/api/v1/admin/force-password-reset/${userId}`, {});
|
|
447
|
+
return response;
|
|
448
|
+
}
|
|
449
|
+
async adminSuspendUser(userId) {
|
|
450
|
+
if (!this.token) {
|
|
451
|
+
throw new Error("Not authenticated");
|
|
452
|
+
}
|
|
453
|
+
const response = await this.httpClient.post(`/api/v1/admin/suspend-user/${userId}`, {});
|
|
454
|
+
return response;
|
|
455
|
+
}
|
|
456
|
+
async adminActivateUser(userId) {
|
|
457
|
+
if (!this.token) {
|
|
458
|
+
throw new Error("Not authenticated");
|
|
459
|
+
}
|
|
460
|
+
const response = await this.httpClient.post(`/api/v1/admin/activate-user/${userId}`, {});
|
|
461
|
+
return response;
|
|
462
|
+
}
|
|
297
463
|
};
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
RegisterForm: () => RegisterForm,
|
|
307
|
-
useAuth: () => useAuth
|
|
308
|
-
});
|
|
309
|
-
var useAuth = (config) => {
|
|
310
|
-
const [authService] = useState(() => new AuthService(config));
|
|
464
|
+
var AuthContext = createContext(void 0);
|
|
465
|
+
var AuthProvider = ({ children, config }) => {
|
|
466
|
+
const authConfig = {
|
|
467
|
+
baseUrl: config?.baseUrl || (typeof window !== "undefined" ? process.env.NEXT_PUBLIC_AUTH_API_URL || process.env.REACT_APP_AUTH_API_URL || "http://localhost:7000" : "http://localhost:7000"),
|
|
468
|
+
localStorageKey: config?.localStorageKey || "auth_token",
|
|
469
|
+
csrfEnabled: config?.csrfEnabled !== void 0 ? config.csrfEnabled : true
|
|
470
|
+
};
|
|
471
|
+
const [authService] = useState(() => new AuthService(authConfig));
|
|
311
472
|
const [user, setUser] = useState(null);
|
|
312
|
-
const [
|
|
313
|
-
const [loading, setLoading] = useState(
|
|
314
|
-
const checkAuthStatus = useCallback(() => {
|
|
473
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
474
|
+
const [loading, setLoading] = useState(false);
|
|
475
|
+
const checkAuthStatus = useCallback(async () => {
|
|
315
476
|
const authenticated = authService.isAuthenticated();
|
|
316
|
-
setIsAuthenticated(authenticated);
|
|
317
477
|
if (authenticated) {
|
|
318
|
-
|
|
319
|
-
|
|
478
|
+
try {
|
|
479
|
+
const currentUser = authService.getCurrentUser();
|
|
480
|
+
setUser(currentUser);
|
|
481
|
+
} catch (error) {
|
|
482
|
+
console.error("Failed to get current user:", error);
|
|
483
|
+
setUser(null);
|
|
484
|
+
}
|
|
320
485
|
} else {
|
|
321
486
|
setUser(null);
|
|
322
487
|
}
|
|
323
|
-
|
|
488
|
+
setIsLoaded(true);
|
|
324
489
|
}, [authService]);
|
|
325
490
|
useEffect(() => {
|
|
326
491
|
checkAuthStatus();
|
|
327
492
|
}, [checkAuthStatus]);
|
|
328
|
-
const
|
|
493
|
+
const signIn = useCallback(async (data) => {
|
|
329
494
|
setLoading(true);
|
|
330
495
|
try {
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
|
|
496
|
+
const response = await authService.login(data);
|
|
497
|
+
if (response.success && response.user) {
|
|
498
|
+
setUser(response.user);
|
|
334
499
|
}
|
|
335
|
-
const response = await authService.register(registerData);
|
|
336
500
|
return response;
|
|
337
501
|
} finally {
|
|
338
502
|
setLoading(false);
|
|
339
503
|
}
|
|
340
504
|
}, [authService]);
|
|
341
|
-
const
|
|
505
|
+
const signUp = useCallback(async (data) => {
|
|
342
506
|
setLoading(true);
|
|
343
507
|
try {
|
|
344
|
-
const response = await authService.
|
|
345
|
-
if (response.success && response.user) {
|
|
346
|
-
setUser(response.user);
|
|
347
|
-
setIsAuthenticated(true);
|
|
348
|
-
}
|
|
508
|
+
const response = await authService.register(data);
|
|
349
509
|
return response;
|
|
350
510
|
} finally {
|
|
351
511
|
setLoading(false);
|
|
352
512
|
}
|
|
353
513
|
}, [authService]);
|
|
514
|
+
const signOut = useCallback(async () => {
|
|
515
|
+
setLoading(true);
|
|
516
|
+
try {
|
|
517
|
+
await authService.logout();
|
|
518
|
+
setUser(null);
|
|
519
|
+
} finally {
|
|
520
|
+
setLoading(false);
|
|
521
|
+
}
|
|
522
|
+
}, [authService]);
|
|
354
523
|
const verify = useCallback(async (data) => {
|
|
355
524
|
setLoading(true);
|
|
356
525
|
try {
|
|
357
526
|
const response = await authService.verify(data);
|
|
358
527
|
if (response.success && response.user) {
|
|
359
528
|
setUser(response.user);
|
|
360
|
-
setIsAuthenticated(true);
|
|
361
529
|
}
|
|
362
530
|
return response;
|
|
363
531
|
} finally {
|
|
@@ -370,23 +538,12 @@ var useAuth = (config) => {
|
|
|
370
538
|
const response = await authService.verifyEmailToken(token);
|
|
371
539
|
if (response.success && response.user) {
|
|
372
540
|
setUser(response.user);
|
|
373
|
-
setIsAuthenticated(true);
|
|
374
541
|
}
|
|
375
542
|
return response;
|
|
376
543
|
} finally {
|
|
377
544
|
setLoading(false);
|
|
378
545
|
}
|
|
379
546
|
}, [authService]);
|
|
380
|
-
const logout = useCallback(async () => {
|
|
381
|
-
setLoading(true);
|
|
382
|
-
try {
|
|
383
|
-
await authService.logout();
|
|
384
|
-
setUser(null);
|
|
385
|
-
setIsAuthenticated(false);
|
|
386
|
-
} finally {
|
|
387
|
-
setLoading(false);
|
|
388
|
-
}
|
|
389
|
-
}, [authService]);
|
|
390
547
|
const updateProfile = useCallback(async (data) => {
|
|
391
548
|
setLoading(true);
|
|
392
549
|
try {
|
|
@@ -409,90 +566,356 @@ var useAuth = (config) => {
|
|
|
409
566
|
setLoading(false);
|
|
410
567
|
}
|
|
411
568
|
}, [authService]);
|
|
412
|
-
const
|
|
569
|
+
const signInWithOAuth = useCallback((provider) => {
|
|
570
|
+
authService.loginWithOAuth(provider);
|
|
571
|
+
}, [authService]);
|
|
572
|
+
const linkOAuthProvider = useCallback((provider) => {
|
|
573
|
+
authService.linkOAuthProvider(provider);
|
|
574
|
+
}, [authService]);
|
|
575
|
+
const unlinkOAuthProvider = useCallback(async (provider) => {
|
|
413
576
|
setLoading(true);
|
|
414
577
|
try {
|
|
415
|
-
return await authService.
|
|
578
|
+
return await authService.unlinkOAuthProvider(provider);
|
|
416
579
|
} finally {
|
|
417
580
|
setLoading(false);
|
|
418
581
|
}
|
|
419
582
|
}, [authService]);
|
|
420
|
-
const
|
|
583
|
+
const forgotPassword = useCallback(async (email) => {
|
|
421
584
|
setLoading(true);
|
|
422
585
|
try {
|
|
423
|
-
return await authService.
|
|
586
|
+
return await authService.forgotPassword(email);
|
|
424
587
|
} finally {
|
|
425
588
|
setLoading(false);
|
|
426
589
|
}
|
|
427
590
|
}, [authService]);
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
isAuthenticated,
|
|
431
|
-
loading,
|
|
432
|
-
register,
|
|
433
|
-
login,
|
|
434
|
-
verify,
|
|
435
|
-
verifyEmailToken,
|
|
436
|
-
logout,
|
|
437
|
-
updateProfile,
|
|
438
|
-
getProfile,
|
|
439
|
-
getAllUsers,
|
|
440
|
-
getUserById
|
|
441
|
-
};
|
|
442
|
-
};
|
|
443
|
-
var LoginForm = ({
|
|
444
|
-
onSuccess,
|
|
445
|
-
onLoginSuccess,
|
|
446
|
-
onRegisterClick,
|
|
447
|
-
showRegisterLink = true,
|
|
448
|
-
config,
|
|
449
|
-
oauthProviders = ["google", "github"],
|
|
450
|
-
showOAuthButtons = true
|
|
451
|
-
}) => {
|
|
452
|
-
const [email, setEmail] = useState("");
|
|
453
|
-
const [password, setPassword] = useState("");
|
|
454
|
-
const [usePassword, setUsePassword] = useState(false);
|
|
455
|
-
const [showPassword, setShowPassword] = useState(false);
|
|
456
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
457
|
-
const [error, setError] = useState(null);
|
|
458
|
-
const [rememberMe, setRememberMe] = useState(false);
|
|
459
|
-
const { login } = useAuth({
|
|
460
|
-
baseUrl: config?.baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
|
|
461
|
-
});
|
|
462
|
-
const handleSubmit = async (e) => {
|
|
463
|
-
e.preventDefault();
|
|
464
|
-
setIsLoading(true);
|
|
465
|
-
setError(null);
|
|
591
|
+
const resetPassword = useCallback(async (token, password) => {
|
|
592
|
+
setLoading(true);
|
|
466
593
|
try {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
594
|
+
return await authService.resetPassword(token, password);
|
|
595
|
+
} finally {
|
|
596
|
+
setLoading(false);
|
|
597
|
+
}
|
|
598
|
+
}, [authService]);
|
|
599
|
+
const changePassword = useCallback(async (oldPassword, newPassword) => {
|
|
600
|
+
setLoading(true);
|
|
601
|
+
try {
|
|
602
|
+
return await authService.changePassword(oldPassword, newPassword);
|
|
603
|
+
} finally {
|
|
604
|
+
setLoading(false);
|
|
605
|
+
}
|
|
606
|
+
}, [authService]);
|
|
607
|
+
const updateAvatar = useCallback(async (avatar) => {
|
|
608
|
+
setLoading(true);
|
|
609
|
+
try {
|
|
610
|
+
const response = await authService.updateAvatar(avatar);
|
|
611
|
+
if (response.success && response.user) {
|
|
612
|
+
setUser(response.user);
|
|
486
613
|
}
|
|
487
|
-
|
|
488
|
-
setError(err instanceof Error ? err.message : "An unknown error occurred");
|
|
614
|
+
return response;
|
|
489
615
|
} finally {
|
|
490
|
-
|
|
616
|
+
setLoading(false);
|
|
491
617
|
}
|
|
492
|
-
};
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
618
|
+
}, [authService]);
|
|
619
|
+
const requestEmailChange = useCallback(async (newEmail) => {
|
|
620
|
+
setLoading(true);
|
|
621
|
+
try {
|
|
622
|
+
return await authService.requestEmailChange(newEmail);
|
|
623
|
+
} finally {
|
|
624
|
+
setLoading(false);
|
|
625
|
+
}
|
|
626
|
+
}, [authService]);
|
|
627
|
+
const verifyEmailChange = useCallback(async (token) => {
|
|
628
|
+
setLoading(true);
|
|
629
|
+
try {
|
|
630
|
+
const response = await authService.verifyEmailChange(token);
|
|
631
|
+
if (response.success && response.user) {
|
|
632
|
+
setUser(response.user);
|
|
633
|
+
}
|
|
634
|
+
return response;
|
|
635
|
+
} finally {
|
|
636
|
+
setLoading(false);
|
|
637
|
+
}
|
|
638
|
+
}, [authService]);
|
|
639
|
+
const generate2FA = useCallback(async () => {
|
|
640
|
+
setLoading(true);
|
|
641
|
+
try {
|
|
642
|
+
return await authService.generate2FA();
|
|
643
|
+
} finally {
|
|
644
|
+
setLoading(false);
|
|
645
|
+
}
|
|
646
|
+
}, [authService]);
|
|
647
|
+
const enable2FA = useCallback(async (token) => {
|
|
648
|
+
setLoading(true);
|
|
649
|
+
try {
|
|
650
|
+
return await authService.enable2FA(token);
|
|
651
|
+
} finally {
|
|
652
|
+
setLoading(false);
|
|
653
|
+
}
|
|
654
|
+
}, [authService]);
|
|
655
|
+
const disable2FA = useCallback(async (token) => {
|
|
656
|
+
setLoading(true);
|
|
657
|
+
try {
|
|
658
|
+
return await authService.disable2FA(token);
|
|
659
|
+
} finally {
|
|
660
|
+
setLoading(false);
|
|
661
|
+
}
|
|
662
|
+
}, [authService]);
|
|
663
|
+
const validate2FA = useCallback(async (token) => {
|
|
664
|
+
setLoading(true);
|
|
665
|
+
try {
|
|
666
|
+
return await authService.validate2FA(token);
|
|
667
|
+
} finally {
|
|
668
|
+
setLoading(false);
|
|
669
|
+
}
|
|
670
|
+
}, [authService]);
|
|
671
|
+
const getSessions = useCallback(async () => {
|
|
672
|
+
setLoading(true);
|
|
673
|
+
try {
|
|
674
|
+
return await authService.getSessions();
|
|
675
|
+
} finally {
|
|
676
|
+
setLoading(false);
|
|
677
|
+
}
|
|
678
|
+
}, [authService]);
|
|
679
|
+
const revokeSession = useCallback(async (sessionId) => {
|
|
680
|
+
setLoading(true);
|
|
681
|
+
try {
|
|
682
|
+
return await authService.revokeSession(sessionId);
|
|
683
|
+
} finally {
|
|
684
|
+
setLoading(false);
|
|
685
|
+
}
|
|
686
|
+
}, [authService]);
|
|
687
|
+
const revokeAllSessions = useCallback(async () => {
|
|
688
|
+
setLoading(true);
|
|
689
|
+
try {
|
|
690
|
+
const response = await authService.revokeAllSessions();
|
|
691
|
+
setUser(null);
|
|
692
|
+
return response;
|
|
693
|
+
} finally {
|
|
694
|
+
setLoading(false);
|
|
695
|
+
}
|
|
696
|
+
}, [authService]);
|
|
697
|
+
const value = {
|
|
698
|
+
user,
|
|
699
|
+
isLoaded,
|
|
700
|
+
isSignedIn: !!user,
|
|
701
|
+
loading,
|
|
702
|
+
signIn,
|
|
703
|
+
signUp,
|
|
704
|
+
signOut,
|
|
705
|
+
verify,
|
|
706
|
+
verifyEmailToken,
|
|
707
|
+
updateProfile,
|
|
708
|
+
getProfile,
|
|
709
|
+
signInWithOAuth,
|
|
710
|
+
linkOAuthProvider,
|
|
711
|
+
unlinkOAuthProvider,
|
|
712
|
+
forgotPassword,
|
|
713
|
+
resetPassword,
|
|
714
|
+
changePassword,
|
|
715
|
+
updateAvatar,
|
|
716
|
+
requestEmailChange,
|
|
717
|
+
verifyEmailChange,
|
|
718
|
+
generate2FA,
|
|
719
|
+
enable2FA,
|
|
720
|
+
disable2FA,
|
|
721
|
+
validate2FA,
|
|
722
|
+
getSessions,
|
|
723
|
+
revokeSession,
|
|
724
|
+
revokeAllSessions,
|
|
725
|
+
authService
|
|
726
|
+
};
|
|
727
|
+
return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children });
|
|
728
|
+
};
|
|
729
|
+
var useAuth = () => {
|
|
730
|
+
const context = useContext(AuthContext);
|
|
731
|
+
if (context === void 0) {
|
|
732
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
733
|
+
}
|
|
734
|
+
return context;
|
|
735
|
+
};
|
|
736
|
+
var useAuth2 = (config) => {
|
|
737
|
+
const [authService] = useState(() => new AuthService(config));
|
|
738
|
+
const [user, setUser] = useState(null);
|
|
739
|
+
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
740
|
+
const [loading, setLoading] = useState(true);
|
|
741
|
+
const checkAuthStatus = useCallback(() => {
|
|
742
|
+
const authenticated = authService.isAuthenticated();
|
|
743
|
+
setIsAuthenticated(authenticated);
|
|
744
|
+
if (authenticated) {
|
|
745
|
+
const currentUser = authService.getCurrentUser();
|
|
746
|
+
setUser(currentUser);
|
|
747
|
+
} else {
|
|
748
|
+
setUser(null);
|
|
749
|
+
}
|
|
750
|
+
setLoading(false);
|
|
751
|
+
}, [authService]);
|
|
752
|
+
useEffect(() => {
|
|
753
|
+
checkAuthStatus();
|
|
754
|
+
}, [checkAuthStatus]);
|
|
755
|
+
const register = useCallback(async (data) => {
|
|
756
|
+
setLoading(true);
|
|
757
|
+
try {
|
|
758
|
+
const response = await authService.register(data);
|
|
759
|
+
return response;
|
|
760
|
+
} finally {
|
|
761
|
+
setLoading(false);
|
|
762
|
+
}
|
|
763
|
+
}, [authService]);
|
|
764
|
+
const login = useCallback(async (data) => {
|
|
765
|
+
setLoading(true);
|
|
766
|
+
try {
|
|
767
|
+
const response = await authService.login(data);
|
|
768
|
+
if (response.success && response.user) {
|
|
769
|
+
setUser(response.user);
|
|
770
|
+
setIsAuthenticated(true);
|
|
771
|
+
}
|
|
772
|
+
return response;
|
|
773
|
+
} finally {
|
|
774
|
+
setLoading(false);
|
|
775
|
+
}
|
|
776
|
+
}, [authService]);
|
|
777
|
+
const verify = useCallback(async (data) => {
|
|
778
|
+
setLoading(true);
|
|
779
|
+
try {
|
|
780
|
+
const response = await authService.verify(data);
|
|
781
|
+
if (response.success && response.user) {
|
|
782
|
+
setUser(response.user);
|
|
783
|
+
setIsAuthenticated(true);
|
|
784
|
+
}
|
|
785
|
+
return response;
|
|
786
|
+
} finally {
|
|
787
|
+
setLoading(false);
|
|
788
|
+
}
|
|
789
|
+
}, [authService]);
|
|
790
|
+
const verifyEmailToken = useCallback(async (token) => {
|
|
791
|
+
setLoading(true);
|
|
792
|
+
try {
|
|
793
|
+
const response = await authService.verifyEmailToken(token);
|
|
794
|
+
if (response.success && response.user) {
|
|
795
|
+
setUser(response.user);
|
|
796
|
+
setIsAuthenticated(true);
|
|
797
|
+
}
|
|
798
|
+
return response;
|
|
799
|
+
} finally {
|
|
800
|
+
setLoading(false);
|
|
801
|
+
}
|
|
802
|
+
}, [authService]);
|
|
803
|
+
const logout = useCallback(async () => {
|
|
804
|
+
setLoading(true);
|
|
805
|
+
try {
|
|
806
|
+
await authService.logout();
|
|
807
|
+
setUser(null);
|
|
808
|
+
setIsAuthenticated(false);
|
|
809
|
+
} finally {
|
|
810
|
+
setLoading(false);
|
|
811
|
+
}
|
|
812
|
+
}, [authService]);
|
|
813
|
+
const updateProfile = useCallback(async (data) => {
|
|
814
|
+
setLoading(true);
|
|
815
|
+
try {
|
|
816
|
+
const response = await authService.updateProfile(data);
|
|
817
|
+
if (response.success && response.user) {
|
|
818
|
+
setUser(response.user);
|
|
819
|
+
}
|
|
820
|
+
return response;
|
|
821
|
+
} finally {
|
|
822
|
+
setLoading(false);
|
|
823
|
+
}
|
|
824
|
+
}, [authService]);
|
|
825
|
+
const getProfile = useCallback(async () => {
|
|
826
|
+
setLoading(true);
|
|
827
|
+
try {
|
|
828
|
+
const userData = await authService.getProfile();
|
|
829
|
+
setUser(userData);
|
|
830
|
+
return userData;
|
|
831
|
+
} finally {
|
|
832
|
+
setLoading(false);
|
|
833
|
+
}
|
|
834
|
+
}, [authService]);
|
|
835
|
+
const getAllUsers = useCallback(async () => {
|
|
836
|
+
setLoading(true);
|
|
837
|
+
try {
|
|
838
|
+
return await authService.getAllUsers();
|
|
839
|
+
} finally {
|
|
840
|
+
setLoading(false);
|
|
841
|
+
}
|
|
842
|
+
}, [authService]);
|
|
843
|
+
const getUserById = useCallback(async (id) => {
|
|
844
|
+
setLoading(true);
|
|
845
|
+
try {
|
|
846
|
+
return await authService.getUserById(id);
|
|
847
|
+
} finally {
|
|
848
|
+
setLoading(false);
|
|
849
|
+
}
|
|
850
|
+
}, [authService]);
|
|
851
|
+
return {
|
|
852
|
+
user,
|
|
853
|
+
isAuthenticated,
|
|
854
|
+
loading,
|
|
855
|
+
register,
|
|
856
|
+
login,
|
|
857
|
+
verify,
|
|
858
|
+
verifyEmailToken,
|
|
859
|
+
logout,
|
|
860
|
+
updateProfile,
|
|
861
|
+
getProfile,
|
|
862
|
+
getAllUsers,
|
|
863
|
+
getUserById
|
|
864
|
+
};
|
|
865
|
+
};
|
|
866
|
+
var LoginForm = ({
|
|
867
|
+
onSuccess,
|
|
868
|
+
onLoginSuccess,
|
|
869
|
+
onRegisterClick,
|
|
870
|
+
showRegisterLink = true,
|
|
871
|
+
config,
|
|
872
|
+
oauthProviders = ["google", "github"],
|
|
873
|
+
showOAuthButtons = true
|
|
874
|
+
}) => {
|
|
875
|
+
const [email, setEmail] = useState("");
|
|
876
|
+
const [password, setPassword] = useState("");
|
|
877
|
+
const [usePassword, setUsePassword] = useState(false);
|
|
878
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
879
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
880
|
+
const [error, setError] = useState(null);
|
|
881
|
+
const [rememberMe, setRememberMe] = useState(false);
|
|
882
|
+
const { login } = useAuth2({
|
|
883
|
+
baseUrl: config?.baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
|
|
884
|
+
});
|
|
885
|
+
const handleSubmit = async (e) => {
|
|
886
|
+
e.preventDefault();
|
|
887
|
+
setIsLoading(true);
|
|
888
|
+
setError(null);
|
|
889
|
+
try {
|
|
890
|
+
let response;
|
|
891
|
+
if (usePassword) {
|
|
892
|
+
response = await login({ email, password });
|
|
893
|
+
} else {
|
|
894
|
+
response = await login({ email });
|
|
895
|
+
}
|
|
896
|
+
if (response.success) {
|
|
897
|
+
onSuccess?.(response);
|
|
898
|
+
if (onLoginSuccess) {
|
|
899
|
+
if (response.message === "OTP sent to your email.") {
|
|
900
|
+
onLoginSuccess(email, true);
|
|
901
|
+
} else if (response.token) {
|
|
902
|
+
onLoginSuccess(email, false);
|
|
903
|
+
} else {
|
|
904
|
+
onLoginSuccess(email, true);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
} else {
|
|
908
|
+
setError(response.message || "Login failed");
|
|
909
|
+
}
|
|
910
|
+
} catch (err) {
|
|
911
|
+
setError(err instanceof Error ? err.message : "An unknown error occurred");
|
|
912
|
+
} finally {
|
|
913
|
+
setIsLoading(false);
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
const toggleAuthMethod = () => {
|
|
917
|
+
setUsePassword(!usePassword);
|
|
918
|
+
setError(null);
|
|
496
919
|
};
|
|
497
920
|
const togglePasswordVisibility = () => {
|
|
498
921
|
setShowPassword(!showPassword);
|
|
@@ -900,7 +1323,7 @@ var RegisterForm = ({
|
|
|
900
1323
|
const config = authConfig || {
|
|
901
1324
|
baseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_AUTH_API_URL || window.location.origin : "http://localhost:7000"
|
|
902
1325
|
};
|
|
903
|
-
const { register } =
|
|
1326
|
+
const { register } = useAuth2(config);
|
|
904
1327
|
const handleSubmit = async (e) => {
|
|
905
1328
|
e.preventDefault();
|
|
906
1329
|
setIsLoading(true);
|
|
@@ -1295,7 +1718,7 @@ var OtpForm = ({
|
|
|
1295
1718
|
const [error, setError] = useState(null);
|
|
1296
1719
|
const [resendCooldown, setResendCooldown] = useState(0);
|
|
1297
1720
|
const [resendLoading, setResendLoading] = useState(false);
|
|
1298
|
-
const { verify, login } =
|
|
1721
|
+
const { verify, login } = useAuth2({
|
|
1299
1722
|
baseUrl: typeof window !== "undefined" ? window.location.origin : "http://localhost:7000"
|
|
1300
1723
|
});
|
|
1301
1724
|
const handleSubmit = async (e) => {
|
|
@@ -1646,7 +2069,7 @@ var EmailVerificationPage = ({
|
|
|
1646
2069
|
const [isLoading, setIsLoading] = useState(true);
|
|
1647
2070
|
const [message, setMessage] = useState("");
|
|
1648
2071
|
const [isSuccess, setIsSuccess] = useState(false);
|
|
1649
|
-
const { verifyEmailToken } =
|
|
2072
|
+
const { verifyEmailToken } = useAuth2({
|
|
1650
2073
|
baseUrl: baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
|
|
1651
2074
|
});
|
|
1652
2075
|
useEffect(() => {
|
|
@@ -1754,6 +2177,1825 @@ var EmailVerificationPage = ({
|
|
|
1754
2177
|
] })
|
|
1755
2178
|
] }) });
|
|
1756
2179
|
};
|
|
2180
|
+
var SignIn = ({ redirectUrl, appearance }) => {
|
|
2181
|
+
const { signIn, isSignedIn, loading: authLoading } = useAuth();
|
|
2182
|
+
const [email, setEmail] = useState("");
|
|
2183
|
+
const [password, setPassword] = useState("");
|
|
2184
|
+
const [otp, setOtp] = useState("");
|
|
2185
|
+
const [usePassword, setUsePassword] = useState(false);
|
|
2186
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
2187
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
2188
|
+
const [error, setError] = useState(null);
|
|
2189
|
+
const [needsOtp, setNeedsOtp] = useState(false);
|
|
2190
|
+
const [success, setSuccess] = useState(null);
|
|
2191
|
+
useEffect(() => {
|
|
2192
|
+
if (isSignedIn && redirectUrl) {
|
|
2193
|
+
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
2194
|
+
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2195
|
+
window.location.href = `${baseUrl}${redirect}`;
|
|
2196
|
+
}
|
|
2197
|
+
}, [isSignedIn, redirectUrl]);
|
|
2198
|
+
const handleSubmit = async (e) => {
|
|
2199
|
+
e.preventDefault();
|
|
2200
|
+
setIsLoading(true);
|
|
2201
|
+
setError(null);
|
|
2202
|
+
setSuccess(null);
|
|
2203
|
+
try {
|
|
2204
|
+
if (needsOtp) {
|
|
2205
|
+
const response = await signIn({ email, otp });
|
|
2206
|
+
if (response.success) {
|
|
2207
|
+
setSuccess("Login successful!");
|
|
2208
|
+
} else {
|
|
2209
|
+
setError(response.message || "OTP verification failed");
|
|
2210
|
+
}
|
|
2211
|
+
} else if (usePassword) {
|
|
2212
|
+
const response = await signIn({ email, password });
|
|
2213
|
+
if (response.success) {
|
|
2214
|
+
setSuccess("Login successful!");
|
|
2215
|
+
} else {
|
|
2216
|
+
setError(response.message || "Login failed");
|
|
2217
|
+
}
|
|
2218
|
+
} else {
|
|
2219
|
+
const response = await signIn({ email });
|
|
2220
|
+
if (response.success && response.message === "OTP sent to your email.") {
|
|
2221
|
+
setNeedsOtp(true);
|
|
2222
|
+
setSuccess("OTP sent to your email. Please check your inbox.");
|
|
2223
|
+
} else {
|
|
2224
|
+
setError(response.message || "Failed to send OTP");
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
} catch (err) {
|
|
2228
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
2229
|
+
} finally {
|
|
2230
|
+
setIsLoading(false);
|
|
2231
|
+
}
|
|
2232
|
+
};
|
|
2233
|
+
const toggleAuthMethod = () => {
|
|
2234
|
+
setUsePassword(!usePassword);
|
|
2235
|
+
setNeedsOtp(false);
|
|
2236
|
+
setError(null);
|
|
2237
|
+
setSuccess(null);
|
|
2238
|
+
setOtp("");
|
|
2239
|
+
};
|
|
2240
|
+
if (authLoading) {
|
|
2241
|
+
return /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsx("div", { children: "Loading..." }) });
|
|
2242
|
+
}
|
|
2243
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
2244
|
+
maxWidth: "400px",
|
|
2245
|
+
margin: "0 auto",
|
|
2246
|
+
padding: "30px",
|
|
2247
|
+
borderRadius: "12px",
|
|
2248
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2249
|
+
backgroundColor: "#ffffff",
|
|
2250
|
+
border: "1px solid #eaeaea",
|
|
2251
|
+
...appearance?.elements?.card
|
|
2252
|
+
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
2253
|
+
/* @__PURE__ */ jsx("h2", { style: {
|
|
2254
|
+
textAlign: "center",
|
|
2255
|
+
marginBottom: "24px",
|
|
2256
|
+
color: "#1f2937",
|
|
2257
|
+
fontSize: "24px",
|
|
2258
|
+
fontWeight: 600,
|
|
2259
|
+
...appearance?.elements?.headerTitle
|
|
2260
|
+
}, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
|
|
2261
|
+
error && /* @__PURE__ */ jsx("div", { style: {
|
|
2262
|
+
padding: "12px 16px",
|
|
2263
|
+
marginBottom: "20px",
|
|
2264
|
+
backgroundColor: "#fee",
|
|
2265
|
+
color: "#c33",
|
|
2266
|
+
border: "1px solid #fcc",
|
|
2267
|
+
borderRadius: "8px",
|
|
2268
|
+
fontSize: "14px"
|
|
2269
|
+
}, children: error }),
|
|
2270
|
+
success && /* @__PURE__ */ jsx("div", { style: {
|
|
2271
|
+
padding: "12px 16px",
|
|
2272
|
+
marginBottom: "20px",
|
|
2273
|
+
backgroundColor: "#efe",
|
|
2274
|
+
color: "#3c3",
|
|
2275
|
+
border: "1px solid #cfc",
|
|
2276
|
+
borderRadius: "8px",
|
|
2277
|
+
fontSize: "14px"
|
|
2278
|
+
}, children: success }),
|
|
2279
|
+
!needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2280
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
|
|
2281
|
+
display: "block",
|
|
2282
|
+
marginBottom: "8px",
|
|
2283
|
+
fontWeight: 500,
|
|
2284
|
+
color: "#374151",
|
|
2285
|
+
fontSize: "14px"
|
|
2286
|
+
}, children: "Email" }),
|
|
2287
|
+
/* @__PURE__ */ jsx(
|
|
2288
|
+
"input",
|
|
2289
|
+
{
|
|
2290
|
+
id: "email",
|
|
2291
|
+
type: "email",
|
|
2292
|
+
value: email,
|
|
2293
|
+
onChange: (e) => setEmail(e.target.value),
|
|
2294
|
+
required: true,
|
|
2295
|
+
disabled: isLoading,
|
|
2296
|
+
style: {
|
|
2297
|
+
width: "100%",
|
|
2298
|
+
padding: "12px 16px",
|
|
2299
|
+
border: "1px solid #ddd",
|
|
2300
|
+
borderRadius: "8px",
|
|
2301
|
+
fontSize: "16px",
|
|
2302
|
+
boxSizing: "border-box",
|
|
2303
|
+
...appearance?.elements?.formFieldInput
|
|
2304
|
+
},
|
|
2305
|
+
placeholder: "Enter your email"
|
|
2306
|
+
}
|
|
2307
|
+
)
|
|
2308
|
+
] }),
|
|
2309
|
+
usePassword && !needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2310
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
|
|
2311
|
+
display: "block",
|
|
2312
|
+
marginBottom: "8px",
|
|
2313
|
+
fontWeight: 500,
|
|
2314
|
+
color: "#374151",
|
|
2315
|
+
fontSize: "14px"
|
|
2316
|
+
}, children: "Password" }),
|
|
2317
|
+
/* @__PURE__ */ jsx(
|
|
2318
|
+
"input",
|
|
2319
|
+
{
|
|
2320
|
+
id: "password",
|
|
2321
|
+
type: showPassword ? "text" : "password",
|
|
2322
|
+
value: password,
|
|
2323
|
+
onChange: (e) => setPassword(e.target.value),
|
|
2324
|
+
required: true,
|
|
2325
|
+
disabled: isLoading,
|
|
2326
|
+
style: {
|
|
2327
|
+
width: "100%",
|
|
2328
|
+
padding: "12px 16px",
|
|
2329
|
+
border: "1px solid #ddd",
|
|
2330
|
+
borderRadius: "8px",
|
|
2331
|
+
fontSize: "16px",
|
|
2332
|
+
boxSizing: "border-box",
|
|
2333
|
+
...appearance?.elements?.formFieldInput
|
|
2334
|
+
},
|
|
2335
|
+
placeholder: "Enter your password"
|
|
2336
|
+
}
|
|
2337
|
+
),
|
|
2338
|
+
/* @__PURE__ */ jsx(
|
|
2339
|
+
"button",
|
|
2340
|
+
{
|
|
2341
|
+
type: "button",
|
|
2342
|
+
onClick: () => setShowPassword(!showPassword),
|
|
2343
|
+
style: {
|
|
2344
|
+
position: "absolute",
|
|
2345
|
+
right: "12px",
|
|
2346
|
+
top: "38px",
|
|
2347
|
+
background: "none",
|
|
2348
|
+
border: "none",
|
|
2349
|
+
cursor: "pointer",
|
|
2350
|
+
color: "#666",
|
|
2351
|
+
fontSize: "14px"
|
|
2352
|
+
},
|
|
2353
|
+
children: showPassword ? "Hide" : "Show"
|
|
2354
|
+
}
|
|
2355
|
+
)
|
|
2356
|
+
] }),
|
|
2357
|
+
needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2358
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "otp", style: {
|
|
2359
|
+
display: "block",
|
|
2360
|
+
marginBottom: "8px",
|
|
2361
|
+
fontWeight: 500,
|
|
2362
|
+
color: "#374151",
|
|
2363
|
+
fontSize: "14px"
|
|
2364
|
+
}, children: "One-Time Password" }),
|
|
2365
|
+
/* @__PURE__ */ jsx(
|
|
2366
|
+
"input",
|
|
2367
|
+
{
|
|
2368
|
+
id: "otp",
|
|
2369
|
+
type: "text",
|
|
2370
|
+
value: otp,
|
|
2371
|
+
onChange: (e) => setOtp(e.target.value),
|
|
2372
|
+
required: true,
|
|
2373
|
+
disabled: isLoading,
|
|
2374
|
+
maxLength: 6,
|
|
2375
|
+
style: {
|
|
2376
|
+
width: "100%",
|
|
2377
|
+
padding: "12px 16px",
|
|
2378
|
+
border: "1px solid #ddd",
|
|
2379
|
+
borderRadius: "8px",
|
|
2380
|
+
fontSize: "16px",
|
|
2381
|
+
boxSizing: "border-box",
|
|
2382
|
+
letterSpacing: "0.5em",
|
|
2383
|
+
textAlign: "center",
|
|
2384
|
+
...appearance?.elements?.formFieldInput
|
|
2385
|
+
},
|
|
2386
|
+
placeholder: "000000"
|
|
2387
|
+
}
|
|
2388
|
+
)
|
|
2389
|
+
] }),
|
|
2390
|
+
/* @__PURE__ */ jsx(
|
|
2391
|
+
"button",
|
|
2392
|
+
{
|
|
2393
|
+
type: "submit",
|
|
2394
|
+
disabled: isLoading,
|
|
2395
|
+
style: {
|
|
2396
|
+
width: "100%",
|
|
2397
|
+
padding: "14px",
|
|
2398
|
+
backgroundColor: "#007bff",
|
|
2399
|
+
color: "white",
|
|
2400
|
+
border: "none",
|
|
2401
|
+
borderRadius: "8px",
|
|
2402
|
+
fontSize: "16px",
|
|
2403
|
+
fontWeight: 600,
|
|
2404
|
+
cursor: "pointer",
|
|
2405
|
+
transition: "all 0.2s ease",
|
|
2406
|
+
...appearance?.elements?.formButtonPrimary
|
|
2407
|
+
},
|
|
2408
|
+
children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : "Continue with email"
|
|
2409
|
+
}
|
|
2410
|
+
),
|
|
2411
|
+
!needsOtp && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsx(
|
|
2412
|
+
"button",
|
|
2413
|
+
{
|
|
2414
|
+
type: "button",
|
|
2415
|
+
onClick: toggleAuthMethod,
|
|
2416
|
+
disabled: isLoading,
|
|
2417
|
+
style: {
|
|
2418
|
+
background: "none",
|
|
2419
|
+
border: "none",
|
|
2420
|
+
color: "#007bff",
|
|
2421
|
+
cursor: "pointer",
|
|
2422
|
+
fontSize: "14px",
|
|
2423
|
+
fontWeight: 600
|
|
2424
|
+
},
|
|
2425
|
+
children: usePassword ? "Use email code instead" : "Use password instead"
|
|
2426
|
+
}
|
|
2427
|
+
) }),
|
|
2428
|
+
needsOtp && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsx(
|
|
2429
|
+
"button",
|
|
2430
|
+
{
|
|
2431
|
+
type: "button",
|
|
2432
|
+
onClick: () => {
|
|
2433
|
+
setNeedsOtp(false);
|
|
2434
|
+
setOtp("");
|
|
2435
|
+
setError(null);
|
|
2436
|
+
setSuccess(null);
|
|
2437
|
+
},
|
|
2438
|
+
disabled: isLoading,
|
|
2439
|
+
style: {
|
|
2440
|
+
background: "none",
|
|
2441
|
+
border: "none",
|
|
2442
|
+
color: "#007bff",
|
|
2443
|
+
cursor: "pointer",
|
|
2444
|
+
fontSize: "14px",
|
|
2445
|
+
fontWeight: 600
|
|
2446
|
+
},
|
|
2447
|
+
children: "Back to sign in"
|
|
2448
|
+
}
|
|
2449
|
+
) })
|
|
2450
|
+
] }) });
|
|
2451
|
+
};
|
|
2452
|
+
var SignUp = ({ redirectUrl, appearance }) => {
|
|
2453
|
+
const { signUp, isSignedIn } = useAuth();
|
|
2454
|
+
const [name, setName] = useState("");
|
|
2455
|
+
const [email, setEmail] = useState("");
|
|
2456
|
+
const [password, setPassword] = useState("");
|
|
2457
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
2458
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
2459
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
2460
|
+
const [error, setError] = useState(null);
|
|
2461
|
+
const [success, setSuccess] = useState(null);
|
|
2462
|
+
useEffect(() => {
|
|
2463
|
+
if (isSignedIn && redirectUrl) {
|
|
2464
|
+
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
|
|
2465
|
+
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2466
|
+
window.location.href = `${baseUrl}${redirect}`;
|
|
2467
|
+
}
|
|
2468
|
+
}, [isSignedIn, redirectUrl]);
|
|
2469
|
+
const getPasswordStrength = (pwd) => {
|
|
2470
|
+
if (!pwd)
|
|
2471
|
+
return { strength: "weak", color: "#ddd" };
|
|
2472
|
+
let score = 0;
|
|
2473
|
+
if (pwd.length >= 6)
|
|
2474
|
+
score++;
|
|
2475
|
+
if (pwd.length >= 8)
|
|
2476
|
+
score++;
|
|
2477
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
|
|
2478
|
+
score++;
|
|
2479
|
+
if (/\d/.test(pwd))
|
|
2480
|
+
score++;
|
|
2481
|
+
if (/[^a-zA-Z\d]/.test(pwd))
|
|
2482
|
+
score++;
|
|
2483
|
+
if (score <= 2)
|
|
2484
|
+
return { strength: "weak", color: "#f44" };
|
|
2485
|
+
if (score <= 3)
|
|
2486
|
+
return { strength: "medium", color: "#fa4" };
|
|
2487
|
+
return { strength: "strong", color: "#4f4" };
|
|
2488
|
+
};
|
|
2489
|
+
const passwordStrength = getPasswordStrength(password);
|
|
2490
|
+
const handleSubmit = async (e) => {
|
|
2491
|
+
e.preventDefault();
|
|
2492
|
+
setIsLoading(true);
|
|
2493
|
+
setError(null);
|
|
2494
|
+
setSuccess(null);
|
|
2495
|
+
if (password !== confirmPassword) {
|
|
2496
|
+
setError("Passwords do not match");
|
|
2497
|
+
setIsLoading(false);
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
if (password.length < 6) {
|
|
2501
|
+
setError("Password must be at least 6 characters");
|
|
2502
|
+
setIsLoading(false);
|
|
2503
|
+
return;
|
|
2504
|
+
}
|
|
2505
|
+
try {
|
|
2506
|
+
const response = await signUp({ name, email, password });
|
|
2507
|
+
if (response.success) {
|
|
2508
|
+
setSuccess("Registration successful! Please check your email to verify your account.");
|
|
2509
|
+
} else {
|
|
2510
|
+
setError(response.message || "Registration failed");
|
|
2511
|
+
}
|
|
2512
|
+
} catch (err) {
|
|
2513
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
2514
|
+
} finally {
|
|
2515
|
+
setIsLoading(false);
|
|
2516
|
+
}
|
|
2517
|
+
};
|
|
2518
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
2519
|
+
maxWidth: "400px",
|
|
2520
|
+
margin: "0 auto",
|
|
2521
|
+
padding: "30px",
|
|
2522
|
+
borderRadius: "12px",
|
|
2523
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2524
|
+
backgroundColor: "#ffffff",
|
|
2525
|
+
border: "1px solid #eaeaea",
|
|
2526
|
+
...appearance?.elements?.card
|
|
2527
|
+
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
2528
|
+
/* @__PURE__ */ jsx("h2", { style: {
|
|
2529
|
+
textAlign: "center",
|
|
2530
|
+
marginBottom: "24px",
|
|
2531
|
+
color: "#1f2937",
|
|
2532
|
+
fontSize: "24px",
|
|
2533
|
+
fontWeight: 600,
|
|
2534
|
+
...appearance?.elements?.headerTitle
|
|
2535
|
+
}, children: "Create your account" }),
|
|
2536
|
+
error && /* @__PURE__ */ jsx("div", { style: {
|
|
2537
|
+
padding: "12px 16px",
|
|
2538
|
+
marginBottom: "20px",
|
|
2539
|
+
backgroundColor: "#fee",
|
|
2540
|
+
color: "#c33",
|
|
2541
|
+
border: "1px solid #fcc",
|
|
2542
|
+
borderRadius: "8px",
|
|
2543
|
+
fontSize: "14px"
|
|
2544
|
+
}, children: error }),
|
|
2545
|
+
success && /* @__PURE__ */ jsx("div", { style: {
|
|
2546
|
+
padding: "12px 16px",
|
|
2547
|
+
marginBottom: "20px",
|
|
2548
|
+
backgroundColor: "#efe",
|
|
2549
|
+
color: "#3c3",
|
|
2550
|
+
border: "1px solid #cfc",
|
|
2551
|
+
borderRadius: "8px",
|
|
2552
|
+
fontSize: "14px"
|
|
2553
|
+
}, children: success }),
|
|
2554
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2555
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "name", style: {
|
|
2556
|
+
display: "block",
|
|
2557
|
+
marginBottom: "8px",
|
|
2558
|
+
fontWeight: 500,
|
|
2559
|
+
color: "#374151",
|
|
2560
|
+
fontSize: "14px"
|
|
2561
|
+
}, children: "Full name" }),
|
|
2562
|
+
/* @__PURE__ */ jsx(
|
|
2563
|
+
"input",
|
|
2564
|
+
{
|
|
2565
|
+
id: "name",
|
|
2566
|
+
type: "text",
|
|
2567
|
+
value: name,
|
|
2568
|
+
onChange: (e) => setName(e.target.value),
|
|
2569
|
+
required: true,
|
|
2570
|
+
disabled: isLoading,
|
|
2571
|
+
style: {
|
|
2572
|
+
width: "100%",
|
|
2573
|
+
padding: "12px 16px",
|
|
2574
|
+
border: "1px solid #ddd",
|
|
2575
|
+
borderRadius: "8px",
|
|
2576
|
+
fontSize: "16px",
|
|
2577
|
+
boxSizing: "border-box",
|
|
2578
|
+
...appearance?.elements?.formFieldInput
|
|
2579
|
+
},
|
|
2580
|
+
placeholder: "Enter your full name"
|
|
2581
|
+
}
|
|
2582
|
+
)
|
|
2583
|
+
] }),
|
|
2584
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2585
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
|
|
2586
|
+
display: "block",
|
|
2587
|
+
marginBottom: "8px",
|
|
2588
|
+
fontWeight: 500,
|
|
2589
|
+
color: "#374151",
|
|
2590
|
+
fontSize: "14px"
|
|
2591
|
+
}, children: "Email" }),
|
|
2592
|
+
/* @__PURE__ */ jsx(
|
|
2593
|
+
"input",
|
|
2594
|
+
{
|
|
2595
|
+
id: "email",
|
|
2596
|
+
type: "email",
|
|
2597
|
+
value: email,
|
|
2598
|
+
onChange: (e) => setEmail(e.target.value),
|
|
2599
|
+
required: true,
|
|
2600
|
+
disabled: isLoading,
|
|
2601
|
+
style: {
|
|
2602
|
+
width: "100%",
|
|
2603
|
+
padding: "12px 16px",
|
|
2604
|
+
border: "1px solid #ddd",
|
|
2605
|
+
borderRadius: "8px",
|
|
2606
|
+
fontSize: "16px",
|
|
2607
|
+
boxSizing: "border-box",
|
|
2608
|
+
...appearance?.elements?.formFieldInput
|
|
2609
|
+
},
|
|
2610
|
+
placeholder: "Enter your email"
|
|
2611
|
+
}
|
|
2612
|
+
)
|
|
2613
|
+
] }),
|
|
2614
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2615
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
|
|
2616
|
+
display: "block",
|
|
2617
|
+
marginBottom: "8px",
|
|
2618
|
+
fontWeight: 500,
|
|
2619
|
+
color: "#374151",
|
|
2620
|
+
fontSize: "14px"
|
|
2621
|
+
}, children: "Password" }),
|
|
2622
|
+
/* @__PURE__ */ jsx(
|
|
2623
|
+
"input",
|
|
2624
|
+
{
|
|
2625
|
+
id: "password",
|
|
2626
|
+
type: showPassword ? "text" : "password",
|
|
2627
|
+
value: password,
|
|
2628
|
+
onChange: (e) => setPassword(e.target.value),
|
|
2629
|
+
required: true,
|
|
2630
|
+
disabled: isLoading,
|
|
2631
|
+
minLength: 6,
|
|
2632
|
+
style: {
|
|
2633
|
+
width: "100%",
|
|
2634
|
+
padding: "12px 16px",
|
|
2635
|
+
border: "1px solid #ddd",
|
|
2636
|
+
borderRadius: "8px",
|
|
2637
|
+
fontSize: "16px",
|
|
2638
|
+
boxSizing: "border-box",
|
|
2639
|
+
...appearance?.elements?.formFieldInput
|
|
2640
|
+
},
|
|
2641
|
+
placeholder: "Create a password"
|
|
2642
|
+
}
|
|
2643
|
+
),
|
|
2644
|
+
/* @__PURE__ */ jsx(
|
|
2645
|
+
"button",
|
|
2646
|
+
{
|
|
2647
|
+
type: "button",
|
|
2648
|
+
onClick: () => setShowPassword(!showPassword),
|
|
2649
|
+
style: {
|
|
2650
|
+
position: "absolute",
|
|
2651
|
+
right: "12px",
|
|
2652
|
+
top: "38px",
|
|
2653
|
+
background: "none",
|
|
2654
|
+
border: "none",
|
|
2655
|
+
cursor: "pointer",
|
|
2656
|
+
color: "#666",
|
|
2657
|
+
fontSize: "14px"
|
|
2658
|
+
},
|
|
2659
|
+
children: showPassword ? "Hide" : "Show"
|
|
2660
|
+
}
|
|
2661
|
+
),
|
|
2662
|
+
password && /* @__PURE__ */ jsxs("div", { style: { marginTop: "8px" }, children: [
|
|
2663
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2664
|
+
height: "4px",
|
|
2665
|
+
backgroundColor: "#eee",
|
|
2666
|
+
borderRadius: "2px",
|
|
2667
|
+
overflow: "hidden"
|
|
2668
|
+
}, children: /* @__PURE__ */ jsx("div", { style: {
|
|
2669
|
+
height: "100%",
|
|
2670
|
+
width: passwordStrength.strength === "weak" ? "33%" : passwordStrength.strength === "medium" ? "66%" : "100%",
|
|
2671
|
+
backgroundColor: passwordStrength.color,
|
|
2672
|
+
transition: "all 0.3s ease"
|
|
2673
|
+
} }) }),
|
|
2674
|
+
/* @__PURE__ */ jsxs("p", { style: {
|
|
2675
|
+
fontSize: "12px",
|
|
2676
|
+
color: passwordStrength.color,
|
|
2677
|
+
marginTop: "4px",
|
|
2678
|
+
textTransform: "capitalize"
|
|
2679
|
+
}, children: [
|
|
2680
|
+
passwordStrength.strength,
|
|
2681
|
+
" password"
|
|
2682
|
+
] })
|
|
2683
|
+
] })
|
|
2684
|
+
] }),
|
|
2685
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2686
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "confirmPassword", style: {
|
|
2687
|
+
display: "block",
|
|
2688
|
+
marginBottom: "8px",
|
|
2689
|
+
fontWeight: 500,
|
|
2690
|
+
color: "#374151",
|
|
2691
|
+
fontSize: "14px"
|
|
2692
|
+
}, children: "Confirm password" }),
|
|
2693
|
+
/* @__PURE__ */ jsx(
|
|
2694
|
+
"input",
|
|
2695
|
+
{
|
|
2696
|
+
id: "confirmPassword",
|
|
2697
|
+
type: showPassword ? "text" : "password",
|
|
2698
|
+
value: confirmPassword,
|
|
2699
|
+
onChange: (e) => setConfirmPassword(e.target.value),
|
|
2700
|
+
required: true,
|
|
2701
|
+
disabled: isLoading,
|
|
2702
|
+
style: {
|
|
2703
|
+
width: "100%",
|
|
2704
|
+
padding: "12px 16px",
|
|
2705
|
+
border: "1px solid #ddd",
|
|
2706
|
+
borderRadius: "8px",
|
|
2707
|
+
fontSize: "16px",
|
|
2708
|
+
boxSizing: "border-box",
|
|
2709
|
+
...appearance?.elements?.formFieldInput
|
|
2710
|
+
},
|
|
2711
|
+
placeholder: "Confirm your password"
|
|
2712
|
+
}
|
|
2713
|
+
)
|
|
2714
|
+
] }),
|
|
2715
|
+
/* @__PURE__ */ jsx(
|
|
2716
|
+
"button",
|
|
2717
|
+
{
|
|
2718
|
+
type: "submit",
|
|
2719
|
+
disabled: isLoading,
|
|
2720
|
+
style: {
|
|
2721
|
+
width: "100%",
|
|
2722
|
+
padding: "14px",
|
|
2723
|
+
backgroundColor: "#007bff",
|
|
2724
|
+
color: "white",
|
|
2725
|
+
border: "none",
|
|
2726
|
+
borderRadius: "8px",
|
|
2727
|
+
fontSize: "16px",
|
|
2728
|
+
fontWeight: 600,
|
|
2729
|
+
cursor: "pointer",
|
|
2730
|
+
transition: "all 0.2s ease",
|
|
2731
|
+
...appearance?.elements?.formButtonPrimary
|
|
2732
|
+
},
|
|
2733
|
+
children: isLoading ? "Creating account..." : "Sign up"
|
|
2734
|
+
}
|
|
2735
|
+
)
|
|
2736
|
+
] }) });
|
|
2737
|
+
};
|
|
2738
|
+
var SignOut = ({ redirectUrl }) => {
|
|
2739
|
+
const { signOut } = useAuth();
|
|
2740
|
+
useEffect(() => {
|
|
2741
|
+
const performSignOut = async () => {
|
|
2742
|
+
await signOut();
|
|
2743
|
+
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
|
|
2744
|
+
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2745
|
+
window.location.href = `${baseUrl}${redirect}`;
|
|
2746
|
+
};
|
|
2747
|
+
performSignOut();
|
|
2748
|
+
}, [signOut, redirectUrl]);
|
|
2749
|
+
return /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsx("div", { children: "Signing out..." }) });
|
|
2750
|
+
};
|
|
2751
|
+
var UserButton = ({ showName = false, appearance }) => {
|
|
2752
|
+
const { user, signOut } = useAuth();
|
|
2753
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
2754
|
+
const dropdownRef = useRef(null);
|
|
2755
|
+
useEffect(() => {
|
|
2756
|
+
const handleClickOutside = (event) => {
|
|
2757
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
2758
|
+
setIsOpen(false);
|
|
2759
|
+
}
|
|
2760
|
+
};
|
|
2761
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
2762
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2763
|
+
}, []);
|
|
2764
|
+
if (!user)
|
|
2765
|
+
return null;
|
|
2766
|
+
const getInitials = (name) => {
|
|
2767
|
+
return name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
|
|
2768
|
+
};
|
|
2769
|
+
const handleSignOut = async () => {
|
|
2770
|
+
await signOut();
|
|
2771
|
+
const redirect = process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
|
|
2772
|
+
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2773
|
+
window.location.href = `${baseUrl}${redirect}`;
|
|
2774
|
+
};
|
|
2775
|
+
return /* @__PURE__ */ jsxs("div", { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
|
|
2776
|
+
/* @__PURE__ */ jsxs(
|
|
2777
|
+
"button",
|
|
2778
|
+
{
|
|
2779
|
+
onClick: () => setIsOpen(!isOpen),
|
|
2780
|
+
style: {
|
|
2781
|
+
display: "flex",
|
|
2782
|
+
alignItems: "center",
|
|
2783
|
+
gap: "8px",
|
|
2784
|
+
padding: "6px",
|
|
2785
|
+
backgroundColor: "transparent",
|
|
2786
|
+
border: "none",
|
|
2787
|
+
borderRadius: "8px",
|
|
2788
|
+
cursor: "pointer",
|
|
2789
|
+
transition: "background-color 0.2s",
|
|
2790
|
+
...appearance?.elements?.userButtonTrigger
|
|
2791
|
+
},
|
|
2792
|
+
onMouseEnter: (e) => {
|
|
2793
|
+
e.currentTarget.style.backgroundColor = "#f5f5f5";
|
|
2794
|
+
},
|
|
2795
|
+
onMouseLeave: (e) => {
|
|
2796
|
+
e.currentTarget.style.backgroundColor = "transparent";
|
|
2797
|
+
},
|
|
2798
|
+
children: [
|
|
2799
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2800
|
+
width: "36px",
|
|
2801
|
+
height: "36px",
|
|
2802
|
+
borderRadius: "50%",
|
|
2803
|
+
backgroundColor: "#007bff",
|
|
2804
|
+
color: "white",
|
|
2805
|
+
display: "flex",
|
|
2806
|
+
alignItems: "center",
|
|
2807
|
+
justifyContent: "center",
|
|
2808
|
+
fontSize: "14px",
|
|
2809
|
+
fontWeight: 600
|
|
2810
|
+
}, children: getInitials(user.name) }),
|
|
2811
|
+
showName && /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: "#333" }, children: user.name })
|
|
2812
|
+
]
|
|
2813
|
+
}
|
|
2814
|
+
),
|
|
2815
|
+
isOpen && /* @__PURE__ */ jsxs("div", { style: {
|
|
2816
|
+
position: "absolute",
|
|
2817
|
+
top: "100%",
|
|
2818
|
+
right: 0,
|
|
2819
|
+
marginTop: "8px",
|
|
2820
|
+
width: "240px",
|
|
2821
|
+
backgroundColor: "white",
|
|
2822
|
+
borderRadius: "12px",
|
|
2823
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
|
|
2824
|
+
border: "1px solid #eaeaea",
|
|
2825
|
+
zIndex: 1e3,
|
|
2826
|
+
...appearance?.elements?.userButtonPopoverCard
|
|
2827
|
+
}, children: [
|
|
2828
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2829
|
+
padding: "16px",
|
|
2830
|
+
borderBottom: "1px solid #eee"
|
|
2831
|
+
}, children: /* @__PURE__ */ jsxs("div", { style: {
|
|
2832
|
+
display: "flex",
|
|
2833
|
+
alignItems: "center",
|
|
2834
|
+
gap: "12px"
|
|
2835
|
+
}, children: [
|
|
2836
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2837
|
+
width: "48px",
|
|
2838
|
+
height: "48px",
|
|
2839
|
+
borderRadius: "50%",
|
|
2840
|
+
backgroundColor: "#007bff",
|
|
2841
|
+
color: "white",
|
|
2842
|
+
display: "flex",
|
|
2843
|
+
alignItems: "center",
|
|
2844
|
+
justifyContent: "center",
|
|
2845
|
+
fontSize: "18px",
|
|
2846
|
+
fontWeight: 600
|
|
2847
|
+
}, children: getInitials(user.name) }),
|
|
2848
|
+
/* @__PURE__ */ jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
2849
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2850
|
+
fontSize: "14px",
|
|
2851
|
+
fontWeight: 600,
|
|
2852
|
+
color: "#333",
|
|
2853
|
+
overflow: "hidden",
|
|
2854
|
+
textOverflow: "ellipsis",
|
|
2855
|
+
whiteSpace: "nowrap"
|
|
2856
|
+
}, children: user.name }),
|
|
2857
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2858
|
+
fontSize: "12px",
|
|
2859
|
+
color: "#666",
|
|
2860
|
+
overflow: "hidden",
|
|
2861
|
+
textOverflow: "ellipsis",
|
|
2862
|
+
whiteSpace: "nowrap"
|
|
2863
|
+
}, children: user.email })
|
|
2864
|
+
] })
|
|
2865
|
+
] }) }),
|
|
2866
|
+
/* @__PURE__ */ jsx("div", { style: { padding: "8px" }, children: /* @__PURE__ */ jsx(
|
|
2867
|
+
"button",
|
|
2868
|
+
{
|
|
2869
|
+
onClick: handleSignOut,
|
|
2870
|
+
style: {
|
|
2871
|
+
width: "100%",
|
|
2872
|
+
padding: "10px 16px",
|
|
2873
|
+
backgroundColor: "transparent",
|
|
2874
|
+
border: "none",
|
|
2875
|
+
borderRadius: "8px",
|
|
2876
|
+
textAlign: "left",
|
|
2877
|
+
cursor: "pointer",
|
|
2878
|
+
fontSize: "14px",
|
|
2879
|
+
color: "#333",
|
|
2880
|
+
fontWeight: 500,
|
|
2881
|
+
transition: "background-color 0.2s"
|
|
2882
|
+
},
|
|
2883
|
+
onMouseEnter: (e) => {
|
|
2884
|
+
e.currentTarget.style.backgroundColor = "#f5f5f5";
|
|
2885
|
+
},
|
|
2886
|
+
onMouseLeave: (e) => {
|
|
2887
|
+
e.currentTarget.style.backgroundColor = "transparent";
|
|
2888
|
+
},
|
|
2889
|
+
children: "Sign out"
|
|
2890
|
+
}
|
|
2891
|
+
) })
|
|
2892
|
+
] })
|
|
2893
|
+
] });
|
|
2894
|
+
};
|
|
2895
|
+
var ProtectedRoute = ({
|
|
2896
|
+
children,
|
|
2897
|
+
fallback,
|
|
2898
|
+
redirectTo
|
|
2899
|
+
}) => {
|
|
2900
|
+
const { isSignedIn, isLoaded } = useAuth();
|
|
2901
|
+
useEffect(() => {
|
|
2902
|
+
if (isLoaded && !isSignedIn) {
|
|
2903
|
+
const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
|
|
2904
|
+
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2905
|
+
window.location.href = `${baseUrl}${loginPath}`;
|
|
2906
|
+
}
|
|
2907
|
+
}, [isSignedIn, isLoaded, redirectTo]);
|
|
2908
|
+
if (!isLoaded) {
|
|
2909
|
+
return fallback || /* @__PURE__ */ jsx("div", { style: {
|
|
2910
|
+
display: "flex",
|
|
2911
|
+
justifyContent: "center",
|
|
2912
|
+
alignItems: "center",
|
|
2913
|
+
minHeight: "100vh"
|
|
2914
|
+
}, children: /* @__PURE__ */ jsx("div", { children: "Loading..." }) });
|
|
2915
|
+
}
|
|
2916
|
+
if (!isSignedIn) {
|
|
2917
|
+
return fallback || null;
|
|
2918
|
+
}
|
|
2919
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
2920
|
+
};
|
|
2921
|
+
var PublicRoute = ({
|
|
2922
|
+
children,
|
|
2923
|
+
redirectTo
|
|
2924
|
+
}) => {
|
|
2925
|
+
const { isSignedIn, isLoaded } = useAuth();
|
|
2926
|
+
useEffect(() => {
|
|
2927
|
+
if (isLoaded && isSignedIn) {
|
|
2928
|
+
const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
2929
|
+
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2930
|
+
window.location.href = `${baseUrl}${dashboardPath}`;
|
|
2931
|
+
}
|
|
2932
|
+
}, [isSignedIn, isLoaded, redirectTo]);
|
|
2933
|
+
if (!isLoaded) {
|
|
2934
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
2935
|
+
display: "flex",
|
|
2936
|
+
justifyContent: "center",
|
|
2937
|
+
alignItems: "center",
|
|
2938
|
+
minHeight: "100vh"
|
|
2939
|
+
}, children: /* @__PURE__ */ jsx("div", { children: "Loading..." }) });
|
|
2940
|
+
}
|
|
2941
|
+
if (isSignedIn) {
|
|
2942
|
+
return null;
|
|
2943
|
+
}
|
|
2944
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
2945
|
+
};
|
|
2946
|
+
var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
2947
|
+
const { verifyEmailToken } = useAuth();
|
|
2948
|
+
const [status, setStatus] = useState("loading");
|
|
2949
|
+
const [message, setMessage] = useState("");
|
|
2950
|
+
useEffect(() => {
|
|
2951
|
+
const verify = async () => {
|
|
2952
|
+
const verifyToken = token || (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") : null);
|
|
2953
|
+
if (!verifyToken) {
|
|
2954
|
+
setStatus("error");
|
|
2955
|
+
setMessage("No verification token provided");
|
|
2956
|
+
onError?.("No verification token provided");
|
|
2957
|
+
return;
|
|
2958
|
+
}
|
|
2959
|
+
try {
|
|
2960
|
+
const response = await verifyEmailToken(verifyToken);
|
|
2961
|
+
if (response.success) {
|
|
2962
|
+
setStatus("success");
|
|
2963
|
+
setMessage("Email verified successfully! Redirecting...");
|
|
2964
|
+
onSuccess?.();
|
|
2965
|
+
setTimeout(() => {
|
|
2966
|
+
const redirect = process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_VERIFY || process.env.REACT_APP_AUTH_REDIRECT_AFTER_VERIFY || "/dashboard";
|
|
2967
|
+
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2968
|
+
window.location.href = `${baseUrl}${redirect}`;
|
|
2969
|
+
}, 2e3);
|
|
2970
|
+
} else {
|
|
2971
|
+
setStatus("error");
|
|
2972
|
+
setMessage(response.message || "Verification failed");
|
|
2973
|
+
onError?.(response.message || "Verification failed");
|
|
2974
|
+
}
|
|
2975
|
+
} catch (err) {
|
|
2976
|
+
setStatus("error");
|
|
2977
|
+
const errorMsg = err instanceof Error ? err.message : "An error occurred";
|
|
2978
|
+
setMessage(errorMsg);
|
|
2979
|
+
onError?.(errorMsg);
|
|
2980
|
+
}
|
|
2981
|
+
};
|
|
2982
|
+
verify();
|
|
2983
|
+
}, [token, verifyEmailToken, onSuccess, onError]);
|
|
2984
|
+
return /* @__PURE__ */ jsxs("div", { style: {
|
|
2985
|
+
maxWidth: "400px",
|
|
2986
|
+
margin: "40px auto",
|
|
2987
|
+
padding: "30px",
|
|
2988
|
+
borderRadius: "12px",
|
|
2989
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2990
|
+
backgroundColor: "#ffffff",
|
|
2991
|
+
border: "1px solid #eaeaea",
|
|
2992
|
+
textAlign: "center"
|
|
2993
|
+
}, children: [
|
|
2994
|
+
status === "loading" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2995
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
2996
|
+
width: "48px",
|
|
2997
|
+
height: "48px",
|
|
2998
|
+
margin: "0 auto 20px",
|
|
2999
|
+
border: "4px solid #f3f3f3",
|
|
3000
|
+
borderTop: "4px solid #007bff",
|
|
3001
|
+
borderRadius: "50%",
|
|
3002
|
+
animation: "spin 1s linear infinite"
|
|
3003
|
+
} }),
|
|
3004
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
3005
|
+
@keyframes spin {
|
|
3006
|
+
0% { transform: rotate(0deg); }
|
|
3007
|
+
100% { transform: rotate(360deg); }
|
|
3008
|
+
}
|
|
3009
|
+
` }),
|
|
3010
|
+
/* @__PURE__ */ jsx("h2", { style: {
|
|
3011
|
+
fontSize: "20px",
|
|
3012
|
+
fontWeight: 600,
|
|
3013
|
+
color: "#333",
|
|
3014
|
+
marginBottom: "12px"
|
|
3015
|
+
}, children: "Verifying your email..." }),
|
|
3016
|
+
/* @__PURE__ */ jsx("p", { style: { fontSize: "14px", color: "#666" }, children: "Please wait while we verify your email address." })
|
|
3017
|
+
] }),
|
|
3018
|
+
status === "success" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3019
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
3020
|
+
width: "64px",
|
|
3021
|
+
height: "64px",
|
|
3022
|
+
margin: "0 auto 20px",
|
|
3023
|
+
backgroundColor: "#4caf50",
|
|
3024
|
+
borderRadius: "50%",
|
|
3025
|
+
display: "flex",
|
|
3026
|
+
alignItems: "center",
|
|
3027
|
+
justifyContent: "center"
|
|
3028
|
+
}, children: /* @__PURE__ */ jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "3", children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" }) }) }),
|
|
3029
|
+
/* @__PURE__ */ jsx("h2", { style: {
|
|
3030
|
+
fontSize: "20px",
|
|
3031
|
+
fontWeight: 600,
|
|
3032
|
+
color: "#333",
|
|
3033
|
+
marginBottom: "12px"
|
|
3034
|
+
}, children: "Email Verified!" }),
|
|
3035
|
+
/* @__PURE__ */ jsx("p", { style: { fontSize: "14px", color: "#666" }, children: message })
|
|
3036
|
+
] }),
|
|
3037
|
+
status === "error" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3038
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
3039
|
+
width: "64px",
|
|
3040
|
+
height: "64px",
|
|
3041
|
+
margin: "0 auto 20px",
|
|
3042
|
+
backgroundColor: "#f44336",
|
|
3043
|
+
borderRadius: "50%",
|
|
3044
|
+
display: "flex",
|
|
3045
|
+
alignItems: "center",
|
|
3046
|
+
justifyContent: "center"
|
|
3047
|
+
}, children: /* @__PURE__ */ jsxs("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "3", children: [
|
|
3048
|
+
/* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
3049
|
+
/* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
3050
|
+
] }) }),
|
|
3051
|
+
/* @__PURE__ */ jsx("h2", { style: {
|
|
3052
|
+
fontSize: "20px",
|
|
3053
|
+
fontWeight: 600,
|
|
3054
|
+
color: "#333",
|
|
3055
|
+
marginBottom: "12px"
|
|
3056
|
+
}, children: "Verification Failed" }),
|
|
3057
|
+
/* @__PURE__ */ jsx("p", { style: { fontSize: "14px", color: "#666", marginBottom: "20px" }, children: message }),
|
|
3058
|
+
/* @__PURE__ */ jsx(
|
|
3059
|
+
"button",
|
|
3060
|
+
{
|
|
3061
|
+
onClick: () => {
|
|
3062
|
+
const loginPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
|
|
3063
|
+
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
3064
|
+
window.location.href = `${baseUrl}${loginPath}`;
|
|
3065
|
+
},
|
|
3066
|
+
style: {
|
|
3067
|
+
padding: "10px 20px",
|
|
3068
|
+
backgroundColor: "#007bff",
|
|
3069
|
+
color: "white",
|
|
3070
|
+
border: "none",
|
|
3071
|
+
borderRadius: "8px",
|
|
3072
|
+
fontSize: "14px",
|
|
3073
|
+
fontWeight: 600,
|
|
3074
|
+
cursor: "pointer"
|
|
3075
|
+
},
|
|
3076
|
+
children: "Go to Login"
|
|
3077
|
+
}
|
|
3078
|
+
)
|
|
3079
|
+
] })
|
|
3080
|
+
] });
|
|
3081
|
+
};
|
|
3082
|
+
var ForgotPassword = ({ appearance }) => {
|
|
3083
|
+
const { forgotPassword } = useAuth();
|
|
3084
|
+
const [email, setEmail] = useState("");
|
|
3085
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
3086
|
+
const [error, setError] = useState(null);
|
|
3087
|
+
const [success, setSuccess] = useState(null);
|
|
3088
|
+
const handleSubmit = async (e) => {
|
|
3089
|
+
e.preventDefault();
|
|
3090
|
+
setIsLoading(true);
|
|
3091
|
+
setError(null);
|
|
3092
|
+
setSuccess(null);
|
|
3093
|
+
try {
|
|
3094
|
+
const response = await forgotPassword(email);
|
|
3095
|
+
if (response.success) {
|
|
3096
|
+
setSuccess("Password reset link sent! Please check your email.");
|
|
3097
|
+
setEmail("");
|
|
3098
|
+
} else {
|
|
3099
|
+
setError(response.message || "Failed to send reset link");
|
|
3100
|
+
}
|
|
3101
|
+
} catch (err) {
|
|
3102
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
3103
|
+
} finally {
|
|
3104
|
+
setIsLoading(false);
|
|
3105
|
+
}
|
|
3106
|
+
};
|
|
3107
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
3108
|
+
maxWidth: "400px",
|
|
3109
|
+
margin: "0 auto",
|
|
3110
|
+
padding: "30px",
|
|
3111
|
+
borderRadius: "12px",
|
|
3112
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
3113
|
+
backgroundColor: "#ffffff",
|
|
3114
|
+
border: "1px solid #eaeaea",
|
|
3115
|
+
...appearance?.elements?.card
|
|
3116
|
+
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
3117
|
+
/* @__PURE__ */ jsx("h2", { style: {
|
|
3118
|
+
textAlign: "center",
|
|
3119
|
+
marginBottom: "12px",
|
|
3120
|
+
color: "#1f2937",
|
|
3121
|
+
fontSize: "24px",
|
|
3122
|
+
fontWeight: 600,
|
|
3123
|
+
...appearance?.elements?.headerTitle
|
|
3124
|
+
}, children: "Forgot password?" }),
|
|
3125
|
+
/* @__PURE__ */ jsx("p", { style: {
|
|
3126
|
+
textAlign: "center",
|
|
3127
|
+
marginBottom: "24px",
|
|
3128
|
+
color: "#666",
|
|
3129
|
+
fontSize: "14px"
|
|
3130
|
+
}, children: "Enter your email address and we'll send you a link to reset your password." }),
|
|
3131
|
+
error && /* @__PURE__ */ jsx("div", { style: {
|
|
3132
|
+
padding: "12px 16px",
|
|
3133
|
+
marginBottom: "20px",
|
|
3134
|
+
backgroundColor: "#fee",
|
|
3135
|
+
color: "#c33",
|
|
3136
|
+
border: "1px solid #fcc",
|
|
3137
|
+
borderRadius: "8px",
|
|
3138
|
+
fontSize: "14px"
|
|
3139
|
+
}, children: error }),
|
|
3140
|
+
success && /* @__PURE__ */ jsx("div", { style: {
|
|
3141
|
+
padding: "12px 16px",
|
|
3142
|
+
marginBottom: "20px",
|
|
3143
|
+
backgroundColor: "#efe",
|
|
3144
|
+
color: "#3c3",
|
|
3145
|
+
border: "1px solid #cfc",
|
|
3146
|
+
borderRadius: "8px",
|
|
3147
|
+
fontSize: "14px"
|
|
3148
|
+
}, children: success }),
|
|
3149
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
3150
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
|
|
3151
|
+
display: "block",
|
|
3152
|
+
marginBottom: "8px",
|
|
3153
|
+
fontWeight: 500,
|
|
3154
|
+
color: "#374151",
|
|
3155
|
+
fontSize: "14px"
|
|
3156
|
+
}, children: "Email" }),
|
|
3157
|
+
/* @__PURE__ */ jsx(
|
|
3158
|
+
"input",
|
|
3159
|
+
{
|
|
3160
|
+
id: "email",
|
|
3161
|
+
type: "email",
|
|
3162
|
+
value: email,
|
|
3163
|
+
onChange: (e) => setEmail(e.target.value),
|
|
3164
|
+
required: true,
|
|
3165
|
+
disabled: isLoading,
|
|
3166
|
+
style: {
|
|
3167
|
+
width: "100%",
|
|
3168
|
+
padding: "12px 16px",
|
|
3169
|
+
border: "1px solid #ddd",
|
|
3170
|
+
borderRadius: "8px",
|
|
3171
|
+
fontSize: "16px",
|
|
3172
|
+
boxSizing: "border-box",
|
|
3173
|
+
...appearance?.elements?.formFieldInput
|
|
3174
|
+
},
|
|
3175
|
+
placeholder: "Enter your email"
|
|
3176
|
+
}
|
|
3177
|
+
)
|
|
3178
|
+
] }),
|
|
3179
|
+
/* @__PURE__ */ jsx(
|
|
3180
|
+
"button",
|
|
3181
|
+
{
|
|
3182
|
+
type: "submit",
|
|
3183
|
+
disabled: isLoading,
|
|
3184
|
+
style: {
|
|
3185
|
+
width: "100%",
|
|
3186
|
+
padding: "14px",
|
|
3187
|
+
backgroundColor: "#007bff",
|
|
3188
|
+
color: "white",
|
|
3189
|
+
border: "none",
|
|
3190
|
+
borderRadius: "8px",
|
|
3191
|
+
fontSize: "16px",
|
|
3192
|
+
fontWeight: 600,
|
|
3193
|
+
cursor: "pointer",
|
|
3194
|
+
transition: "all 0.2s ease",
|
|
3195
|
+
marginBottom: "16px",
|
|
3196
|
+
...appearance?.elements?.formButtonPrimary
|
|
3197
|
+
},
|
|
3198
|
+
children: isLoading ? "Sending..." : "Send reset link"
|
|
3199
|
+
}
|
|
3200
|
+
),
|
|
3201
|
+
/* @__PURE__ */ jsx("div", { style: { textAlign: "center" }, children: /* @__PURE__ */ jsx(
|
|
3202
|
+
"button",
|
|
3203
|
+
{
|
|
3204
|
+
type: "button",
|
|
3205
|
+
onClick: () => {
|
|
3206
|
+
const loginPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
|
|
3207
|
+
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
3208
|
+
window.location.href = `${baseUrl}${loginPath}`;
|
|
3209
|
+
},
|
|
3210
|
+
disabled: isLoading,
|
|
3211
|
+
style: {
|
|
3212
|
+
background: "none",
|
|
3213
|
+
border: "none",
|
|
3214
|
+
color: "#007bff",
|
|
3215
|
+
cursor: "pointer",
|
|
3216
|
+
fontSize: "14px",
|
|
3217
|
+
fontWeight: 600
|
|
3218
|
+
},
|
|
3219
|
+
children: "Back to sign in"
|
|
3220
|
+
}
|
|
3221
|
+
) })
|
|
3222
|
+
] }) });
|
|
3223
|
+
};
|
|
3224
|
+
var ResetPassword = ({ token, appearance }) => {
|
|
3225
|
+
const { resetPassword } = useAuth();
|
|
3226
|
+
const [resetToken, setResetToken] = useState(token || "");
|
|
3227
|
+
const [password, setPassword] = useState("");
|
|
3228
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
3229
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
3230
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
3231
|
+
const [error, setError] = useState(null);
|
|
3232
|
+
const [success, setSuccess] = useState(false);
|
|
3233
|
+
useEffect(() => {
|
|
3234
|
+
if (!resetToken && typeof window !== "undefined") {
|
|
3235
|
+
const urlToken = new URLSearchParams(window.location.search).get("token");
|
|
3236
|
+
if (urlToken) {
|
|
3237
|
+
setResetToken(urlToken);
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
}, [resetToken]);
|
|
3241
|
+
const getPasswordStrength = (pwd) => {
|
|
3242
|
+
if (!pwd)
|
|
3243
|
+
return { strength: "weak", color: "#ddd" };
|
|
3244
|
+
let score = 0;
|
|
3245
|
+
if (pwd.length >= 6)
|
|
3246
|
+
score++;
|
|
3247
|
+
if (pwd.length >= 8)
|
|
3248
|
+
score++;
|
|
3249
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
|
|
3250
|
+
score++;
|
|
3251
|
+
if (/\d/.test(pwd))
|
|
3252
|
+
score++;
|
|
3253
|
+
if (/[^a-zA-Z\d]/.test(pwd))
|
|
3254
|
+
score++;
|
|
3255
|
+
if (score <= 2)
|
|
3256
|
+
return { strength: "weak", color: "#f44" };
|
|
3257
|
+
if (score <= 3)
|
|
3258
|
+
return { strength: "medium", color: "#fa4" };
|
|
3259
|
+
return { strength: "strong", color: "#4f4" };
|
|
3260
|
+
};
|
|
3261
|
+
const passwordStrength = getPasswordStrength(password);
|
|
3262
|
+
const handleSubmit = async (e) => {
|
|
3263
|
+
e.preventDefault();
|
|
3264
|
+
setIsLoading(true);
|
|
3265
|
+
setError(null);
|
|
3266
|
+
if (password !== confirmPassword) {
|
|
3267
|
+
setError("Passwords do not match");
|
|
3268
|
+
setIsLoading(false);
|
|
3269
|
+
return;
|
|
3270
|
+
}
|
|
3271
|
+
if (password.length < 6) {
|
|
3272
|
+
setError("Password must be at least 6 characters");
|
|
3273
|
+
setIsLoading(false);
|
|
3274
|
+
return;
|
|
3275
|
+
}
|
|
3276
|
+
if (!resetToken) {
|
|
3277
|
+
setError("Invalid reset token");
|
|
3278
|
+
setIsLoading(false);
|
|
3279
|
+
return;
|
|
3280
|
+
}
|
|
3281
|
+
try {
|
|
3282
|
+
const response = await resetPassword(resetToken, password);
|
|
3283
|
+
if (response.success) {
|
|
3284
|
+
setSuccess(true);
|
|
3285
|
+
setTimeout(() => {
|
|
3286
|
+
const loginPath = process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
|
|
3287
|
+
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
3288
|
+
window.location.href = `${baseUrl}${loginPath}`;
|
|
3289
|
+
}, 2e3);
|
|
3290
|
+
} else {
|
|
3291
|
+
setError(response.message || "Failed to reset password");
|
|
3292
|
+
}
|
|
3293
|
+
} catch (err) {
|
|
3294
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
3295
|
+
} finally {
|
|
3296
|
+
setIsLoading(false);
|
|
3297
|
+
}
|
|
3298
|
+
};
|
|
3299
|
+
if (success) {
|
|
3300
|
+
return /* @__PURE__ */ jsxs("div", { style: {
|
|
3301
|
+
maxWidth: "400px",
|
|
3302
|
+
margin: "40px auto",
|
|
3303
|
+
padding: "30px",
|
|
3304
|
+
borderRadius: "12px",
|
|
3305
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
3306
|
+
backgroundColor: "#ffffff",
|
|
3307
|
+
border: "1px solid #eaeaea",
|
|
3308
|
+
textAlign: "center"
|
|
3309
|
+
}, children: [
|
|
3310
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
3311
|
+
width: "64px",
|
|
3312
|
+
height: "64px",
|
|
3313
|
+
margin: "0 auto 20px",
|
|
3314
|
+
backgroundColor: "#4caf50",
|
|
3315
|
+
borderRadius: "50%",
|
|
3316
|
+
display: "flex",
|
|
3317
|
+
alignItems: "center",
|
|
3318
|
+
justifyContent: "center"
|
|
3319
|
+
}, children: /* @__PURE__ */ jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "3", children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" }) }) }),
|
|
3320
|
+
/* @__PURE__ */ jsx("h2", { style: {
|
|
3321
|
+
fontSize: "20px",
|
|
3322
|
+
fontWeight: 600,
|
|
3323
|
+
color: "#333",
|
|
3324
|
+
marginBottom: "12px"
|
|
3325
|
+
}, children: "Password Reset Successful!" }),
|
|
3326
|
+
/* @__PURE__ */ jsx("p", { style: { fontSize: "14px", color: "#666" }, children: "Your password has been reset. Redirecting to login..." })
|
|
3327
|
+
] });
|
|
3328
|
+
}
|
|
3329
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
3330
|
+
maxWidth: "400px",
|
|
3331
|
+
margin: "0 auto",
|
|
3332
|
+
padding: "30px",
|
|
3333
|
+
borderRadius: "12px",
|
|
3334
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
3335
|
+
backgroundColor: "#ffffff",
|
|
3336
|
+
border: "1px solid #eaeaea",
|
|
3337
|
+
...appearance?.elements?.card
|
|
3338
|
+
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
3339
|
+
/* @__PURE__ */ jsx("h2", { style: {
|
|
3340
|
+
textAlign: "center",
|
|
3341
|
+
marginBottom: "12px",
|
|
3342
|
+
color: "#1f2937",
|
|
3343
|
+
fontSize: "24px",
|
|
3344
|
+
fontWeight: 600,
|
|
3345
|
+
...appearance?.elements?.headerTitle
|
|
3346
|
+
}, children: "Reset your password" }),
|
|
3347
|
+
/* @__PURE__ */ jsx("p", { style: {
|
|
3348
|
+
textAlign: "center",
|
|
3349
|
+
marginBottom: "24px",
|
|
3350
|
+
color: "#666",
|
|
3351
|
+
fontSize: "14px"
|
|
3352
|
+
}, children: "Enter your new password below." }),
|
|
3353
|
+
error && /* @__PURE__ */ jsx("div", { style: {
|
|
3354
|
+
padding: "12px 16px",
|
|
3355
|
+
marginBottom: "20px",
|
|
3356
|
+
backgroundColor: "#fee",
|
|
3357
|
+
color: "#c33",
|
|
3358
|
+
border: "1px solid #fcc",
|
|
3359
|
+
borderRadius: "8px",
|
|
3360
|
+
fontSize: "14px"
|
|
3361
|
+
}, children: error }),
|
|
3362
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
3363
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
|
|
3364
|
+
display: "block",
|
|
3365
|
+
marginBottom: "8px",
|
|
3366
|
+
fontWeight: 500,
|
|
3367
|
+
color: "#374151",
|
|
3368
|
+
fontSize: "14px"
|
|
3369
|
+
}, children: "New password" }),
|
|
3370
|
+
/* @__PURE__ */ jsx(
|
|
3371
|
+
"input",
|
|
3372
|
+
{
|
|
3373
|
+
id: "password",
|
|
3374
|
+
type: showPassword ? "text" : "password",
|
|
3375
|
+
value: password,
|
|
3376
|
+
onChange: (e) => setPassword(e.target.value),
|
|
3377
|
+
required: true,
|
|
3378
|
+
disabled: isLoading,
|
|
3379
|
+
minLength: 6,
|
|
3380
|
+
style: {
|
|
3381
|
+
width: "100%",
|
|
3382
|
+
padding: "12px 16px",
|
|
3383
|
+
border: "1px solid #ddd",
|
|
3384
|
+
borderRadius: "8px",
|
|
3385
|
+
fontSize: "16px",
|
|
3386
|
+
boxSizing: "border-box",
|
|
3387
|
+
...appearance?.elements?.formFieldInput
|
|
3388
|
+
},
|
|
3389
|
+
placeholder: "Enter new password"
|
|
3390
|
+
}
|
|
3391
|
+
),
|
|
3392
|
+
/* @__PURE__ */ jsx(
|
|
3393
|
+
"button",
|
|
3394
|
+
{
|
|
3395
|
+
type: "button",
|
|
3396
|
+
onClick: () => setShowPassword(!showPassword),
|
|
3397
|
+
style: {
|
|
3398
|
+
position: "absolute",
|
|
3399
|
+
right: "12px",
|
|
3400
|
+
top: "38px",
|
|
3401
|
+
background: "none",
|
|
3402
|
+
border: "none",
|
|
3403
|
+
cursor: "pointer",
|
|
3404
|
+
color: "#666",
|
|
3405
|
+
fontSize: "14px"
|
|
3406
|
+
},
|
|
3407
|
+
children: showPassword ? "Hide" : "Show"
|
|
3408
|
+
}
|
|
3409
|
+
),
|
|
3410
|
+
password && /* @__PURE__ */ jsxs("div", { style: { marginTop: "8px" }, children: [
|
|
3411
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
3412
|
+
height: "4px",
|
|
3413
|
+
backgroundColor: "#eee",
|
|
3414
|
+
borderRadius: "2px",
|
|
3415
|
+
overflow: "hidden"
|
|
3416
|
+
}, children: /* @__PURE__ */ jsx("div", { style: {
|
|
3417
|
+
height: "100%",
|
|
3418
|
+
width: passwordStrength.strength === "weak" ? "33%" : passwordStrength.strength === "medium" ? "66%" : "100%",
|
|
3419
|
+
backgroundColor: passwordStrength.color,
|
|
3420
|
+
transition: "all 0.3s ease"
|
|
3421
|
+
} }) }),
|
|
3422
|
+
/* @__PURE__ */ jsxs("p", { style: {
|
|
3423
|
+
fontSize: "12px",
|
|
3424
|
+
color: passwordStrength.color,
|
|
3425
|
+
marginTop: "4px",
|
|
3426
|
+
textTransform: "capitalize"
|
|
3427
|
+
}, children: [
|
|
3428
|
+
passwordStrength.strength,
|
|
3429
|
+
" password"
|
|
3430
|
+
] })
|
|
3431
|
+
] })
|
|
3432
|
+
] }),
|
|
3433
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
3434
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "confirmPassword", style: {
|
|
3435
|
+
display: "block",
|
|
3436
|
+
marginBottom: "8px",
|
|
3437
|
+
fontWeight: 500,
|
|
3438
|
+
color: "#374151",
|
|
3439
|
+
fontSize: "14px"
|
|
3440
|
+
}, children: "Confirm password" }),
|
|
3441
|
+
/* @__PURE__ */ jsx(
|
|
3442
|
+
"input",
|
|
3443
|
+
{
|
|
3444
|
+
id: "confirmPassword",
|
|
3445
|
+
type: showPassword ? "text" : "password",
|
|
3446
|
+
value: confirmPassword,
|
|
3447
|
+
onChange: (e) => setConfirmPassword(e.target.value),
|
|
3448
|
+
required: true,
|
|
3449
|
+
disabled: isLoading,
|
|
3450
|
+
style: {
|
|
3451
|
+
width: "100%",
|
|
3452
|
+
padding: "12px 16px",
|
|
3453
|
+
border: "1px solid #ddd",
|
|
3454
|
+
borderRadius: "8px",
|
|
3455
|
+
fontSize: "16px",
|
|
3456
|
+
boxSizing: "border-box",
|
|
3457
|
+
...appearance?.elements?.formFieldInput
|
|
3458
|
+
},
|
|
3459
|
+
placeholder: "Confirm new password"
|
|
3460
|
+
}
|
|
3461
|
+
)
|
|
3462
|
+
] }),
|
|
3463
|
+
/* @__PURE__ */ jsx(
|
|
3464
|
+
"button",
|
|
3465
|
+
{
|
|
3466
|
+
type: "submit",
|
|
3467
|
+
disabled: isLoading,
|
|
3468
|
+
style: {
|
|
3469
|
+
width: "100%",
|
|
3470
|
+
padding: "14px",
|
|
3471
|
+
backgroundColor: "#007bff",
|
|
3472
|
+
color: "white",
|
|
3473
|
+
border: "none",
|
|
3474
|
+
borderRadius: "8px",
|
|
3475
|
+
fontSize: "16px",
|
|
3476
|
+
fontWeight: 600,
|
|
3477
|
+
cursor: "pointer",
|
|
3478
|
+
transition: "all 0.2s ease",
|
|
3479
|
+
...appearance?.elements?.formButtonPrimary
|
|
3480
|
+
},
|
|
3481
|
+
children: isLoading ? "Resetting..." : "Reset password"
|
|
3482
|
+
}
|
|
3483
|
+
)
|
|
3484
|
+
] }) });
|
|
3485
|
+
};
|
|
3486
|
+
var ChangePassword = ({ onSuccess, appearance }) => {
|
|
3487
|
+
const { changePassword } = useAuth();
|
|
3488
|
+
const [oldPassword, setOldPassword] = useState("");
|
|
3489
|
+
const [newPassword, setNewPassword] = useState("");
|
|
3490
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
3491
|
+
const [showPasswords, setShowPasswords] = useState(false);
|
|
3492
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
3493
|
+
const [error, setError] = useState(null);
|
|
3494
|
+
const [success, setSuccess] = useState(false);
|
|
3495
|
+
const getPasswordStrength = (pwd) => {
|
|
3496
|
+
if (!pwd)
|
|
3497
|
+
return { strength: "weak", color: "#ddd" };
|
|
3498
|
+
let score = 0;
|
|
3499
|
+
if (pwd.length >= 6)
|
|
3500
|
+
score++;
|
|
3501
|
+
if (pwd.length >= 8)
|
|
3502
|
+
score++;
|
|
3503
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
|
|
3504
|
+
score++;
|
|
3505
|
+
if (/\d/.test(pwd))
|
|
3506
|
+
score++;
|
|
3507
|
+
if (/[^a-zA-Z\d]/.test(pwd))
|
|
3508
|
+
score++;
|
|
3509
|
+
if (score <= 2)
|
|
3510
|
+
return { strength: "weak", color: "#f44" };
|
|
3511
|
+
if (score <= 3)
|
|
3512
|
+
return { strength: "medium", color: "#fa4" };
|
|
3513
|
+
return { strength: "strong", color: "#4f4" };
|
|
3514
|
+
};
|
|
3515
|
+
const passwordStrength = getPasswordStrength(newPassword);
|
|
3516
|
+
const handleSubmit = async (e) => {
|
|
3517
|
+
e.preventDefault();
|
|
3518
|
+
setIsLoading(true);
|
|
3519
|
+
setError(null);
|
|
3520
|
+
setSuccess(false);
|
|
3521
|
+
if (newPassword !== confirmPassword) {
|
|
3522
|
+
setError("New passwords do not match");
|
|
3523
|
+
setIsLoading(false);
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
if (newPassword.length < 6) {
|
|
3527
|
+
setError("New password must be at least 6 characters");
|
|
3528
|
+
setIsLoading(false);
|
|
3529
|
+
return;
|
|
3530
|
+
}
|
|
3531
|
+
try {
|
|
3532
|
+
const response = await changePassword(oldPassword, newPassword);
|
|
3533
|
+
if (response.success) {
|
|
3534
|
+
setSuccess(true);
|
|
3535
|
+
setOldPassword("");
|
|
3536
|
+
setNewPassword("");
|
|
3537
|
+
setConfirmPassword("");
|
|
3538
|
+
onSuccess?.();
|
|
3539
|
+
} else {
|
|
3540
|
+
setError(response.message || "Failed to change password");
|
|
3541
|
+
}
|
|
3542
|
+
} catch (err) {
|
|
3543
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
3544
|
+
} finally {
|
|
3545
|
+
setIsLoading(false);
|
|
3546
|
+
}
|
|
3547
|
+
};
|
|
3548
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
3549
|
+
maxWidth: "400px",
|
|
3550
|
+
margin: "0 auto",
|
|
3551
|
+
padding: "30px",
|
|
3552
|
+
borderRadius: "12px",
|
|
3553
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
3554
|
+
backgroundColor: "#ffffff",
|
|
3555
|
+
border: "1px solid #eaeaea",
|
|
3556
|
+
...appearance?.elements?.card
|
|
3557
|
+
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
3558
|
+
/* @__PURE__ */ jsx("h2", { style: {
|
|
3559
|
+
textAlign: "center",
|
|
3560
|
+
marginBottom: "24px",
|
|
3561
|
+
color: "#1f2937",
|
|
3562
|
+
fontSize: "24px",
|
|
3563
|
+
fontWeight: 600,
|
|
3564
|
+
...appearance?.elements?.headerTitle
|
|
3565
|
+
}, children: "Change Password" }),
|
|
3566
|
+
error && /* @__PURE__ */ jsx("div", { style: {
|
|
3567
|
+
padding: "12px 16px",
|
|
3568
|
+
marginBottom: "20px",
|
|
3569
|
+
backgroundColor: "#fee",
|
|
3570
|
+
color: "#c33",
|
|
3571
|
+
border: "1px solid #fcc",
|
|
3572
|
+
borderRadius: "8px",
|
|
3573
|
+
fontSize: "14px"
|
|
3574
|
+
}, children: error }),
|
|
3575
|
+
success && /* @__PURE__ */ jsx("div", { style: {
|
|
3576
|
+
padding: "12px 16px",
|
|
3577
|
+
marginBottom: "20px",
|
|
3578
|
+
backgroundColor: "#efe",
|
|
3579
|
+
color: "#3c3",
|
|
3580
|
+
border: "1px solid #cfc",
|
|
3581
|
+
borderRadius: "8px",
|
|
3582
|
+
fontSize: "14px"
|
|
3583
|
+
}, children: "Password changed successfully!" }),
|
|
3584
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
3585
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "oldPassword", style: {
|
|
3586
|
+
display: "block",
|
|
3587
|
+
marginBottom: "8px",
|
|
3588
|
+
fontWeight: 500,
|
|
3589
|
+
color: "#374151",
|
|
3590
|
+
fontSize: "14px"
|
|
3591
|
+
}, children: "Current password" }),
|
|
3592
|
+
/* @__PURE__ */ jsx(
|
|
3593
|
+
"input",
|
|
3594
|
+
{
|
|
3595
|
+
id: "oldPassword",
|
|
3596
|
+
type: showPasswords ? "text" : "password",
|
|
3597
|
+
value: oldPassword,
|
|
3598
|
+
onChange: (e) => setOldPassword(e.target.value),
|
|
3599
|
+
required: true,
|
|
3600
|
+
disabled: isLoading,
|
|
3601
|
+
style: {
|
|
3602
|
+
width: "100%",
|
|
3603
|
+
padding: "12px 16px",
|
|
3604
|
+
border: "1px solid #ddd",
|
|
3605
|
+
borderRadius: "8px",
|
|
3606
|
+
fontSize: "16px",
|
|
3607
|
+
boxSizing: "border-box",
|
|
3608
|
+
...appearance?.elements?.formFieldInput
|
|
3609
|
+
},
|
|
3610
|
+
placeholder: "Enter current password"
|
|
3611
|
+
}
|
|
3612
|
+
)
|
|
3613
|
+
] }),
|
|
3614
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
3615
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "newPassword", style: {
|
|
3616
|
+
display: "block",
|
|
3617
|
+
marginBottom: "8px",
|
|
3618
|
+
fontWeight: 500,
|
|
3619
|
+
color: "#374151",
|
|
3620
|
+
fontSize: "14px"
|
|
3621
|
+
}, children: "New password" }),
|
|
3622
|
+
/* @__PURE__ */ jsx(
|
|
3623
|
+
"input",
|
|
3624
|
+
{
|
|
3625
|
+
id: "newPassword",
|
|
3626
|
+
type: showPasswords ? "text" : "password",
|
|
3627
|
+
value: newPassword,
|
|
3628
|
+
onChange: (e) => setNewPassword(e.target.value),
|
|
3629
|
+
required: true,
|
|
3630
|
+
disabled: isLoading,
|
|
3631
|
+
minLength: 6,
|
|
3632
|
+
style: {
|
|
3633
|
+
width: "100%",
|
|
3634
|
+
padding: "12px 16px",
|
|
3635
|
+
border: "1px solid #ddd",
|
|
3636
|
+
borderRadius: "8px",
|
|
3637
|
+
fontSize: "16px",
|
|
3638
|
+
boxSizing: "border-box",
|
|
3639
|
+
...appearance?.elements?.formFieldInput
|
|
3640
|
+
},
|
|
3641
|
+
placeholder: "Enter new password"
|
|
3642
|
+
}
|
|
3643
|
+
),
|
|
3644
|
+
newPassword && /* @__PURE__ */ jsxs("div", { style: { marginTop: "8px" }, children: [
|
|
3645
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
3646
|
+
height: "4px",
|
|
3647
|
+
backgroundColor: "#eee",
|
|
3648
|
+
borderRadius: "2px",
|
|
3649
|
+
overflow: "hidden"
|
|
3650
|
+
}, children: /* @__PURE__ */ jsx("div", { style: {
|
|
3651
|
+
height: "100%",
|
|
3652
|
+
width: passwordStrength.strength === "weak" ? "33%" : passwordStrength.strength === "medium" ? "66%" : "100%",
|
|
3653
|
+
backgroundColor: passwordStrength.color,
|
|
3654
|
+
transition: "all 0.3s ease"
|
|
3655
|
+
} }) }),
|
|
3656
|
+
/* @__PURE__ */ jsxs("p", { style: {
|
|
3657
|
+
fontSize: "12px",
|
|
3658
|
+
color: passwordStrength.color,
|
|
3659
|
+
marginTop: "4px",
|
|
3660
|
+
textTransform: "capitalize"
|
|
3661
|
+
}, children: [
|
|
3662
|
+
passwordStrength.strength,
|
|
3663
|
+
" password"
|
|
3664
|
+
] })
|
|
3665
|
+
] })
|
|
3666
|
+
] }),
|
|
3667
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
3668
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "confirmPassword", style: {
|
|
3669
|
+
display: "block",
|
|
3670
|
+
marginBottom: "8px",
|
|
3671
|
+
fontWeight: 500,
|
|
3672
|
+
color: "#374151",
|
|
3673
|
+
fontSize: "14px"
|
|
3674
|
+
}, children: "Confirm new password" }),
|
|
3675
|
+
/* @__PURE__ */ jsx(
|
|
3676
|
+
"input",
|
|
3677
|
+
{
|
|
3678
|
+
id: "confirmPassword",
|
|
3679
|
+
type: showPasswords ? "text" : "password",
|
|
3680
|
+
value: confirmPassword,
|
|
3681
|
+
onChange: (e) => setConfirmPassword(e.target.value),
|
|
3682
|
+
required: true,
|
|
3683
|
+
disabled: isLoading,
|
|
3684
|
+
style: {
|
|
3685
|
+
width: "100%",
|
|
3686
|
+
padding: "12px 16px",
|
|
3687
|
+
border: "1px solid #ddd",
|
|
3688
|
+
borderRadius: "8px",
|
|
3689
|
+
fontSize: "16px",
|
|
3690
|
+
boxSizing: "border-box",
|
|
3691
|
+
...appearance?.elements?.formFieldInput
|
|
3692
|
+
},
|
|
3693
|
+
placeholder: "Confirm new password"
|
|
3694
|
+
}
|
|
3695
|
+
)
|
|
3696
|
+
] }),
|
|
3697
|
+
/* @__PURE__ */ jsx("div", { style: { marginBottom: "20px" }, children: /* @__PURE__ */ jsxs("label", { style: { display: "flex", alignItems: "center", cursor: "pointer" }, children: [
|
|
3698
|
+
/* @__PURE__ */ jsx(
|
|
3699
|
+
"input",
|
|
3700
|
+
{
|
|
3701
|
+
type: "checkbox",
|
|
3702
|
+
checked: showPasswords,
|
|
3703
|
+
onChange: (e) => setShowPasswords(e.target.checked),
|
|
3704
|
+
style: { marginRight: "8px" }
|
|
3705
|
+
}
|
|
3706
|
+
),
|
|
3707
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "14px", color: "#666" }, children: "Show passwords" })
|
|
3708
|
+
] }) }),
|
|
3709
|
+
/* @__PURE__ */ jsx(
|
|
3710
|
+
"button",
|
|
3711
|
+
{
|
|
3712
|
+
type: "submit",
|
|
3713
|
+
disabled: isLoading,
|
|
3714
|
+
style: {
|
|
3715
|
+
width: "100%",
|
|
3716
|
+
padding: "14px",
|
|
3717
|
+
backgroundColor: "#007bff",
|
|
3718
|
+
color: "white",
|
|
3719
|
+
border: "none",
|
|
3720
|
+
borderRadius: "8px",
|
|
3721
|
+
fontSize: "16px",
|
|
3722
|
+
fontWeight: 600,
|
|
3723
|
+
cursor: "pointer",
|
|
3724
|
+
transition: "all 0.2s ease",
|
|
3725
|
+
...appearance?.elements?.formButtonPrimary
|
|
3726
|
+
},
|
|
3727
|
+
children: isLoading ? "Changing password..." : "Change password"
|
|
3728
|
+
}
|
|
3729
|
+
)
|
|
3730
|
+
] }) });
|
|
3731
|
+
};
|
|
3732
|
+
var UserProfile = ({
|
|
3733
|
+
showAvatar = true,
|
|
3734
|
+
showEmailChange = true,
|
|
3735
|
+
showPasswordChange = true
|
|
3736
|
+
}) => {
|
|
3737
|
+
const { user, updateProfile, updateAvatar, requestEmailChange } = useAuth();
|
|
3738
|
+
const [name, setName] = useState(user?.name || "");
|
|
3739
|
+
const [avatar, setAvatar] = useState("");
|
|
3740
|
+
const [newEmail, setNewEmail] = useState("");
|
|
3741
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
3742
|
+
const [error, setError] = useState(null);
|
|
3743
|
+
const [success, setSuccess] = useState(null);
|
|
3744
|
+
const handleUpdateName = async (e) => {
|
|
3745
|
+
e.preventDefault();
|
|
3746
|
+
setIsLoading(true);
|
|
3747
|
+
setError(null);
|
|
3748
|
+
setSuccess(null);
|
|
3749
|
+
try {
|
|
3750
|
+
const response = await updateProfile({ name });
|
|
3751
|
+
if (response.success) {
|
|
3752
|
+
setSuccess("Name updated successfully!");
|
|
3753
|
+
} else {
|
|
3754
|
+
setError(response.message || "Failed to update name");
|
|
3755
|
+
}
|
|
3756
|
+
} catch (err) {
|
|
3757
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
3758
|
+
} finally {
|
|
3759
|
+
setIsLoading(false);
|
|
3760
|
+
}
|
|
3761
|
+
};
|
|
3762
|
+
const handleUpdateAvatar = async (e) => {
|
|
3763
|
+
e.preventDefault();
|
|
3764
|
+
setIsLoading(true);
|
|
3765
|
+
setError(null);
|
|
3766
|
+
setSuccess(null);
|
|
3767
|
+
try {
|
|
3768
|
+
const response = await updateAvatar(avatar);
|
|
3769
|
+
if (response.success) {
|
|
3770
|
+
setSuccess("Avatar updated successfully!");
|
|
3771
|
+
setAvatar("");
|
|
3772
|
+
} else {
|
|
3773
|
+
setError(response.message || "Failed to update avatar");
|
|
3774
|
+
}
|
|
3775
|
+
} catch (err) {
|
|
3776
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
3777
|
+
} finally {
|
|
3778
|
+
setIsLoading(false);
|
|
3779
|
+
}
|
|
3780
|
+
};
|
|
3781
|
+
const handleRequestEmailChange = async (e) => {
|
|
3782
|
+
e.preventDefault();
|
|
3783
|
+
setIsLoading(true);
|
|
3784
|
+
setError(null);
|
|
3785
|
+
setSuccess(null);
|
|
3786
|
+
try {
|
|
3787
|
+
const response = await requestEmailChange(newEmail);
|
|
3788
|
+
if (response.success) {
|
|
3789
|
+
setSuccess("Verification email sent! Please check your inbox.");
|
|
3790
|
+
setNewEmail("");
|
|
3791
|
+
} else {
|
|
3792
|
+
setError(response.message || "Failed to request email change");
|
|
3793
|
+
}
|
|
3794
|
+
} catch (err) {
|
|
3795
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
3796
|
+
} finally {
|
|
3797
|
+
setIsLoading(false);
|
|
3798
|
+
}
|
|
3799
|
+
};
|
|
3800
|
+
if (!user)
|
|
3801
|
+
return null;
|
|
3802
|
+
return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "600px", margin: "0 auto", padding: "20px" }, children: [
|
|
3803
|
+
/* @__PURE__ */ jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600 }, children: "Profile Settings" }),
|
|
3804
|
+
error && /* @__PURE__ */ jsx("div", { style: {
|
|
3805
|
+
padding: "12px 16px",
|
|
3806
|
+
marginBottom: "20px",
|
|
3807
|
+
backgroundColor: "#fee",
|
|
3808
|
+
color: "#c33",
|
|
3809
|
+
border: "1px solid #fcc",
|
|
3810
|
+
borderRadius: "8px",
|
|
3811
|
+
fontSize: "14px"
|
|
3812
|
+
}, children: error }),
|
|
3813
|
+
success && /* @__PURE__ */ jsx("div", { style: {
|
|
3814
|
+
padding: "12px 16px",
|
|
3815
|
+
marginBottom: "20px",
|
|
3816
|
+
backgroundColor: "#efe",
|
|
3817
|
+
color: "#3c3",
|
|
3818
|
+
border: "1px solid #cfc",
|
|
3819
|
+
borderRadius: "8px",
|
|
3820
|
+
fontSize: "14px"
|
|
3821
|
+
}, children: success }),
|
|
3822
|
+
/* @__PURE__ */ jsxs("div", { style: {
|
|
3823
|
+
padding: "20px",
|
|
3824
|
+
backgroundColor: "#fff",
|
|
3825
|
+
borderRadius: "8px",
|
|
3826
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3827
|
+
marginBottom: "20px"
|
|
3828
|
+
}, children: [
|
|
3829
|
+
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Name" }),
|
|
3830
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateName, children: [
|
|
3831
|
+
/* @__PURE__ */ jsx(
|
|
3832
|
+
"input",
|
|
3833
|
+
{
|
|
3834
|
+
type: "text",
|
|
3835
|
+
value: name,
|
|
3836
|
+
onChange: (e) => setName(e.target.value),
|
|
3837
|
+
required: true,
|
|
3838
|
+
disabled: isLoading,
|
|
3839
|
+
style: {
|
|
3840
|
+
width: "100%",
|
|
3841
|
+
padding: "12px 16px",
|
|
3842
|
+
border: "1px solid #ddd",
|
|
3843
|
+
borderRadius: "8px",
|
|
3844
|
+
fontSize: "16px",
|
|
3845
|
+
boxSizing: "border-box",
|
|
3846
|
+
marginBottom: "12px"
|
|
3847
|
+
},
|
|
3848
|
+
placeholder: "Your name"
|
|
3849
|
+
}
|
|
3850
|
+
),
|
|
3851
|
+
/* @__PURE__ */ jsx(
|
|
3852
|
+
"button",
|
|
3853
|
+
{
|
|
3854
|
+
type: "submit",
|
|
3855
|
+
disabled: isLoading,
|
|
3856
|
+
style: {
|
|
3857
|
+
padding: "10px 20px",
|
|
3858
|
+
backgroundColor: "#007bff",
|
|
3859
|
+
color: "white",
|
|
3860
|
+
border: "none",
|
|
3861
|
+
borderRadius: "8px",
|
|
3862
|
+
fontSize: "14px",
|
|
3863
|
+
fontWeight: 600,
|
|
3864
|
+
cursor: "pointer"
|
|
3865
|
+
},
|
|
3866
|
+
children: "Update Name"
|
|
3867
|
+
}
|
|
3868
|
+
)
|
|
3869
|
+
] })
|
|
3870
|
+
] }),
|
|
3871
|
+
showAvatar && /* @__PURE__ */ jsxs("div", { style: {
|
|
3872
|
+
padding: "20px",
|
|
3873
|
+
backgroundColor: "#fff",
|
|
3874
|
+
borderRadius: "8px",
|
|
3875
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3876
|
+
marginBottom: "20px"
|
|
3877
|
+
}, children: [
|
|
3878
|
+
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Avatar" }),
|
|
3879
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateAvatar, children: [
|
|
3880
|
+
/* @__PURE__ */ jsx(
|
|
3881
|
+
"input",
|
|
3882
|
+
{
|
|
3883
|
+
type: "url",
|
|
3884
|
+
value: avatar,
|
|
3885
|
+
onChange: (e) => setAvatar(e.target.value),
|
|
3886
|
+
required: true,
|
|
3887
|
+
disabled: isLoading,
|
|
3888
|
+
style: {
|
|
3889
|
+
width: "100%",
|
|
3890
|
+
padding: "12px 16px",
|
|
3891
|
+
border: "1px solid #ddd",
|
|
3892
|
+
borderRadius: "8px",
|
|
3893
|
+
fontSize: "16px",
|
|
3894
|
+
boxSizing: "border-box",
|
|
3895
|
+
marginBottom: "12px"
|
|
3896
|
+
},
|
|
3897
|
+
placeholder: "Avatar URL"
|
|
3898
|
+
}
|
|
3899
|
+
),
|
|
3900
|
+
/* @__PURE__ */ jsx(
|
|
3901
|
+
"button",
|
|
3902
|
+
{
|
|
3903
|
+
type: "submit",
|
|
3904
|
+
disabled: isLoading,
|
|
3905
|
+
style: {
|
|
3906
|
+
padding: "10px 20px",
|
|
3907
|
+
backgroundColor: "#007bff",
|
|
3908
|
+
color: "white",
|
|
3909
|
+
border: "none",
|
|
3910
|
+
borderRadius: "8px",
|
|
3911
|
+
fontSize: "14px",
|
|
3912
|
+
fontWeight: 600,
|
|
3913
|
+
cursor: "pointer"
|
|
3914
|
+
},
|
|
3915
|
+
children: "Update Avatar"
|
|
3916
|
+
}
|
|
3917
|
+
)
|
|
3918
|
+
] })
|
|
3919
|
+
] }),
|
|
3920
|
+
showEmailChange && /* @__PURE__ */ jsxs("div", { style: {
|
|
3921
|
+
padding: "20px",
|
|
3922
|
+
backgroundColor: "#fff",
|
|
3923
|
+
borderRadius: "8px",
|
|
3924
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3925
|
+
marginBottom: "20px"
|
|
3926
|
+
}, children: [
|
|
3927
|
+
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Change Email" }),
|
|
3928
|
+
/* @__PURE__ */ jsxs("p", { style: { fontSize: "14px", color: "#666", marginBottom: "12px" }, children: [
|
|
3929
|
+
"Current email: ",
|
|
3930
|
+
/* @__PURE__ */ jsx("strong", { children: user.email })
|
|
3931
|
+
] }),
|
|
3932
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: handleRequestEmailChange, children: [
|
|
3933
|
+
/* @__PURE__ */ jsx(
|
|
3934
|
+
"input",
|
|
3935
|
+
{
|
|
3936
|
+
type: "email",
|
|
3937
|
+
value: newEmail,
|
|
3938
|
+
onChange: (e) => setNewEmail(e.target.value),
|
|
3939
|
+
required: true,
|
|
3940
|
+
disabled: isLoading,
|
|
3941
|
+
style: {
|
|
3942
|
+
width: "100%",
|
|
3943
|
+
padding: "12px 16px",
|
|
3944
|
+
border: "1px solid #ddd",
|
|
3945
|
+
borderRadius: "8px",
|
|
3946
|
+
fontSize: "16px",
|
|
3947
|
+
boxSizing: "border-box",
|
|
3948
|
+
marginBottom: "12px"
|
|
3949
|
+
},
|
|
3950
|
+
placeholder: "New email address"
|
|
3951
|
+
}
|
|
3952
|
+
),
|
|
3953
|
+
/* @__PURE__ */ jsx(
|
|
3954
|
+
"button",
|
|
3955
|
+
{
|
|
3956
|
+
type: "submit",
|
|
3957
|
+
disabled: isLoading,
|
|
3958
|
+
style: {
|
|
3959
|
+
padding: "10px 20px",
|
|
3960
|
+
backgroundColor: "#007bff",
|
|
3961
|
+
color: "white",
|
|
3962
|
+
border: "none",
|
|
3963
|
+
borderRadius: "8px",
|
|
3964
|
+
fontSize: "14px",
|
|
3965
|
+
fontWeight: 600,
|
|
3966
|
+
cursor: "pointer"
|
|
3967
|
+
},
|
|
3968
|
+
children: "Request Email Change"
|
|
3969
|
+
}
|
|
3970
|
+
)
|
|
3971
|
+
] })
|
|
3972
|
+
] })
|
|
3973
|
+
] });
|
|
3974
|
+
};
|
|
3975
|
+
|
|
3976
|
+
// src/react/index.ts
|
|
3977
|
+
var react_exports = {};
|
|
3978
|
+
__export(react_exports, {
|
|
3979
|
+
AuthFlow: () => AuthFlow,
|
|
3980
|
+
AuthProvider: () => AuthProvider,
|
|
3981
|
+
ChangePassword: () => ChangePassword,
|
|
3982
|
+
EmailVerificationPage: () => EmailVerificationPage,
|
|
3983
|
+
ForgotPassword: () => ForgotPassword,
|
|
3984
|
+
LoginForm: () => LoginForm,
|
|
3985
|
+
OtpForm: () => OtpForm,
|
|
3986
|
+
ProtectedRoute: () => ProtectedRoute,
|
|
3987
|
+
PublicRoute: () => PublicRoute,
|
|
3988
|
+
RegisterForm: () => RegisterForm,
|
|
3989
|
+
ResetPassword: () => ResetPassword,
|
|
3990
|
+
SignIn: () => SignIn,
|
|
3991
|
+
SignOut: () => SignOut,
|
|
3992
|
+
SignUp: () => SignUp,
|
|
3993
|
+
UserButton: () => UserButton,
|
|
3994
|
+
UserProfile: () => UserProfile,
|
|
3995
|
+
VerifyEmail: () => VerifyEmail,
|
|
3996
|
+
useAuth: () => useAuth,
|
|
3997
|
+
useAuthLegacy: () => useAuth2
|
|
3998
|
+
});
|
|
1757
3999
|
|
|
1758
4000
|
// src/node/index.ts
|
|
1759
4001
|
var node_exports = {};
|
|
@@ -1769,11 +4011,11 @@ var AuthClient = class extends AuthService {
|
|
|
1769
4011
|
// Override methods that require browser-specific features
|
|
1770
4012
|
// For Node.js, token persistence must be handled manually
|
|
1771
4013
|
async register(data) {
|
|
1772
|
-
const
|
|
1773
|
-
if (
|
|
1774
|
-
|
|
4014
|
+
const frontendBaseUrl = process.env.FRONTEND_BASE_URL || process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL;
|
|
4015
|
+
if (frontendBaseUrl) {
|
|
4016
|
+
this["httpClient"].setFrontendBaseUrl(frontendBaseUrl);
|
|
1775
4017
|
}
|
|
1776
|
-
const response = await this["httpClient"].post("/api/v1/auth/register",
|
|
4018
|
+
const response = await this["httpClient"].post("/api/v1/auth/register", data);
|
|
1777
4019
|
if (response.success && response.message === "Registration data saved. Verification email sent. Please check your inbox.") {
|
|
1778
4020
|
return response;
|
|
1779
4021
|
}
|
|
@@ -1839,6 +4081,6 @@ var AuthClient = class extends AuthService {
|
|
|
1839
4081
|
}
|
|
1840
4082
|
};
|
|
1841
4083
|
|
|
1842
|
-
export { AuthService, HttpClient, node_exports as node, react_exports as react };
|
|
4084
|
+
export { AuthFlow, AuthProvider, AuthService, ChangePassword, EmailVerificationPage, ForgotPassword, HttpClient, LoginForm, OtpForm, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail, node_exports as node, react_exports as react, useAuth };
|
|
1843
4085
|
//# sourceMappingURL=out.js.map
|
|
1844
4086
|
//# sourceMappingURL=index.mjs.map
|