@thetechfossil/auth2 1.2.14 → 1.2.15

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.
@@ -7,9 +7,8 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
8
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
9
  }) : x)(function(x) {
10
- if (typeof require !== "undefined")
11
- return require.apply(this, arguments);
12
- throw new Error('Dynamic require of "' + x + '" is not supported');
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
12
  });
14
13
  var HttpClient = class {
15
14
  constructor(baseUrl, defaultHeaders = {}) {
@@ -182,8 +181,7 @@ var AuthService = class {
182
181
  return this.token;
183
182
  }
184
183
  getCurrentUser() {
185
- if (!this.token)
186
- return null;
184
+ if (!this.token) return null;
187
185
  try {
188
186
  const payload = JSON.parse(atob(this.token.split(".")[1]));
189
187
  return payload.user || null;
@@ -194,8 +192,7 @@ var AuthService = class {
194
192
  }
195
193
  // CSRF Token Management
196
194
  async refreshCsrfToken() {
197
- if (!this.config.csrfEnabled)
198
- return;
195
+ if (!this.config.csrfEnabled) return;
199
196
  try {
200
197
  const response = await this.httpClient.get("/api/v1/auth/csrf-token");
201
198
  if (response.csrfToken) {
@@ -1422,26 +1419,18 @@ var RegisterForm = ({
1422
1419
  const [confirmPassword, setConfirmPassword] = useState("");
1423
1420
  const [isLoading, setIsLoading] = useState(false);
1424
1421
  const [error, setError] = useState(null);
1425
- useState(false);
1426
- useState(false);
1422
+ const [showPassword, setShowPassword] = useState(false);
1423
+ const [showConfirmPassword, setShowConfirmPassword] = useState(false);
1427
1424
  const getPasswordStrength = (pwd) => {
1428
- if (!pwd)
1429
- return { strength: "weak", score: 0, label: "" };
1425
+ if (!pwd) return { strength: "weak", score: 0, label: "" };
1430
1426
  let score = 0;
1431
- if (pwd.length >= 6)
1432
- score++;
1433
- if (pwd.length >= 8)
1434
- score++;
1435
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
1436
- score++;
1437
- if (/\d/.test(pwd))
1438
- score++;
1439
- if (/[^a-zA-Z\d]/.test(pwd))
1440
- score++;
1441
- if (score <= 2)
1442
- return { strength: "weak", score, label: "Weak" };
1443
- if (score <= 3)
1444
- return { strength: "medium", score, label: "Medium" };
1427
+ if (pwd.length >= 6) score++;
1428
+ if (pwd.length >= 8) score++;
1429
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
1430
+ if (/\d/.test(pwd)) score++;
1431
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
1432
+ if (score <= 2) return { strength: "weak", score, label: "Weak" };
1433
+ if (score <= 3) return { strength: "medium", score, label: "Medium" };
1445
1434
  return { strength: "strong", score, label: "Strong" };
1446
1435
  };
1447
1436
  getPasswordStrength(password);
@@ -1493,10 +1482,8 @@ var RegisterForm = ({
1493
1482
  password,
1494
1483
  frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1495
1484
  };
1496
- if (email)
1497
- registerData.email = email;
1498
- if (phoneNumber)
1499
- registerData.phoneNumber = phoneNumber;
1485
+ if (email) registerData.email = email;
1486
+ if (phoneNumber) registerData.phoneNumber = phoneNumber;
1500
1487
  const response = await register(registerData);
1501
1488
  if (response.success) {
1502
1489
  onRegisterSuccess?.();
@@ -1926,8 +1913,7 @@ var OtpForm = ({
1926
1913
  }
1927
1914
  };
1928
1915
  const handleResendOtp = async () => {
1929
- if (resendCooldown > 0 || resendLoading)
1930
- return;
1916
+ if (resendCooldown > 0 || resendLoading) return;
1931
1917
  setResendLoading(true);
1932
1918
  setError(null);
1933
1919
  try {
@@ -2793,23 +2779,15 @@ var SignUp = ({ redirectUrl, appearance }) => {
2793
2779
  }
2794
2780
  }, [isSignedIn, redirectUrl]);
2795
2781
  const getPasswordStrength = (pwd, colors2) => {
2796
- if (!pwd)
2797
- return { strength: "weak", color: colors2.borderSecondary };
2782
+ if (!pwd) return { strength: "weak", color: colors2.borderSecondary };
2798
2783
  let score = 0;
2799
- if (pwd.length >= 6)
2800
- score++;
2801
- if (pwd.length >= 8)
2802
- score++;
2803
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
2804
- score++;
2805
- if (/\d/.test(pwd))
2806
- score++;
2807
- if (/[^a-zA-Z\d]/.test(pwd))
2808
- score++;
2809
- if (score <= 2)
2810
- return { strength: "weak", color: colors2.errorText };
2811
- if (score <= 3)
2812
- return { strength: "medium", color: colors2.warningText || "#fa4" };
2784
+ if (pwd.length >= 6) score++;
2785
+ if (pwd.length >= 8) score++;
2786
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
2787
+ if (/\d/.test(pwd)) score++;
2788
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
2789
+ if (score <= 2) return { strength: "weak", color: colors2.errorText };
2790
+ if (score <= 3) return { strength: "medium", color: colors2.warningText || "#fa4" };
2813
2791
  return { strength: "strong", color: colors2.successText };
2814
2792
  };
2815
2793
  const passwordStrength = getPasswordStrength(password, colors);
@@ -2830,10 +2808,8 @@ var SignUp = ({ redirectUrl, appearance }) => {
2830
2808
  }
2831
2809
  try {
2832
2810
  const signUpData = { name, password };
2833
- if (email)
2834
- signUpData.email = email;
2835
- if (phoneNumber)
2836
- signUpData.phoneNumber = phoneNumber;
2811
+ if (email) signUpData.email = email;
2812
+ if (phoneNumber) signUpData.phoneNumber = phoneNumber;
2837
2813
  const response = await signUp(signUpData);
2838
2814
  if (response.success) {
2839
2815
  setSuccess("Registration successful! Please check your email to verify your account.");
@@ -3174,8 +3150,7 @@ var UserButton = ({ showName = false, appearance }) => {
3174
3150
  document.addEventListener("mousedown", handleClickOutside);
3175
3151
  return () => document.removeEventListener("mousedown", handleClickOutside);
3176
3152
  }, []);
3177
- if (!user)
3178
- return null;
3153
+ if (!user) return null;
3179
3154
  const getInitials = (name) => {
3180
3155
  return name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
3181
3156
  };
@@ -3652,23 +3627,15 @@ var ResetPassword = ({ token, appearance }) => {
3652
3627
  }
3653
3628
  }, [resetToken]);
3654
3629
  const getPasswordStrength = (pwd) => {
3655
- if (!pwd)
3656
- return { strength: "weak", color: "#ddd" };
3630
+ if (!pwd) return { strength: "weak", color: "#ddd" };
3657
3631
  let score = 0;
3658
- if (pwd.length >= 6)
3659
- score++;
3660
- if (pwd.length >= 8)
3661
- score++;
3662
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
3663
- score++;
3664
- if (/\d/.test(pwd))
3665
- score++;
3666
- if (/[^a-zA-Z\d]/.test(pwd))
3667
- score++;
3668
- if (score <= 2)
3669
- return { strength: "weak", color: "#f44" };
3670
- if (score <= 3)
3671
- return { strength: "medium", color: "#fa4" };
3632
+ if (pwd.length >= 6) score++;
3633
+ if (pwd.length >= 8) score++;
3634
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
3635
+ if (/\d/.test(pwd)) score++;
3636
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
3637
+ if (score <= 2) return { strength: "weak", color: "#f44" };
3638
+ if (score <= 3) return { strength: "medium", color: "#fa4" };
3672
3639
  return { strength: "strong", color: "#4f4" };
3673
3640
  };
3674
3641
  const passwordStrength = getPasswordStrength(password);
@@ -3906,23 +3873,15 @@ var ChangePassword = ({ onSuccess, appearance }) => {
3906
3873
  const [error, setError] = useState(null);
3907
3874
  const [success, setSuccess] = useState(false);
3908
3875
  const getPasswordStrength = (pwd) => {
3909
- if (!pwd)
3910
- return { strength: "weak", color: "#ddd" };
3876
+ if (!pwd) return { strength: "weak", color: "#ddd" };
3911
3877
  let score = 0;
3912
- if (pwd.length >= 6)
3913
- score++;
3914
- if (pwd.length >= 8)
3915
- score++;
3916
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
3917
- score++;
3918
- if (/\d/.test(pwd))
3919
- score++;
3920
- if (/[^a-zA-Z\d]/.test(pwd))
3921
- score++;
3922
- if (score <= 2)
3923
- return { strength: "weak", color: "#f44" };
3924
- if (score <= 3)
3925
- return { strength: "medium", color: "#fa4" };
3878
+ if (pwd.length >= 6) score++;
3879
+ if (pwd.length >= 8) score++;
3880
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
3881
+ if (/\d/.test(pwd)) score++;
3882
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
3883
+ if (score <= 2) return { strength: "weak", color: "#f44" };
3884
+ if (score <= 3) return { strength: "medium", color: "#fa4" };
3926
3885
  return { strength: "strong", color: "#4f4" };
3927
3886
  };
3928
3887
  const passwordStrength = getPasswordStrength(newPassword);
@@ -4290,8 +4249,7 @@ var UserProfile = ({
4290
4249
  setIsLoading(false);
4291
4250
  }
4292
4251
  };
4293
- if (!user)
4294
- return null;
4252
+ if (!user) return null;
4295
4253
  return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
4296
4254
  /* @__PURE__ */ jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
4297
4255
  error && /* @__PURE__ */ jsx("div", { style: {
@@ -4575,5 +4533,5 @@ var AvatarManager = ({
4575
4533
  };
4576
4534
 
4577
4535
  export { AuthFlow, AvatarManager, AvatarUploader, ChangePassword, EmailVerificationPage, ForgotPassword, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail };
4578
- //# sourceMappingURL=out.js.map
4536
+ //# sourceMappingURL=index.components.mjs.map
4579
4537
  //# sourceMappingURL=index.components.mjs.map