@thetechfossil/auth2 1.2.15 → 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.
@@ -3,13 +3,13 @@
3
3
 
4
4
  var axios = require('axios');
5
5
  var upfiles = require('@thetechfossil/upfiles');
6
- var React3 = require('react');
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 React3__default = /*#__PURE__*/_interopDefault(React3);
12
+ var React__default = /*#__PURE__*/_interopDefault(React);
13
13
 
14
14
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
15
15
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -69,6 +69,11 @@ var HttpClient = class {
69
69
  return Promise.reject(refreshError);
70
70
  }
71
71
  }
72
+ if (error.response && error.response.data && error.response.data.message) {
73
+ const customError = new Error(error.response.data.message);
74
+ customError.response = error.response;
75
+ return Promise.reject(customError);
76
+ }
72
77
  return Promise.reject(error);
73
78
  }
74
79
  );
@@ -506,11 +511,11 @@ var AuthService = class {
506
511
  }
507
512
  };
508
513
  var useAuth = (config) => {
509
- const [authService] = React3.useState(() => new AuthService(config));
510
- const [user, setUser] = React3.useState(null);
511
- const [isAuthenticated, setIsAuthenticated] = React3.useState(false);
512
- const [loading, setLoading] = React3.useState(true);
513
- const checkAuthStatus = React3.useCallback(() => {
514
+ const [authService] = React.useState(() => new AuthService(config));
515
+ const [user, setUser] = React.useState(null);
516
+ const [isAuthenticated, setIsAuthenticated] = React.useState(false);
517
+ const [loading, setLoading] = React.useState(true);
518
+ const checkAuthStatus = React.useCallback(() => {
514
519
  const authenticated = authService.isAuthenticated();
515
520
  setIsAuthenticated(authenticated);
516
521
  if (authenticated) {
@@ -521,10 +526,10 @@ var useAuth = (config) => {
521
526
  }
522
527
  setLoading(false);
523
528
  }, [authService]);
524
- React3.useEffect(() => {
529
+ React.useEffect(() => {
525
530
  checkAuthStatus();
526
531
  }, [checkAuthStatus]);
527
- const register = React3.useCallback(async (data) => {
532
+ const register = React.useCallback(async (data) => {
528
533
  setLoading(true);
529
534
  try {
530
535
  const response = await authService.register(data);
@@ -533,7 +538,7 @@ var useAuth = (config) => {
533
538
  setLoading(false);
534
539
  }
535
540
  }, [authService]);
536
- const login = React3.useCallback(async (data) => {
541
+ const login = React.useCallback(async (data) => {
537
542
  setLoading(true);
538
543
  try {
539
544
  const response = await authService.login(data);
@@ -546,7 +551,7 @@ var useAuth = (config) => {
546
551
  setLoading(false);
547
552
  }
548
553
  }, [authService]);
549
- const verify = React3.useCallback(async (data) => {
554
+ const verify = React.useCallback(async (data) => {
550
555
  setLoading(true);
551
556
  try {
552
557
  const response = await authService.verify(data);
@@ -559,7 +564,7 @@ var useAuth = (config) => {
559
564
  setLoading(false);
560
565
  }
561
566
  }, [authService]);
562
- const verifyEmailToken = React3.useCallback(async (token) => {
567
+ const verifyEmailToken = React.useCallback(async (token) => {
563
568
  setLoading(true);
564
569
  try {
565
570
  const response = await authService.verifyEmailToken(token);
@@ -572,7 +577,7 @@ var useAuth = (config) => {
572
577
  setLoading(false);
573
578
  }
574
579
  }, [authService]);
575
- const logout = React3.useCallback(async () => {
580
+ const logout = React.useCallback(async () => {
576
581
  setLoading(true);
577
582
  try {
578
583
  await authService.logout();
@@ -582,7 +587,7 @@ var useAuth = (config) => {
582
587
  setLoading(false);
583
588
  }
584
589
  }, [authService]);
585
- const updateProfile = React3.useCallback(async (data) => {
590
+ const updateProfile = React.useCallback(async (data) => {
586
591
  setLoading(true);
587
592
  try {
588
593
  const response = await authService.updateProfile(data);
@@ -594,7 +599,7 @@ var useAuth = (config) => {
594
599
  setLoading(false);
595
600
  }
596
601
  }, [authService]);
597
- const getProfile = React3.useCallback(async () => {
602
+ const getProfile = React.useCallback(async () => {
598
603
  setLoading(true);
599
604
  try {
600
605
  const userData = await authService.getProfile();
@@ -604,7 +609,7 @@ var useAuth = (config) => {
604
609
  setLoading(false);
605
610
  }
606
611
  }, [authService]);
607
- const getAllUsers = React3.useCallback(async () => {
612
+ const getAllUsers = React.useCallback(async () => {
608
613
  setLoading(true);
609
614
  try {
610
615
  return await authService.getAllUsers();
@@ -612,7 +617,7 @@ var useAuth = (config) => {
612
617
  setLoading(false);
613
618
  }
614
619
  }, [authService]);
615
- const getUserById = React3.useCallback(async (id) => {
620
+ const getUserById = React.useCallback(async (id) => {
616
621
  setLoading(true);
617
622
  try {
618
623
  return await authService.getUserById(id);
@@ -620,7 +625,7 @@ var useAuth = (config) => {
620
625
  setLoading(false);
621
626
  }
622
627
  }, [authService]);
623
- const uploadAndUpdateAvatar = React3.useCallback(async (file) => {
628
+ const uploadAndUpdateAvatar = React.useCallback(async (file) => {
624
629
  setLoading(true);
625
630
  try {
626
631
  const response = await authService.uploadAndUpdateAvatar(file);
@@ -648,11 +653,11 @@ var useAuth = (config) => {
648
653
  uploadAndUpdateAvatar
649
654
  };
650
655
  };
651
- var ThemeContext = React3.createContext({ theme: "light", mounted: false });
656
+ var ThemeContext = React__default.default.createContext({ theme: "light", mounted: false });
652
657
  function AuthThemeProvider({ children }) {
653
- const [theme, setTheme] = React3.useState("light");
654
- const [mounted, setMounted] = React3.useState(false);
655
- React3.useEffect(() => {
658
+ const [theme, setTheme] = React.useState("light");
659
+ const [mounted, setMounted] = React.useState(false);
660
+ React.useEffect(() => {
656
661
  const detectTheme = () => {
657
662
  const htmlElement = document.documentElement;
658
663
  const bodyElement = document.body;
@@ -697,9 +702,9 @@ function AuthThemeProvider({ children }) {
697
702
  return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: { theme, mounted }, children });
698
703
  }
699
704
  function useAuthTheme() {
700
- return React3.useContext(ThemeContext);
705
+ return React.useContext(ThemeContext);
701
706
  }
702
- var AuthContext = React3.createContext(void 0);
707
+ var AuthContext = React.createContext(void 0);
703
708
  var AuthProvider = ({ children, config }) => {
704
709
  const authConfig = {
705
710
  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"),
@@ -707,29 +712,35 @@ var AuthProvider = ({ children, config }) => {
707
712
  csrfEnabled: config?.csrfEnabled !== void 0 ? config.csrfEnabled : true,
708
713
  upfilesConfig: config?.upfilesConfig
709
714
  };
710
- const [authService] = React3.useState(() => new AuthService(authConfig));
711
- const [user, setUser] = React3.useState(null);
712
- const [isLoaded, setIsLoaded] = React3.useState(false);
713
- const [loading, setLoading] = React3.useState(false);
714
- const checkAuthStatus = React3.useCallback(async () => {
715
+ const [authService] = React.useState(() => new AuthService(authConfig));
716
+ const [user, setUser] = React.useState(null);
717
+ const [isLoaded, setIsLoaded] = React.useState(false);
718
+ const [loading, setLoading] = React.useState(false);
719
+ const checkAuthStatus = React.useCallback(async () => {
715
720
  const authenticated = authService.isAuthenticated();
716
721
  if (authenticated) {
717
722
  try {
718
- const currentUser = authService.getCurrentUser();
719
- setUser(currentUser);
723
+ const freshUser = await authService.getProfile();
724
+ setUser(freshUser);
720
725
  } catch (error) {
721
- console.error("Failed to get current user:", error);
722
- setUser(null);
726
+ console.error("Failed to fetch fresh user profile, falling back to token:", error);
727
+ try {
728
+ const currentUser = authService.getCurrentUser();
729
+ setUser(currentUser);
730
+ } catch (fallbackError) {
731
+ console.error("Failed to get current user from token:", fallbackError);
732
+ setUser(null);
733
+ }
723
734
  }
724
735
  } else {
725
736
  setUser(null);
726
737
  }
727
738
  setIsLoaded(true);
728
739
  }, [authService]);
729
- React3.useEffect(() => {
740
+ React.useEffect(() => {
730
741
  checkAuthStatus();
731
742
  }, [checkAuthStatus]);
732
- const signIn = React3.useCallback(async (data) => {
743
+ const signIn = React.useCallback(async (data) => {
733
744
  setLoading(true);
734
745
  try {
735
746
  const response = await authService.login(data);
@@ -741,7 +752,7 @@ var AuthProvider = ({ children, config }) => {
741
752
  setLoading(false);
742
753
  }
743
754
  }, [authService]);
744
- const signUp = React3.useCallback(async (data) => {
755
+ const signUp = React.useCallback(async (data) => {
745
756
  setLoading(true);
746
757
  try {
747
758
  const response = await authService.register(data);
@@ -750,7 +761,7 @@ var AuthProvider = ({ children, config }) => {
750
761
  setLoading(false);
751
762
  }
752
763
  }, [authService]);
753
- const signOut = React3.useCallback(async () => {
764
+ const signOut = React.useCallback(async () => {
754
765
  setLoading(true);
755
766
  try {
756
767
  await authService.logout();
@@ -759,7 +770,7 @@ var AuthProvider = ({ children, config }) => {
759
770
  setLoading(false);
760
771
  }
761
772
  }, [authService]);
762
- const verify = React3.useCallback(async (data) => {
773
+ const verify = React.useCallback(async (data) => {
763
774
  setLoading(true);
764
775
  try {
765
776
  const response = await authService.verify(data);
@@ -771,7 +782,7 @@ var AuthProvider = ({ children, config }) => {
771
782
  setLoading(false);
772
783
  }
773
784
  }, [authService]);
774
- const verifyEmailToken = React3.useCallback(async (token) => {
785
+ const verifyEmailToken = React.useCallback(async (token) => {
775
786
  setLoading(true);
776
787
  try {
777
788
  const response = await authService.verifyEmailToken(token);
@@ -783,7 +794,7 @@ var AuthProvider = ({ children, config }) => {
783
794
  setLoading(false);
784
795
  }
785
796
  }, [authService]);
786
- const updateProfile = React3.useCallback(async (data) => {
797
+ const updateProfile = React.useCallback(async (data) => {
787
798
  setLoading(true);
788
799
  try {
789
800
  const response = await authService.updateProfile(data);
@@ -795,7 +806,7 @@ var AuthProvider = ({ children, config }) => {
795
806
  setLoading(false);
796
807
  }
797
808
  }, [authService]);
798
- const getProfile = React3.useCallback(async () => {
809
+ const getProfile = React.useCallback(async () => {
799
810
  setLoading(true);
800
811
  try {
801
812
  const userData = await authService.getProfile();
@@ -805,13 +816,13 @@ var AuthProvider = ({ children, config }) => {
805
816
  setLoading(false);
806
817
  }
807
818
  }, [authService]);
808
- const signInWithOAuth = React3.useCallback((provider) => {
819
+ const signInWithOAuth = React.useCallback((provider) => {
809
820
  authService.loginWithOAuth(provider);
810
821
  }, [authService]);
811
- const linkOAuthProvider = React3.useCallback((provider) => {
822
+ const linkOAuthProvider = React.useCallback((provider) => {
812
823
  authService.linkOAuthProvider(provider);
813
824
  }, [authService]);
814
- const unlinkOAuthProvider = React3.useCallback(async (provider) => {
825
+ const unlinkOAuthProvider = React.useCallback(async (provider) => {
815
826
  setLoading(true);
816
827
  try {
817
828
  return await authService.unlinkOAuthProvider(provider);
@@ -819,7 +830,7 @@ var AuthProvider = ({ children, config }) => {
819
830
  setLoading(false);
820
831
  }
821
832
  }, [authService]);
822
- const forgotPassword = React3.useCallback(async (email) => {
833
+ const forgotPassword = React.useCallback(async (email) => {
823
834
  setLoading(true);
824
835
  try {
825
836
  return await authService.forgotPassword(email);
@@ -827,7 +838,7 @@ var AuthProvider = ({ children, config }) => {
827
838
  setLoading(false);
828
839
  }
829
840
  }, [authService]);
830
- const resetPassword = React3.useCallback(async (token, password) => {
841
+ const resetPassword = React.useCallback(async (token, password) => {
831
842
  setLoading(true);
832
843
  try {
833
844
  return await authService.resetPassword(token, password);
@@ -835,7 +846,7 @@ var AuthProvider = ({ children, config }) => {
835
846
  setLoading(false);
836
847
  }
837
848
  }, [authService]);
838
- const changePassword = React3.useCallback(async (oldPassword, newPassword) => {
849
+ const changePassword = React.useCallback(async (oldPassword, newPassword) => {
839
850
  setLoading(true);
840
851
  try {
841
852
  return await authService.changePassword(oldPassword, newPassword);
@@ -843,7 +854,7 @@ var AuthProvider = ({ children, config }) => {
843
854
  setLoading(false);
844
855
  }
845
856
  }, [authService]);
846
- const updateAvatar = React3.useCallback(async (avatar) => {
857
+ const updateAvatar = React.useCallback(async (avatar) => {
847
858
  setLoading(true);
848
859
  try {
849
860
  const response = await authService.updateAvatar(avatar);
@@ -855,7 +866,7 @@ var AuthProvider = ({ children, config }) => {
855
866
  setLoading(false);
856
867
  }
857
868
  }, [authService]);
858
- const uploadAndUpdateAvatar = React3.useCallback(async (file) => {
869
+ const uploadAndUpdateAvatar = React.useCallback(async (file) => {
859
870
  setLoading(true);
860
871
  try {
861
872
  const response = await authService.uploadAndUpdateAvatar(file);
@@ -867,7 +878,7 @@ var AuthProvider = ({ children, config }) => {
867
878
  setLoading(false);
868
879
  }
869
880
  }, [authService]);
870
- const requestEmailChange = React3.useCallback(async (newEmail) => {
881
+ const requestEmailChange = React.useCallback(async (newEmail) => {
871
882
  setLoading(true);
872
883
  try {
873
884
  return await authService.requestEmailChange(newEmail);
@@ -875,7 +886,7 @@ var AuthProvider = ({ children, config }) => {
875
886
  setLoading(false);
876
887
  }
877
888
  }, [authService]);
878
- const verifyEmailChange = React3.useCallback(async (token) => {
889
+ const verifyEmailChange = React.useCallback(async (token) => {
879
890
  setLoading(true);
880
891
  try {
881
892
  const response = await authService.verifyEmailChange(token);
@@ -887,7 +898,7 @@ var AuthProvider = ({ children, config }) => {
887
898
  setLoading(false);
888
899
  }
889
900
  }, [authService]);
890
- const generate2FA = React3.useCallback(async () => {
901
+ const generate2FA = React.useCallback(async () => {
891
902
  setLoading(true);
892
903
  try {
893
904
  return await authService.generate2FA();
@@ -895,7 +906,7 @@ var AuthProvider = ({ children, config }) => {
895
906
  setLoading(false);
896
907
  }
897
908
  }, [authService]);
898
- const enable2FA = React3.useCallback(async (token) => {
909
+ const enable2FA = React.useCallback(async (token) => {
899
910
  setLoading(true);
900
911
  try {
901
912
  return await authService.enable2FA(token);
@@ -903,7 +914,7 @@ var AuthProvider = ({ children, config }) => {
903
914
  setLoading(false);
904
915
  }
905
916
  }, [authService]);
906
- const disable2FA = React3.useCallback(async (token) => {
917
+ const disable2FA = React.useCallback(async (token) => {
907
918
  setLoading(true);
908
919
  try {
909
920
  return await authService.disable2FA(token);
@@ -911,7 +922,7 @@ var AuthProvider = ({ children, config }) => {
911
922
  setLoading(false);
912
923
  }
913
924
  }, [authService]);
914
- const validate2FA = React3.useCallback(async (token) => {
925
+ const validate2FA = React.useCallback(async (token) => {
915
926
  setLoading(true);
916
927
  try {
917
928
  return await authService.validate2FA(token);
@@ -919,7 +930,7 @@ var AuthProvider = ({ children, config }) => {
919
930
  setLoading(false);
920
931
  }
921
932
  }, [authService]);
922
- const getSessions = React3.useCallback(async () => {
933
+ const getSessions = React.useCallback(async () => {
923
934
  setLoading(true);
924
935
  try {
925
936
  return await authService.getSessions();
@@ -927,7 +938,7 @@ var AuthProvider = ({ children, config }) => {
927
938
  setLoading(false);
928
939
  }
929
940
  }, [authService]);
930
- const revokeSession = React3.useCallback(async (sessionId) => {
941
+ const revokeSession = React.useCallback(async (sessionId) => {
931
942
  setLoading(true);
932
943
  try {
933
944
  return await authService.revokeSession(sessionId);
@@ -935,7 +946,7 @@ var AuthProvider = ({ children, config }) => {
935
946
  setLoading(false);
936
947
  }
937
948
  }, [authService]);
938
- const revokeAllSessions = React3.useCallback(async () => {
949
+ const revokeAllSessions = React.useCallback(async () => {
939
950
  setLoading(true);
940
951
  try {
941
952
  const response = await authService.revokeAllSessions();
@@ -979,7 +990,7 @@ var AuthProvider = ({ children, config }) => {
979
990
  return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(AuthThemeProvider, { children }) });
980
991
  };
981
992
  var useAuth2 = () => {
982
- const context = React3.useContext(AuthContext);
993
+ const context = React.useContext(AuthContext);
983
994
  if (context === void 0) {
984
995
  throw new Error("useAuth must be used within an AuthProvider");
985
996
  }
@@ -1035,7 +1046,7 @@ try {
1035
1046
  } catch (error) {
1036
1047
  console.warn("react-phone-number-input not available, using fallback");
1037
1048
  }
1038
- var CustomPhoneInput = React3__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1049
+ var CustomPhoneInput = React__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1039
1050
  "input",
1040
1051
  {
1041
1052
  ...props,
@@ -1054,8 +1065,8 @@ var PhoneInput = ({
1054
1065
  style = {}
1055
1066
  }) => {
1056
1067
  const colors = useThemeColors();
1057
- const [defaultCountry, setDefaultCountry] = React3.useState("US");
1058
- const styleContent = React3.useMemo(() => `
1068
+ const [defaultCountry, setDefaultCountry] = React.useState("US");
1069
+ const styleContent = React.useMemo(() => `
1059
1070
  .PhoneInput {
1060
1071
  display: flex;
1061
1072
  align-items: center;
@@ -1167,7 +1178,7 @@ var PhoneInput = ({
1167
1178
  opacity: 0.6;
1168
1179
  }
1169
1180
  `, [colors]);
1170
- React3.useEffect(() => {
1181
+ React.useEffect(() => {
1171
1182
  const detectCountry = async () => {
1172
1183
  try {
1173
1184
  const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
@@ -1224,7 +1235,7 @@ var PhoneInput = ({
1224
1235
  };
1225
1236
  detectCountry();
1226
1237
  }, []);
1227
- const handleChange = React3.useMemo(() => (val) => {
1238
+ const handleChange = React.useMemo(() => (val) => {
1228
1239
  onChange(val || "");
1229
1240
  }, [onChange]);
1230
1241
  if (!PhoneInputWithCountry) {
@@ -1288,15 +1299,15 @@ var LoginForm = ({
1288
1299
  showOAuthButtons = true
1289
1300
  }) => {
1290
1301
  const colors = useThemeColors();
1291
- const [email, setEmail] = React3.useState("");
1292
- const [phoneNumber, setPhoneNumber] = React3.useState("");
1293
- const [usePhone, setUsePhone] = React3.useState(false);
1294
- const [password, setPassword] = React3.useState("");
1295
- const [usePassword, setUsePassword] = React3.useState(false);
1296
- const [showPassword, setShowPassword] = React3.useState(false);
1297
- const [isLoading, setIsLoading] = React3.useState(false);
1298
- const [error, setError] = React3.useState(null);
1299
- const [rememberMe, setRememberMe] = React3.useState(false);
1302
+ const [email, setEmail] = React.useState("");
1303
+ const [phoneNumber, setPhoneNumber] = React.useState("");
1304
+ const [usePhone, setUsePhone] = React.useState(false);
1305
+ const [password, setPassword] = React.useState("");
1306
+ const [usePassword, setUsePassword] = React.useState(false);
1307
+ const [showPassword, setShowPassword] = React.useState(false);
1308
+ const [isLoading, setIsLoading] = React.useState(false);
1309
+ const [error, setError] = React.useState(null);
1310
+ const [rememberMe, setRememberMe] = React.useState(false);
1300
1311
  const { login } = useAuth({
1301
1312
  baseUrl: config?.baseUrl || "http://localhost:7000"
1302
1313
  });
@@ -1750,15 +1761,15 @@ var RegisterForm = ({
1750
1761
  invitationToken
1751
1762
  }) => {
1752
1763
  const colors = useThemeColors();
1753
- const [name, setName] = React3.useState("");
1754
- const [email, setEmail] = React3.useState("");
1755
- const [phoneNumber, setPhoneNumber] = React3.useState("");
1756
- const [password, setPassword] = React3.useState("");
1757
- const [confirmPassword, setConfirmPassword] = React3.useState("");
1758
- const [isLoading, setIsLoading] = React3.useState(false);
1759
- const [error, setError] = React3.useState(null);
1760
- const [showPassword, setShowPassword] = React3.useState(false);
1761
- const [showConfirmPassword, setShowConfirmPassword] = React3.useState(false);
1764
+ const [name, setName] = React.useState("");
1765
+ const [email, setEmail] = React.useState("");
1766
+ const [phoneNumber, setPhoneNumber] = React.useState("");
1767
+ const [password, setPassword] = React.useState("");
1768
+ const [confirmPassword, setConfirmPassword] = React.useState("");
1769
+ const [isLoading, setIsLoading] = React.useState(false);
1770
+ const [error, setError] = React.useState(null);
1771
+ const [showPassword, setShowPassword] = React.useState(false);
1772
+ const [showConfirmPassword, setShowConfirmPassword] = React.useState(false);
1762
1773
  const getPasswordStrength = (pwd) => {
1763
1774
  if (!pwd) return { strength: "weak", score: 0, label: "" };
1764
1775
  let score = 0;
@@ -2214,11 +2225,11 @@ var OtpForm = ({
2214
2225
  baseUrl
2215
2226
  }) => {
2216
2227
  const colors = useThemeColors();
2217
- const [otp, setOtp] = React3.useState("");
2218
- const [isLoading, setIsLoading] = React3.useState(false);
2219
- const [error, setError] = React3.useState(null);
2220
- const [resendCooldown, setResendCooldown] = React3.useState(0);
2221
- const [resendLoading, setResendLoading] = React3.useState(false);
2228
+ const [otp, setOtp] = React.useState("");
2229
+ const [isLoading, setIsLoading] = React.useState(false);
2230
+ const [error, setError] = React.useState(null);
2231
+ const [resendCooldown, setResendCooldown] = React.useState(0);
2232
+ const [resendLoading, setResendLoading] = React.useState(false);
2222
2233
  const { verify, login } = useAuth({
2223
2234
  baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
2224
2235
  });
@@ -2429,9 +2440,9 @@ var AuthFlow = ({
2429
2440
  initialStep = "login",
2430
2441
  showTitle = true
2431
2442
  }) => {
2432
- const [step, setStep] = React3.useState(initialStep);
2433
- const [email, setEmail] = React3.useState("");
2434
- const [message, setMessage] = React3.useState(null);
2443
+ const [step, setStep] = React.useState(initialStep);
2444
+ const [email, setEmail] = React.useState("");
2445
+ const [message, setMessage] = React.useState(null);
2435
2446
  const handleLoginSuccess = (email2, needsOtpVerification) => {
2436
2447
  setEmail(email2);
2437
2448
  if (needsOtpVerification) {
@@ -2566,13 +2577,13 @@ var EmailVerificationPage = ({
2566
2577
  onVerificationError,
2567
2578
  baseUrl
2568
2579
  }) => {
2569
- const [isLoading, setIsLoading] = React3.useState(true);
2570
- const [message, setMessage] = React3.useState("");
2571
- const [isSuccess, setIsSuccess] = React3.useState(false);
2580
+ const [isLoading, setIsLoading] = React.useState(true);
2581
+ const [message, setMessage] = React.useState("");
2582
+ const [isSuccess, setIsSuccess] = React.useState(false);
2572
2583
  const { verifyEmailToken } = useAuth({
2573
2584
  baseUrl: baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
2574
2585
  });
2575
- React3.useEffect(() => {
2586
+ React.useEffect(() => {
2576
2587
  const verifyEmail = async () => {
2577
2588
  if (!token) {
2578
2589
  setIsLoading(false);
@@ -2677,7 +2688,7 @@ var EmailVerificationPage = ({
2677
2688
  ] })
2678
2689
  ] }) });
2679
2690
  };
2680
- var ThemeWrapper = React3.forwardRef(
2691
+ var ThemeWrapper = React.forwardRef(
2681
2692
  ({ children, className = "", style }, ref) => {
2682
2693
  const { theme, mounted } = useAuthTheme();
2683
2694
  if (!mounted) {
@@ -2690,18 +2701,18 @@ ThemeWrapper.displayName = "ThemeWrapper";
2690
2701
  var SignIn = ({ redirectUrl, appearance }) => {
2691
2702
  const { signIn, isSignedIn, loading: authLoading } = useAuth2();
2692
2703
  const colors = useThemeColors();
2693
- const [email, setEmail] = React3.useState("");
2694
- const [phoneNumber, setPhoneNumber] = React3.useState("");
2695
- const [password, setPassword] = React3.useState("");
2696
- const [otp, setOtp] = React3.useState("");
2697
- const [usePassword, setUsePassword] = React3.useState(false);
2698
- const [usePhone, setUsePhone] = React3.useState(false);
2699
- const [showPassword, setShowPassword] = React3.useState(false);
2700
- const [isLoading, setIsLoading] = React3.useState(false);
2701
- const [error, setError] = React3.useState(null);
2702
- const [needsOtp, setNeedsOtp] = React3.useState(false);
2703
- const [success, setSuccess] = React3.useState(null);
2704
- React3.useEffect(() => {
2704
+ const [email, setEmail] = React.useState("");
2705
+ const [phoneNumber, setPhoneNumber] = React.useState("");
2706
+ const [password, setPassword] = React.useState("");
2707
+ const [otp, setOtp] = React.useState("");
2708
+ const [usePassword, setUsePassword] = React.useState(false);
2709
+ const [usePhone, setUsePhone] = React.useState(false);
2710
+ const [showPassword, setShowPassword] = React.useState(false);
2711
+ const [isLoading, setIsLoading] = React.useState(false);
2712
+ const [error, setError] = React.useState(null);
2713
+ const [needsOtp, setNeedsOtp] = React.useState(false);
2714
+ const [success, setSuccess] = React.useState(null);
2715
+ React.useEffect(() => {
2705
2716
  if (isSignedIn && redirectUrl) {
2706
2717
  const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
2707
2718
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -3092,16 +3103,16 @@ var SignIn = ({ redirectUrl, appearance }) => {
3092
3103
  var SignUp = ({ redirectUrl, appearance }) => {
3093
3104
  const { signUp, isSignedIn } = useAuth2();
3094
3105
  const colors = useThemeColors();
3095
- const [name, setName] = React3.useState("");
3096
- const [email, setEmail] = React3.useState("");
3097
- const [phoneNumber, setPhoneNumber] = React3.useState("");
3098
- const [password, setPassword] = React3.useState("");
3099
- const [confirmPassword, setConfirmPassword] = React3.useState("");
3100
- const [showPassword, setShowPassword] = React3.useState(false);
3101
- const [isLoading, setIsLoading] = React3.useState(false);
3102
- const [error, setError] = React3.useState(null);
3103
- const [success, setSuccess] = React3.useState(null);
3104
- React3.useEffect(() => {
3106
+ const [name, setName] = React.useState("");
3107
+ const [email, setEmail] = React.useState("");
3108
+ const [phoneNumber, setPhoneNumber] = React.useState("");
3109
+ const [password, setPassword] = React.useState("");
3110
+ const [confirmPassword, setConfirmPassword] = React.useState("");
3111
+ const [showPassword, setShowPassword] = React.useState(false);
3112
+ const [isLoading, setIsLoading] = React.useState(false);
3113
+ const [error, setError] = React.useState(null);
3114
+ const [success, setSuccess] = React.useState(null);
3115
+ React.useEffect(() => {
3105
3116
  if (isSignedIn && redirectUrl) {
3106
3117
  const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
3107
3118
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -3455,7 +3466,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
3455
3466
  };
3456
3467
  var SignOut = ({ redirectUrl }) => {
3457
3468
  const { signOut } = useAuth2();
3458
- React3.useEffect(() => {
3469
+ React.useEffect(() => {
3459
3470
  const performSignOut = async () => {
3460
3471
  await signOut();
3461
3472
  const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
@@ -3469,9 +3480,9 @@ var SignOut = ({ redirectUrl }) => {
3469
3480
  var UserButton = ({ showName = false, appearance }) => {
3470
3481
  const { user, signOut } = useAuth2();
3471
3482
  const colors = useThemeColors();
3472
- const [isOpen, setIsOpen] = React3.useState(false);
3473
- const dropdownRef = React3.useRef(null);
3474
- React3.useEffect(() => {
3483
+ const [isOpen, setIsOpen] = React.useState(false);
3484
+ const dropdownRef = React.useRef(null);
3485
+ React.useEffect(() => {
3475
3486
  const handleClickOutside = (event) => {
3476
3487
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
3477
3488
  setIsOpen(false);
@@ -3514,7 +3525,19 @@ var UserButton = ({ showName = false, appearance }) => {
3514
3525
  e.currentTarget.style.backgroundColor = "transparent";
3515
3526
  },
3516
3527
  children: [
3517
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3528
+ user.avatar ? /* @__PURE__ */ jsxRuntime.jsx(
3529
+ "img",
3530
+ {
3531
+ src: user.avatar,
3532
+ alt: user.name,
3533
+ style: {
3534
+ width: "36px",
3535
+ height: "36px",
3536
+ borderRadius: "50%",
3537
+ objectFit: "cover"
3538
+ }
3539
+ }
3540
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3518
3541
  width: "36px",
3519
3542
  height: "36px",
3520
3543
  borderRadius: "50%",
@@ -3551,7 +3574,19 @@ var UserButton = ({ showName = false, appearance }) => {
3551
3574
  alignItems: "center",
3552
3575
  gap: "12px"
3553
3576
  }, children: [
3554
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3577
+ user.avatar ? /* @__PURE__ */ jsxRuntime.jsx(
3578
+ "img",
3579
+ {
3580
+ src: user.avatar,
3581
+ alt: user.name,
3582
+ style: {
3583
+ width: "48px",
3584
+ height: "48px",
3585
+ borderRadius: "50%",
3586
+ objectFit: "cover"
3587
+ }
3588
+ }
3589
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3555
3590
  width: "48px",
3556
3591
  height: "48px",
3557
3592
  borderRadius: "50%",
@@ -3616,7 +3651,7 @@ var ProtectedRoute = ({
3616
3651
  redirectTo
3617
3652
  }) => {
3618
3653
  const { isSignedIn, isLoaded } = useAuth2();
3619
- React3.useEffect(() => {
3654
+ React.useEffect(() => {
3620
3655
  if (isLoaded && !isSignedIn) {
3621
3656
  const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
3622
3657
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -3641,7 +3676,7 @@ var PublicRoute = ({
3641
3676
  redirectTo
3642
3677
  }) => {
3643
3678
  const { isSignedIn, isLoaded } = useAuth2();
3644
- React3.useEffect(() => {
3679
+ React.useEffect(() => {
3645
3680
  if (isLoaded && isSignedIn) {
3646
3681
  const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
3647
3682
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -3663,9 +3698,9 @@ var PublicRoute = ({
3663
3698
  };
3664
3699
  var VerifyEmail = ({ token, onSuccess, onError }) => {
3665
3700
  const { verifyEmailToken } = useAuth2();
3666
- const [status, setStatus] = React3.useState("loading");
3667
- const [message, setMessage] = React3.useState("");
3668
- React3.useEffect(() => {
3701
+ const [status, setStatus] = React.useState("loading");
3702
+ const [message, setMessage] = React.useState("");
3703
+ React.useEffect(() => {
3669
3704
  const verify = async () => {
3670
3705
  const verifyToken = token || (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") : null);
3671
3706
  if (!verifyToken) {
@@ -3799,10 +3834,10 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
3799
3834
  };
3800
3835
  var ForgotPassword = ({ appearance }) => {
3801
3836
  const { forgotPassword } = useAuth2();
3802
- const [email, setEmail] = React3.useState("");
3803
- const [isLoading, setIsLoading] = React3.useState(false);
3804
- const [error, setError] = React3.useState(null);
3805
- const [success, setSuccess] = React3.useState(null);
3837
+ const [email, setEmail] = React.useState("");
3838
+ const [isLoading, setIsLoading] = React.useState(false);
3839
+ const [error, setError] = React.useState(null);
3840
+ const [success, setSuccess] = React.useState(null);
3806
3841
  const handleSubmit = async (e) => {
3807
3842
  e.preventDefault();
3808
3843
  setIsLoading(true);
@@ -3941,14 +3976,14 @@ var ForgotPassword = ({ appearance }) => {
3941
3976
  };
3942
3977
  var ResetPassword = ({ token, appearance }) => {
3943
3978
  const { resetPassword } = useAuth2();
3944
- const [resetToken, setResetToken] = React3.useState(token || "");
3945
- const [password, setPassword] = React3.useState("");
3946
- const [confirmPassword, setConfirmPassword] = React3.useState("");
3947
- const [showPassword, setShowPassword] = React3.useState(false);
3948
- const [isLoading, setIsLoading] = React3.useState(false);
3949
- const [error, setError] = React3.useState(null);
3950
- const [success, setSuccess] = React3.useState(false);
3951
- React3.useEffect(() => {
3979
+ const [resetToken, setResetToken] = React.useState(token || "");
3980
+ const [password, setPassword] = React.useState("");
3981
+ const [confirmPassword, setConfirmPassword] = React.useState("");
3982
+ const [showPassword, setShowPassword] = React.useState(false);
3983
+ const [isLoading, setIsLoading] = React.useState(false);
3984
+ const [error, setError] = React.useState(null);
3985
+ const [success, setSuccess] = React.useState(false);
3986
+ React.useEffect(() => {
3952
3987
  if (!resetToken && typeof window !== "undefined") {
3953
3988
  const urlToken = new URLSearchParams(window.location.search).get("token");
3954
3989
  if (urlToken) {
@@ -4195,13 +4230,13 @@ var ResetPassword = ({ token, appearance }) => {
4195
4230
  };
4196
4231
  var ChangePassword = ({ onSuccess, appearance }) => {
4197
4232
  const { changePassword } = useAuth2();
4198
- const [oldPassword, setOldPassword] = React3.useState("");
4199
- const [newPassword, setNewPassword] = React3.useState("");
4200
- const [confirmPassword, setConfirmPassword] = React3.useState("");
4201
- const [showPasswords, setShowPasswords] = React3.useState(false);
4202
- const [isLoading, setIsLoading] = React3.useState(false);
4203
- const [error, setError] = React3.useState(null);
4204
- const [success, setSuccess] = React3.useState(false);
4233
+ const [oldPassword, setOldPassword] = React.useState("");
4234
+ const [newPassword, setNewPassword] = React.useState("");
4235
+ const [confirmPassword, setConfirmPassword] = React.useState("");
4236
+ const [showPasswords, setShowPasswords] = React.useState(false);
4237
+ const [isLoading, setIsLoading] = React.useState(false);
4238
+ const [error, setError] = React.useState(null);
4239
+ const [success, setSuccess] = React.useState(false);
4205
4240
  const getPasswordStrength = (pwd) => {
4206
4241
  if (!pwd) return { strength: "weak", color: "#ddd" };
4207
4242
  let score = 0;
@@ -4442,31 +4477,21 @@ var AvatarUploader = ({
4442
4477
  buttonText = "Upload Avatar"
4443
4478
  }) => {
4444
4479
  const { uploadAndUpdateAvatar } = useAuth2();
4445
- const [open, setOpen] = React3.useState(false);
4446
- const [uploading, setUploading] = React3.useState(false);
4480
+ const [open, setOpen] = React.useState(false);
4481
+ const [uploading, setUploading] = React.useState(false);
4447
4482
  const handleSelect = async (image) => {
4448
4483
  setUploading(true);
4449
4484
  try {
4450
- const proxyUrl = `${upfilesConfig.baseUrl}/api/download?fileKey=${encodeURIComponent(image.key)}`;
4451
- const response = await fetch(proxyUrl, {
4452
- headers: upfilesConfig.apiKey ? {
4453
- [upfilesConfig.apiKeyHeader || "authorization"]: upfilesConfig.apiKey.startsWith("upk_") ? `Bearer ${upfilesConfig.apiKey}` : upfilesConfig.apiKey
4454
- } : {}
4455
- });
4456
- if (!response.ok) {
4457
- throw new Error("Failed to fetch image");
4458
- }
4459
- const blob = await response.blob();
4460
- const file = new File([blob], image.originalName, { type: image.contentType });
4461
- const result = await uploadAndUpdateAvatar(file);
4462
- if (result.success && result.user?.avatar) {
4463
- onUploadComplete?.(result.user.avatar);
4485
+ const { updateProfile } = useAuth2();
4486
+ const response = await updateProfile({ avatar: image.url });
4487
+ if (response.success && response.user?.avatar) {
4488
+ onUploadComplete?.(response.user.avatar);
4464
4489
  setOpen(false);
4465
4490
  } else {
4466
- throw new Error(result.message || "Failed to update avatar");
4491
+ throw new Error(response.message || "Failed to update avatar");
4467
4492
  }
4468
4493
  } catch (error) {
4469
- const err = error instanceof Error ? error : new Error("Upload failed");
4494
+ const err = error instanceof Error ? error : new Error("Failed to update avatar");
4470
4495
  onError?.(err);
4471
4496
  } finally {
4472
4497
  setUploading(false);
@@ -4517,12 +4542,12 @@ var UserProfile = ({
4517
4542
  }) => {
4518
4543
  const { user, updateProfile, requestEmailChange } = useAuth2();
4519
4544
  const colors = useThemeColors();
4520
- const [name, setName] = React3.useState(user?.name || "");
4521
- const [phoneNumber, setPhoneNumber] = React3.useState(user?.phoneNumber || "");
4522
- const [newEmail, setNewEmail] = React3.useState("");
4523
- const [isLoading, setIsLoading] = React3.useState(false);
4524
- const [error, setError] = React3.useState(null);
4525
- const [success, setSuccess] = React3.useState(null);
4545
+ const [name, setName] = React.useState(user?.name || "");
4546
+ const [phoneNumber, setPhoneNumber] = React.useState(user?.phoneNumber || "");
4547
+ const [newEmail, setNewEmail] = React.useState("");
4548
+ const [isLoading, setIsLoading] = React.useState(false);
4549
+ const [error, setError] = React.useState(null);
4550
+ const [success, setSuccess] = React.useState(null);
4526
4551
  const handleUpdateProfile = async (e) => {
4527
4552
  e.preventDefault();
4528
4553
  setIsLoading(true);
@@ -4813,12 +4838,18 @@ var AvatarManager = ({
4813
4838
  gridClassName,
4814
4839
  maxFileSize = 5 * 1024 * 1024,
4815
4840
  // 5MB default
4841
+ maxFiles = 10,
4816
4842
  mode = "full",
4817
4843
  showDelete = false,
4844
+ autoRecordToDb = true,
4845
+ fetchThumbnails = true,
4846
+ projectId,
4847
+ deleteUrl,
4848
+ onDelete,
4818
4849
  upfilesConfig
4819
4850
  }) => {
4820
4851
  const { updateProfile } = useAuth2();
4821
- const [updating, setUpdating] = React3.useState(false);
4852
+ const [updating, setUpdating] = React.useState(false);
4822
4853
  const handleSelect = async (image) => {
4823
4854
  setUpdating(true);
4824
4855
  try {
@@ -4846,24 +4877,31 @@ var AvatarManager = ({
4846
4877
  apiKey: upfilesConfig.apiKey,
4847
4878
  apiKeyHeader: upfilesConfig.apiKeyHeader || "authorization",
4848
4879
  presignUrl: upfilesConfig.presignUrl,
4849
- presignPath: upfilesConfig.presignPath
4880
+ presignPath: upfilesConfig.presignPath,
4881
+ headers: upfilesConfig.headers,
4882
+ withCredentials: upfilesConfig.withCredentials
4850
4883
  },
4851
- folderPath: upfilesConfig.folderPath || "avatars/",
4884
+ projectId,
4885
+ folderPath: upfilesConfig.folderPath || "/",
4852
4886
  title,
4853
4887
  description,
4854
4888
  className,
4855
4889
  gridClassName,
4856
4890
  onSelect: handleSelect,
4891
+ onDelete,
4892
+ deleteUrl,
4893
+ autoRecordToDb,
4894
+ fetchThumbnails,
4857
4895
  maxFileSize,
4896
+ maxFiles,
4858
4897
  mode,
4859
- showDelete,
4860
- fetchThumbnails: true
4898
+ showDelete
4861
4899
  }
4862
4900
  );
4863
4901
  };
4864
4902
  var isServer = typeof window === "undefined";
4865
4903
  var useNextAuth = (config) => {
4866
- const [authService] = React3.useState(() => {
4904
+ const [authService] = React.useState(() => {
4867
4905
  const service = new AuthService(config);
4868
4906
  if (isServer && config.token) {
4869
4907
  service["token"] = config.token;
@@ -4871,10 +4909,10 @@ var useNextAuth = (config) => {
4871
4909
  }
4872
4910
  return service;
4873
4911
  });
4874
- const [user, setUser] = React3.useState(null);
4875
- const [isAuthenticated, setIsAuthenticated] = React3.useState(false);
4876
- const [loading, setLoading] = React3.useState(true);
4877
- const checkAuthStatus = React3.useCallback(() => {
4912
+ const [user, setUser] = React.useState(null);
4913
+ const [isAuthenticated, setIsAuthenticated] = React.useState(false);
4914
+ const [loading, setLoading] = React.useState(true);
4915
+ const checkAuthStatus = React.useCallback(() => {
4878
4916
  if (isServer) {
4879
4917
  const token = config.token || authService.getToken();
4880
4918
  const authenticated = !!token;
@@ -4902,10 +4940,10 @@ var useNextAuth = (config) => {
4902
4940
  }
4903
4941
  setLoading(false);
4904
4942
  }, [authService, config.token]);
4905
- React3.useEffect(() => {
4943
+ React.useEffect(() => {
4906
4944
  checkAuthStatus();
4907
4945
  }, [checkAuthStatus]);
4908
- const register = React3.useCallback(async (data) => {
4946
+ const register = React.useCallback(async (data) => {
4909
4947
  setLoading(true);
4910
4948
  try {
4911
4949
  const response = await authService.register(data);
@@ -4914,7 +4952,7 @@ var useNextAuth = (config) => {
4914
4952
  setLoading(false);
4915
4953
  }
4916
4954
  }, [authService]);
4917
- const login = React3.useCallback(async (data) => {
4955
+ const login = React.useCallback(async (data) => {
4918
4956
  setLoading(true);
4919
4957
  try {
4920
4958
  const response = await authService.login(data);
@@ -4923,7 +4961,7 @@ var useNextAuth = (config) => {
4923
4961
  setLoading(false);
4924
4962
  }
4925
4963
  }, [authService]);
4926
- const verify = React3.useCallback(async (data) => {
4964
+ const verify = React.useCallback(async (data) => {
4927
4965
  setLoading(true);
4928
4966
  try {
4929
4967
  const response = await authService.verify(data);
@@ -4936,7 +4974,7 @@ var useNextAuth = (config) => {
4936
4974
  setLoading(false);
4937
4975
  }
4938
4976
  }, [authService]);
4939
- const verifyEmailToken = React3.useCallback(async (token) => {
4977
+ const verifyEmailToken = React.useCallback(async (token) => {
4940
4978
  setLoading(true);
4941
4979
  try {
4942
4980
  const response = await authService.verifyEmailToken(token);
@@ -4949,7 +4987,7 @@ var useNextAuth = (config) => {
4949
4987
  setLoading(false);
4950
4988
  }
4951
4989
  }, [authService]);
4952
- const logout = React3.useCallback(async () => {
4990
+ const logout = React.useCallback(async () => {
4953
4991
  setLoading(true);
4954
4992
  try {
4955
4993
  await authService.logout();
@@ -4959,7 +4997,7 @@ var useNextAuth = (config) => {
4959
4997
  setLoading(false);
4960
4998
  }
4961
4999
  }, [authService]);
4962
- const updateProfile = React3.useCallback(async (data) => {
5000
+ const updateProfile = React.useCallback(async (data) => {
4963
5001
  setLoading(true);
4964
5002
  try {
4965
5003
  const response = await authService.updateProfile(data);
@@ -4971,7 +5009,7 @@ var useNextAuth = (config) => {
4971
5009
  setLoading(false);
4972
5010
  }
4973
5011
  }, [authService]);
4974
- const getProfile = React3.useCallback(async () => {
5012
+ const getProfile = React.useCallback(async () => {
4975
5013
  setLoading(true);
4976
5014
  try {
4977
5015
  const userData = await authService.getProfile();
@@ -4981,7 +5019,7 @@ var useNextAuth = (config) => {
4981
5019
  setLoading(false);
4982
5020
  }
4983
5021
  }, [authService]);
4984
- const getAllUsers = React3.useCallback(async () => {
5022
+ const getAllUsers = React.useCallback(async () => {
4985
5023
  setLoading(true);
4986
5024
  try {
4987
5025
  return await authService.getAllUsers();
@@ -4989,7 +5027,7 @@ var useNextAuth = (config) => {
4989
5027
  setLoading(false);
4990
5028
  }
4991
5029
  }, [authService]);
4992
- const getUserById = React3.useCallback(async (id) => {
5030
+ const getUserById = React.useCallback(async (id) => {
4993
5031
  setLoading(true);
4994
5032
  try {
4995
5033
  return await authService.getUserById(id);
@@ -4997,7 +5035,7 @@ var useNextAuth = (config) => {
4997
5035
  setLoading(false);
4998
5036
  }
4999
5037
  }, [authService]);
5000
- const forgotPassword = React3.useCallback(async (email) => {
5038
+ const forgotPassword = React.useCallback(async (email) => {
5001
5039
  setLoading(true);
5002
5040
  try {
5003
5041
  const response = await authService.forgotPassword(email);
@@ -5006,7 +5044,7 @@ var useNextAuth = (config) => {
5006
5044
  setLoading(false);
5007
5045
  }
5008
5046
  }, [authService]);
5009
- const resetPassword = React3.useCallback(async (token, password) => {
5047
+ const resetPassword = React.useCallback(async (token, password) => {
5010
5048
  setLoading(true);
5011
5049
  try {
5012
5050
  const response = await authService.resetPassword(token, password);
@@ -5015,7 +5053,7 @@ var useNextAuth = (config) => {
5015
5053
  setLoading(false);
5016
5054
  }
5017
5055
  }, [authService]);
5018
- const setToken = React3.useCallback((token) => {
5056
+ const setToken = React.useCallback((token) => {
5019
5057
  authService["token"] = token;
5020
5058
  authService["httpClient"].setAuthToken(token);
5021
5059
  setIsAuthenticated(true);
@@ -5027,7 +5065,7 @@ var useNextAuth = (config) => {
5027
5065
  setUser(null);
5028
5066
  }
5029
5067
  }, [authService]);
5030
- const clearToken = React3.useCallback(() => {
5068
+ const clearToken = React.useCallback(() => {
5031
5069
  authService["token"] = null;
5032
5070
  authService["httpClient"].removeAuthToken();
5033
5071
  setIsAuthenticated(false);