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