@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.
package/README.md CHANGED
File without changes
@@ -231,8 +231,14 @@ interface AvatarManagerProps {
231
231
  className?: string;
232
232
  gridClassName?: string;
233
233
  maxFileSize?: number;
234
+ maxFiles?: number;
234
235
  mode?: 'full' | 'browse' | 'upload';
235
236
  showDelete?: boolean;
237
+ autoRecordToDb?: boolean;
238
+ fetchThumbnails?: boolean;
239
+ projectId?: string;
240
+ deleteUrl?: string;
241
+ onDelete?: (key: string) => Promise<void>;
236
242
  upfilesConfig: {
237
243
  baseUrl: string;
238
244
  apiKey?: string;
@@ -240,6 +246,8 @@ interface AvatarManagerProps {
240
246
  presignUrl?: string;
241
247
  presignPath?: string;
242
248
  folderPath?: string;
249
+ headers?: Record<string, string>;
250
+ withCredentials?: boolean;
243
251
  };
244
252
  }
245
253
  declare const AvatarManager: React.FC<AvatarManagerProps>;
@@ -231,8 +231,14 @@ interface AvatarManagerProps {
231
231
  className?: string;
232
232
  gridClassName?: string;
233
233
  maxFileSize?: number;
234
+ maxFiles?: number;
234
235
  mode?: 'full' | 'browse' | 'upload';
235
236
  showDelete?: boolean;
237
+ autoRecordToDb?: boolean;
238
+ fetchThumbnails?: boolean;
239
+ projectId?: string;
240
+ deleteUrl?: string;
241
+ onDelete?: (key: string) => Promise<void>;
236
242
  upfilesConfig: {
237
243
  baseUrl: string;
238
244
  apiKey?: string;
@@ -240,6 +246,8 @@ interface AvatarManagerProps {
240
246
  presignUrl?: string;
241
247
  presignPath?: string;
242
248
  folderPath?: string;
249
+ headers?: Record<string, string>;
250
+ withCredentials?: boolean;
243
251
  };
244
252
  }
245
253
  declare const AvatarManager: React.FC<AvatarManagerProps>;
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var React2 = require('react');
4
+ var React = require('react');
5
5
  var axios = require('axios');
6
6
  var upfiles = require('@thetechfossil/upfiles');
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
- var React2__default = /*#__PURE__*/_interopDefault(React2);
11
+ var React__default = /*#__PURE__*/_interopDefault(React);
12
12
  var axios__default = /*#__PURE__*/_interopDefault(axios);
13
13
 
14
14
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
@@ -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
  );
@@ -508,11 +513,11 @@ var AuthService = class {
508
513
 
509
514
  // src/react/use-auth.ts
510
515
  var useAuth = (config) => {
511
- const [authService] = React2.useState(() => new AuthService(config));
512
- const [user, setUser] = React2.useState(null);
513
- const [isAuthenticated, setIsAuthenticated] = React2.useState(false);
514
- const [loading, setLoading] = React2.useState(true);
515
- const checkAuthStatus = React2.useCallback(() => {
516
+ const [authService] = React.useState(() => new AuthService(config));
517
+ const [user, setUser] = React.useState(null);
518
+ const [isAuthenticated, setIsAuthenticated] = React.useState(false);
519
+ const [loading, setLoading] = React.useState(true);
520
+ const checkAuthStatus = React.useCallback(() => {
516
521
  const authenticated = authService.isAuthenticated();
517
522
  setIsAuthenticated(authenticated);
518
523
  if (authenticated) {
@@ -523,10 +528,10 @@ var useAuth = (config) => {
523
528
  }
524
529
  setLoading(false);
525
530
  }, [authService]);
526
- React2.useEffect(() => {
531
+ React.useEffect(() => {
527
532
  checkAuthStatus();
528
533
  }, [checkAuthStatus]);
529
- const register = React2.useCallback(async (data) => {
534
+ const register = React.useCallback(async (data) => {
530
535
  setLoading(true);
531
536
  try {
532
537
  const response = await authService.register(data);
@@ -535,7 +540,7 @@ var useAuth = (config) => {
535
540
  setLoading(false);
536
541
  }
537
542
  }, [authService]);
538
- const login = React2.useCallback(async (data) => {
543
+ const login = React.useCallback(async (data) => {
539
544
  setLoading(true);
540
545
  try {
541
546
  const response = await authService.login(data);
@@ -548,7 +553,7 @@ var useAuth = (config) => {
548
553
  setLoading(false);
549
554
  }
550
555
  }, [authService]);
551
- const verify = React2.useCallback(async (data) => {
556
+ const verify = React.useCallback(async (data) => {
552
557
  setLoading(true);
553
558
  try {
554
559
  const response = await authService.verify(data);
@@ -561,7 +566,7 @@ var useAuth = (config) => {
561
566
  setLoading(false);
562
567
  }
563
568
  }, [authService]);
564
- const verifyEmailToken = React2.useCallback(async (token) => {
569
+ const verifyEmailToken = React.useCallback(async (token) => {
565
570
  setLoading(true);
566
571
  try {
567
572
  const response = await authService.verifyEmailToken(token);
@@ -574,7 +579,7 @@ var useAuth = (config) => {
574
579
  setLoading(false);
575
580
  }
576
581
  }, [authService]);
577
- const logout = React2.useCallback(async () => {
582
+ const logout = React.useCallback(async () => {
578
583
  setLoading(true);
579
584
  try {
580
585
  await authService.logout();
@@ -584,7 +589,7 @@ var useAuth = (config) => {
584
589
  setLoading(false);
585
590
  }
586
591
  }, [authService]);
587
- const updateProfile = React2.useCallback(async (data) => {
592
+ const updateProfile = React.useCallback(async (data) => {
588
593
  setLoading(true);
589
594
  try {
590
595
  const response = await authService.updateProfile(data);
@@ -596,7 +601,7 @@ var useAuth = (config) => {
596
601
  setLoading(false);
597
602
  }
598
603
  }, [authService]);
599
- const getProfile = React2.useCallback(async () => {
604
+ const getProfile = React.useCallback(async () => {
600
605
  setLoading(true);
601
606
  try {
602
607
  const userData = await authService.getProfile();
@@ -606,7 +611,7 @@ var useAuth = (config) => {
606
611
  setLoading(false);
607
612
  }
608
613
  }, [authService]);
609
- const getAllUsers = React2.useCallback(async () => {
614
+ const getAllUsers = React.useCallback(async () => {
610
615
  setLoading(true);
611
616
  try {
612
617
  return await authService.getAllUsers();
@@ -614,7 +619,7 @@ var useAuth = (config) => {
614
619
  setLoading(false);
615
620
  }
616
621
  }, [authService]);
617
- const getUserById = React2.useCallback(async (id) => {
622
+ const getUserById = React.useCallback(async (id) => {
618
623
  setLoading(true);
619
624
  try {
620
625
  return await authService.getUserById(id);
@@ -622,7 +627,7 @@ var useAuth = (config) => {
622
627
  setLoading(false);
623
628
  }
624
629
  }, [authService]);
625
- const uploadAndUpdateAvatar = React2.useCallback(async (file) => {
630
+ const uploadAndUpdateAvatar = React.useCallback(async (file) => {
626
631
  setLoading(true);
627
632
  try {
628
633
  const response = await authService.uploadAndUpdateAvatar(file);
@@ -650,9 +655,9 @@ var useAuth = (config) => {
650
655
  uploadAndUpdateAvatar
651
656
  };
652
657
  };
653
- var ThemeContext = React2.createContext({ theme: "light", mounted: false });
658
+ var ThemeContext = React__default.default.createContext({ theme: "light", mounted: false });
654
659
  function useAuthTheme() {
655
- return React2.useContext(ThemeContext);
660
+ return React.useContext(ThemeContext);
656
661
  }
657
662
 
658
663
  // src/react/hooks/useThemeColors.ts
@@ -704,7 +709,7 @@ try {
704
709
  } catch (error) {
705
710
  console.warn("react-phone-number-input not available, using fallback");
706
711
  }
707
- var CustomPhoneInput = React2__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
712
+ var CustomPhoneInput = React__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
708
713
  "input",
709
714
  {
710
715
  ...props,
@@ -723,8 +728,8 @@ var PhoneInput = ({
723
728
  style = {}
724
729
  }) => {
725
730
  const colors = useThemeColors();
726
- const [defaultCountry, setDefaultCountry] = React2.useState("US");
727
- const styleContent = React2.useMemo(() => `
731
+ const [defaultCountry, setDefaultCountry] = React.useState("US");
732
+ const styleContent = React.useMemo(() => `
728
733
  .PhoneInput {
729
734
  display: flex;
730
735
  align-items: center;
@@ -836,7 +841,7 @@ var PhoneInput = ({
836
841
  opacity: 0.6;
837
842
  }
838
843
  `, [colors]);
839
- React2.useEffect(() => {
844
+ React.useEffect(() => {
840
845
  const detectCountry = async () => {
841
846
  try {
842
847
  const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
@@ -893,7 +898,7 @@ var PhoneInput = ({
893
898
  };
894
899
  detectCountry();
895
900
  }, []);
896
- const handleChange = React2.useMemo(() => (val) => {
901
+ const handleChange = React.useMemo(() => (val) => {
897
902
  onChange(val || "");
898
903
  }, [onChange]);
899
904
  if (!PhoneInputWithCountry) {
@@ -957,15 +962,15 @@ var LoginForm = ({
957
962
  showOAuthButtons = true
958
963
  }) => {
959
964
  const colors = useThemeColors();
960
- const [email, setEmail] = React2.useState("");
961
- const [phoneNumber, setPhoneNumber] = React2.useState("");
962
- const [usePhone, setUsePhone] = React2.useState(false);
963
- const [password, setPassword] = React2.useState("");
964
- const [usePassword, setUsePassword] = React2.useState(false);
965
- const [showPassword, setShowPassword] = React2.useState(false);
966
- const [isLoading, setIsLoading] = React2.useState(false);
967
- const [error, setError] = React2.useState(null);
968
- const [rememberMe, setRememberMe] = React2.useState(false);
965
+ const [email, setEmail] = React.useState("");
966
+ const [phoneNumber, setPhoneNumber] = React.useState("");
967
+ const [usePhone, setUsePhone] = React.useState(false);
968
+ const [password, setPassword] = React.useState("");
969
+ const [usePassword, setUsePassword] = React.useState(false);
970
+ const [showPassword, setShowPassword] = React.useState(false);
971
+ const [isLoading, setIsLoading] = React.useState(false);
972
+ const [error, setError] = React.useState(null);
973
+ const [rememberMe, setRememberMe] = React.useState(false);
969
974
  const { login } = useAuth({
970
975
  baseUrl: config?.baseUrl || "http://localhost:7000"
971
976
  });
@@ -1419,15 +1424,15 @@ var RegisterForm = ({
1419
1424
  invitationToken
1420
1425
  }) => {
1421
1426
  const colors = useThemeColors();
1422
- const [name, setName] = React2.useState("");
1423
- const [email, setEmail] = React2.useState("");
1424
- const [phoneNumber, setPhoneNumber] = React2.useState("");
1425
- const [password, setPassword] = React2.useState("");
1426
- const [confirmPassword, setConfirmPassword] = React2.useState("");
1427
- const [isLoading, setIsLoading] = React2.useState(false);
1428
- const [error, setError] = React2.useState(null);
1429
- const [showPassword, setShowPassword] = React2.useState(false);
1430
- const [showConfirmPassword, setShowConfirmPassword] = React2.useState(false);
1427
+ const [name, setName] = React.useState("");
1428
+ const [email, setEmail] = React.useState("");
1429
+ const [phoneNumber, setPhoneNumber] = React.useState("");
1430
+ const [password, setPassword] = React.useState("");
1431
+ const [confirmPassword, setConfirmPassword] = React.useState("");
1432
+ const [isLoading, setIsLoading] = React.useState(false);
1433
+ const [error, setError] = React.useState(null);
1434
+ const [showPassword, setShowPassword] = React.useState(false);
1435
+ const [showConfirmPassword, setShowConfirmPassword] = React.useState(false);
1431
1436
  const getPasswordStrength = (pwd) => {
1432
1437
  if (!pwd) return { strength: "weak", score: 0, label: "" };
1433
1438
  let score = 0;
@@ -1883,11 +1888,11 @@ var OtpForm = ({
1883
1888
  baseUrl
1884
1889
  }) => {
1885
1890
  const colors = useThemeColors();
1886
- const [otp, setOtp] = React2.useState("");
1887
- const [isLoading, setIsLoading] = React2.useState(false);
1888
- const [error, setError] = React2.useState(null);
1889
- const [resendCooldown, setResendCooldown] = React2.useState(0);
1890
- const [resendLoading, setResendLoading] = React2.useState(false);
1891
+ const [otp, setOtp] = React.useState("");
1892
+ const [isLoading, setIsLoading] = React.useState(false);
1893
+ const [error, setError] = React.useState(null);
1894
+ const [resendCooldown, setResendCooldown] = React.useState(0);
1895
+ const [resendLoading, setResendLoading] = React.useState(false);
1891
1896
  const { verify, login } = useAuth({
1892
1897
  baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
1893
1898
  });
@@ -2098,9 +2103,9 @@ var AuthFlow = ({
2098
2103
  initialStep = "login",
2099
2104
  showTitle = true
2100
2105
  }) => {
2101
- const [step, setStep] = React2.useState(initialStep);
2102
- const [email, setEmail] = React2.useState("");
2103
- const [message, setMessage] = React2.useState(null);
2106
+ const [step, setStep] = React.useState(initialStep);
2107
+ const [email, setEmail] = React.useState("");
2108
+ const [message, setMessage] = React.useState(null);
2104
2109
  const handleLoginSuccess = (email2, needsOtpVerification) => {
2105
2110
  setEmail(email2);
2106
2111
  if (needsOtpVerification) {
@@ -2235,13 +2240,13 @@ var EmailVerificationPage = ({
2235
2240
  onVerificationError,
2236
2241
  baseUrl
2237
2242
  }) => {
2238
- const [isLoading, setIsLoading] = React2.useState(true);
2239
- const [message, setMessage] = React2.useState("");
2240
- const [isSuccess, setIsSuccess] = React2.useState(false);
2243
+ const [isLoading, setIsLoading] = React.useState(true);
2244
+ const [message, setMessage] = React.useState("");
2245
+ const [isSuccess, setIsSuccess] = React.useState(false);
2241
2246
  const { verifyEmailToken } = useAuth({
2242
2247
  baseUrl: baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
2243
2248
  });
2244
- React2.useEffect(() => {
2249
+ React.useEffect(() => {
2245
2250
  const verifyEmail = async () => {
2246
2251
  if (!token) {
2247
2252
  setIsLoading(false);
@@ -2346,15 +2351,15 @@ var EmailVerificationPage = ({
2346
2351
  ] })
2347
2352
  ] }) });
2348
2353
  };
2349
- var AuthContext = React2.createContext(void 0);
2354
+ var AuthContext = React.createContext(void 0);
2350
2355
  var useAuth2 = () => {
2351
- const context = React2.useContext(AuthContext);
2356
+ const context = React.useContext(AuthContext);
2352
2357
  if (context === void 0) {
2353
2358
  throw new Error("useAuth must be used within an AuthProvider");
2354
2359
  }
2355
2360
  return context;
2356
2361
  };
2357
- var ThemeWrapper = React2.forwardRef(
2362
+ var ThemeWrapper = React.forwardRef(
2358
2363
  ({ children, className = "", style }, ref) => {
2359
2364
  const { theme, mounted } = useAuthTheme();
2360
2365
  if (!mounted) {
@@ -2367,18 +2372,18 @@ ThemeWrapper.displayName = "ThemeWrapper";
2367
2372
  var SignIn = ({ redirectUrl, appearance }) => {
2368
2373
  const { signIn, isSignedIn, loading: authLoading } = useAuth2();
2369
2374
  const colors = useThemeColors();
2370
- const [email, setEmail] = React2.useState("");
2371
- const [phoneNumber, setPhoneNumber] = React2.useState("");
2372
- const [password, setPassword] = React2.useState("");
2373
- const [otp, setOtp] = React2.useState("");
2374
- const [usePassword, setUsePassword] = React2.useState(false);
2375
- const [usePhone, setUsePhone] = React2.useState(false);
2376
- const [showPassword, setShowPassword] = React2.useState(false);
2377
- const [isLoading, setIsLoading] = React2.useState(false);
2378
- const [error, setError] = React2.useState(null);
2379
- const [needsOtp, setNeedsOtp] = React2.useState(false);
2380
- const [success, setSuccess] = React2.useState(null);
2381
- React2.useEffect(() => {
2375
+ const [email, setEmail] = React.useState("");
2376
+ const [phoneNumber, setPhoneNumber] = React.useState("");
2377
+ const [password, setPassword] = React.useState("");
2378
+ const [otp, setOtp] = React.useState("");
2379
+ const [usePassword, setUsePassword] = React.useState(false);
2380
+ const [usePhone, setUsePhone] = React.useState(false);
2381
+ const [showPassword, setShowPassword] = React.useState(false);
2382
+ const [isLoading, setIsLoading] = React.useState(false);
2383
+ const [error, setError] = React.useState(null);
2384
+ const [needsOtp, setNeedsOtp] = React.useState(false);
2385
+ const [success, setSuccess] = React.useState(null);
2386
+ React.useEffect(() => {
2382
2387
  if (isSignedIn && redirectUrl) {
2383
2388
  const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
2384
2389
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -2769,16 +2774,16 @@ var SignIn = ({ redirectUrl, appearance }) => {
2769
2774
  var SignUp = ({ redirectUrl, appearance }) => {
2770
2775
  const { signUp, isSignedIn } = useAuth2();
2771
2776
  const colors = useThemeColors();
2772
- const [name, setName] = React2.useState("");
2773
- const [email, setEmail] = React2.useState("");
2774
- const [phoneNumber, setPhoneNumber] = React2.useState("");
2775
- const [password, setPassword] = React2.useState("");
2776
- const [confirmPassword, setConfirmPassword] = React2.useState("");
2777
- const [showPassword, setShowPassword] = React2.useState(false);
2778
- const [isLoading, setIsLoading] = React2.useState(false);
2779
- const [error, setError] = React2.useState(null);
2780
- const [success, setSuccess] = React2.useState(null);
2781
- React2.useEffect(() => {
2777
+ const [name, setName] = React.useState("");
2778
+ const [email, setEmail] = React.useState("");
2779
+ const [phoneNumber, setPhoneNumber] = React.useState("");
2780
+ const [password, setPassword] = React.useState("");
2781
+ const [confirmPassword, setConfirmPassword] = React.useState("");
2782
+ const [showPassword, setShowPassword] = React.useState(false);
2783
+ const [isLoading, setIsLoading] = React.useState(false);
2784
+ const [error, setError] = React.useState(null);
2785
+ const [success, setSuccess] = React.useState(null);
2786
+ React.useEffect(() => {
2782
2787
  if (isSignedIn && redirectUrl) {
2783
2788
  const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
2784
2789
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -3132,7 +3137,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
3132
3137
  };
3133
3138
  var SignOut = ({ redirectUrl }) => {
3134
3139
  const { signOut } = useAuth2();
3135
- React2.useEffect(() => {
3140
+ React.useEffect(() => {
3136
3141
  const performSignOut = async () => {
3137
3142
  await signOut();
3138
3143
  const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
@@ -3146,9 +3151,9 @@ var SignOut = ({ redirectUrl }) => {
3146
3151
  var UserButton = ({ showName = false, appearance }) => {
3147
3152
  const { user, signOut } = useAuth2();
3148
3153
  const colors = useThemeColors();
3149
- const [isOpen, setIsOpen] = React2.useState(false);
3150
- const dropdownRef = React2.useRef(null);
3151
- React2.useEffect(() => {
3154
+ const [isOpen, setIsOpen] = React.useState(false);
3155
+ const dropdownRef = React.useRef(null);
3156
+ React.useEffect(() => {
3152
3157
  const handleClickOutside = (event) => {
3153
3158
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
3154
3159
  setIsOpen(false);
@@ -3191,7 +3196,19 @@ var UserButton = ({ showName = false, appearance }) => {
3191
3196
  e.currentTarget.style.backgroundColor = "transparent";
3192
3197
  },
3193
3198
  children: [
3194
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3199
+ user.avatar ? /* @__PURE__ */ jsxRuntime.jsx(
3200
+ "img",
3201
+ {
3202
+ src: user.avatar,
3203
+ alt: user.name,
3204
+ style: {
3205
+ width: "36px",
3206
+ height: "36px",
3207
+ borderRadius: "50%",
3208
+ objectFit: "cover"
3209
+ }
3210
+ }
3211
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3195
3212
  width: "36px",
3196
3213
  height: "36px",
3197
3214
  borderRadius: "50%",
@@ -3228,7 +3245,19 @@ var UserButton = ({ showName = false, appearance }) => {
3228
3245
  alignItems: "center",
3229
3246
  gap: "12px"
3230
3247
  }, children: [
3231
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3248
+ user.avatar ? /* @__PURE__ */ jsxRuntime.jsx(
3249
+ "img",
3250
+ {
3251
+ src: user.avatar,
3252
+ alt: user.name,
3253
+ style: {
3254
+ width: "48px",
3255
+ height: "48px",
3256
+ borderRadius: "50%",
3257
+ objectFit: "cover"
3258
+ }
3259
+ }
3260
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3232
3261
  width: "48px",
3233
3262
  height: "48px",
3234
3263
  borderRadius: "50%",
@@ -3293,7 +3322,7 @@ var ProtectedRoute = ({
3293
3322
  redirectTo
3294
3323
  }) => {
3295
3324
  const { isSignedIn, isLoaded } = useAuth2();
3296
- React2.useEffect(() => {
3325
+ React.useEffect(() => {
3297
3326
  if (isLoaded && !isSignedIn) {
3298
3327
  const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
3299
3328
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -3318,7 +3347,7 @@ var PublicRoute = ({
3318
3347
  redirectTo
3319
3348
  }) => {
3320
3349
  const { isSignedIn, isLoaded } = useAuth2();
3321
- React2.useEffect(() => {
3350
+ React.useEffect(() => {
3322
3351
  if (isLoaded && isSignedIn) {
3323
3352
  const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
3324
3353
  const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
@@ -3340,9 +3369,9 @@ var PublicRoute = ({
3340
3369
  };
3341
3370
  var VerifyEmail = ({ token, onSuccess, onError }) => {
3342
3371
  const { verifyEmailToken } = useAuth2();
3343
- const [status, setStatus] = React2.useState("loading");
3344
- const [message, setMessage] = React2.useState("");
3345
- React2.useEffect(() => {
3372
+ const [status, setStatus] = React.useState("loading");
3373
+ const [message, setMessage] = React.useState("");
3374
+ React.useEffect(() => {
3346
3375
  const verify = async () => {
3347
3376
  const verifyToken = token || (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") : null);
3348
3377
  if (!verifyToken) {
@@ -3476,10 +3505,10 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
3476
3505
  };
3477
3506
  var ForgotPassword = ({ appearance }) => {
3478
3507
  const { forgotPassword } = useAuth2();
3479
- const [email, setEmail] = React2.useState("");
3480
- const [isLoading, setIsLoading] = React2.useState(false);
3481
- const [error, setError] = React2.useState(null);
3482
- const [success, setSuccess] = React2.useState(null);
3508
+ const [email, setEmail] = React.useState("");
3509
+ const [isLoading, setIsLoading] = React.useState(false);
3510
+ const [error, setError] = React.useState(null);
3511
+ const [success, setSuccess] = React.useState(null);
3483
3512
  const handleSubmit = async (e) => {
3484
3513
  e.preventDefault();
3485
3514
  setIsLoading(true);
@@ -3618,14 +3647,14 @@ var ForgotPassword = ({ appearance }) => {
3618
3647
  };
3619
3648
  var ResetPassword = ({ token, appearance }) => {
3620
3649
  const { resetPassword } = useAuth2();
3621
- const [resetToken, setResetToken] = React2.useState(token || "");
3622
- const [password, setPassword] = React2.useState("");
3623
- const [confirmPassword, setConfirmPassword] = React2.useState("");
3624
- const [showPassword, setShowPassword] = React2.useState(false);
3625
- const [isLoading, setIsLoading] = React2.useState(false);
3626
- const [error, setError] = React2.useState(null);
3627
- const [success, setSuccess] = React2.useState(false);
3628
- React2.useEffect(() => {
3650
+ const [resetToken, setResetToken] = React.useState(token || "");
3651
+ const [password, setPassword] = React.useState("");
3652
+ const [confirmPassword, setConfirmPassword] = React.useState("");
3653
+ const [showPassword, setShowPassword] = React.useState(false);
3654
+ const [isLoading, setIsLoading] = React.useState(false);
3655
+ const [error, setError] = React.useState(null);
3656
+ const [success, setSuccess] = React.useState(false);
3657
+ React.useEffect(() => {
3629
3658
  if (!resetToken && typeof window !== "undefined") {
3630
3659
  const urlToken = new URLSearchParams(window.location.search).get("token");
3631
3660
  if (urlToken) {
@@ -3872,13 +3901,13 @@ var ResetPassword = ({ token, appearance }) => {
3872
3901
  };
3873
3902
  var ChangePassword = ({ onSuccess, appearance }) => {
3874
3903
  const { changePassword } = useAuth2();
3875
- const [oldPassword, setOldPassword] = React2.useState("");
3876
- const [newPassword, setNewPassword] = React2.useState("");
3877
- const [confirmPassword, setConfirmPassword] = React2.useState("");
3878
- const [showPasswords, setShowPasswords] = React2.useState(false);
3879
- const [isLoading, setIsLoading] = React2.useState(false);
3880
- const [error, setError] = React2.useState(null);
3881
- const [success, setSuccess] = React2.useState(false);
3904
+ const [oldPassword, setOldPassword] = React.useState("");
3905
+ const [newPassword, setNewPassword] = React.useState("");
3906
+ const [confirmPassword, setConfirmPassword] = React.useState("");
3907
+ const [showPasswords, setShowPasswords] = React.useState(false);
3908
+ const [isLoading, setIsLoading] = React.useState(false);
3909
+ const [error, setError] = React.useState(null);
3910
+ const [success, setSuccess] = React.useState(false);
3882
3911
  const getPasswordStrength = (pwd) => {
3883
3912
  if (!pwd) return { strength: "weak", color: "#ddd" };
3884
3913
  let score = 0;
@@ -4119,31 +4148,21 @@ var AvatarUploader = ({
4119
4148
  buttonText = "Upload Avatar"
4120
4149
  }) => {
4121
4150
  const { uploadAndUpdateAvatar } = useAuth2();
4122
- const [open, setOpen] = React2.useState(false);
4123
- const [uploading, setUploading] = React2.useState(false);
4151
+ const [open, setOpen] = React.useState(false);
4152
+ const [uploading, setUploading] = React.useState(false);
4124
4153
  const handleSelect = async (image) => {
4125
4154
  setUploading(true);
4126
4155
  try {
4127
- const proxyUrl = `${upfilesConfig.baseUrl}/api/download?fileKey=${encodeURIComponent(image.key)}`;
4128
- const response = await fetch(proxyUrl, {
4129
- headers: upfilesConfig.apiKey ? {
4130
- [upfilesConfig.apiKeyHeader || "authorization"]: upfilesConfig.apiKey.startsWith("upk_") ? `Bearer ${upfilesConfig.apiKey}` : upfilesConfig.apiKey
4131
- } : {}
4132
- });
4133
- if (!response.ok) {
4134
- throw new Error("Failed to fetch image");
4135
- }
4136
- const blob = await response.blob();
4137
- const file = new File([blob], image.originalName, { type: image.contentType });
4138
- const result = await uploadAndUpdateAvatar(file);
4139
- if (result.success && result.user?.avatar) {
4140
- onUploadComplete?.(result.user.avatar);
4156
+ const { updateProfile } = useAuth2();
4157
+ const response = await updateProfile({ avatar: image.url });
4158
+ if (response.success && response.user?.avatar) {
4159
+ onUploadComplete?.(response.user.avatar);
4141
4160
  setOpen(false);
4142
4161
  } else {
4143
- throw new Error(result.message || "Failed to update avatar");
4162
+ throw new Error(response.message || "Failed to update avatar");
4144
4163
  }
4145
4164
  } catch (error) {
4146
- const err = error instanceof Error ? error : new Error("Upload failed");
4165
+ const err = error instanceof Error ? error : new Error("Failed to update avatar");
4147
4166
  onError?.(err);
4148
4167
  } finally {
4149
4168
  setUploading(false);
@@ -4194,12 +4213,12 @@ var UserProfile = ({
4194
4213
  }) => {
4195
4214
  const { user, updateProfile, requestEmailChange } = useAuth2();
4196
4215
  const colors = useThemeColors();
4197
- const [name, setName] = React2.useState(user?.name || "");
4198
- const [phoneNumber, setPhoneNumber] = React2.useState(user?.phoneNumber || "");
4199
- const [newEmail, setNewEmail] = React2.useState("");
4200
- const [isLoading, setIsLoading] = React2.useState(false);
4201
- const [error, setError] = React2.useState(null);
4202
- const [success, setSuccess] = React2.useState(null);
4216
+ const [name, setName] = React.useState(user?.name || "");
4217
+ const [phoneNumber, setPhoneNumber] = React.useState(user?.phoneNumber || "");
4218
+ const [newEmail, setNewEmail] = React.useState("");
4219
+ const [isLoading, setIsLoading] = React.useState(false);
4220
+ const [error, setError] = React.useState(null);
4221
+ const [success, setSuccess] = React.useState(null);
4203
4222
  const handleUpdateProfile = async (e) => {
4204
4223
  e.preventDefault();
4205
4224
  setIsLoading(true);
@@ -4490,12 +4509,18 @@ var AvatarManager = ({
4490
4509
  gridClassName,
4491
4510
  maxFileSize = 5 * 1024 * 1024,
4492
4511
  // 5MB default
4512
+ maxFiles = 10,
4493
4513
  mode = "full",
4494
4514
  showDelete = false,
4515
+ autoRecordToDb = true,
4516
+ fetchThumbnails = true,
4517
+ projectId,
4518
+ deleteUrl,
4519
+ onDelete,
4495
4520
  upfilesConfig
4496
4521
  }) => {
4497
4522
  const { updateProfile } = useAuth2();
4498
- const [updating, setUpdating] = React2.useState(false);
4523
+ const [updating, setUpdating] = React.useState(false);
4499
4524
  const handleSelect = async (image) => {
4500
4525
  setUpdating(true);
4501
4526
  try {
@@ -4523,18 +4548,25 @@ var AvatarManager = ({
4523
4548
  apiKey: upfilesConfig.apiKey,
4524
4549
  apiKeyHeader: upfilesConfig.apiKeyHeader || "authorization",
4525
4550
  presignUrl: upfilesConfig.presignUrl,
4526
- presignPath: upfilesConfig.presignPath
4551
+ presignPath: upfilesConfig.presignPath,
4552
+ headers: upfilesConfig.headers,
4553
+ withCredentials: upfilesConfig.withCredentials
4527
4554
  },
4528
- folderPath: upfilesConfig.folderPath || "avatars/",
4555
+ projectId,
4556
+ folderPath: upfilesConfig.folderPath || "/",
4529
4557
  title,
4530
4558
  description,
4531
4559
  className,
4532
4560
  gridClassName,
4533
4561
  onSelect: handleSelect,
4562
+ onDelete,
4563
+ deleteUrl,
4564
+ autoRecordToDb,
4565
+ fetchThumbnails,
4534
4566
  maxFileSize,
4567
+ maxFiles,
4535
4568
  mode,
4536
- showDelete,
4537
- fetchThumbnails: true
4569
+ showDelete
4538
4570
  }
4539
4571
  );
4540
4572
  };