@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.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
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
interface LoginFormProps {
|
|
4
|
+
onSuccess?: (response: {
|
|
5
|
+
message: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
token?: string;
|
|
8
|
+
success: boolean;
|
|
9
|
+
user?: any;
|
|
10
|
+
}) => void;
|
|
11
|
+
onLoginSuccess?: (email: string, needsOtpVerification: boolean) => void;
|
|
12
|
+
onRegisterClick?: () => void;
|
|
13
|
+
showRegisterLink?: boolean;
|
|
14
|
+
config?: {
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
};
|
|
17
|
+
oauthProviders?: Array<'google' | 'github'>;
|
|
18
|
+
showOAuthButtons?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare const LoginForm: React.FC<LoginFormProps>;
|
|
21
|
+
|
|
22
|
+
interface AuthConfig {
|
|
23
|
+
baseUrl: string;
|
|
24
|
+
localStorageKey?: string;
|
|
25
|
+
token?: string;
|
|
26
|
+
csrfEnabled?: boolean;
|
|
27
|
+
upfilesConfig?: UpfilesConfig;
|
|
28
|
+
}
|
|
29
|
+
interface UpfilesConfig {
|
|
30
|
+
baseUrl: string;
|
|
31
|
+
apiKey?: string;
|
|
32
|
+
apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
|
|
33
|
+
presignUrl?: string;
|
|
34
|
+
presignPath?: string;
|
|
35
|
+
folderPath?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface RegisterFormProps {
|
|
39
|
+
onRegisterSuccess?: () => void;
|
|
40
|
+
onLoginClick?: () => void;
|
|
41
|
+
showLoginLink?: boolean;
|
|
42
|
+
authConfig?: AuthConfig;
|
|
43
|
+
oauthProviders?: Array<'google' | 'github'>;
|
|
44
|
+
showOAuthButtons?: boolean;
|
|
45
|
+
invitationToken?: string | null;
|
|
46
|
+
}
|
|
47
|
+
declare const RegisterForm: React.FC<RegisterFormProps>;
|
|
48
|
+
|
|
49
|
+
interface OtpFormProps {
|
|
50
|
+
email: string;
|
|
51
|
+
onVerifySuccess?: () => void;
|
|
52
|
+
onBackToLogin?: () => void;
|
|
53
|
+
baseUrl?: string;
|
|
54
|
+
}
|
|
55
|
+
declare const OtpForm: React.FC<OtpFormProps>;
|
|
56
|
+
|
|
57
|
+
type AuthStep = 'login' | 'register' | 'otp';
|
|
58
|
+
interface AuthFlowProps {
|
|
59
|
+
onAuthComplete?: () => void;
|
|
60
|
+
initialStep?: AuthStep;
|
|
61
|
+
showTitle?: boolean;
|
|
62
|
+
}
|
|
63
|
+
declare const AuthFlow: React.FC<AuthFlowProps>;
|
|
64
|
+
|
|
65
|
+
interface EmailVerificationPageProps {
|
|
66
|
+
token: string;
|
|
67
|
+
onVerificationSuccess?: () => void;
|
|
68
|
+
onVerificationError?: (error: string) => void;
|
|
69
|
+
baseUrl?: string;
|
|
70
|
+
}
|
|
71
|
+
declare const EmailVerificationPage: React.FC<EmailVerificationPageProps>;
|
|
72
|
+
|
|
73
|
+
interface SignInProps {
|
|
74
|
+
redirectUrl?: string;
|
|
75
|
+
appearance?: {
|
|
76
|
+
elements?: {
|
|
77
|
+
formButtonPrimary?: React.CSSProperties;
|
|
78
|
+
card?: React.CSSProperties;
|
|
79
|
+
headerTitle?: React.CSSProperties;
|
|
80
|
+
formFieldInput?: React.CSSProperties;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
routing?: 'path' | 'virtual';
|
|
84
|
+
path?: string;
|
|
85
|
+
}
|
|
86
|
+
declare const SignIn: React.FC<SignInProps>;
|
|
87
|
+
|
|
88
|
+
interface SignUpProps {
|
|
89
|
+
redirectUrl?: string;
|
|
90
|
+
appearance?: {
|
|
91
|
+
elements?: {
|
|
92
|
+
formButtonPrimary?: React.CSSProperties;
|
|
93
|
+
card?: React.CSSProperties;
|
|
94
|
+
headerTitle?: React.CSSProperties;
|
|
95
|
+
formFieldInput?: React.CSSProperties;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
declare const SignUp: React.FC<SignUpProps>;
|
|
100
|
+
|
|
101
|
+
interface SignOutProps {
|
|
102
|
+
redirectUrl?: string;
|
|
103
|
+
}
|
|
104
|
+
declare const SignOut: React.FC<SignOutProps>;
|
|
105
|
+
|
|
106
|
+
interface UserButtonProps {
|
|
107
|
+
showName?: boolean;
|
|
108
|
+
appearance?: {
|
|
109
|
+
elements?: {
|
|
110
|
+
userButtonBox?: React.CSSProperties;
|
|
111
|
+
userButtonTrigger?: React.CSSProperties;
|
|
112
|
+
userButtonPopoverCard?: React.CSSProperties;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
declare const UserButton: React.FC<UserButtonProps>;
|
|
117
|
+
|
|
118
|
+
interface ProtectedRouteProps {
|
|
119
|
+
children: ReactNode;
|
|
120
|
+
fallback?: ReactNode;
|
|
121
|
+
redirectTo?: string;
|
|
122
|
+
}
|
|
123
|
+
declare const ProtectedRoute: React.FC<ProtectedRouteProps>;
|
|
124
|
+
|
|
125
|
+
interface PublicRouteProps {
|
|
126
|
+
children: ReactNode;
|
|
127
|
+
redirectTo?: string;
|
|
128
|
+
}
|
|
129
|
+
declare const PublicRoute: React.FC<PublicRouteProps>;
|
|
130
|
+
|
|
131
|
+
interface VerifyEmailProps {
|
|
132
|
+
token?: string;
|
|
133
|
+
onSuccess?: () => void;
|
|
134
|
+
onError?: (error: string) => void;
|
|
135
|
+
}
|
|
136
|
+
declare const VerifyEmail: React.FC<VerifyEmailProps>;
|
|
137
|
+
|
|
138
|
+
interface ForgotPasswordProps {
|
|
139
|
+
appearance?: {
|
|
140
|
+
elements?: {
|
|
141
|
+
formButtonPrimary?: React.CSSProperties;
|
|
142
|
+
card?: React.CSSProperties;
|
|
143
|
+
headerTitle?: React.CSSProperties;
|
|
144
|
+
formFieldInput?: React.CSSProperties;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
declare const ForgotPassword: React.FC<ForgotPasswordProps>;
|
|
149
|
+
|
|
150
|
+
interface ResetPasswordProps {
|
|
151
|
+
token?: string;
|
|
152
|
+
appearance?: {
|
|
153
|
+
elements?: {
|
|
154
|
+
formButtonPrimary?: React.CSSProperties;
|
|
155
|
+
card?: React.CSSProperties;
|
|
156
|
+
headerTitle?: React.CSSProperties;
|
|
157
|
+
formFieldInput?: React.CSSProperties;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
declare const ResetPassword: React.FC<ResetPasswordProps>;
|
|
162
|
+
|
|
163
|
+
interface ChangePasswordProps {
|
|
164
|
+
onSuccess?: () => void;
|
|
165
|
+
appearance?: {
|
|
166
|
+
elements?: {
|
|
167
|
+
formButtonPrimary?: React.CSSProperties;
|
|
168
|
+
card?: React.CSSProperties;
|
|
169
|
+
headerTitle?: React.CSSProperties;
|
|
170
|
+
formFieldInput?: React.CSSProperties;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
declare const ChangePassword: React.FC<ChangePasswordProps>;
|
|
175
|
+
|
|
176
|
+
interface UserProfileProps {
|
|
177
|
+
showAvatar?: boolean;
|
|
178
|
+
showEmailChange?: boolean;
|
|
179
|
+
showPasswordChange?: boolean;
|
|
180
|
+
upfilesConfig?: {
|
|
181
|
+
baseUrl: string;
|
|
182
|
+
apiKey?: string;
|
|
183
|
+
apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
|
|
184
|
+
presignUrl?: string;
|
|
185
|
+
presignPath?: string;
|
|
186
|
+
folderPath?: string;
|
|
187
|
+
projectId?: string;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
declare const UserProfile: React.FC<UserProfileProps>;
|
|
191
|
+
|
|
192
|
+
interface PhoneInputProps {
|
|
193
|
+
value: string;
|
|
194
|
+
onChange: (value: string) => void;
|
|
195
|
+
disabled?: boolean;
|
|
196
|
+
required?: boolean;
|
|
197
|
+
placeholder?: string;
|
|
198
|
+
id?: string;
|
|
199
|
+
style?: React.CSSProperties;
|
|
200
|
+
}
|
|
201
|
+
declare const PhoneInput: React.FC<PhoneInputProps>;
|
|
202
|
+
|
|
203
|
+
interface AvatarUploaderProps {
|
|
204
|
+
onUploadComplete?: (avatarUrl: string) => void;
|
|
205
|
+
onError?: (error: Error) => void;
|
|
206
|
+
className?: string;
|
|
207
|
+
buttonClassName?: string;
|
|
208
|
+
dropzoneClassName?: string;
|
|
209
|
+
maxFileSize?: number;
|
|
210
|
+
accept?: string[];
|
|
211
|
+
upfilesConfig: {
|
|
212
|
+
baseUrl: string;
|
|
213
|
+
apiKey?: string;
|
|
214
|
+
apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
|
|
215
|
+
presignUrl?: string;
|
|
216
|
+
presignPath?: string;
|
|
217
|
+
folderPath?: string;
|
|
218
|
+
projectId?: string;
|
|
219
|
+
};
|
|
220
|
+
buttonText?: string;
|
|
221
|
+
}
|
|
222
|
+
declare const AvatarUploader: React.FC<AvatarUploaderProps>;
|
|
223
|
+
|
|
224
|
+
interface AvatarManagerProps {
|
|
225
|
+
open: boolean;
|
|
226
|
+
onOpenChange: (open: boolean) => void;
|
|
227
|
+
onAvatarUpdated?: (avatarUrl: string) => void;
|
|
228
|
+
onError?: (error: Error) => void;
|
|
229
|
+
title?: string;
|
|
230
|
+
description?: string;
|
|
231
|
+
className?: string;
|
|
232
|
+
gridClassName?: string;
|
|
233
|
+
maxFileSize?: number;
|
|
234
|
+
mode?: 'full' | 'browse' | 'upload';
|
|
235
|
+
showDelete?: boolean;
|
|
236
|
+
upfilesConfig: {
|
|
237
|
+
baseUrl: string;
|
|
238
|
+
apiKey?: string;
|
|
239
|
+
apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
|
|
240
|
+
presignUrl?: string;
|
|
241
|
+
presignPath?: string;
|
|
242
|
+
folderPath?: string;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
declare const AvatarManager: React.FC<AvatarManagerProps>;
|
|
246
|
+
|
|
247
|
+
export { AuthFlow, AvatarManager, type AvatarManagerProps, AvatarUploader, type AvatarUploaderProps, ChangePassword, EmailVerificationPage, ForgotPassword, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, type RegisterFormProps, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail };
|
|
@@ -244,4 +244,4 @@ interface AvatarManagerProps {
|
|
|
244
244
|
}
|
|
245
245
|
declare const AvatarManager: React.FC<AvatarManagerProps>;
|
|
246
246
|
|
|
247
|
-
export { AuthFlow, AvatarManager, AvatarManagerProps, AvatarUploader, AvatarUploaderProps, ChangePassword, EmailVerificationPage, ForgotPassword, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, RegisterFormProps, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail };
|
|
247
|
+
export { AuthFlow, AvatarManager, type AvatarManagerProps, AvatarUploader, type AvatarUploaderProps, ChangePassword, EmailVerificationPage, ForgotPassword, LoginForm, OtpForm, PhoneInput, ProtectedRoute, PublicRoute, RegisterForm, type RegisterFormProps, ResetPassword, SignIn, SignOut, SignUp, UserButton, UserProfile, VerifyEmail };
|
package/dist/index.components.js
CHANGED
|
@@ -14,9 +14,8 @@ var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
|
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
|
-
|
|
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) {
|
|
@@ -1429,26 +1426,18 @@ var RegisterForm = ({
|
|
|
1429
1426
|
const [confirmPassword, setConfirmPassword] = React2.useState("");
|
|
1430
1427
|
const [isLoading, setIsLoading] = React2.useState(false);
|
|
1431
1428
|
const [error, setError] = React2.useState(null);
|
|
1432
|
-
React2.useState(false);
|
|
1433
|
-
React2.useState(false);
|
|
1429
|
+
const [showPassword, setShowPassword] = React2.useState(false);
|
|
1430
|
+
const [showConfirmPassword, setShowConfirmPassword] = React2.useState(false);
|
|
1434
1431
|
const getPasswordStrength = (pwd) => {
|
|
1435
|
-
if (!pwd)
|
|
1436
|
-
return { strength: "weak", score: 0, label: "" };
|
|
1432
|
+
if (!pwd) return { strength: "weak", score: 0, label: "" };
|
|
1437
1433
|
let score = 0;
|
|
1438
|
-
if (pwd.length >= 6)
|
|
1439
|
-
|
|
1440
|
-
if (pwd
|
|
1441
|
-
|
|
1442
|
-
if (/[a-
|
|
1443
|
-
|
|
1444
|
-
if (
|
|
1445
|
-
score++;
|
|
1446
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
1447
|
-
score++;
|
|
1448
|
-
if (score <= 2)
|
|
1449
|
-
return { strength: "weak", score, label: "Weak" };
|
|
1450
|
-
if (score <= 3)
|
|
1451
|
-
return { strength: "medium", score, label: "Medium" };
|
|
1434
|
+
if (pwd.length >= 6) score++;
|
|
1435
|
+
if (pwd.length >= 8) score++;
|
|
1436
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
1437
|
+
if (/\d/.test(pwd)) score++;
|
|
1438
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
1439
|
+
if (score <= 2) return { strength: "weak", score, label: "Weak" };
|
|
1440
|
+
if (score <= 3) return { strength: "medium", score, label: "Medium" };
|
|
1452
1441
|
return { strength: "strong", score, label: "Strong" };
|
|
1453
1442
|
};
|
|
1454
1443
|
getPasswordStrength(password);
|
|
@@ -1500,10 +1489,8 @@ var RegisterForm = ({
|
|
|
1500
1489
|
password,
|
|
1501
1490
|
frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
|
|
1502
1491
|
};
|
|
1503
|
-
if (email)
|
|
1504
|
-
|
|
1505
|
-
if (phoneNumber)
|
|
1506
|
-
registerData.phoneNumber = phoneNumber;
|
|
1492
|
+
if (email) registerData.email = email;
|
|
1493
|
+
if (phoneNumber) registerData.phoneNumber = phoneNumber;
|
|
1507
1494
|
const response = await register(registerData);
|
|
1508
1495
|
if (response.success) {
|
|
1509
1496
|
onRegisterSuccess?.();
|
|
@@ -1933,8 +1920,7 @@ var OtpForm = ({
|
|
|
1933
1920
|
}
|
|
1934
1921
|
};
|
|
1935
1922
|
const handleResendOtp = async () => {
|
|
1936
|
-
if (resendCooldown > 0 || resendLoading)
|
|
1937
|
-
return;
|
|
1923
|
+
if (resendCooldown > 0 || resendLoading) return;
|
|
1938
1924
|
setResendLoading(true);
|
|
1939
1925
|
setError(null);
|
|
1940
1926
|
try {
|
|
@@ -2800,23 +2786,15 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2800
2786
|
}
|
|
2801
2787
|
}, [isSignedIn, redirectUrl]);
|
|
2802
2788
|
const getPasswordStrength = (pwd, colors2) => {
|
|
2803
|
-
if (!pwd)
|
|
2804
|
-
return { strength: "weak", color: colors2.borderSecondary };
|
|
2789
|
+
if (!pwd) return { strength: "weak", color: colors2.borderSecondary };
|
|
2805
2790
|
let score = 0;
|
|
2806
|
-
if (pwd.length >= 6)
|
|
2807
|
-
|
|
2808
|
-
if (pwd
|
|
2809
|
-
|
|
2810
|
-
if (/[a-
|
|
2811
|
-
|
|
2812
|
-
if (
|
|
2813
|
-
score++;
|
|
2814
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
2815
|
-
score++;
|
|
2816
|
-
if (score <= 2)
|
|
2817
|
-
return { strength: "weak", color: colors2.errorText };
|
|
2818
|
-
if (score <= 3)
|
|
2819
|
-
return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
2791
|
+
if (pwd.length >= 6) score++;
|
|
2792
|
+
if (pwd.length >= 8) score++;
|
|
2793
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
2794
|
+
if (/\d/.test(pwd)) score++;
|
|
2795
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
2796
|
+
if (score <= 2) return { strength: "weak", color: colors2.errorText };
|
|
2797
|
+
if (score <= 3) return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
2820
2798
|
return { strength: "strong", color: colors2.successText };
|
|
2821
2799
|
};
|
|
2822
2800
|
const passwordStrength = getPasswordStrength(password, colors);
|
|
@@ -2837,10 +2815,8 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2837
2815
|
}
|
|
2838
2816
|
try {
|
|
2839
2817
|
const signUpData = { name, password };
|
|
2840
|
-
if (email)
|
|
2841
|
-
|
|
2842
|
-
if (phoneNumber)
|
|
2843
|
-
signUpData.phoneNumber = phoneNumber;
|
|
2818
|
+
if (email) signUpData.email = email;
|
|
2819
|
+
if (phoneNumber) signUpData.phoneNumber = phoneNumber;
|
|
2844
2820
|
const response = await signUp(signUpData);
|
|
2845
2821
|
if (response.success) {
|
|
2846
2822
|
setSuccess("Registration successful! Please check your email to verify your account.");
|
|
@@ -3181,8 +3157,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3181
3157
|
document.addEventListener("mousedown", handleClickOutside);
|
|
3182
3158
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
3183
3159
|
}, []);
|
|
3184
|
-
if (!user)
|
|
3185
|
-
return null;
|
|
3160
|
+
if (!user) return null;
|
|
3186
3161
|
const getInitials = (name) => {
|
|
3187
3162
|
return name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
|
|
3188
3163
|
};
|
|
@@ -3659,23 +3634,15 @@ var ResetPassword = ({ token, appearance }) => {
|
|
|
3659
3634
|
}
|
|
3660
3635
|
}, [resetToken]);
|
|
3661
3636
|
const getPasswordStrength = (pwd) => {
|
|
3662
|
-
if (!pwd)
|
|
3663
|
-
return { strength: "weak", color: "#ddd" };
|
|
3637
|
+
if (!pwd) return { strength: "weak", color: "#ddd" };
|
|
3664
3638
|
let score = 0;
|
|
3665
|
-
if (pwd.length >= 6)
|
|
3666
|
-
|
|
3667
|
-
if (pwd
|
|
3668
|
-
|
|
3669
|
-
if (/[a-
|
|
3670
|
-
|
|
3671
|
-
if (
|
|
3672
|
-
score++;
|
|
3673
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
3674
|
-
score++;
|
|
3675
|
-
if (score <= 2)
|
|
3676
|
-
return { strength: "weak", color: "#f44" };
|
|
3677
|
-
if (score <= 3)
|
|
3678
|
-
return { strength: "medium", color: "#fa4" };
|
|
3639
|
+
if (pwd.length >= 6) score++;
|
|
3640
|
+
if (pwd.length >= 8) score++;
|
|
3641
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
3642
|
+
if (/\d/.test(pwd)) score++;
|
|
3643
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
3644
|
+
if (score <= 2) return { strength: "weak", color: "#f44" };
|
|
3645
|
+
if (score <= 3) return { strength: "medium", color: "#fa4" };
|
|
3679
3646
|
return { strength: "strong", color: "#4f4" };
|
|
3680
3647
|
};
|
|
3681
3648
|
const passwordStrength = getPasswordStrength(password);
|
|
@@ -3913,23 +3880,15 @@ var ChangePassword = ({ onSuccess, appearance }) => {
|
|
|
3913
3880
|
const [error, setError] = React2.useState(null);
|
|
3914
3881
|
const [success, setSuccess] = React2.useState(false);
|
|
3915
3882
|
const getPasswordStrength = (pwd) => {
|
|
3916
|
-
if (!pwd)
|
|
3917
|
-
return { strength: "weak", color: "#ddd" };
|
|
3883
|
+
if (!pwd) return { strength: "weak", color: "#ddd" };
|
|
3918
3884
|
let score = 0;
|
|
3919
|
-
if (pwd.length >= 6)
|
|
3920
|
-
|
|
3921
|
-
if (pwd
|
|
3922
|
-
|
|
3923
|
-
if (/[a-
|
|
3924
|
-
|
|
3925
|
-
if (
|
|
3926
|
-
score++;
|
|
3927
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
3928
|
-
score++;
|
|
3929
|
-
if (score <= 2)
|
|
3930
|
-
return { strength: "weak", color: "#f44" };
|
|
3931
|
-
if (score <= 3)
|
|
3932
|
-
return { strength: "medium", color: "#fa4" };
|
|
3885
|
+
if (pwd.length >= 6) score++;
|
|
3886
|
+
if (pwd.length >= 8) score++;
|
|
3887
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
3888
|
+
if (/\d/.test(pwd)) score++;
|
|
3889
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
3890
|
+
if (score <= 2) return { strength: "weak", color: "#f44" };
|
|
3891
|
+
if (score <= 3) return { strength: "medium", color: "#fa4" };
|
|
3933
3892
|
return { strength: "strong", color: "#4f4" };
|
|
3934
3893
|
};
|
|
3935
3894
|
const passwordStrength = getPasswordStrength(newPassword);
|
|
@@ -4297,8 +4256,7 @@ var UserProfile = ({
|
|
|
4297
4256
|
setIsLoading(false);
|
|
4298
4257
|
}
|
|
4299
4258
|
};
|
|
4300
|
-
if (!user)
|
|
4301
|
-
return null;
|
|
4259
|
+
if (!user) return null;
|
|
4302
4260
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
|
|
4303
4261
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
|
|
4304
4262
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
@@ -4600,5 +4558,5 @@ exports.SignUp = SignUp;
|
|
|
4600
4558
|
exports.UserButton = UserButton;
|
|
4601
4559
|
exports.UserProfile = UserProfile;
|
|
4602
4560
|
exports.VerifyEmail = VerifyEmail;
|
|
4603
|
-
//# sourceMappingURL=
|
|
4561
|
+
//# sourceMappingURL=index.components.js.map
|
|
4604
4562
|
//# sourceMappingURL=index.components.js.map
|