@thetechfossil/auth2 1.2.13 → 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.js CHANGED
@@ -15,9 +15,8 @@ var __defProp = Object.defineProperty;
15
15
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
16
16
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
17
17
  }) : x)(function(x) {
18
- if (typeof require !== "undefined")
19
- return require.apply(this, arguments);
20
- throw new Error('Dynamic require of "' + x + '" is not supported');
18
+ if (typeof require !== "undefined") return require.apply(this, arguments);
19
+ throw Error('Dynamic require of "' + x + '" is not supported');
21
20
  });
22
21
  var __export = (target, all) => {
23
22
  for (var name in all)
@@ -194,8 +193,7 @@ var AuthService = class {
194
193
  return this.token;
195
194
  }
196
195
  getCurrentUser() {
197
- if (!this.token)
198
- return null;
196
+ if (!this.token) return null;
199
197
  try {
200
198
  const payload = JSON.parse(atob(this.token.split(".")[1]));
201
199
  return payload.user || null;
@@ -206,8 +204,7 @@ var AuthService = class {
206
204
  }
207
205
  // CSRF Token Management
208
206
  async refreshCsrfToken() {
209
- if (!this.config.csrfEnabled)
210
- return;
207
+ if (!this.config.csrfEnabled) return;
211
208
  try {
212
209
  const response = await this.httpClient.get("/api/v1/auth/csrf-token");
213
210
  if (response.csrfToken) {
@@ -1765,26 +1762,18 @@ var RegisterForm = ({
1765
1762
  const [confirmPassword, setConfirmPassword] = React3.useState("");
1766
1763
  const [isLoading, setIsLoading] = React3.useState(false);
1767
1764
  const [error, setError] = React3.useState(null);
1768
- React3.useState(false);
1769
- React3.useState(false);
1765
+ const [showPassword, setShowPassword] = React3.useState(false);
1766
+ const [showConfirmPassword, setShowConfirmPassword] = React3.useState(false);
1770
1767
  const getPasswordStrength = (pwd) => {
1771
- if (!pwd)
1772
- return { strength: "weak", score: 0, label: "" };
1768
+ if (!pwd) return { strength: "weak", score: 0, label: "" };
1773
1769
  let score = 0;
1774
- if (pwd.length >= 6)
1775
- score++;
1776
- if (pwd.length >= 8)
1777
- score++;
1778
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
1779
- score++;
1780
- if (/\d/.test(pwd))
1781
- score++;
1782
- if (/[^a-zA-Z\d]/.test(pwd))
1783
- score++;
1784
- if (score <= 2)
1785
- return { strength: "weak", score, label: "Weak" };
1786
- if (score <= 3)
1787
- return { strength: "medium", score, label: "Medium" };
1770
+ if (pwd.length >= 6) score++;
1771
+ if (pwd.length >= 8) score++;
1772
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
1773
+ if (/\d/.test(pwd)) score++;
1774
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
1775
+ if (score <= 2) return { strength: "weak", score, label: "Weak" };
1776
+ if (score <= 3) return { strength: "medium", score, label: "Medium" };
1788
1777
  return { strength: "strong", score, label: "Strong" };
1789
1778
  };
1790
1779
  getPasswordStrength(password);
@@ -1836,10 +1825,8 @@ var RegisterForm = ({
1836
1825
  password,
1837
1826
  frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
1838
1827
  };
1839
- if (email)
1840
- registerData.email = email;
1841
- if (phoneNumber)
1842
- registerData.phoneNumber = phoneNumber;
1828
+ if (email) registerData.email = email;
1829
+ if (phoneNumber) registerData.phoneNumber = phoneNumber;
1843
1830
  const response = await register(registerData);
1844
1831
  if (response.success) {
1845
1832
  onRegisterSuccess?.();
@@ -2269,8 +2256,7 @@ var OtpForm = ({
2269
2256
  }
2270
2257
  };
2271
2258
  const handleResendOtp = async () => {
2272
- if (resendCooldown > 0 || resendLoading)
2273
- return;
2259
+ if (resendCooldown > 0 || resendLoading) return;
2274
2260
  setResendLoading(true);
2275
2261
  setError(null);
2276
2262
  try {
@@ -3128,23 +3114,15 @@ var SignUp = ({ redirectUrl, appearance }) => {
3128
3114
  }
3129
3115
  }, [isSignedIn, redirectUrl]);
3130
3116
  const getPasswordStrength = (pwd, colors2) => {
3131
- if (!pwd)
3132
- return { strength: "weak", color: colors2.borderSecondary };
3117
+ if (!pwd) return { strength: "weak", color: colors2.borderSecondary };
3133
3118
  let score = 0;
3134
- if (pwd.length >= 6)
3135
- score++;
3136
- if (pwd.length >= 8)
3137
- score++;
3138
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
3139
- score++;
3140
- if (/\d/.test(pwd))
3141
- score++;
3142
- if (/[^a-zA-Z\d]/.test(pwd))
3143
- score++;
3144
- if (score <= 2)
3145
- return { strength: "weak", color: colors2.errorText };
3146
- if (score <= 3)
3147
- return { strength: "medium", color: colors2.warningText || "#fa4" };
3119
+ if (pwd.length >= 6) score++;
3120
+ if (pwd.length >= 8) score++;
3121
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
3122
+ if (/\d/.test(pwd)) score++;
3123
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
3124
+ if (score <= 2) return { strength: "weak", color: colors2.errorText };
3125
+ if (score <= 3) return { strength: "medium", color: colors2.warningText || "#fa4" };
3148
3126
  return { strength: "strong", color: colors2.successText };
3149
3127
  };
3150
3128
  const passwordStrength = getPasswordStrength(password, colors);
@@ -3165,10 +3143,8 @@ var SignUp = ({ redirectUrl, appearance }) => {
3165
3143
  }
3166
3144
  try {
3167
3145
  const signUpData = { name, password };
3168
- if (email)
3169
- signUpData.email = email;
3170
- if (phoneNumber)
3171
- signUpData.phoneNumber = phoneNumber;
3146
+ if (email) signUpData.email = email;
3147
+ if (phoneNumber) signUpData.phoneNumber = phoneNumber;
3172
3148
  const response = await signUp(signUpData);
3173
3149
  if (response.success) {
3174
3150
  setSuccess("Registration successful! Please check your email to verify your account.");
@@ -3509,8 +3485,7 @@ var UserButton = ({ showName = false, appearance }) => {
3509
3485
  document.addEventListener("mousedown", handleClickOutside);
3510
3486
  return () => document.removeEventListener("mousedown", handleClickOutside);
3511
3487
  }, []);
3512
- if (!user)
3513
- return null;
3488
+ if (!user) return null;
3514
3489
  const getInitials = (name) => {
3515
3490
  return name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
3516
3491
  };
@@ -3987,23 +3962,15 @@ var ResetPassword = ({ token, appearance }) => {
3987
3962
  }
3988
3963
  }, [resetToken]);
3989
3964
  const getPasswordStrength = (pwd) => {
3990
- if (!pwd)
3991
- return { strength: "weak", color: "#ddd" };
3965
+ if (!pwd) return { strength: "weak", color: "#ddd" };
3992
3966
  let score = 0;
3993
- if (pwd.length >= 6)
3994
- score++;
3995
- if (pwd.length >= 8)
3996
- score++;
3997
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
3998
- score++;
3999
- if (/\d/.test(pwd))
4000
- score++;
4001
- if (/[^a-zA-Z\d]/.test(pwd))
4002
- score++;
4003
- if (score <= 2)
4004
- return { strength: "weak", color: "#f44" };
4005
- if (score <= 3)
4006
- return { strength: "medium", color: "#fa4" };
3967
+ if (pwd.length >= 6) score++;
3968
+ if (pwd.length >= 8) score++;
3969
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
3970
+ if (/\d/.test(pwd)) score++;
3971
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
3972
+ if (score <= 2) return { strength: "weak", color: "#f44" };
3973
+ if (score <= 3) return { strength: "medium", color: "#fa4" };
4007
3974
  return { strength: "strong", color: "#4f4" };
4008
3975
  };
4009
3976
  const passwordStrength = getPasswordStrength(password);
@@ -4241,23 +4208,15 @@ var ChangePassword = ({ onSuccess, appearance }) => {
4241
4208
  const [error, setError] = React3.useState(null);
4242
4209
  const [success, setSuccess] = React3.useState(false);
4243
4210
  const getPasswordStrength = (pwd) => {
4244
- if (!pwd)
4245
- return { strength: "weak", color: "#ddd" };
4211
+ if (!pwd) return { strength: "weak", color: "#ddd" };
4246
4212
  let score = 0;
4247
- if (pwd.length >= 6)
4248
- score++;
4249
- if (pwd.length >= 8)
4250
- score++;
4251
- if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd))
4252
- score++;
4253
- if (/\d/.test(pwd))
4254
- score++;
4255
- if (/[^a-zA-Z\d]/.test(pwd))
4256
- score++;
4257
- if (score <= 2)
4258
- return { strength: "weak", color: "#f44" };
4259
- if (score <= 3)
4260
- return { strength: "medium", color: "#fa4" };
4213
+ if (pwd.length >= 6) score++;
4214
+ if (pwd.length >= 8) score++;
4215
+ if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
4216
+ if (/\d/.test(pwd)) score++;
4217
+ if (/[^a-zA-Z\d]/.test(pwd)) score++;
4218
+ if (score <= 2) return { strength: "weak", color: "#f44" };
4219
+ if (score <= 3) return { strength: "medium", color: "#fa4" };
4261
4220
  return { strength: "strong", color: "#4f4" };
4262
4221
  };
4263
4222
  const passwordStrength = getPasswordStrength(newPassword);
@@ -4625,8 +4584,7 @@ var UserProfile = ({
4625
4584
  setIsLoading(false);
4626
4585
  }
4627
4586
  };
4628
- if (!user)
4629
- return null;
4587
+ if (!user) return null;
4630
4588
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
4631
4589
  /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
4632
4590
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
@@ -5022,23 +4980,23 @@ var AuthClient = class extends AuthService {
5022
4980
  }
5023
4981
  };
5024
4982
 
5025
- Object.defineProperty(exports, 'ConnectProjectDialog', {
4983
+ Object.defineProperty(exports, "ConnectProjectDialog", {
5026
4984
  enumerable: true,
5027
4985
  get: function () { return upfiles.ConnectProjectDialog; }
5028
4986
  });
5029
- Object.defineProperty(exports, 'ImageManager', {
4987
+ Object.defineProperty(exports, "ImageManager", {
5030
4988
  enumerable: true,
5031
4989
  get: function () { return upfiles.ImageManager; }
5032
4990
  });
5033
- Object.defineProperty(exports, 'ProjectFilesWidget', {
4991
+ Object.defineProperty(exports, "ProjectFilesWidget", {
5034
4992
  enumerable: true,
5035
4993
  get: function () { return upfiles.ProjectFilesWidget; }
5036
4994
  });
5037
- Object.defineProperty(exports, 'UpfilesClient', {
4995
+ Object.defineProperty(exports, "UpfilesClient", {
5038
4996
  enumerable: true,
5039
4997
  get: function () { return upfiles.UpfilesClient; }
5040
4998
  });
5041
- Object.defineProperty(exports, 'Uploader', {
4999
+ Object.defineProperty(exports, "Uploader", {
5042
5000
  enumerable: true,
5043
5001
  get: function () { return upfiles.Uploader; }
5044
5002
  });
@@ -5066,5 +5024,5 @@ exports.VerifyEmail = VerifyEmail;
5066
5024
  exports.node = node_exports;
5067
5025
  exports.react = react_exports;
5068
5026
  exports.useAuth = useAuth;
5069
- //# sourceMappingURL=out.js.map
5027
+ //# sourceMappingURL=index.js.map
5070
5028
  //# sourceMappingURL=index.js.map