@thetechfossil/auth2 1.2.14 → 1.2.16
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.md +0 -0
- package/dist/index.components.d.mts +255 -0
- package/dist/index.components.d.ts +9 -1
- package/dist/index.components.js +215 -225
- package/dist/index.components.js.map +1 -1
- package/dist/index.components.mjs +103 -113
- package/dist/index.components.mjs.map +1 -1
- package/dist/index.d.mts +566 -0
- package/dist/index.d.ts +11 -33
- package/dist/index.js +263 -267
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -117
- package/dist/index.mjs.map +1 -1
- package/dist/index.next.d.mts +538 -0
- package/dist/index.next.d.ts +9 -1
- package/dist/index.next.js +277 -281
- package/dist/index.next.js.map +1 -1
- package/dist/index.next.mjs +113 -117
- package/dist/index.next.mjs.map +1 -1
- package/dist/index.next.server.d.mts +272 -0
- package/dist/index.next.server.d.ts +1 -1
- package/dist/index.next.server.js +12 -11
- package/dist/index.next.server.js.map +1 -1
- package/dist/index.next.server.mjs +12 -11
- package/dist/index.next.server.mjs.map +1 -1
- package/dist/index.node.d.mts +227 -0
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +8 -5
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +8 -5
- package/dist/index.node.mjs.map +1 -1
- package/next/index.js +0 -0
- package/next/index.mjs +0 -0
- package/next/package.json +0 -0
- package/next/server/package.json +0 -0
- package/next/server.js +0 -0
- package/next/server.mjs +0 -0
- package/package.json +21 -21
package/dist/index.js
CHANGED
|
@@ -3,21 +3,20 @@
|
|
|
3
3
|
|
|
4
4
|
var axios = require('axios');
|
|
5
5
|
var upfiles = require('@thetechfossil/upfiles');
|
|
6
|
-
var
|
|
6
|
+
var React = require('react');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
|
|
9
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
|
|
11
11
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
12
|
-
var
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
13
13
|
|
|
14
14
|
var __defProp = Object.defineProperty;
|
|
15
15
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
16
16
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
17
17
|
}) : x)(function(x) {
|
|
18
|
-
if (typeof require !== "undefined")
|
|
19
|
-
|
|
20
|
-
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
18
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
19
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
21
20
|
});
|
|
22
21
|
var __export = (target, all) => {
|
|
23
22
|
for (var name in all)
|
|
@@ -75,6 +74,11 @@ var HttpClient = class {
|
|
|
75
74
|
return Promise.reject(refreshError);
|
|
76
75
|
}
|
|
77
76
|
}
|
|
77
|
+
if (error.response && error.response.data && error.response.data.message) {
|
|
78
|
+
const customError = new Error(error.response.data.message);
|
|
79
|
+
customError.response = error.response;
|
|
80
|
+
return Promise.reject(customError);
|
|
81
|
+
}
|
|
78
82
|
return Promise.reject(error);
|
|
79
83
|
}
|
|
80
84
|
);
|
|
@@ -194,8 +198,7 @@ var AuthService = class {
|
|
|
194
198
|
return this.token;
|
|
195
199
|
}
|
|
196
200
|
getCurrentUser() {
|
|
197
|
-
if (!this.token)
|
|
198
|
-
return null;
|
|
201
|
+
if (!this.token) return null;
|
|
199
202
|
try {
|
|
200
203
|
const payload = JSON.parse(atob(this.token.split(".")[1]));
|
|
201
204
|
return payload.user || null;
|
|
@@ -206,8 +209,7 @@ var AuthService = class {
|
|
|
206
209
|
}
|
|
207
210
|
// CSRF Token Management
|
|
208
211
|
async refreshCsrfToken() {
|
|
209
|
-
if (!this.config.csrfEnabled)
|
|
210
|
-
return;
|
|
212
|
+
if (!this.config.csrfEnabled) return;
|
|
211
213
|
try {
|
|
212
214
|
const response = await this.httpClient.get("/api/v1/auth/csrf-token");
|
|
213
215
|
if (response.csrfToken) {
|
|
@@ -513,11 +515,11 @@ var AuthService = class {
|
|
|
513
515
|
return response;
|
|
514
516
|
}
|
|
515
517
|
};
|
|
516
|
-
var ThemeContext =
|
|
518
|
+
var ThemeContext = React__default.default.createContext({ theme: "light", mounted: false });
|
|
517
519
|
function AuthThemeProvider({ children }) {
|
|
518
|
-
const [theme, setTheme] =
|
|
519
|
-
const [mounted, setMounted] =
|
|
520
|
-
|
|
520
|
+
const [theme, setTheme] = React.useState("light");
|
|
521
|
+
const [mounted, setMounted] = React.useState(false);
|
|
522
|
+
React.useEffect(() => {
|
|
521
523
|
const detectTheme = () => {
|
|
522
524
|
const htmlElement = document.documentElement;
|
|
523
525
|
const bodyElement = document.body;
|
|
@@ -562,9 +564,9 @@ function AuthThemeProvider({ children }) {
|
|
|
562
564
|
return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: { theme, mounted }, children });
|
|
563
565
|
}
|
|
564
566
|
function useAuthTheme() {
|
|
565
|
-
return
|
|
567
|
+
return React.useContext(ThemeContext);
|
|
566
568
|
}
|
|
567
|
-
var AuthContext =
|
|
569
|
+
var AuthContext = React.createContext(void 0);
|
|
568
570
|
var AuthProvider = ({ children, config }) => {
|
|
569
571
|
const authConfig = {
|
|
570
572
|
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"),
|
|
@@ -572,29 +574,35 @@ var AuthProvider = ({ children, config }) => {
|
|
|
572
574
|
csrfEnabled: config?.csrfEnabled !== void 0 ? config.csrfEnabled : true,
|
|
573
575
|
upfilesConfig: config?.upfilesConfig
|
|
574
576
|
};
|
|
575
|
-
const [authService] =
|
|
576
|
-
const [user, setUser] =
|
|
577
|
-
const [isLoaded, setIsLoaded] =
|
|
578
|
-
const [loading, setLoading] =
|
|
579
|
-
const checkAuthStatus =
|
|
577
|
+
const [authService] = React.useState(() => new AuthService(authConfig));
|
|
578
|
+
const [user, setUser] = React.useState(null);
|
|
579
|
+
const [isLoaded, setIsLoaded] = React.useState(false);
|
|
580
|
+
const [loading, setLoading] = React.useState(false);
|
|
581
|
+
const checkAuthStatus = React.useCallback(async () => {
|
|
580
582
|
const authenticated = authService.isAuthenticated();
|
|
581
583
|
if (authenticated) {
|
|
582
584
|
try {
|
|
583
|
-
const
|
|
584
|
-
setUser(
|
|
585
|
+
const freshUser = await authService.getProfile();
|
|
586
|
+
setUser(freshUser);
|
|
585
587
|
} catch (error) {
|
|
586
|
-
console.error("Failed to
|
|
587
|
-
|
|
588
|
+
console.error("Failed to fetch fresh user profile, falling back to token:", error);
|
|
589
|
+
try {
|
|
590
|
+
const currentUser = authService.getCurrentUser();
|
|
591
|
+
setUser(currentUser);
|
|
592
|
+
} catch (fallbackError) {
|
|
593
|
+
console.error("Failed to get current user from token:", fallbackError);
|
|
594
|
+
setUser(null);
|
|
595
|
+
}
|
|
588
596
|
}
|
|
589
597
|
} else {
|
|
590
598
|
setUser(null);
|
|
591
599
|
}
|
|
592
600
|
setIsLoaded(true);
|
|
593
601
|
}, [authService]);
|
|
594
|
-
|
|
602
|
+
React.useEffect(() => {
|
|
595
603
|
checkAuthStatus();
|
|
596
604
|
}, [checkAuthStatus]);
|
|
597
|
-
const signIn =
|
|
605
|
+
const signIn = React.useCallback(async (data) => {
|
|
598
606
|
setLoading(true);
|
|
599
607
|
try {
|
|
600
608
|
const response = await authService.login(data);
|
|
@@ -606,7 +614,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
606
614
|
setLoading(false);
|
|
607
615
|
}
|
|
608
616
|
}, [authService]);
|
|
609
|
-
const signUp =
|
|
617
|
+
const signUp = React.useCallback(async (data) => {
|
|
610
618
|
setLoading(true);
|
|
611
619
|
try {
|
|
612
620
|
const response = await authService.register(data);
|
|
@@ -615,7 +623,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
615
623
|
setLoading(false);
|
|
616
624
|
}
|
|
617
625
|
}, [authService]);
|
|
618
|
-
const signOut =
|
|
626
|
+
const signOut = React.useCallback(async () => {
|
|
619
627
|
setLoading(true);
|
|
620
628
|
try {
|
|
621
629
|
await authService.logout();
|
|
@@ -624,7 +632,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
624
632
|
setLoading(false);
|
|
625
633
|
}
|
|
626
634
|
}, [authService]);
|
|
627
|
-
const verify =
|
|
635
|
+
const verify = React.useCallback(async (data) => {
|
|
628
636
|
setLoading(true);
|
|
629
637
|
try {
|
|
630
638
|
const response = await authService.verify(data);
|
|
@@ -636,7 +644,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
636
644
|
setLoading(false);
|
|
637
645
|
}
|
|
638
646
|
}, [authService]);
|
|
639
|
-
const verifyEmailToken =
|
|
647
|
+
const verifyEmailToken = React.useCallback(async (token) => {
|
|
640
648
|
setLoading(true);
|
|
641
649
|
try {
|
|
642
650
|
const response = await authService.verifyEmailToken(token);
|
|
@@ -648,7 +656,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
648
656
|
setLoading(false);
|
|
649
657
|
}
|
|
650
658
|
}, [authService]);
|
|
651
|
-
const updateProfile =
|
|
659
|
+
const updateProfile = React.useCallback(async (data) => {
|
|
652
660
|
setLoading(true);
|
|
653
661
|
try {
|
|
654
662
|
const response = await authService.updateProfile(data);
|
|
@@ -660,7 +668,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
660
668
|
setLoading(false);
|
|
661
669
|
}
|
|
662
670
|
}, [authService]);
|
|
663
|
-
const getProfile =
|
|
671
|
+
const getProfile = React.useCallback(async () => {
|
|
664
672
|
setLoading(true);
|
|
665
673
|
try {
|
|
666
674
|
const userData = await authService.getProfile();
|
|
@@ -670,13 +678,13 @@ var AuthProvider = ({ children, config }) => {
|
|
|
670
678
|
setLoading(false);
|
|
671
679
|
}
|
|
672
680
|
}, [authService]);
|
|
673
|
-
const signInWithOAuth =
|
|
681
|
+
const signInWithOAuth = React.useCallback((provider) => {
|
|
674
682
|
authService.loginWithOAuth(provider);
|
|
675
683
|
}, [authService]);
|
|
676
|
-
const linkOAuthProvider =
|
|
684
|
+
const linkOAuthProvider = React.useCallback((provider) => {
|
|
677
685
|
authService.linkOAuthProvider(provider);
|
|
678
686
|
}, [authService]);
|
|
679
|
-
const unlinkOAuthProvider =
|
|
687
|
+
const unlinkOAuthProvider = React.useCallback(async (provider) => {
|
|
680
688
|
setLoading(true);
|
|
681
689
|
try {
|
|
682
690
|
return await authService.unlinkOAuthProvider(provider);
|
|
@@ -684,7 +692,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
684
692
|
setLoading(false);
|
|
685
693
|
}
|
|
686
694
|
}, [authService]);
|
|
687
|
-
const forgotPassword =
|
|
695
|
+
const forgotPassword = React.useCallback(async (email) => {
|
|
688
696
|
setLoading(true);
|
|
689
697
|
try {
|
|
690
698
|
return await authService.forgotPassword(email);
|
|
@@ -692,7 +700,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
692
700
|
setLoading(false);
|
|
693
701
|
}
|
|
694
702
|
}, [authService]);
|
|
695
|
-
const resetPassword =
|
|
703
|
+
const resetPassword = React.useCallback(async (token, password) => {
|
|
696
704
|
setLoading(true);
|
|
697
705
|
try {
|
|
698
706
|
return await authService.resetPassword(token, password);
|
|
@@ -700,7 +708,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
700
708
|
setLoading(false);
|
|
701
709
|
}
|
|
702
710
|
}, [authService]);
|
|
703
|
-
const changePassword =
|
|
711
|
+
const changePassword = React.useCallback(async (oldPassword, newPassword) => {
|
|
704
712
|
setLoading(true);
|
|
705
713
|
try {
|
|
706
714
|
return await authService.changePassword(oldPassword, newPassword);
|
|
@@ -708,7 +716,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
708
716
|
setLoading(false);
|
|
709
717
|
}
|
|
710
718
|
}, [authService]);
|
|
711
|
-
const updateAvatar =
|
|
719
|
+
const updateAvatar = React.useCallback(async (avatar) => {
|
|
712
720
|
setLoading(true);
|
|
713
721
|
try {
|
|
714
722
|
const response = await authService.updateAvatar(avatar);
|
|
@@ -720,7 +728,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
720
728
|
setLoading(false);
|
|
721
729
|
}
|
|
722
730
|
}, [authService]);
|
|
723
|
-
const uploadAndUpdateAvatar =
|
|
731
|
+
const uploadAndUpdateAvatar = React.useCallback(async (file) => {
|
|
724
732
|
setLoading(true);
|
|
725
733
|
try {
|
|
726
734
|
const response = await authService.uploadAndUpdateAvatar(file);
|
|
@@ -732,7 +740,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
732
740
|
setLoading(false);
|
|
733
741
|
}
|
|
734
742
|
}, [authService]);
|
|
735
|
-
const requestEmailChange =
|
|
743
|
+
const requestEmailChange = React.useCallback(async (newEmail) => {
|
|
736
744
|
setLoading(true);
|
|
737
745
|
try {
|
|
738
746
|
return await authService.requestEmailChange(newEmail);
|
|
@@ -740,7 +748,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
740
748
|
setLoading(false);
|
|
741
749
|
}
|
|
742
750
|
}, [authService]);
|
|
743
|
-
const verifyEmailChange =
|
|
751
|
+
const verifyEmailChange = React.useCallback(async (token) => {
|
|
744
752
|
setLoading(true);
|
|
745
753
|
try {
|
|
746
754
|
const response = await authService.verifyEmailChange(token);
|
|
@@ -752,7 +760,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
752
760
|
setLoading(false);
|
|
753
761
|
}
|
|
754
762
|
}, [authService]);
|
|
755
|
-
const generate2FA =
|
|
763
|
+
const generate2FA = React.useCallback(async () => {
|
|
756
764
|
setLoading(true);
|
|
757
765
|
try {
|
|
758
766
|
return await authService.generate2FA();
|
|
@@ -760,7 +768,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
760
768
|
setLoading(false);
|
|
761
769
|
}
|
|
762
770
|
}, [authService]);
|
|
763
|
-
const enable2FA =
|
|
771
|
+
const enable2FA = React.useCallback(async (token) => {
|
|
764
772
|
setLoading(true);
|
|
765
773
|
try {
|
|
766
774
|
return await authService.enable2FA(token);
|
|
@@ -768,7 +776,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
768
776
|
setLoading(false);
|
|
769
777
|
}
|
|
770
778
|
}, [authService]);
|
|
771
|
-
const disable2FA =
|
|
779
|
+
const disable2FA = React.useCallback(async (token) => {
|
|
772
780
|
setLoading(true);
|
|
773
781
|
try {
|
|
774
782
|
return await authService.disable2FA(token);
|
|
@@ -776,7 +784,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
776
784
|
setLoading(false);
|
|
777
785
|
}
|
|
778
786
|
}, [authService]);
|
|
779
|
-
const validate2FA =
|
|
787
|
+
const validate2FA = React.useCallback(async (token) => {
|
|
780
788
|
setLoading(true);
|
|
781
789
|
try {
|
|
782
790
|
return await authService.validate2FA(token);
|
|
@@ -784,7 +792,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
784
792
|
setLoading(false);
|
|
785
793
|
}
|
|
786
794
|
}, [authService]);
|
|
787
|
-
const getSessions =
|
|
795
|
+
const getSessions = React.useCallback(async () => {
|
|
788
796
|
setLoading(true);
|
|
789
797
|
try {
|
|
790
798
|
return await authService.getSessions();
|
|
@@ -792,7 +800,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
792
800
|
setLoading(false);
|
|
793
801
|
}
|
|
794
802
|
}, [authService]);
|
|
795
|
-
const revokeSession =
|
|
803
|
+
const revokeSession = React.useCallback(async (sessionId) => {
|
|
796
804
|
setLoading(true);
|
|
797
805
|
try {
|
|
798
806
|
return await authService.revokeSession(sessionId);
|
|
@@ -800,7 +808,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
800
808
|
setLoading(false);
|
|
801
809
|
}
|
|
802
810
|
}, [authService]);
|
|
803
|
-
const revokeAllSessions =
|
|
811
|
+
const revokeAllSessions = React.useCallback(async () => {
|
|
804
812
|
setLoading(true);
|
|
805
813
|
try {
|
|
806
814
|
const response = await authService.revokeAllSessions();
|
|
@@ -844,18 +852,18 @@ var AuthProvider = ({ children, config }) => {
|
|
|
844
852
|
return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(AuthThemeProvider, { children }) });
|
|
845
853
|
};
|
|
846
854
|
var useAuth = () => {
|
|
847
|
-
const context =
|
|
855
|
+
const context = React.useContext(AuthContext);
|
|
848
856
|
if (context === void 0) {
|
|
849
857
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
850
858
|
}
|
|
851
859
|
return context;
|
|
852
860
|
};
|
|
853
861
|
var useAuth2 = (config) => {
|
|
854
|
-
const [authService] =
|
|
855
|
-
const [user, setUser] =
|
|
856
|
-
const [isAuthenticated, setIsAuthenticated] =
|
|
857
|
-
const [loading, setLoading] =
|
|
858
|
-
const checkAuthStatus =
|
|
862
|
+
const [authService] = React.useState(() => new AuthService(config));
|
|
863
|
+
const [user, setUser] = React.useState(null);
|
|
864
|
+
const [isAuthenticated, setIsAuthenticated] = React.useState(false);
|
|
865
|
+
const [loading, setLoading] = React.useState(true);
|
|
866
|
+
const checkAuthStatus = React.useCallback(() => {
|
|
859
867
|
const authenticated = authService.isAuthenticated();
|
|
860
868
|
setIsAuthenticated(authenticated);
|
|
861
869
|
if (authenticated) {
|
|
@@ -866,10 +874,10 @@ var useAuth2 = (config) => {
|
|
|
866
874
|
}
|
|
867
875
|
setLoading(false);
|
|
868
876
|
}, [authService]);
|
|
869
|
-
|
|
877
|
+
React.useEffect(() => {
|
|
870
878
|
checkAuthStatus();
|
|
871
879
|
}, [checkAuthStatus]);
|
|
872
|
-
const register =
|
|
880
|
+
const register = React.useCallback(async (data) => {
|
|
873
881
|
setLoading(true);
|
|
874
882
|
try {
|
|
875
883
|
const response = await authService.register(data);
|
|
@@ -878,7 +886,7 @@ var useAuth2 = (config) => {
|
|
|
878
886
|
setLoading(false);
|
|
879
887
|
}
|
|
880
888
|
}, [authService]);
|
|
881
|
-
const login =
|
|
889
|
+
const login = React.useCallback(async (data) => {
|
|
882
890
|
setLoading(true);
|
|
883
891
|
try {
|
|
884
892
|
const response = await authService.login(data);
|
|
@@ -891,7 +899,7 @@ var useAuth2 = (config) => {
|
|
|
891
899
|
setLoading(false);
|
|
892
900
|
}
|
|
893
901
|
}, [authService]);
|
|
894
|
-
const verify =
|
|
902
|
+
const verify = React.useCallback(async (data) => {
|
|
895
903
|
setLoading(true);
|
|
896
904
|
try {
|
|
897
905
|
const response = await authService.verify(data);
|
|
@@ -904,7 +912,7 @@ var useAuth2 = (config) => {
|
|
|
904
912
|
setLoading(false);
|
|
905
913
|
}
|
|
906
914
|
}, [authService]);
|
|
907
|
-
const verifyEmailToken =
|
|
915
|
+
const verifyEmailToken = React.useCallback(async (token) => {
|
|
908
916
|
setLoading(true);
|
|
909
917
|
try {
|
|
910
918
|
const response = await authService.verifyEmailToken(token);
|
|
@@ -917,7 +925,7 @@ var useAuth2 = (config) => {
|
|
|
917
925
|
setLoading(false);
|
|
918
926
|
}
|
|
919
927
|
}, [authService]);
|
|
920
|
-
const logout =
|
|
928
|
+
const logout = React.useCallback(async () => {
|
|
921
929
|
setLoading(true);
|
|
922
930
|
try {
|
|
923
931
|
await authService.logout();
|
|
@@ -927,7 +935,7 @@ var useAuth2 = (config) => {
|
|
|
927
935
|
setLoading(false);
|
|
928
936
|
}
|
|
929
937
|
}, [authService]);
|
|
930
|
-
const updateProfile =
|
|
938
|
+
const updateProfile = React.useCallback(async (data) => {
|
|
931
939
|
setLoading(true);
|
|
932
940
|
try {
|
|
933
941
|
const response = await authService.updateProfile(data);
|
|
@@ -939,7 +947,7 @@ var useAuth2 = (config) => {
|
|
|
939
947
|
setLoading(false);
|
|
940
948
|
}
|
|
941
949
|
}, [authService]);
|
|
942
|
-
const getProfile =
|
|
950
|
+
const getProfile = React.useCallback(async () => {
|
|
943
951
|
setLoading(true);
|
|
944
952
|
try {
|
|
945
953
|
const userData = await authService.getProfile();
|
|
@@ -949,7 +957,7 @@ var useAuth2 = (config) => {
|
|
|
949
957
|
setLoading(false);
|
|
950
958
|
}
|
|
951
959
|
}, [authService]);
|
|
952
|
-
const getAllUsers =
|
|
960
|
+
const getAllUsers = React.useCallback(async () => {
|
|
953
961
|
setLoading(true);
|
|
954
962
|
try {
|
|
955
963
|
return await authService.getAllUsers();
|
|
@@ -957,7 +965,7 @@ var useAuth2 = (config) => {
|
|
|
957
965
|
setLoading(false);
|
|
958
966
|
}
|
|
959
967
|
}, [authService]);
|
|
960
|
-
const getUserById =
|
|
968
|
+
const getUserById = React.useCallback(async (id) => {
|
|
961
969
|
setLoading(true);
|
|
962
970
|
try {
|
|
963
971
|
return await authService.getUserById(id);
|
|
@@ -965,7 +973,7 @@ var useAuth2 = (config) => {
|
|
|
965
973
|
setLoading(false);
|
|
966
974
|
}
|
|
967
975
|
}, [authService]);
|
|
968
|
-
const uploadAndUpdateAvatar =
|
|
976
|
+
const uploadAndUpdateAvatar = React.useCallback(async (file) => {
|
|
969
977
|
setLoading(true);
|
|
970
978
|
try {
|
|
971
979
|
const response = await authService.uploadAndUpdateAvatar(file);
|
|
@@ -1043,7 +1051,7 @@ try {
|
|
|
1043
1051
|
} catch (error) {
|
|
1044
1052
|
console.warn("react-phone-number-input not available, using fallback");
|
|
1045
1053
|
}
|
|
1046
|
-
var CustomPhoneInput =
|
|
1054
|
+
var CustomPhoneInput = React__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1047
1055
|
"input",
|
|
1048
1056
|
{
|
|
1049
1057
|
...props,
|
|
@@ -1062,8 +1070,8 @@ var PhoneInput = ({
|
|
|
1062
1070
|
style = {}
|
|
1063
1071
|
}) => {
|
|
1064
1072
|
const colors = useThemeColors();
|
|
1065
|
-
const [defaultCountry, setDefaultCountry] =
|
|
1066
|
-
const styleContent =
|
|
1073
|
+
const [defaultCountry, setDefaultCountry] = React.useState("US");
|
|
1074
|
+
const styleContent = React.useMemo(() => `
|
|
1067
1075
|
.PhoneInput {
|
|
1068
1076
|
display: flex;
|
|
1069
1077
|
align-items: center;
|
|
@@ -1175,7 +1183,7 @@ var PhoneInput = ({
|
|
|
1175
1183
|
opacity: 0.6;
|
|
1176
1184
|
}
|
|
1177
1185
|
`, [colors]);
|
|
1178
|
-
|
|
1186
|
+
React.useEffect(() => {
|
|
1179
1187
|
const detectCountry = async () => {
|
|
1180
1188
|
try {
|
|
1181
1189
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
@@ -1232,7 +1240,7 @@ var PhoneInput = ({
|
|
|
1232
1240
|
};
|
|
1233
1241
|
detectCountry();
|
|
1234
1242
|
}, []);
|
|
1235
|
-
const handleChange =
|
|
1243
|
+
const handleChange = React.useMemo(() => (val) => {
|
|
1236
1244
|
onChange(val || "");
|
|
1237
1245
|
}, [onChange]);
|
|
1238
1246
|
if (!PhoneInputWithCountry) {
|
|
@@ -1296,15 +1304,15 @@ var LoginForm = ({
|
|
|
1296
1304
|
showOAuthButtons = true
|
|
1297
1305
|
}) => {
|
|
1298
1306
|
const colors = useThemeColors();
|
|
1299
|
-
const [email, setEmail] =
|
|
1300
|
-
const [phoneNumber, setPhoneNumber] =
|
|
1301
|
-
const [usePhone, setUsePhone] =
|
|
1302
|
-
const [password, setPassword] =
|
|
1303
|
-
const [usePassword, setUsePassword] =
|
|
1304
|
-
const [showPassword, setShowPassword] =
|
|
1305
|
-
const [isLoading, setIsLoading] =
|
|
1306
|
-
const [error, setError] =
|
|
1307
|
-
const [rememberMe, setRememberMe] =
|
|
1307
|
+
const [email, setEmail] = React.useState("");
|
|
1308
|
+
const [phoneNumber, setPhoneNumber] = React.useState("");
|
|
1309
|
+
const [usePhone, setUsePhone] = React.useState(false);
|
|
1310
|
+
const [password, setPassword] = React.useState("");
|
|
1311
|
+
const [usePassword, setUsePassword] = React.useState(false);
|
|
1312
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
1313
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
1314
|
+
const [error, setError] = React.useState(null);
|
|
1315
|
+
const [rememberMe, setRememberMe] = React.useState(false);
|
|
1308
1316
|
const { login } = useAuth2({
|
|
1309
1317
|
baseUrl: config?.baseUrl || "http://localhost:7000"
|
|
1310
1318
|
});
|
|
@@ -1758,33 +1766,25 @@ var RegisterForm = ({
|
|
|
1758
1766
|
invitationToken
|
|
1759
1767
|
}) => {
|
|
1760
1768
|
const colors = useThemeColors();
|
|
1761
|
-
const [name, setName] =
|
|
1762
|
-
const [email, setEmail] =
|
|
1763
|
-
const [phoneNumber, setPhoneNumber] =
|
|
1764
|
-
const [password, setPassword] =
|
|
1765
|
-
const [confirmPassword, setConfirmPassword] =
|
|
1766
|
-
const [isLoading, setIsLoading] =
|
|
1767
|
-
const [error, setError] =
|
|
1768
|
-
|
|
1769
|
-
|
|
1769
|
+
const [name, setName] = React.useState("");
|
|
1770
|
+
const [email, setEmail] = React.useState("");
|
|
1771
|
+
const [phoneNumber, setPhoneNumber] = React.useState("");
|
|
1772
|
+
const [password, setPassword] = React.useState("");
|
|
1773
|
+
const [confirmPassword, setConfirmPassword] = React.useState("");
|
|
1774
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
1775
|
+
const [error, setError] = React.useState(null);
|
|
1776
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
1777
|
+
const [showConfirmPassword, setShowConfirmPassword] = React.useState(false);
|
|
1770
1778
|
const getPasswordStrength = (pwd) => {
|
|
1771
|
-
if (!pwd)
|
|
1772
|
-
return { strength: "weak", score: 0, label: "" };
|
|
1779
|
+
if (!pwd) return { strength: "weak", score: 0, label: "" };
|
|
1773
1780
|
let score = 0;
|
|
1774
|
-
if (pwd.length >= 6)
|
|
1775
|
-
|
|
1776
|
-
if (pwd
|
|
1777
|
-
|
|
1778
|
-
if (/[a-
|
|
1779
|
-
|
|
1780
|
-
if (
|
|
1781
|
-
score++;
|
|
1782
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
1783
|
-
score++;
|
|
1784
|
-
if (score <= 2)
|
|
1785
|
-
return { strength: "weak", score, label: "Weak" };
|
|
1786
|
-
if (score <= 3)
|
|
1787
|
-
return { strength: "medium", score, label: "Medium" };
|
|
1781
|
+
if (pwd.length >= 6) score++;
|
|
1782
|
+
if (pwd.length >= 8) score++;
|
|
1783
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
1784
|
+
if (/\d/.test(pwd)) score++;
|
|
1785
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
1786
|
+
if (score <= 2) return { strength: "weak", score, label: "Weak" };
|
|
1787
|
+
if (score <= 3) return { strength: "medium", score, label: "Medium" };
|
|
1788
1788
|
return { strength: "strong", score, label: "Strong" };
|
|
1789
1789
|
};
|
|
1790
1790
|
getPasswordStrength(password);
|
|
@@ -1836,10 +1836,8 @@ var RegisterForm = ({
|
|
|
1836
1836
|
password,
|
|
1837
1837
|
frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
|
|
1838
1838
|
};
|
|
1839
|
-
if (email)
|
|
1840
|
-
|
|
1841
|
-
if (phoneNumber)
|
|
1842
|
-
registerData.phoneNumber = phoneNumber;
|
|
1839
|
+
if (email) registerData.email = email;
|
|
1840
|
+
if (phoneNumber) registerData.phoneNumber = phoneNumber;
|
|
1843
1841
|
const response = await register(registerData);
|
|
1844
1842
|
if (response.success) {
|
|
1845
1843
|
onRegisterSuccess?.();
|
|
@@ -2232,11 +2230,11 @@ var OtpForm = ({
|
|
|
2232
2230
|
baseUrl
|
|
2233
2231
|
}) => {
|
|
2234
2232
|
const colors = useThemeColors();
|
|
2235
|
-
const [otp, setOtp] =
|
|
2236
|
-
const [isLoading, setIsLoading] =
|
|
2237
|
-
const [error, setError] =
|
|
2238
|
-
const [resendCooldown, setResendCooldown] =
|
|
2239
|
-
const [resendLoading, setResendLoading] =
|
|
2233
|
+
const [otp, setOtp] = React.useState("");
|
|
2234
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
2235
|
+
const [error, setError] = React.useState(null);
|
|
2236
|
+
const [resendCooldown, setResendCooldown] = React.useState(0);
|
|
2237
|
+
const [resendLoading, setResendLoading] = React.useState(false);
|
|
2240
2238
|
const { verify, login } = useAuth2({
|
|
2241
2239
|
baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
|
|
2242
2240
|
});
|
|
@@ -2269,8 +2267,7 @@ var OtpForm = ({
|
|
|
2269
2267
|
}
|
|
2270
2268
|
};
|
|
2271
2269
|
const handleResendOtp = async () => {
|
|
2272
|
-
if (resendCooldown > 0 || resendLoading)
|
|
2273
|
-
return;
|
|
2270
|
+
if (resendCooldown > 0 || resendLoading) return;
|
|
2274
2271
|
setResendLoading(true);
|
|
2275
2272
|
setError(null);
|
|
2276
2273
|
try {
|
|
@@ -2448,9 +2445,9 @@ var AuthFlow = ({
|
|
|
2448
2445
|
initialStep = "login",
|
|
2449
2446
|
showTitle = true
|
|
2450
2447
|
}) => {
|
|
2451
|
-
const [step, setStep] =
|
|
2452
|
-
const [email, setEmail] =
|
|
2453
|
-
const [message, setMessage] =
|
|
2448
|
+
const [step, setStep] = React.useState(initialStep);
|
|
2449
|
+
const [email, setEmail] = React.useState("");
|
|
2450
|
+
const [message, setMessage] = React.useState(null);
|
|
2454
2451
|
const handleLoginSuccess = (email2, needsOtpVerification) => {
|
|
2455
2452
|
setEmail(email2);
|
|
2456
2453
|
if (needsOtpVerification) {
|
|
@@ -2585,13 +2582,13 @@ var EmailVerificationPage = ({
|
|
|
2585
2582
|
onVerificationError,
|
|
2586
2583
|
baseUrl
|
|
2587
2584
|
}) => {
|
|
2588
|
-
const [isLoading, setIsLoading] =
|
|
2589
|
-
const [message, setMessage] =
|
|
2590
|
-
const [isSuccess, setIsSuccess] =
|
|
2585
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
2586
|
+
const [message, setMessage] = React.useState("");
|
|
2587
|
+
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
2591
2588
|
const { verifyEmailToken } = useAuth2({
|
|
2592
2589
|
baseUrl: baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
|
|
2593
2590
|
});
|
|
2594
|
-
|
|
2591
|
+
React.useEffect(() => {
|
|
2595
2592
|
const verifyEmail = async () => {
|
|
2596
2593
|
if (!token) {
|
|
2597
2594
|
setIsLoading(false);
|
|
@@ -2696,7 +2693,7 @@ var EmailVerificationPage = ({
|
|
|
2696
2693
|
] })
|
|
2697
2694
|
] }) });
|
|
2698
2695
|
};
|
|
2699
|
-
var ThemeWrapper =
|
|
2696
|
+
var ThemeWrapper = React.forwardRef(
|
|
2700
2697
|
({ children, className = "", style }, ref) => {
|
|
2701
2698
|
const { theme, mounted } = useAuthTheme();
|
|
2702
2699
|
if (!mounted) {
|
|
@@ -2709,18 +2706,18 @@ ThemeWrapper.displayName = "ThemeWrapper";
|
|
|
2709
2706
|
var SignIn = ({ redirectUrl, appearance }) => {
|
|
2710
2707
|
const { signIn, isSignedIn, loading: authLoading } = useAuth();
|
|
2711
2708
|
const colors = useThemeColors();
|
|
2712
|
-
const [email, setEmail] =
|
|
2713
|
-
const [phoneNumber, setPhoneNumber] =
|
|
2714
|
-
const [password, setPassword] =
|
|
2715
|
-
const [otp, setOtp] =
|
|
2716
|
-
const [usePassword, setUsePassword] =
|
|
2717
|
-
const [usePhone, setUsePhone] =
|
|
2718
|
-
const [showPassword, setShowPassword] =
|
|
2719
|
-
const [isLoading, setIsLoading] =
|
|
2720
|
-
const [error, setError] =
|
|
2721
|
-
const [needsOtp, setNeedsOtp] =
|
|
2722
|
-
const [success, setSuccess] =
|
|
2723
|
-
|
|
2709
|
+
const [email, setEmail] = React.useState("");
|
|
2710
|
+
const [phoneNumber, setPhoneNumber] = React.useState("");
|
|
2711
|
+
const [password, setPassword] = React.useState("");
|
|
2712
|
+
const [otp, setOtp] = React.useState("");
|
|
2713
|
+
const [usePassword, setUsePassword] = React.useState(false);
|
|
2714
|
+
const [usePhone, setUsePhone] = React.useState(false);
|
|
2715
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
2716
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
2717
|
+
const [error, setError] = React.useState(null);
|
|
2718
|
+
const [needsOtp, setNeedsOtp] = React.useState(false);
|
|
2719
|
+
const [success, setSuccess] = React.useState(null);
|
|
2720
|
+
React.useEffect(() => {
|
|
2724
2721
|
if (isSignedIn && redirectUrl) {
|
|
2725
2722
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
2726
2723
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -3111,16 +3108,16 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
3111
3108
|
var SignUp = ({ redirectUrl, appearance }) => {
|
|
3112
3109
|
const { signUp, isSignedIn } = useAuth();
|
|
3113
3110
|
const colors = useThemeColors();
|
|
3114
|
-
const [name, setName] =
|
|
3115
|
-
const [email, setEmail] =
|
|
3116
|
-
const [phoneNumber, setPhoneNumber] =
|
|
3117
|
-
const [password, setPassword] =
|
|
3118
|
-
const [confirmPassword, setConfirmPassword] =
|
|
3119
|
-
const [showPassword, setShowPassword] =
|
|
3120
|
-
const [isLoading, setIsLoading] =
|
|
3121
|
-
const [error, setError] =
|
|
3122
|
-
const [success, setSuccess] =
|
|
3123
|
-
|
|
3111
|
+
const [name, setName] = React.useState("");
|
|
3112
|
+
const [email, setEmail] = React.useState("");
|
|
3113
|
+
const [phoneNumber, setPhoneNumber] = React.useState("");
|
|
3114
|
+
const [password, setPassword] = React.useState("");
|
|
3115
|
+
const [confirmPassword, setConfirmPassword] = React.useState("");
|
|
3116
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
3117
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
3118
|
+
const [error, setError] = React.useState(null);
|
|
3119
|
+
const [success, setSuccess] = React.useState(null);
|
|
3120
|
+
React.useEffect(() => {
|
|
3124
3121
|
if (isSignedIn && redirectUrl) {
|
|
3125
3122
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
|
|
3126
3123
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -3128,23 +3125,15 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
3128
3125
|
}
|
|
3129
3126
|
}, [isSignedIn, redirectUrl]);
|
|
3130
3127
|
const getPasswordStrength = (pwd, colors2) => {
|
|
3131
|
-
if (!pwd)
|
|
3132
|
-
return { strength: "weak", color: colors2.borderSecondary };
|
|
3128
|
+
if (!pwd) return { strength: "weak", color: colors2.borderSecondary };
|
|
3133
3129
|
let score = 0;
|
|
3134
|
-
if (pwd.length >= 6)
|
|
3135
|
-
|
|
3136
|
-
if (pwd
|
|
3137
|
-
|
|
3138
|
-
if (/[a-
|
|
3139
|
-
|
|
3140
|
-
if (
|
|
3141
|
-
score++;
|
|
3142
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
3143
|
-
score++;
|
|
3144
|
-
if (score <= 2)
|
|
3145
|
-
return { strength: "weak", color: colors2.errorText };
|
|
3146
|
-
if (score <= 3)
|
|
3147
|
-
return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
3130
|
+
if (pwd.length >= 6) score++;
|
|
3131
|
+
if (pwd.length >= 8) score++;
|
|
3132
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
3133
|
+
if (/\d/.test(pwd)) score++;
|
|
3134
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
3135
|
+
if (score <= 2) return { strength: "weak", color: colors2.errorText };
|
|
3136
|
+
if (score <= 3) return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
3148
3137
|
return { strength: "strong", color: colors2.successText };
|
|
3149
3138
|
};
|
|
3150
3139
|
const passwordStrength = getPasswordStrength(password, colors);
|
|
@@ -3165,10 +3154,8 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
3165
3154
|
}
|
|
3166
3155
|
try {
|
|
3167
3156
|
const signUpData = { name, password };
|
|
3168
|
-
if (email)
|
|
3169
|
-
|
|
3170
|
-
if (phoneNumber)
|
|
3171
|
-
signUpData.phoneNumber = phoneNumber;
|
|
3157
|
+
if (email) signUpData.email = email;
|
|
3158
|
+
if (phoneNumber) signUpData.phoneNumber = phoneNumber;
|
|
3172
3159
|
const response = await signUp(signUpData);
|
|
3173
3160
|
if (response.success) {
|
|
3174
3161
|
setSuccess("Registration successful! Please check your email to verify your account.");
|
|
@@ -3484,7 +3471,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
3484
3471
|
};
|
|
3485
3472
|
var SignOut = ({ redirectUrl }) => {
|
|
3486
3473
|
const { signOut } = useAuth();
|
|
3487
|
-
|
|
3474
|
+
React.useEffect(() => {
|
|
3488
3475
|
const performSignOut = async () => {
|
|
3489
3476
|
await signOut();
|
|
3490
3477
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
|
|
@@ -3498,9 +3485,9 @@ var SignOut = ({ redirectUrl }) => {
|
|
|
3498
3485
|
var UserButton = ({ showName = false, appearance }) => {
|
|
3499
3486
|
const { user, signOut } = useAuth();
|
|
3500
3487
|
const colors = useThemeColors();
|
|
3501
|
-
const [isOpen, setIsOpen] =
|
|
3502
|
-
const dropdownRef =
|
|
3503
|
-
|
|
3488
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
3489
|
+
const dropdownRef = React.useRef(null);
|
|
3490
|
+
React.useEffect(() => {
|
|
3504
3491
|
const handleClickOutside = (event) => {
|
|
3505
3492
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
3506
3493
|
setIsOpen(false);
|
|
@@ -3509,8 +3496,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3509
3496
|
document.addEventListener("mousedown", handleClickOutside);
|
|
3510
3497
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
3511
3498
|
}, []);
|
|
3512
|
-
if (!user)
|
|
3513
|
-
return null;
|
|
3499
|
+
if (!user) return null;
|
|
3514
3500
|
const getInitials = (name) => {
|
|
3515
3501
|
return name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
|
|
3516
3502
|
};
|
|
@@ -3544,7 +3530,19 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3544
3530
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
3545
3531
|
},
|
|
3546
3532
|
children: [
|
|
3547
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3533
|
+
user.avatar ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3534
|
+
"img",
|
|
3535
|
+
{
|
|
3536
|
+
src: user.avatar,
|
|
3537
|
+
alt: user.name,
|
|
3538
|
+
style: {
|
|
3539
|
+
width: "36px",
|
|
3540
|
+
height: "36px",
|
|
3541
|
+
borderRadius: "50%",
|
|
3542
|
+
objectFit: "cover"
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
3548
3546
|
width: "36px",
|
|
3549
3547
|
height: "36px",
|
|
3550
3548
|
borderRadius: "50%",
|
|
@@ -3581,7 +3579,19 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3581
3579
|
alignItems: "center",
|
|
3582
3580
|
gap: "12px"
|
|
3583
3581
|
}, children: [
|
|
3584
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3582
|
+
user.avatar ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3583
|
+
"img",
|
|
3584
|
+
{
|
|
3585
|
+
src: user.avatar,
|
|
3586
|
+
alt: user.name,
|
|
3587
|
+
style: {
|
|
3588
|
+
width: "48px",
|
|
3589
|
+
height: "48px",
|
|
3590
|
+
borderRadius: "50%",
|
|
3591
|
+
objectFit: "cover"
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
3585
3595
|
width: "48px",
|
|
3586
3596
|
height: "48px",
|
|
3587
3597
|
borderRadius: "50%",
|
|
@@ -3646,7 +3656,7 @@ var ProtectedRoute = ({
|
|
|
3646
3656
|
redirectTo
|
|
3647
3657
|
}) => {
|
|
3648
3658
|
const { isSignedIn, isLoaded } = useAuth();
|
|
3649
|
-
|
|
3659
|
+
React.useEffect(() => {
|
|
3650
3660
|
if (isLoaded && !isSignedIn) {
|
|
3651
3661
|
const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
|
|
3652
3662
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -3671,7 +3681,7 @@ var PublicRoute = ({
|
|
|
3671
3681
|
redirectTo
|
|
3672
3682
|
}) => {
|
|
3673
3683
|
const { isSignedIn, isLoaded } = useAuth();
|
|
3674
|
-
|
|
3684
|
+
React.useEffect(() => {
|
|
3675
3685
|
if (isLoaded && isSignedIn) {
|
|
3676
3686
|
const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
3677
3687
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -3693,9 +3703,9 @@ var PublicRoute = ({
|
|
|
3693
3703
|
};
|
|
3694
3704
|
var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
3695
3705
|
const { verifyEmailToken } = useAuth();
|
|
3696
|
-
const [status, setStatus] =
|
|
3697
|
-
const [message, setMessage] =
|
|
3698
|
-
|
|
3706
|
+
const [status, setStatus] = React.useState("loading");
|
|
3707
|
+
const [message, setMessage] = React.useState("");
|
|
3708
|
+
React.useEffect(() => {
|
|
3699
3709
|
const verify = async () => {
|
|
3700
3710
|
const verifyToken = token || (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") : null);
|
|
3701
3711
|
if (!verifyToken) {
|
|
@@ -3829,10 +3839,10 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
|
3829
3839
|
};
|
|
3830
3840
|
var ForgotPassword = ({ appearance }) => {
|
|
3831
3841
|
const { forgotPassword } = useAuth();
|
|
3832
|
-
const [email, setEmail] =
|
|
3833
|
-
const [isLoading, setIsLoading] =
|
|
3834
|
-
const [error, setError] =
|
|
3835
|
-
const [success, setSuccess] =
|
|
3842
|
+
const [email, setEmail] = React.useState("");
|
|
3843
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
3844
|
+
const [error, setError] = React.useState(null);
|
|
3845
|
+
const [success, setSuccess] = React.useState(null);
|
|
3836
3846
|
const handleSubmit = async (e) => {
|
|
3837
3847
|
e.preventDefault();
|
|
3838
3848
|
setIsLoading(true);
|
|
@@ -3971,14 +3981,14 @@ var ForgotPassword = ({ appearance }) => {
|
|
|
3971
3981
|
};
|
|
3972
3982
|
var ResetPassword = ({ token, appearance }) => {
|
|
3973
3983
|
const { resetPassword } = useAuth();
|
|
3974
|
-
const [resetToken, setResetToken] =
|
|
3975
|
-
const [password, setPassword] =
|
|
3976
|
-
const [confirmPassword, setConfirmPassword] =
|
|
3977
|
-
const [showPassword, setShowPassword] =
|
|
3978
|
-
const [isLoading, setIsLoading] =
|
|
3979
|
-
const [error, setError] =
|
|
3980
|
-
const [success, setSuccess] =
|
|
3981
|
-
|
|
3984
|
+
const [resetToken, setResetToken] = React.useState(token || "");
|
|
3985
|
+
const [password, setPassword] = React.useState("");
|
|
3986
|
+
const [confirmPassword, setConfirmPassword] = React.useState("");
|
|
3987
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
3988
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
3989
|
+
const [error, setError] = React.useState(null);
|
|
3990
|
+
const [success, setSuccess] = React.useState(false);
|
|
3991
|
+
React.useEffect(() => {
|
|
3982
3992
|
if (!resetToken && typeof window !== "undefined") {
|
|
3983
3993
|
const urlToken = new URLSearchParams(window.location.search).get("token");
|
|
3984
3994
|
if (urlToken) {
|
|
@@ -3987,23 +3997,15 @@ var ResetPassword = ({ token, appearance }) => {
|
|
|
3987
3997
|
}
|
|
3988
3998
|
}, [resetToken]);
|
|
3989
3999
|
const getPasswordStrength = (pwd) => {
|
|
3990
|
-
if (!pwd)
|
|
3991
|
-
return { strength: "weak", color: "#ddd" };
|
|
4000
|
+
if (!pwd) return { strength: "weak", color: "#ddd" };
|
|
3992
4001
|
let score = 0;
|
|
3993
|
-
if (pwd.length >= 6)
|
|
3994
|
-
|
|
3995
|
-
if (pwd
|
|
3996
|
-
|
|
3997
|
-
if (/[a-
|
|
3998
|
-
|
|
3999
|
-
if (
|
|
4000
|
-
score++;
|
|
4001
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
4002
|
-
score++;
|
|
4003
|
-
if (score <= 2)
|
|
4004
|
-
return { strength: "weak", color: "#f44" };
|
|
4005
|
-
if (score <= 3)
|
|
4006
|
-
return { strength: "medium", color: "#fa4" };
|
|
4002
|
+
if (pwd.length >= 6) score++;
|
|
4003
|
+
if (pwd.length >= 8) score++;
|
|
4004
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
4005
|
+
if (/\d/.test(pwd)) score++;
|
|
4006
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
4007
|
+
if (score <= 2) return { strength: "weak", color: "#f44" };
|
|
4008
|
+
if (score <= 3) return { strength: "medium", color: "#fa4" };
|
|
4007
4009
|
return { strength: "strong", color: "#4f4" };
|
|
4008
4010
|
};
|
|
4009
4011
|
const passwordStrength = getPasswordStrength(password);
|
|
@@ -4233,31 +4235,23 @@ var ResetPassword = ({ token, appearance }) => {
|
|
|
4233
4235
|
};
|
|
4234
4236
|
var ChangePassword = ({ onSuccess, appearance }) => {
|
|
4235
4237
|
const { changePassword } = useAuth();
|
|
4236
|
-
const [oldPassword, setOldPassword] =
|
|
4237
|
-
const [newPassword, setNewPassword] =
|
|
4238
|
-
const [confirmPassword, setConfirmPassword] =
|
|
4239
|
-
const [showPasswords, setShowPasswords] =
|
|
4240
|
-
const [isLoading, setIsLoading] =
|
|
4241
|
-
const [error, setError] =
|
|
4242
|
-
const [success, setSuccess] =
|
|
4238
|
+
const [oldPassword, setOldPassword] = React.useState("");
|
|
4239
|
+
const [newPassword, setNewPassword] = React.useState("");
|
|
4240
|
+
const [confirmPassword, setConfirmPassword] = React.useState("");
|
|
4241
|
+
const [showPasswords, setShowPasswords] = React.useState(false);
|
|
4242
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
4243
|
+
const [error, setError] = React.useState(null);
|
|
4244
|
+
const [success, setSuccess] = React.useState(false);
|
|
4243
4245
|
const getPasswordStrength = (pwd) => {
|
|
4244
|
-
if (!pwd)
|
|
4245
|
-
return { strength: "weak", color: "#ddd" };
|
|
4246
|
+
if (!pwd) return { strength: "weak", color: "#ddd" };
|
|
4246
4247
|
let score = 0;
|
|
4247
|
-
if (pwd.length >= 6)
|
|
4248
|
-
|
|
4249
|
-
if (pwd
|
|
4250
|
-
|
|
4251
|
-
if (/[a-
|
|
4252
|
-
|
|
4253
|
-
if (
|
|
4254
|
-
score++;
|
|
4255
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
4256
|
-
score++;
|
|
4257
|
-
if (score <= 2)
|
|
4258
|
-
return { strength: "weak", color: "#f44" };
|
|
4259
|
-
if (score <= 3)
|
|
4260
|
-
return { strength: "medium", color: "#fa4" };
|
|
4248
|
+
if (pwd.length >= 6) score++;
|
|
4249
|
+
if (pwd.length >= 8) score++;
|
|
4250
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
4251
|
+
if (/\d/.test(pwd)) score++;
|
|
4252
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
4253
|
+
if (score <= 2) return { strength: "weak", color: "#f44" };
|
|
4254
|
+
if (score <= 3) return { strength: "medium", color: "#fa4" };
|
|
4261
4255
|
return { strength: "strong", color: "#4f4" };
|
|
4262
4256
|
};
|
|
4263
4257
|
const passwordStrength = getPasswordStrength(newPassword);
|
|
@@ -4488,31 +4482,21 @@ var AvatarUploader = ({
|
|
|
4488
4482
|
buttonText = "Upload Avatar"
|
|
4489
4483
|
}) => {
|
|
4490
4484
|
const { uploadAndUpdateAvatar } = useAuth();
|
|
4491
|
-
const [open, setOpen] =
|
|
4492
|
-
const [uploading, setUploading] =
|
|
4485
|
+
const [open, setOpen] = React.useState(false);
|
|
4486
|
+
const [uploading, setUploading] = React.useState(false);
|
|
4493
4487
|
const handleSelect = async (image) => {
|
|
4494
4488
|
setUploading(true);
|
|
4495
4489
|
try {
|
|
4496
|
-
const
|
|
4497
|
-
const response = await
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
} : {}
|
|
4501
|
-
});
|
|
4502
|
-
if (!response.ok) {
|
|
4503
|
-
throw new Error("Failed to fetch image");
|
|
4504
|
-
}
|
|
4505
|
-
const blob = await response.blob();
|
|
4506
|
-
const file = new File([blob], image.originalName, { type: image.contentType });
|
|
4507
|
-
const result = await uploadAndUpdateAvatar(file);
|
|
4508
|
-
if (result.success && result.user?.avatar) {
|
|
4509
|
-
onUploadComplete?.(result.user.avatar);
|
|
4490
|
+
const { updateProfile } = useAuth();
|
|
4491
|
+
const response = await updateProfile({ avatar: image.url });
|
|
4492
|
+
if (response.success && response.user?.avatar) {
|
|
4493
|
+
onUploadComplete?.(response.user.avatar);
|
|
4510
4494
|
setOpen(false);
|
|
4511
4495
|
} else {
|
|
4512
|
-
throw new Error(
|
|
4496
|
+
throw new Error(response.message || "Failed to update avatar");
|
|
4513
4497
|
}
|
|
4514
4498
|
} catch (error) {
|
|
4515
|
-
const err = error instanceof Error ? error : new Error("
|
|
4499
|
+
const err = error instanceof Error ? error : new Error("Failed to update avatar");
|
|
4516
4500
|
onError?.(err);
|
|
4517
4501
|
} finally {
|
|
4518
4502
|
setUploading(false);
|
|
@@ -4563,12 +4547,12 @@ var UserProfile = ({
|
|
|
4563
4547
|
}) => {
|
|
4564
4548
|
const { user, updateProfile, requestEmailChange } = useAuth();
|
|
4565
4549
|
const colors = useThemeColors();
|
|
4566
|
-
const [name, setName] =
|
|
4567
|
-
const [phoneNumber, setPhoneNumber] =
|
|
4568
|
-
const [newEmail, setNewEmail] =
|
|
4569
|
-
const [isLoading, setIsLoading] =
|
|
4570
|
-
const [error, setError] =
|
|
4571
|
-
const [success, setSuccess] =
|
|
4550
|
+
const [name, setName] = React.useState(user?.name || "");
|
|
4551
|
+
const [phoneNumber, setPhoneNumber] = React.useState(user?.phoneNumber || "");
|
|
4552
|
+
const [newEmail, setNewEmail] = React.useState("");
|
|
4553
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
4554
|
+
const [error, setError] = React.useState(null);
|
|
4555
|
+
const [success, setSuccess] = React.useState(null);
|
|
4572
4556
|
const handleUpdateProfile = async (e) => {
|
|
4573
4557
|
e.preventDefault();
|
|
4574
4558
|
setIsLoading(true);
|
|
@@ -4625,8 +4609,7 @@ var UserProfile = ({
|
|
|
4625
4609
|
setIsLoading(false);
|
|
4626
4610
|
}
|
|
4627
4611
|
};
|
|
4628
|
-
if (!user)
|
|
4629
|
-
return null;
|
|
4612
|
+
if (!user) return null;
|
|
4630
4613
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
|
|
4631
4614
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
|
|
4632
4615
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
@@ -4860,12 +4843,18 @@ var AvatarManager = ({
|
|
|
4860
4843
|
gridClassName,
|
|
4861
4844
|
maxFileSize = 5 * 1024 * 1024,
|
|
4862
4845
|
// 5MB default
|
|
4846
|
+
maxFiles = 10,
|
|
4863
4847
|
mode = "full",
|
|
4864
4848
|
showDelete = false,
|
|
4849
|
+
autoRecordToDb = true,
|
|
4850
|
+
fetchThumbnails = true,
|
|
4851
|
+
projectId,
|
|
4852
|
+
deleteUrl,
|
|
4853
|
+
onDelete,
|
|
4865
4854
|
upfilesConfig
|
|
4866
4855
|
}) => {
|
|
4867
4856
|
const { updateProfile } = useAuth();
|
|
4868
|
-
const [updating, setUpdating] =
|
|
4857
|
+
const [updating, setUpdating] = React.useState(false);
|
|
4869
4858
|
const handleSelect = async (image) => {
|
|
4870
4859
|
setUpdating(true);
|
|
4871
4860
|
try {
|
|
@@ -4893,18 +4882,25 @@ var AvatarManager = ({
|
|
|
4893
4882
|
apiKey: upfilesConfig.apiKey,
|
|
4894
4883
|
apiKeyHeader: upfilesConfig.apiKeyHeader || "authorization",
|
|
4895
4884
|
presignUrl: upfilesConfig.presignUrl,
|
|
4896
|
-
presignPath: upfilesConfig.presignPath
|
|
4885
|
+
presignPath: upfilesConfig.presignPath,
|
|
4886
|
+
headers: upfilesConfig.headers,
|
|
4887
|
+
withCredentials: upfilesConfig.withCredentials
|
|
4897
4888
|
},
|
|
4898
|
-
|
|
4889
|
+
projectId,
|
|
4890
|
+
folderPath: upfilesConfig.folderPath || "/",
|
|
4899
4891
|
title,
|
|
4900
4892
|
description,
|
|
4901
4893
|
className,
|
|
4902
4894
|
gridClassName,
|
|
4903
4895
|
onSelect: handleSelect,
|
|
4896
|
+
onDelete,
|
|
4897
|
+
deleteUrl,
|
|
4898
|
+
autoRecordToDb,
|
|
4899
|
+
fetchThumbnails,
|
|
4904
4900
|
maxFileSize,
|
|
4901
|
+
maxFiles,
|
|
4905
4902
|
mode,
|
|
4906
|
-
showDelete
|
|
4907
|
-
fetchThumbnails: true
|
|
4903
|
+
showDelete
|
|
4908
4904
|
}
|
|
4909
4905
|
);
|
|
4910
4906
|
};
|
|
@@ -5022,23 +5018,23 @@ var AuthClient = class extends AuthService {
|
|
|
5022
5018
|
}
|
|
5023
5019
|
};
|
|
5024
5020
|
|
|
5025
|
-
Object.defineProperty(exports,
|
|
5021
|
+
Object.defineProperty(exports, "ConnectProjectDialog", {
|
|
5026
5022
|
enumerable: true,
|
|
5027
5023
|
get: function () { return upfiles.ConnectProjectDialog; }
|
|
5028
5024
|
});
|
|
5029
|
-
Object.defineProperty(exports,
|
|
5025
|
+
Object.defineProperty(exports, "ImageManager", {
|
|
5030
5026
|
enumerable: true,
|
|
5031
5027
|
get: function () { return upfiles.ImageManager; }
|
|
5032
5028
|
});
|
|
5033
|
-
Object.defineProperty(exports,
|
|
5029
|
+
Object.defineProperty(exports, "ProjectFilesWidget", {
|
|
5034
5030
|
enumerable: true,
|
|
5035
5031
|
get: function () { return upfiles.ProjectFilesWidget; }
|
|
5036
5032
|
});
|
|
5037
|
-
Object.defineProperty(exports,
|
|
5033
|
+
Object.defineProperty(exports, "UpfilesClient", {
|
|
5038
5034
|
enumerable: true,
|
|
5039
5035
|
get: function () { return upfiles.UpfilesClient; }
|
|
5040
5036
|
});
|
|
5041
|
-
Object.defineProperty(exports,
|
|
5037
|
+
Object.defineProperty(exports, "Uploader", {
|
|
5042
5038
|
enumerable: true,
|
|
5043
5039
|
get: function () { return upfiles.Uploader; }
|
|
5044
5040
|
});
|
|
@@ -5066,5 +5062,5 @@ exports.VerifyEmail = VerifyEmail;
|
|
|
5066
5062
|
exports.node = node_exports;
|
|
5067
5063
|
exports.react = react_exports;
|
|
5068
5064
|
exports.useAuth = useAuth;
|
|
5069
|
-
//# sourceMappingURL=
|
|
5065
|
+
//# sourceMappingURL=index.js.map
|
|
5070
5066
|
//# sourceMappingURL=index.js.map
|