@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.components.d.mts +247 -0
- package/dist/index.components.d.ts +1 -1
- package/dist/index.components.js +46 -88
- package/dist/index.components.js.map +1 -1
- package/dist/index.components.mjs +46 -88
- package/dist/index.components.mjs.map +1 -1
- package/dist/index.d.mts +558 -0
- package/dist/index.d.ts +3 -33
- package/dist/index.js +51 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -88
- package/dist/index.mjs.map +1 -1
- package/dist/index.next.d.mts +530 -0
- package/dist/index.next.d.ts +1 -1
- package/dist/index.next.js +46 -88
- package/dist/index.next.js.map +1 -1
- package/dist/index.next.mjs +47 -89
- package/dist/index.next.mjs.map +1 -1
- package/dist/index.next.server.d.mts +272 -0
- package/dist/index.next.server.d.ts +1 -1
- package/dist/index.next.server.js +7 -11
- package/dist/index.next.server.js.map +1 -1
- package/dist/index.next.server.mjs +7 -11
- package/dist/index.next.server.mjs.map +1 -1
- package/dist/index.node.d.mts +227 -0
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +3 -5
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +3 -5
- package/dist/index.node.mjs.map +1 -1
- package/package.json +101 -102
package/dist/index.next.mjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { UpfilesClient, ImageManager } from '@thetechfossil/upfiles';
|
|
4
|
-
import React3, { createContext, forwardRef, useState, useCallback, useEffect,
|
|
4
|
+
import React3, { createContext, forwardRef, useContext, useState, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
|
|
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
|
-
|
|
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) {
|
|
@@ -1753,26 +1750,18 @@ var RegisterForm = ({
|
|
|
1753
1750
|
const [confirmPassword, setConfirmPassword] = useState("");
|
|
1754
1751
|
const [isLoading, setIsLoading] = useState(false);
|
|
1755
1752
|
const [error, setError] = useState(null);
|
|
1756
|
-
useState(false);
|
|
1757
|
-
useState(false);
|
|
1753
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
1754
|
+
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
|
1758
1755
|
const getPasswordStrength = (pwd) => {
|
|
1759
|
-
if (!pwd)
|
|
1760
|
-
return { strength: "weak", score: 0, label: "" };
|
|
1756
|
+
if (!pwd) return { strength: "weak", score: 0, label: "" };
|
|
1761
1757
|
let score = 0;
|
|
1762
|
-
if (pwd.length >= 6)
|
|
1763
|
-
|
|
1764
|
-
if (pwd
|
|
1765
|
-
|
|
1766
|
-
if (/[a-
|
|
1767
|
-
|
|
1768
|
-
if (
|
|
1769
|
-
score++;
|
|
1770
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
1771
|
-
score++;
|
|
1772
|
-
if (score <= 2)
|
|
1773
|
-
return { strength: "weak", score, label: "Weak" };
|
|
1774
|
-
if (score <= 3)
|
|
1775
|
-
return { strength: "medium", score, label: "Medium" };
|
|
1758
|
+
if (pwd.length >= 6) score++;
|
|
1759
|
+
if (pwd.length >= 8) score++;
|
|
1760
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
1761
|
+
if (/\d/.test(pwd)) score++;
|
|
1762
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
1763
|
+
if (score <= 2) return { strength: "weak", score, label: "Weak" };
|
|
1764
|
+
if (score <= 3) return { strength: "medium", score, label: "Medium" };
|
|
1776
1765
|
return { strength: "strong", score, label: "Strong" };
|
|
1777
1766
|
};
|
|
1778
1767
|
getPasswordStrength(password);
|
|
@@ -1824,10 +1813,8 @@ var RegisterForm = ({
|
|
|
1824
1813
|
password,
|
|
1825
1814
|
frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
|
|
1826
1815
|
};
|
|
1827
|
-
if (email)
|
|
1828
|
-
|
|
1829
|
-
if (phoneNumber)
|
|
1830
|
-
registerData.phoneNumber = phoneNumber;
|
|
1816
|
+
if (email) registerData.email = email;
|
|
1817
|
+
if (phoneNumber) registerData.phoneNumber = phoneNumber;
|
|
1831
1818
|
const response = await register(registerData);
|
|
1832
1819
|
if (response.success) {
|
|
1833
1820
|
onRegisterSuccess?.();
|
|
@@ -2257,8 +2244,7 @@ var OtpForm = ({
|
|
|
2257
2244
|
}
|
|
2258
2245
|
};
|
|
2259
2246
|
const handleResendOtp = async () => {
|
|
2260
|
-
if (resendCooldown > 0 || resendLoading)
|
|
2261
|
-
return;
|
|
2247
|
+
if (resendCooldown > 0 || resendLoading) return;
|
|
2262
2248
|
setResendLoading(true);
|
|
2263
2249
|
setError(null);
|
|
2264
2250
|
try {
|
|
@@ -3116,23 +3102,15 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
3116
3102
|
}
|
|
3117
3103
|
}, [isSignedIn, redirectUrl]);
|
|
3118
3104
|
const getPasswordStrength = (pwd, colors2) => {
|
|
3119
|
-
if (!pwd)
|
|
3120
|
-
return { strength: "weak", color: colors2.borderSecondary };
|
|
3105
|
+
if (!pwd) return { strength: "weak", color: colors2.borderSecondary };
|
|
3121
3106
|
let score = 0;
|
|
3122
|
-
if (pwd.length >= 6)
|
|
3123
|
-
|
|
3124
|
-
if (pwd
|
|
3125
|
-
|
|
3126
|
-
if (/[a-
|
|
3127
|
-
|
|
3128
|
-
if (
|
|
3129
|
-
score++;
|
|
3130
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
3131
|
-
score++;
|
|
3132
|
-
if (score <= 2)
|
|
3133
|
-
return { strength: "weak", color: colors2.errorText };
|
|
3134
|
-
if (score <= 3)
|
|
3135
|
-
return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
3107
|
+
if (pwd.length >= 6) score++;
|
|
3108
|
+
if (pwd.length >= 8) score++;
|
|
3109
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
3110
|
+
if (/\d/.test(pwd)) score++;
|
|
3111
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
3112
|
+
if (score <= 2) return { strength: "weak", color: colors2.errorText };
|
|
3113
|
+
if (score <= 3) return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
3136
3114
|
return { strength: "strong", color: colors2.successText };
|
|
3137
3115
|
};
|
|
3138
3116
|
const passwordStrength = getPasswordStrength(password, colors);
|
|
@@ -3153,10 +3131,8 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
3153
3131
|
}
|
|
3154
3132
|
try {
|
|
3155
3133
|
const signUpData = { name, password };
|
|
3156
|
-
if (email)
|
|
3157
|
-
|
|
3158
|
-
if (phoneNumber)
|
|
3159
|
-
signUpData.phoneNumber = phoneNumber;
|
|
3134
|
+
if (email) signUpData.email = email;
|
|
3135
|
+
if (phoneNumber) signUpData.phoneNumber = phoneNumber;
|
|
3160
3136
|
const response = await signUp(signUpData);
|
|
3161
3137
|
if (response.success) {
|
|
3162
3138
|
setSuccess("Registration successful! Please check your email to verify your account.");
|
|
@@ -3497,8 +3473,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3497
3473
|
document.addEventListener("mousedown", handleClickOutside);
|
|
3498
3474
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
3499
3475
|
}, []);
|
|
3500
|
-
if (!user)
|
|
3501
|
-
return null;
|
|
3476
|
+
if (!user) return null;
|
|
3502
3477
|
const getInitials = (name) => {
|
|
3503
3478
|
return name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
|
|
3504
3479
|
};
|
|
@@ -3975,23 +3950,15 @@ var ResetPassword = ({ token, appearance }) => {
|
|
|
3975
3950
|
}
|
|
3976
3951
|
}, [resetToken]);
|
|
3977
3952
|
const getPasswordStrength = (pwd) => {
|
|
3978
|
-
if (!pwd)
|
|
3979
|
-
return { strength: "weak", color: "#ddd" };
|
|
3953
|
+
if (!pwd) return { strength: "weak", color: "#ddd" };
|
|
3980
3954
|
let score = 0;
|
|
3981
|
-
if (pwd.length >= 6)
|
|
3982
|
-
|
|
3983
|
-
if (pwd
|
|
3984
|
-
|
|
3985
|
-
if (/[a-
|
|
3986
|
-
|
|
3987
|
-
if (
|
|
3988
|
-
score++;
|
|
3989
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
3990
|
-
score++;
|
|
3991
|
-
if (score <= 2)
|
|
3992
|
-
return { strength: "weak", color: "#f44" };
|
|
3993
|
-
if (score <= 3)
|
|
3994
|
-
return { strength: "medium", color: "#fa4" };
|
|
3955
|
+
if (pwd.length >= 6) score++;
|
|
3956
|
+
if (pwd.length >= 8) score++;
|
|
3957
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
3958
|
+
if (/\d/.test(pwd)) score++;
|
|
3959
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
3960
|
+
if (score <= 2) return { strength: "weak", color: "#f44" };
|
|
3961
|
+
if (score <= 3) return { strength: "medium", color: "#fa4" };
|
|
3995
3962
|
return { strength: "strong", color: "#4f4" };
|
|
3996
3963
|
};
|
|
3997
3964
|
const passwordStrength = getPasswordStrength(password);
|
|
@@ -4229,23 +4196,15 @@ var ChangePassword = ({ onSuccess, appearance }) => {
|
|
|
4229
4196
|
const [error, setError] = useState(null);
|
|
4230
4197
|
const [success, setSuccess] = useState(false);
|
|
4231
4198
|
const getPasswordStrength = (pwd) => {
|
|
4232
|
-
if (!pwd)
|
|
4233
|
-
return { strength: "weak", color: "#ddd" };
|
|
4199
|
+
if (!pwd) return { strength: "weak", color: "#ddd" };
|
|
4234
4200
|
let score = 0;
|
|
4235
|
-
if (pwd.length >= 6)
|
|
4236
|
-
|
|
4237
|
-
if (pwd
|
|
4238
|
-
|
|
4239
|
-
if (/[a-
|
|
4240
|
-
|
|
4241
|
-
if (
|
|
4242
|
-
score++;
|
|
4243
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
4244
|
-
score++;
|
|
4245
|
-
if (score <= 2)
|
|
4246
|
-
return { strength: "weak", color: "#f44" };
|
|
4247
|
-
if (score <= 3)
|
|
4248
|
-
return { strength: "medium", color: "#fa4" };
|
|
4201
|
+
if (pwd.length >= 6) score++;
|
|
4202
|
+
if (pwd.length >= 8) score++;
|
|
4203
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
4204
|
+
if (/\d/.test(pwd)) score++;
|
|
4205
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
4206
|
+
if (score <= 2) return { strength: "weak", color: "#f44" };
|
|
4207
|
+
if (score <= 3) return { strength: "medium", color: "#fa4" };
|
|
4249
4208
|
return { strength: "strong", color: "#4f4" };
|
|
4250
4209
|
};
|
|
4251
4210
|
const passwordStrength = getPasswordStrength(newPassword);
|
|
@@ -4613,8 +4572,7 @@ var UserProfile = ({
|
|
|
4613
4572
|
setIsLoading(false);
|
|
4614
4573
|
}
|
|
4615
4574
|
};
|
|
4616
|
-
if (!user)
|
|
4617
|
-
return null;
|
|
4575
|
+
if (!user) return null;
|
|
4618
4576
|
return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
|
|
4619
4577
|
/* @__PURE__ */ jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
|
|
4620
4578
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
@@ -5089,5 +5047,5 @@ var useNextAuth = (config) => {
|
|
|
5089
5047
|
};
|
|
5090
5048
|
|
|
5091
5049
|
export { AuthFlow, AuthProvider, AuthService, AuthThemeProvider, AvatarManager, AvatarUploader, ChangePassword, EmailVerificationPage, ForgotPassword, HttpClient, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail, useAuth2 as useAuth, useAuth as useAuthLegacy, useAuthTheme, useNextAuth };
|
|
5092
|
-
//# sourceMappingURL=
|
|
5050
|
+
//# sourceMappingURL=index.next.mjs.map
|
|
5093
5051
|
//# sourceMappingURL=index.next.mjs.map
|