@mesob/auth-react 0.1.0 → 0.2.0
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/components/auth/{auth-page-layout.d.ts → auth-layout.d.ts} +3 -3
- package/dist/components/auth/{auth-page-layout.js → auth-layout.js} +4 -4
- package/dist/components/auth/auth-layout.js.map +1 -0
- package/dist/components/auth/countdown.js +15 -6
- package/dist/components/auth/countdown.js.map +1 -1
- package/dist/components/auth/forgot-password.d.ts +1 -9
- package/dist/components/auth/forgot-password.js +267 -43
- package/dist/components/auth/forgot-password.js.map +1 -1
- package/dist/components/auth/reset-password-form.d.ts +2 -10
- package/dist/components/auth/reset-password-form.js +366 -118
- package/dist/components/auth/reset-password-form.js.map +1 -1
- package/dist/components/auth/sign-in.d.ts +2 -10
- package/dist/components/auth/sign-in.js +358 -130
- package/dist/components/auth/sign-in.js.map +1 -1
- package/dist/components/auth/sign-up.d.ts +2 -10
- package/dist/components/auth/sign-up.js +379 -131
- package/dist/components/auth/sign-up.js.map +1 -1
- package/dist/components/auth/verification-form.d.ts +2 -16
- package/dist/components/auth/verification-form.js +15 -6
- package/dist/components/auth/verification-form.js.map +1 -1
- package/dist/components/auth/verify-email.d.ts +10 -0
- package/dist/components/auth/{pages/verify-email-page.js → verify-email.js} +54 -34
- package/dist/components/auth/verify-email.js.map +1 -0
- package/dist/components/auth/verify-phone.d.ts +11 -0
- package/dist/components/auth/{pages/verify-phone-page.js → verify-phone.js} +53 -46
- package/dist/components/auth/verify-phone.js.map +1 -0
- package/dist/components/error-boundary.d.ts +2 -2
- package/dist/components/iam/permissions.d.ts +5 -0
- package/dist/components/iam/{permissions/permissions-page.js → permissions.js} +29 -13
- package/dist/components/iam/permissions.js.map +1 -0
- package/dist/components/iam/roles.d.ts +5 -0
- package/dist/components/iam/{roles/roles-page.js → roles.js} +29 -13
- package/dist/components/iam/roles.js.map +1 -0
- package/dist/components/iam/sessions.d.ts +5 -0
- package/dist/components/iam/{sessions/sessions-page.js → sessions.js} +13 -11
- package/dist/components/iam/sessions.js.map +1 -0
- package/dist/components/iam/tenants.d.ts +5 -0
- package/dist/components/iam/{tenants/tenants-page.js → tenants.js} +13 -11
- package/dist/components/iam/tenants.js.map +1 -0
- package/dist/components/iam/users.d.ts +5 -0
- package/dist/components/iam/{users/users-page.js → users.js} +13 -11
- package/dist/components/iam/users.js.map +1 -0
- package/dist/components/profile/account.d.ts +5 -0
- package/dist/components/profile/account.js +66 -0
- package/dist/components/profile/account.js.map +1 -0
- package/dist/components/profile/change-email-form.d.ts +5 -0
- package/dist/components/profile/change-email-form.js +721 -0
- package/dist/components/profile/change-email-form.js.map +1 -0
- package/dist/components/profile/change-password-form.d.ts +5 -0
- package/dist/components/profile/change-password-form.js +256 -0
- package/dist/components/profile/change-password-form.js.map +1 -0
- package/dist/components/profile/change-phone-form.d.ts +5 -0
- package/dist/components/profile/change-phone-form.js +758 -0
- package/dist/components/profile/change-phone-form.js.map +1 -0
- package/dist/components/profile/change-profile.d.ts +9 -0
- package/dist/components/profile/change-profile.js +37 -0
- package/dist/components/profile/change-profile.js.map +1 -0
- package/dist/components/profile/otp-verification-modal.d.ts +15 -0
- package/dist/components/profile/otp-verification-modal.js +261 -0
- package/dist/components/profile/otp-verification-modal.js.map +1 -0
- package/dist/components/profile/request-change-email-form.d.ts +10 -0
- package/dist/components/profile/request-change-email-form.js +293 -0
- package/dist/components/profile/request-change-email-form.js.map +1 -0
- package/dist/components/profile/request-change-phone-form.d.ts +10 -0
- package/dist/components/profile/request-change-phone-form.js +331 -0
- package/dist/components/profile/request-change-phone-form.js.map +1 -0
- package/dist/components/profile/security.d.ts +5 -0
- package/dist/components/profile/security.js +1439 -0
- package/dist/components/profile/security.js.map +1 -0
- package/dist/components/profile/verify-change-email-form.d.ts +11 -0
- package/dist/components/profile/verify-change-email-form.js +402 -0
- package/dist/components/profile/verify-change-email-form.js.map +1 -0
- package/dist/components/profile/verify-change-phone-form.d.ts +11 -0
- package/dist/components/profile/verify-change-phone-form.js +406 -0
- package/dist/components/profile/verify-change-phone-form.js.map +1 -0
- package/dist/components/shared/{data-table/data-table.js → data-table.js} +2 -2
- package/dist/components/shared/data-table.js.map +1 -0
- package/dist/index.d.ts +42 -88
- package/dist/index.js +2297 -1299
- package/dist/index.js.map +1 -1
- package/dist/types-D3s9oE-5.d.ts +75 -0
- package/dist/verification-form-ipSRTtQB.d.ts +22 -0
- package/package.json +3 -2
- package/dist/components/auth/auth-page-layout.js.map +0 -1
- package/dist/components/auth/pages/forgot-password-page.d.ts +0 -6
- package/dist/components/auth/pages/forgot-password-page.js +0 -362
- package/dist/components/auth/pages/forgot-password-page.js.map +0 -1
- package/dist/components/auth/pages/reset-password-page.d.ts +0 -9
- package/dist/components/auth/pages/reset-password-page.js +0 -514
- package/dist/components/auth/pages/reset-password-page.js.map +0 -1
- package/dist/components/auth/pages/sign-in-page.d.ts +0 -8
- package/dist/components/auth/pages/sign-in-page.js +0 -565
- package/dist/components/auth/pages/sign-in-page.js.map +0 -1
- package/dist/components/auth/pages/sign-up-page.d.ts +0 -9
- package/dist/components/auth/pages/sign-up-page.js +0 -518
- package/dist/components/auth/pages/sign-up-page.js.map +0 -1
- package/dist/components/auth/pages/verify-email-page.d.ts +0 -10
- package/dist/components/auth/pages/verify-email-page.js.map +0 -1
- package/dist/components/auth/pages/verify-phone-page.d.ts +0 -11
- package/dist/components/auth/pages/verify-phone-page.js.map +0 -1
- package/dist/components/iam/permissions/permissions-page.d.ts +0 -5
- package/dist/components/iam/permissions/permissions-page.js.map +0 -1
- package/dist/components/iam/roles/roles-page.d.ts +0 -5
- package/dist/components/iam/roles/roles-page.js.map +0 -1
- package/dist/components/iam/sessions/sessions-page.d.ts +0 -5
- package/dist/components/iam/sessions/sessions-page.js.map +0 -1
- package/dist/components/iam/tenants/tenants-page.d.ts +0 -5
- package/dist/components/iam/tenants/tenants-page.js.map +0 -1
- package/dist/components/iam/users/users-page.d.ts +0 -5
- package/dist/components/iam/users/users-page.js.map +0 -1
- package/dist/components/profile/profile-page.d.ts +0 -8
- package/dist/components/profile/profile-page.js +0 -163
- package/dist/components/profile/profile-page.js.map +0 -1
- package/dist/components/shared/data-table/data-table.js.map +0 -1
- package/dist/handle-error-BqDMxnQZ.d.ts +0 -8
- /package/dist/components/shared/{data-table/data-table.d.ts → data-table.d.ts} +0 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/profile/request-change-phone-form.tsx
|
|
4
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
5
|
+
import { Button } from "@mesob/ui/components/button";
|
|
6
|
+
import { Input } from "@mesob/ui/components/input";
|
|
7
|
+
import { Label } from "@mesob/ui/components/label";
|
|
8
|
+
import { Spinner } from "@mesob/ui/components/spinner";
|
|
9
|
+
import { IconEye, IconEyeOff } from "@tabler/icons-react";
|
|
10
|
+
import { useEffect, useState as useState2 } from "react";
|
|
11
|
+
import { useForm } from "react-hook-form";
|
|
12
|
+
import { toast } from "sonner";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
|
|
15
|
+
// src/provider.tsx
|
|
16
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
17
|
+
import { deepmerge } from "deepmerge-ts";
|
|
18
|
+
import createFetchClient from "openapi-fetch";
|
|
19
|
+
import createClient from "openapi-react-query";
|
|
20
|
+
import { createContext, useContext, useMemo, useState } from "react";
|
|
21
|
+
|
|
22
|
+
// src/utils/cookie.ts
|
|
23
|
+
var isProduction = typeof process !== "undefined" && process.env.NODE_ENV === "production";
|
|
24
|
+
|
|
25
|
+
// src/provider.tsx
|
|
26
|
+
import { jsx } from "react/jsx-runtime";
|
|
27
|
+
var SessionContext = createContext(null);
|
|
28
|
+
var ApiContext = createContext(null);
|
|
29
|
+
var ConfigContext = createContext(null);
|
|
30
|
+
var queryClient = new QueryClient({
|
|
31
|
+
defaultOptions: {
|
|
32
|
+
queries: {
|
|
33
|
+
refetchOnWindowFocus: false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
function useSession() {
|
|
38
|
+
const context = useContext(SessionContext);
|
|
39
|
+
if (!context) {
|
|
40
|
+
throw new Error("useSession must be used within MesobAuthProvider");
|
|
41
|
+
}
|
|
42
|
+
return context;
|
|
43
|
+
}
|
|
44
|
+
function useApi() {
|
|
45
|
+
const context = useContext(ApiContext);
|
|
46
|
+
if (!context) {
|
|
47
|
+
throw new Error("useApi must be used within MesobAuthProvider");
|
|
48
|
+
}
|
|
49
|
+
return context;
|
|
50
|
+
}
|
|
51
|
+
function useConfig() {
|
|
52
|
+
const context = useContext(ConfigContext);
|
|
53
|
+
if (!context) {
|
|
54
|
+
throw new Error("useConfig must be used within MesobAuthProvider");
|
|
55
|
+
}
|
|
56
|
+
return context;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/utils/normalize-phone.ts
|
|
60
|
+
function normalizePhone(phone) {
|
|
61
|
+
const cleaned = phone.trim().replace(/\s/g, "");
|
|
62
|
+
if (cleaned.startsWith("+2519") || cleaned.startsWith("+2517")) {
|
|
63
|
+
return cleaned;
|
|
64
|
+
}
|
|
65
|
+
if (cleaned.startsWith("2519") || cleaned.startsWith("2517")) {
|
|
66
|
+
return `+${cleaned}`;
|
|
67
|
+
}
|
|
68
|
+
if (cleaned.startsWith("09") || cleaned.startsWith("07")) {
|
|
69
|
+
return `+251${cleaned.slice(1)}`;
|
|
70
|
+
}
|
|
71
|
+
if ((cleaned.startsWith("9") || cleaned.startsWith("7")) && cleaned.length === 9) {
|
|
72
|
+
return `+251${cleaned}`;
|
|
73
|
+
}
|
|
74
|
+
return cleaned;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/components/profile/request-change-phone-form.tsx
|
|
78
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
79
|
+
var phonePasswordSchema = (phoneRegex) => z.object({
|
|
80
|
+
phone: z.string().trim().min(1, { message: "Phone number is required" }).refine(
|
|
81
|
+
(val) => {
|
|
82
|
+
const isPhone = phoneRegex.test(val);
|
|
83
|
+
return isPhone;
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
message: "Invalid phone number"
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
password: z.string().min(8, "Password must be at least 8 characters").max(128, "Password too long")
|
|
90
|
+
});
|
|
91
|
+
function isAuthError(error) {
|
|
92
|
+
return typeof error === "object" && error !== null && ("code" in error || "message" in error || "name" in error);
|
|
93
|
+
}
|
|
94
|
+
function getErrorCode(error) {
|
|
95
|
+
if (error.code) {
|
|
96
|
+
return error.code;
|
|
97
|
+
}
|
|
98
|
+
if (error.message) {
|
|
99
|
+
const upperMessage = error.message.toUpperCase().trim();
|
|
100
|
+
const validCodes = [
|
|
101
|
+
"USER_NOT_FOUND",
|
|
102
|
+
"USER_EXISTS",
|
|
103
|
+
"INVALID_PASSWORD",
|
|
104
|
+
"VERIFICATION_EXPIRED",
|
|
105
|
+
"VERIFICATION_MISMATCH",
|
|
106
|
+
"VERIFICATION_NOT_FOUND",
|
|
107
|
+
"TOO_MANY_ATTEMPTS",
|
|
108
|
+
"UNAUTHORIZED"
|
|
109
|
+
];
|
|
110
|
+
if (validCodes.includes(upperMessage)) {
|
|
111
|
+
return upperMessage;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
function getErrorMessage(error) {
|
|
117
|
+
if (isAuthError(error)) {
|
|
118
|
+
const errorCode = getErrorCode(error);
|
|
119
|
+
switch (errorCode) {
|
|
120
|
+
case "USER_EXISTS":
|
|
121
|
+
return "This phone number is already taken. Please use a different number.";
|
|
122
|
+
case "VERIFICATION_EXPIRED":
|
|
123
|
+
return "Verification code has expired. Please request a new one.";
|
|
124
|
+
case "VERIFICATION_MISMATCH":
|
|
125
|
+
return "Invalid verification code. Please try again.";
|
|
126
|
+
case "VERIFICATION_NOT_FOUND":
|
|
127
|
+
return "Verification not found. Please request a new code.";
|
|
128
|
+
default:
|
|
129
|
+
return error.message || "An error occurred. Please try again.";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (error instanceof Error) {
|
|
133
|
+
return error.message;
|
|
134
|
+
}
|
|
135
|
+
return "An error occurred. Please try again.";
|
|
136
|
+
}
|
|
137
|
+
function RequestChangePhoneForm({
|
|
138
|
+
onSuccess,
|
|
139
|
+
onCancel,
|
|
140
|
+
buttonText
|
|
141
|
+
}) {
|
|
142
|
+
const { user } = useSession();
|
|
143
|
+
const { hooks } = useApi();
|
|
144
|
+
const { config } = useConfig();
|
|
145
|
+
const [isSubmitting, setIsSubmitting] = useState2(false);
|
|
146
|
+
const [isChecking, setIsChecking] = useState2(true);
|
|
147
|
+
const [showPassword, setShowPassword] = useState2(false);
|
|
148
|
+
const phoneRegex = typeof config.phoneRegex === "string" ? new RegExp(config.phoneRegex) : config.phoneRegex || /^(\+2519|\+2517|2519|2517|09|07)\d{8}$/;
|
|
149
|
+
const getPendingAccountChangeQuery = hooks.useQuery(
|
|
150
|
+
"get",
|
|
151
|
+
"/account-change/pending",
|
|
152
|
+
{},
|
|
153
|
+
{ enabled: false }
|
|
154
|
+
);
|
|
155
|
+
const verifyPasswordMutation = hooks.useMutation("post", "/password/verify");
|
|
156
|
+
const checkUserMutation = hooks.useMutation("post", "/check-account");
|
|
157
|
+
const requestPhoneOtpMutation = hooks.useMutation(
|
|
158
|
+
"post",
|
|
159
|
+
"/phone/verification/request"
|
|
160
|
+
);
|
|
161
|
+
const phonePasswordForm = useForm({
|
|
162
|
+
resolver: zodResolver(phonePasswordSchema(phoneRegex)),
|
|
163
|
+
defaultValues: {
|
|
164
|
+
phone: "",
|
|
165
|
+
password: ""
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
const {
|
|
169
|
+
register,
|
|
170
|
+
handleSubmit,
|
|
171
|
+
getValues,
|
|
172
|
+
setValue,
|
|
173
|
+
formState: { errors }
|
|
174
|
+
} = phonePasswordForm;
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
let active = true;
|
|
177
|
+
const run = async () => {
|
|
178
|
+
try {
|
|
179
|
+
const data = await getPendingAccountChangeQuery.refetch();
|
|
180
|
+
if (!active) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const accountChange = data.data?.accountChange;
|
|
184
|
+
const verificationId = data.data?.verificationId;
|
|
185
|
+
if (accountChange?.changeType !== "phone") {
|
|
186
|
+
setIsChecking(false);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!accountChange.newPhone) {
|
|
190
|
+
setIsChecking(false);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (getValues("phone")) {
|
|
194
|
+
setIsChecking(false);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
setValue("phone", accountChange.newPhone, { shouldValidate: true });
|
|
198
|
+
if (verificationId) {
|
|
199
|
+
toast.message("Resuming verification\u2026");
|
|
200
|
+
onSuccess(verificationId, accountChange.newPhone);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
setIsChecking(false);
|
|
204
|
+
} catch {
|
|
205
|
+
setIsChecking(false);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
run().catch(() => void 0);
|
|
209
|
+
return () => {
|
|
210
|
+
active = false;
|
|
211
|
+
};
|
|
212
|
+
}, [getPendingAccountChangeQuery.refetch, getValues, onSuccess, setValue]);
|
|
213
|
+
const onPhonePasswordSubmit = async (data) => {
|
|
214
|
+
if (!user) {
|
|
215
|
+
toast.error("User not found");
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
setIsSubmitting(true);
|
|
220
|
+
const normalizedPhone = normalizePhone(data.phone);
|
|
221
|
+
await verifyPasswordMutation.mutateAsync({
|
|
222
|
+
body: { password: data.password }
|
|
223
|
+
});
|
|
224
|
+
const checkResult = await checkUserMutation.mutateAsync({
|
|
225
|
+
body: { identifier: normalizedPhone }
|
|
226
|
+
});
|
|
227
|
+
if (checkResult.data?.exists) {
|
|
228
|
+
if (user?.phone?.replace(/\s/g, "") === normalizedPhone.replace(/\s/g, "")) {
|
|
229
|
+
toast.error("This is already your current phone number.");
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
toast.error(
|
|
233
|
+
"This phone number is already taken. Please use a different number."
|
|
234
|
+
);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const verification = await requestPhoneOtpMutation.mutateAsync({
|
|
238
|
+
body: {
|
|
239
|
+
phone: normalizedPhone,
|
|
240
|
+
context: "change-phone"
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
toast.success("Verification code sent to your phone");
|
|
244
|
+
onSuccess(verification.data?.verificationId ?? "", normalizedPhone);
|
|
245
|
+
} catch (error) {
|
|
246
|
+
const errorMessage = getErrorMessage(error);
|
|
247
|
+
if (isAuthError(error)) {
|
|
248
|
+
const errorCode = getErrorCode(error);
|
|
249
|
+
if (errorCode === "INVALID_PASSWORD" || errorCode === "USER_NOT_FOUND") {
|
|
250
|
+
toast.error("Incorrect password. Please try again.");
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
toast.error(errorMessage);
|
|
255
|
+
} finally {
|
|
256
|
+
setIsSubmitting(false);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const isLoading = isSubmitting || isChecking;
|
|
260
|
+
return /* @__PURE__ */ jsxs(
|
|
261
|
+
"form",
|
|
262
|
+
{
|
|
263
|
+
onSubmit: handleSubmit(onPhonePasswordSubmit),
|
|
264
|
+
className: "p-4 space-y-4 border-t",
|
|
265
|
+
children: [
|
|
266
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-4 w-full md:w-1/2", children: [
|
|
267
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
268
|
+
/* @__PURE__ */ jsx2(Label, { htmlFor: "phone", children: "Phone Number" }),
|
|
269
|
+
/* @__PURE__ */ jsx2(
|
|
270
|
+
Input,
|
|
271
|
+
{
|
|
272
|
+
id: "phone",
|
|
273
|
+
type: "tel",
|
|
274
|
+
placeholder: "Enter your new phone number",
|
|
275
|
+
...register("phone"),
|
|
276
|
+
disabled: isLoading
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
errors.phone && /* @__PURE__ */ jsx2("p", { className: "text-sm text-destructive", children: errors.phone.message })
|
|
280
|
+
] }),
|
|
281
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
282
|
+
/* @__PURE__ */ jsx2(Label, { htmlFor: "password", children: "Password" }),
|
|
283
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
284
|
+
/* @__PURE__ */ jsx2(
|
|
285
|
+
Input,
|
|
286
|
+
{
|
|
287
|
+
id: "password",
|
|
288
|
+
type: showPassword ? "text" : "password",
|
|
289
|
+
autoComplete: "current-password",
|
|
290
|
+
placeholder: "Enter your password",
|
|
291
|
+
...register("password"),
|
|
292
|
+
disabled: isLoading
|
|
293
|
+
}
|
|
294
|
+
),
|
|
295
|
+
/* @__PURE__ */ jsx2(
|
|
296
|
+
"button",
|
|
297
|
+
{
|
|
298
|
+
type: "button",
|
|
299
|
+
onClick: () => setShowPassword(!showPassword),
|
|
300
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",
|
|
301
|
+
children: showPassword ? /* @__PURE__ */ jsx2(IconEyeOff, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx2(IconEye, { className: "h-4 w-4" })
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
] }),
|
|
305
|
+
errors.password && /* @__PURE__ */ jsx2("p", { className: "text-sm text-destructive", children: errors.password.message })
|
|
306
|
+
] })
|
|
307
|
+
] }),
|
|
308
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
309
|
+
/* @__PURE__ */ jsx2(
|
|
310
|
+
Button,
|
|
311
|
+
{
|
|
312
|
+
type: "button",
|
|
313
|
+
variant: "outline",
|
|
314
|
+
onClick: onCancel,
|
|
315
|
+
disabled: isLoading,
|
|
316
|
+
children: "Cancel"
|
|
317
|
+
}
|
|
318
|
+
),
|
|
319
|
+
/* @__PURE__ */ jsxs(Button, { type: "submit", disabled: isLoading, children: [
|
|
320
|
+
isLoading && /* @__PURE__ */ jsx2(Spinner, { className: "mr-2 h-4 w-4" }),
|
|
321
|
+
isChecking ? "Checking\u2026" : buttonText
|
|
322
|
+
] })
|
|
323
|
+
] })
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
export {
|
|
329
|
+
RequestChangePhoneForm
|
|
330
|
+
};
|
|
331
|
+
//# sourceMappingURL=request-change-phone-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/profile/request-change-phone-form.tsx","../../../src/provider.tsx","../../../src/utils/cookie.ts","../../../src/utils/normalize-phone.ts"],"sourcesContent":["'use client';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { Button } from '@mesob/ui/components/button';\nimport { Input } from '@mesob/ui/components/input';\nimport { Label } from '@mesob/ui/components/label';\nimport { Spinner } from '@mesob/ui/components/spinner';\nimport { IconEye, IconEyeOff } from '@tabler/icons-react';\nimport { useEffect, useState } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { toast } from 'sonner';\nimport { z } from 'zod';\nimport { useApi, useConfig, useSession } from '../../provider';\nimport { normalizePhone } from '../../utils/normalize-phone';\n\nconst phonePasswordSchema = (phoneRegex: RegExp) =>\n z.object({\n phone: z\n .string()\n .trim()\n .min(1, { message: 'Phone number is required' })\n .refine(\n (val) => {\n const isPhone = phoneRegex.test(val);\n return isPhone;\n },\n {\n message: 'Invalid phone number',\n },\n ),\n password: z\n .string()\n .min(8, 'Password must be at least 8 characters')\n .max(128, 'Password too long'),\n });\n\ntype PhonePasswordFormData = z.infer<ReturnType<typeof phonePasswordSchema>>;\n\ntype AuthErrorLike = {\n code?: string;\n message?: string;\n name?: string;\n};\n\nfunction isAuthError(error: unknown): error is AuthErrorLike {\n return (\n typeof error === 'object' &&\n error !== null &&\n ('code' in error || 'message' in error || 'name' in error)\n );\n}\n\nfunction getErrorCode(error: AuthErrorLike): string | undefined {\n if (error.code) {\n return error.code;\n }\n if (error.message) {\n const upperMessage = error.message.toUpperCase().trim();\n const validCodes = [\n 'USER_NOT_FOUND',\n 'USER_EXISTS',\n 'INVALID_PASSWORD',\n 'VERIFICATION_EXPIRED',\n 'VERIFICATION_MISMATCH',\n 'VERIFICATION_NOT_FOUND',\n 'TOO_MANY_ATTEMPTS',\n 'UNAUTHORIZED',\n ];\n if (validCodes.includes(upperMessage)) {\n return upperMessage;\n }\n }\n return undefined;\n}\n\nfunction getErrorMessage(error: unknown): string {\n if (isAuthError(error)) {\n const errorCode = getErrorCode(error);\n switch (errorCode) {\n case 'USER_EXISTS':\n return 'This phone number is already taken. Please use a different number.';\n case 'VERIFICATION_EXPIRED':\n return 'Verification code has expired. Please request a new one.';\n case 'VERIFICATION_MISMATCH':\n return 'Invalid verification code. Please try again.';\n case 'VERIFICATION_NOT_FOUND':\n return 'Verification not found. Please request a new code.';\n default:\n return error.message || 'An error occurred. Please try again.';\n }\n }\n if (error instanceof Error) {\n return error.message;\n }\n return 'An error occurred. Please try again.';\n}\n\ninterface RequestChangePhoneFormProps {\n onSuccess: (verificationId: string, phone: string) => void;\n onCancel: () => void;\n buttonText: string;\n}\n\nexport function RequestChangePhoneForm({\n onSuccess,\n onCancel,\n buttonText,\n}: RequestChangePhoneFormProps) {\n const { user } = useSession();\n const { hooks } = useApi();\n const { config } = useConfig();\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [isChecking, setIsChecking] = useState(true);\n const [showPassword, setShowPassword] = useState(false);\n\n const phoneRegex =\n typeof config.phoneRegex === 'string'\n ? new RegExp(config.phoneRegex)\n : config.phoneRegex || /^(\\+2519|\\+2517|2519|2517|09|07)\\d{8}$/;\n\n const getPendingAccountChangeQuery = hooks.useQuery(\n 'get',\n '/account-change/pending',\n {},\n { enabled: false },\n );\n const verifyPasswordMutation = hooks.useMutation('post', '/password/verify');\n const checkUserMutation = hooks.useMutation('post', '/check-account');\n const requestPhoneOtpMutation = hooks.useMutation(\n 'post',\n '/phone/verification/request',\n );\n\n const phonePasswordForm = useForm<PhonePasswordFormData>({\n resolver: zodResolver(phonePasswordSchema(phoneRegex)),\n defaultValues: {\n phone: '',\n password: '',\n },\n });\n\n const {\n register,\n handleSubmit,\n getValues,\n setValue,\n formState: { errors },\n } = phonePasswordForm;\n\n useEffect(() => {\n let active = true;\n const run = async () => {\n try {\n const data = await getPendingAccountChangeQuery.refetch();\n if (!active) {\n return;\n }\n const accountChange = data.data?.accountChange;\n const verificationId = data.data?.verificationId;\n if (accountChange?.changeType !== 'phone') {\n setIsChecking(false);\n return;\n }\n if (!accountChange.newPhone) {\n setIsChecking(false);\n return;\n }\n if (getValues('phone')) {\n setIsChecking(false);\n return;\n }\n setValue('phone', accountChange.newPhone, { shouldValidate: true });\n\n if (verificationId) {\n toast.message('Resuming verification…');\n onSuccess(verificationId, accountChange.newPhone);\n return;\n }\n\n setIsChecking(false);\n } catch {\n setIsChecking(false);\n }\n };\n run().catch(() => undefined);\n return () => {\n active = false;\n };\n }, [getPendingAccountChangeQuery.refetch, getValues, onSuccess, setValue]);\n\n const onPhonePasswordSubmit = async (data: PhonePasswordFormData) => {\n if (!user) {\n toast.error('User not found');\n return;\n }\n\n try {\n setIsSubmitting(true);\n\n const normalizedPhone = normalizePhone(data.phone);\n\n // Verify password first\n await verifyPasswordMutation.mutateAsync({\n body: { password: data.password },\n });\n\n // Check if phone exists\n const checkResult = await checkUserMutation.mutateAsync({\n body: { identifier: normalizedPhone },\n });\n if (checkResult.data?.exists) {\n // Check if it belongs to current user\n if (\n user?.phone?.replace(/\\s/g, '') === normalizedPhone.replace(/\\s/g, '')\n ) {\n toast.error('This is already your current phone number.');\n return;\n }\n toast.error(\n 'This phone number is already taken. Please use a different number.',\n );\n return;\n }\n\n // Request OTP\n const verification = await requestPhoneOtpMutation.mutateAsync({\n body: {\n phone: normalizedPhone,\n context: 'change-phone',\n },\n });\n\n toast.success('Verification code sent to your phone');\n onSuccess(verification.data?.verificationId ?? '', normalizedPhone);\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n if (isAuthError(error)) {\n const errorCode = getErrorCode(error);\n if (\n errorCode === 'INVALID_PASSWORD' ||\n errorCode === 'USER_NOT_FOUND'\n ) {\n toast.error('Incorrect password. Please try again.');\n return;\n }\n }\n toast.error(errorMessage);\n } finally {\n setIsSubmitting(false);\n }\n };\n\n const isLoading = isSubmitting || isChecking;\n\n return (\n <form\n onSubmit={handleSubmit(onPhonePasswordSubmit)}\n className=\"p-4 space-y-4 border-t\"\n >\n <div className=\"space-y-4 w-full md:w-1/2\">\n <div className=\"space-y-2\">\n <Label htmlFor=\"phone\">Phone Number</Label>\n <Input\n id=\"phone\"\n type=\"tel\"\n placeholder=\"Enter your new phone number\"\n {...register('phone')}\n disabled={isLoading}\n />\n {errors.phone && (\n <p className=\"text-sm text-destructive\">{errors.phone.message}</p>\n )}\n </div>\n <div className=\"space-y-2\">\n <Label htmlFor=\"password\">Password</Label>\n <div className=\"relative\">\n <Input\n id=\"password\"\n type={showPassword ? 'text' : 'password'}\n autoComplete=\"current-password\"\n placeholder=\"Enter your password\"\n {...register('password')}\n disabled={isLoading}\n />\n <button\n type=\"button\"\n onClick={() => setShowPassword(!showPassword)}\n className=\"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground\"\n >\n {showPassword ? (\n <IconEyeOff className=\"h-4 w-4\" />\n ) : (\n <IconEye className=\"h-4 w-4\" />\n )}\n </button>\n </div>\n {errors.password && (\n <p className=\"text-sm text-destructive\">\n {errors.password.message}\n </p>\n )}\n </div>\n </div>\n\n <div className=\"flex justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={onCancel}\n disabled={isLoading}\n >\n Cancel\n </Button>\n <Button type=\"submit\" disabled={isLoading}>\n {isLoading && <Spinner className=\"mr-2 h-4 w-4\" />}\n {isChecking ? 'Checking…' : buttonText}\n </Button>\n </div>\n </form>\n );\n}\n","'use client';\n\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { deepmerge } from 'deepmerge-ts';\nimport createFetchClient from 'openapi-fetch';\nimport createClient from 'openapi-react-query';\nimport type { ReactNode } from 'react';\nimport { createContext, useContext, useMemo, useState } from 'react';\nimport type { paths } from './data/openapi';\nimport { createTranslator } from './lib/translations';\nimport {\n type AuthClientConfig,\n type AuthResponse,\n defaultAuthClientConfig,\n type Session,\n type User,\n} from './types';\nimport { getSessionCookieName } from './utils/cookie';\nimport { createCustomFetch } from './utils/custom-fetch';\n\n// biome-ignore lint/suspicious/noExplicitAny: OpenAPI hooks type\ntype OpenApiHooks = any;\n\n// --- Utility: Check if running on server ---\nfunction isServer(): boolean {\n return typeof document === 'undefined';\n}\n\n/**\n * @deprecated Cookie is httpOnly and cannot be read client-side.\n * Use `useSession().isAuthenticated` instead.\n * This function always returns false on client.\n */\nexport function hasAuthCookie(_cookieName: string): boolean {\n // Cookie is httpOnly, can't check client-side\n // Always return false - use useSession() for auth status\n return false;\n}\n\n// --- Types ---\nexport type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated';\n\ntype AuthState = {\n user: User | null;\n session: Session | null;\n status: AuthStatus;\n error: Error | null;\n};\n\ntype SessionContextValue = AuthState & {\n isLoading: boolean;\n isAuthenticated: boolean;\n refresh: () => Promise<void>;\n signOut: () => Promise<void>;\n};\n\ntype ApiContextValue = {\n hooks: OpenApiHooks;\n setAuth: (auth: AuthResponse) => void;\n clearAuth: () => void;\n refresh: () => Promise<void>;\n};\n\ntype ConfigContextValue = {\n config: AuthClientConfig;\n cookieName: string;\n t: (key: string, params?: Record<string, string | number>) => string;\n};\n\nconst SessionContext = createContext<SessionContextValue | null>(null);\nconst ApiContext = createContext<ApiContextValue | null>(null);\nconst ConfigContext = createContext<ConfigContextValue | null>(null);\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n },\n },\n});\n\n// --- Hooks ---\n\n/**\n * Get session state including user, session, and auth status.\n * - `status`: 'loading' | 'authenticated' | 'unauthenticated'\n * - `isLoading`: true while fetching session\n * - `isAuthenticated`: true if user and session exist\n */\nexport function useSession(): SessionContextValue {\n const context = useContext(SessionContext);\n if (!context) {\n throw new Error('useSession must be used within MesobAuthProvider');\n }\n return context;\n}\n\nexport function useApi(): ApiContextValue {\n const context = useContext(ApiContext);\n if (!context) {\n throw new Error('useApi must be used within MesobAuthProvider');\n }\n return context;\n}\n\nexport function useConfig(): ConfigContextValue {\n const context = useContext(ConfigContext);\n if (!context) {\n throw new Error('useConfig must be used within MesobAuthProvider');\n }\n return context;\n}\n\n/**\n * @deprecated Cookie is httpOnly, can't be checked client-side.\n * Use `useSession().isAuthenticated` instead.\n */\nexport function useHasAuthCookie(): boolean {\n const { status } = useSession();\n return status === 'authenticated' || status === 'loading';\n}\n\n// --- Provider ---\n\ntype MesobAuthProviderProps = {\n config: AuthClientConfig;\n children: ReactNode;\n};\n\nexport function MesobAuthProvider({\n config,\n children,\n}: MesobAuthProviderProps) {\n const mergedConfig = useMemo(\n () =>\n deepmerge(\n { ...defaultAuthClientConfig } as Partial<AuthClientConfig>,\n config,\n ) as AuthClientConfig,\n [config],\n );\n\n const api = useMemo(\n () =>\n createFetchClient<paths>({\n baseUrl: mergedConfig.baseURL,\n fetch: createCustomFetch(mergedConfig),\n }),\n [mergedConfig],\n );\n\n const hooks = useMemo(() => createClient(api), [api]);\n const cookieName = useMemo(\n () => getSessionCookieName(mergedConfig),\n [mergedConfig],\n );\n\n return (\n <QueryClientProvider client={queryClient}>\n <AuthStateProvider\n config={mergedConfig}\n hooks={hooks}\n cookieName={cookieName}\n >\n {children}\n </AuthStateProvider>\n </QueryClientProvider>\n );\n}\n\ntype AuthStateProviderProps = {\n config: AuthClientConfig;\n hooks: OpenApiHooks;\n cookieName: string;\n children: ReactNode;\n};\n\nfunction AuthStateProvider({\n config,\n hooks,\n cookieName,\n children,\n}: AuthStateProviderProps) {\n // Manual override for sign-out / sign-in\n const [override, setOverride] = useState<AuthState | null>(null);\n\n // Always fetch session - cookie is httpOnly, can't check client-side\n // Server will read the cookie and return user/session if valid\n const {\n data: sessionData,\n isLoading,\n isFetched,\n error: sessionError,\n refetch,\n } = hooks.useQuery(\n 'get',\n '/session',\n {},\n {\n enabled: !(override || isServer()),\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n retry: false,\n gcTime: 0,\n staleTime: 0,\n },\n );\n\n // Derive state directly - no useEffect\n const user = override?.user ?? sessionData?.user ?? null;\n const session = override?.session ?? sessionData?.session ?? null;\n const error = override?.error ?? (sessionError as Error | null);\n\n // Check error status code\n const errorStatus = (() => {\n if (!sessionError) {\n return null;\n }\n const err = sessionError as { status?: number };\n return err.status ?? null;\n })();\n\n // Check if error is a network/connection error\n const isNetworkError = (() => {\n if (!sessionError) {\n return false;\n }\n const error = sessionError as Error & { cause?: unknown; data?: unknown };\n const errorMessage =\n error.message || String(error) || JSON.stringify(error);\n // Network errors: TypeError, DOMException, or fetch failures\n if (\n error instanceof TypeError ||\n error instanceof DOMException ||\n error.name === 'TypeError' ||\n errorMessage.includes('Failed to fetch') ||\n errorMessage.includes('ERR_CONNECTION_REFUSED') ||\n errorMessage.includes('NetworkError') ||\n errorMessage.includes('Network request failed') ||\n errorMessage.includes('fetch failed')\n ) {\n return true;\n }\n // Check error cause\n if (error.cause) {\n const causeStr = String(error.cause);\n if (\n causeStr.includes('Failed to fetch') ||\n causeStr.includes('ERR_CONNECTION_REFUSED') ||\n causeStr.includes('NetworkError')\n ) {\n return true;\n }\n }\n return false;\n })();\n\n // Compute status\n // biome-ignore lint: Status determination requires multiple checks\n const status: AuthStatus = (() => {\n if (override) {\n return override.status;\n }\n if (isServer()) {\n return 'loading';\n }\n if (user && session) {\n return 'authenticated';\n }\n // Check for network errors or auth errors first - allow auth page to show\n if (isNetworkError || errorStatus === 401) {\n return 'unauthenticated';\n }\n // If we have an error but it's not a network error, still check loading state\n if (sessionError && !isNetworkError && errorStatus !== 401) {\n if (errorStatus && errorStatus >= 500) {\n return 'authenticated';\n }\n // Other errors mean unauthenticated\n if (isFetched) {\n return 'unauthenticated';\n }\n }\n if (isLoading || !isFetched) {\n return 'loading';\n }\n if (isFetched && !user && !session) {\n return 'unauthenticated';\n }\n return 'unauthenticated';\n })();\n\n const signOutMutation = hooks.useMutation('post', '/sign-out');\n const t = createTranslator(config.messages || {});\n\n const setAuth = (auth: AuthResponse) => {\n setOverride({\n user: auth.user,\n session: auth.session,\n status: 'authenticated',\n error: null,\n });\n };\n\n const clearAuth = () => {\n setOverride({\n user: null,\n session: null,\n status: 'unauthenticated',\n error: null,\n });\n };\n\n const refresh = async () => {\n setOverride(null);\n await refetch();\n };\n\n const signOut = async () => {\n try {\n await signOutMutation.mutateAsync({});\n } finally {\n clearAuth();\n }\n };\n\n return (\n <ConfigContext.Provider value={{ config, cookieName, t }}>\n <ApiContext.Provider value={{ hooks, setAuth, clearAuth, refresh }}>\n <SessionContext.Provider\n value={{\n user,\n session,\n status,\n error,\n isLoading: status === 'loading',\n isAuthenticated: status === 'authenticated',\n refresh,\n signOut,\n }}\n >\n {children}\n </SessionContext.Provider>\n </ApiContext.Provider>\n </ConfigContext.Provider>\n );\n}\n","import type { AuthClientConfig } from '../types';\n\nconst isProduction =\n typeof process !== 'undefined' && process.env.NODE_ENV === 'production';\n\nexport const getSessionCookieName = (config: AuthClientConfig): string => {\n const prefix = config.cookiePrefix || '';\n const baseName = 'session_token';\n if (prefix) {\n return `${prefix}_${baseName}`;\n }\n return isProduction ? '__Host-session_token' : baseName;\n};\n","export function normalizePhone(phone: string): string {\n const cleaned = phone.trim().replace(/\\s/g, '');\n if (cleaned.startsWith('+2519') || cleaned.startsWith('+2517')) {\n return cleaned;\n }\n if (cleaned.startsWith('2519') || cleaned.startsWith('2517')) {\n return `+${cleaned}`;\n }\n if (cleaned.startsWith('09') || cleaned.startsWith('07')) {\n return `+251${cleaned.slice(1)}`;\n }\n if (\n (cleaned.startsWith('9') || cleaned.startsWith('7')) &&\n cleaned.length === 9\n ) {\n return `+251${cleaned}`;\n }\n return cleaned;\n}\n"],"mappings":";;;AAEA,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,SAAS,kBAAkB;AACpC,SAAS,WAAW,YAAAA,iBAAgB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,SAAS;;;ACTlB,SAAS,aAAa,2BAA2B;AACjD,SAAS,iBAAiB;AAC1B,OAAO,uBAAuB;AAC9B,OAAO,kBAAkB;AAEzB,SAAS,eAAe,YAAY,SAAS,gBAAgB;;;ACL7D,IAAM,eACJ,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa;;;AD4JvD;AA1FN,IAAM,iBAAiB,cAA0C,IAAI;AACrE,IAAM,aAAa,cAAsC,IAAI;AAC7D,IAAM,gBAAgB,cAAyC,IAAI;AAEnE,IAAM,cAAc,IAAI,YAAY;AAAA,EAClC,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,sBAAsB;AAAA,IACxB;AAAA,EACF;AACF,CAAC;AAUM,SAAS,aAAkC;AAChD,QAAM,UAAU,WAAW,cAAc;AACzC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAO;AACT;AAEO,SAAS,SAA0B;AACxC,QAAM,UAAU,WAAW,UAAU;AACrC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,8CAA8C;AAAA,EAChE;AACA,SAAO;AACT;AAEO,SAAS,YAAgC;AAC9C,QAAM,UAAU,WAAW,aAAa;AACxC,MAAI,CAAC,SAAS;A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