@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.
package/dist/index.mjs CHANGED
@@ -9,9 +9,8 @@ var __defProp = Object.defineProperty;
9
9
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
10
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
11
  }) : x)(function(x) {
12
- if (typeof require !== "undefined")
13
- return require.apply(this, arguments);
14
- throw new Error('Dynamic require of "' + x + '" is not supported');
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
15
14
  });
16
15
  var __export = (target, all) => {
17
16
  for (var name in all)
@@ -188,8 +187,7 @@ var AuthService = class {
188
187
  return this.token;
189
188
  }
190
189
  getCurrentUser() {
191
- if (!this.token)
192
- return null;
190
+ if (!this.token) return null;
193
191
  try {
194
192
  const payload = JSON.parse(atob(this.token.split(".")[1]));
195
193
  return payload.user || null;
@@ -200,8 +198,7 @@ var AuthService = class {
200
198
  }
201
199
  // CSRF Token Management
202
200
  async refreshCsrfToken() {
203
- if (!this.config.csrfEnabled)
204
- return;
201
+ if (!this.config.csrfEnabled) return;
205
202
  try {
206
203
  const response = await this.httpClient.get("/api/v1/auth/csrf-token");
207
204
  if (response.csrfToken) {
@@ -1759,26 +1756,18 @@ var RegisterForm = ({
1759
1756
  const [confirmPassword, setConfirmPassword] = useState("");
1760
1757
  const [isLoading, setIsLoading] = useState(false);
1761
1758
  const [error, setError] = useState(null);
1762
- useState(false);
1763
- useState(false);
1759
+ const [showPassword, setShowPassword] = useState(false);
1760
+ const [showConfirmPassword, setShowConfirmPassword] = useState(false);
1764
1761
  const getPasswordStrength = (pwd) => {
1765
- if (!pwd)
1766
- return { strength: "weak", score: 0, label: "" };
1762
+ if (!pwd) return { strength: "weak", score: 0, label: "" };
1767
1763
  let score = 0;
1768
- if (pwd.length >= 6)
1769
- score++;
1770
- if (pwd.length >= 8)
1771
- score++;
1772
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
1773
- score++;
1774
- if (/\d/.test(pwd))
1775
- score++;
1776
- if (/[^a-zA-Z\d]/.test(pwd))
1777
- score++;
1778
- if (score <= 2)
1779
- return { strength: "weak", score, label: "Weak" };
1780
- if (score <= 3)
1781
- return { strength: "medium", score, label: "Medium" };
1764
+ if (pwd.length >= 6) score++;
1765
+ if (pwd.length >= 8) score++;
1766
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
1767
+ if (/\d/.test(pwd)) score++;
1768
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
1769
+ if (score <= 2) return { strength: "weak", score, label: "Weak" };
1770
+ if (score <= 3) return { strength: "medium", score, label: "Medium" };
1782
1771
  return { strength: "strong", score, label: "Strong" };
1783
1772
  };
1784
1773
  getPasswordStrength(password);
@@ -1830,10 +1819,8 @@ var RegisterForm = ({
1830
1819
  password,
1831
1820
  frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1832
1821
  };
1833
- if (email)
1834
- registerData.email = email;
1835
- if (phoneNumber)
1836
- registerData.phoneNumber = phoneNumber;
1822
+ if (email) registerData.email = email;
1823
+ if (phoneNumber) registerData.phoneNumber = phoneNumber;
1837
1824
  const response = await register(registerData);
1838
1825
  if (response.success) {
1839
1826
  onRegisterSuccess?.();
@@ -2263,8 +2250,7 @@ var OtpForm = ({
2263
2250
  }
2264
2251
  };
2265
2252
  const handleResendOtp = async () => {
2266
- if (resendCooldown > 0 || resendLoading)
2267
- return;
2253
+ if (resendCooldown > 0 || resendLoading) return;
2268
2254
  setResendLoading(true);
2269
2255
  setError(null);
2270
2256
  try {
@@ -3122,23 +3108,15 @@ var SignUp = ({ redirectUrl, appearance }) => {
3122
3108
  }
3123
3109
  }, [isSignedIn, redirectUrl]);
3124
3110
  const getPasswordStrength = (pwd, colors2) => {
3125
- if (!pwd)
3126
- return { strength: "weak", color: colors2.borderSecondary };
3111
+ if (!pwd) return { strength: "weak", color: colors2.borderSecondary };
3127
3112
  let score = 0;
3128
- if (pwd.length >= 6)
3129
- score++;
3130
- if (pwd.length >= 8)
3131
- score++;
3132
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
3133
- score++;
3134
- if (/\d/.test(pwd))
3135
- score++;
3136
- if (/[^a-zA-Z\d]/.test(pwd))
3137
- score++;
3138
- if (score <= 2)
3139
- return { strength: "weak", color: colors2.errorText };
3140
- if (score <= 3)
3141
- return { strength: "medium", color: colors2.warningText || "#fa4" };
3113
+ if (pwd.length >= 6) score++;
3114
+ if (pwd.length >= 8) score++;
3115
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
3116
+ if (/\d/.test(pwd)) score++;
3117
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
3118
+ if (score <= 2) return { strength: "weak", color: colors2.errorText };
3119
+ if (score <= 3) return { strength: "medium", color: colors2.warningText || "#fa4" };
3142
3120
  return { strength: "strong", color: colors2.successText };
3143
3121
  };
3144
3122
  const passwordStrength = getPasswordStrength(password, colors);
@@ -3159,10 +3137,8 @@ var SignUp = ({ redirectUrl, appearance }) => {
3159
3137
  }
3160
3138
  try {
3161
3139
  const signUpData = { name, password };
3162
- if (email)
3163
- signUpData.email = email;
3164
- if (phoneNumber)
3165
- signUpData.phoneNumber = phoneNumber;
3140
+ if (email) signUpData.email = email;
3141
+ if (phoneNumber) signUpData.phoneNumber = phoneNumber;
3166
3142
  const response = await signUp(signUpData);
3167
3143
  if (response.success) {
3168
3144
  setSuccess("Registration successful! Please check your email to verify your account.");
@@ -3503,8 +3479,7 @@ var UserButton = ({ showName = false, appearance }) => {
3503
3479
  document.addEventListener("mousedown", handleClickOutside);
3504
3480
  return () => document.removeEventListener("mousedown", handleClickOutside);
3505
3481
  }, []);
3506
- if (!user)
3507
- return null;
3482
+ if (!user) return null;
3508
3483
  const getInitials = (name) => {
3509
3484
  return name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
3510
3485
  };
@@ -3981,23 +3956,15 @@ var ResetPassword = ({ token, appearance }) => {
3981
3956
  }
3982
3957
  }, [resetToken]);
3983
3958
  const getPasswordStrength = (pwd) => {
3984
- if (!pwd)
3985
- return { strength: "weak", color: "#ddd" };
3959
+ if (!pwd) return { strength: "weak", color: "#ddd" };
3986
3960
  let score = 0;
3987
- if (pwd.length >= 6)
3988
- score++;
3989
- if (pwd.length >= 8)
3990
- score++;
3991
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
3992
- score++;
3993
- if (/\d/.test(pwd))
3994
- score++;
3995
- if (/[^a-zA-Z\d]/.test(pwd))
3996
- score++;
3997
- if (score <= 2)
3998
- return { strength: "weak", color: "#f44" };
3999
- if (score <= 3)
4000
- return { strength: "medium", color: "#fa4" };
3961
+ if (pwd.length >= 6) score++;
3962
+ if (pwd.length >= 8) score++;
3963
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
3964
+ if (/\d/.test(pwd)) score++;
3965
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
3966
+ if (score <= 2) return { strength: "weak", color: "#f44" };
3967
+ if (score <= 3) return { strength: "medium", color: "#fa4" };
4001
3968
  return { strength: "strong", color: "#4f4" };
4002
3969
  };
4003
3970
  const passwordStrength = getPasswordStrength(password);
@@ -4235,23 +4202,15 @@ var ChangePassword = ({ onSuccess, appearance }) => {
4235
4202
  const [error, setError] = useState(null);
4236
4203
  const [success, setSuccess] = useState(false);
4237
4204
  const getPasswordStrength = (pwd) => {
4238
- if (!pwd)
4239
- return { strength: "weak", color: "#ddd" };
4205
+ if (!pwd) return { strength: "weak", color: "#ddd" };
4240
4206
  let score = 0;
4241
- if (pwd.length >= 6)
4242
- score++;
4243
- if (pwd.length >= 8)
4244
- score++;
4245
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
4246
- score++;
4247
- if (/\d/.test(pwd))
4248
- score++;
4249
- if (/[^a-zA-Z\d]/.test(pwd))
4250
- score++;
4251
- if (score <= 2)
4252
- return { strength: "weak", color: "#f44" };
4253
- if (score <= 3)
4254
- return { strength: "medium", color: "#fa4" };
4207
+ if (pwd.length >= 6) score++;
4208
+ if (pwd.length >= 8) score++;
4209
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
4210
+ if (/\d/.test(pwd)) score++;
4211
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
4212
+ if (score <= 2) return { strength: "weak", color: "#f44" };
4213
+ if (score <= 3) return { strength: "medium", color: "#fa4" };
4255
4214
  return { strength: "strong", color: "#4f4" };
4256
4215
  };
4257
4216
  const passwordStrength = getPasswordStrength(newPassword);
@@ -4619,8 +4578,7 @@ var UserProfile = ({
4619
4578
  setIsLoading(false);
4620
4579
  }
4621
4580
  };
4622
- if (!user)
4623
- return null;
4581
+ if (!user) return null;
4624
4582
  return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
4625
4583
  /* @__PURE__ */ jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
4626
4584
  error && /* @__PURE__ */ jsx("div", { style: {
@@ -5017,5 +4975,5 @@ var AuthClient = class extends AuthService {
5017
4975
  };
5018
4976
 
5019
4977
  export { AuthFlow, AuthProvider, AuthService, AvatarManager, AvatarUploader, ChangePassword, EmailVerificationPage, ForgotPassword, HttpClient, LoginForm, OtpForm, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail, node_exports as node, react_exports as react, useAuth };
5020
- //# sourceMappingURL=out.js.map
4978
+ //# sourceMappingURL=index.mjs.map
5021
4979
  //# sourceMappingURL=index.mjs.map