@mesob/auth-react 0.3.4 → 0.4.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-layout.d.ts +1 -1
- package/dist/components/auth/auth-layout.js +10 -2
- package/dist/components/auth/auth-layout.js.map +1 -1
- package/dist/components/auth/countdown.js +8 -6
- package/dist/components/auth/countdown.js.map +1 -1
- package/dist/components/auth/forgot-password.js +21 -19
- package/dist/components/auth/forgot-password.js.map +1 -1
- package/dist/components/auth/reset-password-form.js +22 -21
- package/dist/components/auth/reset-password-form.js.map +1 -1
- package/dist/components/auth/set-password.d.ts +9 -0
- package/dist/components/auth/set-password.js +527 -0
- package/dist/components/auth/set-password.js.map +1 -0
- package/dist/components/auth/sign-in.js +45 -26
- package/dist/components/auth/sign-in.js.map +1 -1
- package/dist/components/auth/sign-up.js +25 -29
- package/dist/components/auth/sign-up.js.map +1 -1
- package/dist/components/auth/verification-form.js +24 -27
- package/dist/components/auth/verification-form.js.map +1 -1
- package/dist/components/auth/verify-email.js +40 -31
- package/dist/components/auth/verify-email.js.map +1 -1
- package/dist/components/auth/verify-phone.js +40 -31
- package/dist/components/auth/verify-phone.js.map +1 -1
- package/dist/components/authorization/deny.d.ts +11 -0
- package/dist/components/authorization/deny.js +52 -0
- package/dist/components/authorization/deny.js.map +1 -0
- package/dist/components/authorization/grant.d.ts +12 -0
- package/dist/components/authorization/grant.js +57 -0
- package/dist/components/authorization/grant.js.map +1 -0
- package/dist/components/iam/permission-selector.d.ts +19 -0
- package/dist/components/iam/permission-selector.js +122 -0
- package/dist/components/iam/permission-selector.js.map +1 -0
- package/dist/components/iam/permissions.js +21 -33
- package/dist/components/iam/permissions.js.map +1 -1
- package/dist/components/iam/role-detail-layout.d.ts +11 -0
- package/dist/components/iam/role-detail-layout.js +137 -0
- package/dist/components/iam/role-detail-layout.js.map +1 -0
- package/dist/components/iam/role-detail-page.d.ts +9 -0
- package/dist/components/iam/role-detail-page.js +229 -0
- package/dist/components/iam/role-detail-page.js.map +1 -0
- package/dist/components/iam/role-permissions-page.d.ts +8 -0
- package/dist/components/iam/role-permissions-page.js +397 -0
- package/dist/components/iam/role-permissions-page.js.map +1 -0
- package/dist/components/iam/roles.js +20 -10
- package/dist/components/iam/roles.js.map +1 -1
- package/dist/components/iam/tenants.js +9 -2
- package/dist/components/iam/tenants.js.map +1 -1
- package/dist/components/iam/users.js +10 -9
- package/dist/components/iam/users.js.map +1 -1
- package/dist/components/profile/account.js +110 -19
- package/dist/components/profile/account.js.map +1 -1
- package/dist/components/profile/change-email-form.js +26 -29
- package/dist/components/profile/change-email-form.js.map +1 -1
- package/dist/components/profile/change-phone-form.js +26 -29
- package/dist/components/profile/change-phone-form.js.map +1 -1
- package/dist/components/profile/change-profile.d.ts +2 -1
- package/dist/components/profile/change-profile.js +16 -8
- package/dist/components/profile/change-profile.js.map +1 -1
- package/dist/components/profile/otp-verification-modal.js +24 -27
- package/dist/components/profile/otp-verification-modal.js.map +1 -1
- package/dist/components/profile/security.js +88 -57
- package/dist/components/profile/security.js.map +1 -1
- package/dist/components/profile/verify-change-email-form.js +24 -27
- package/dist/components/profile/verify-change-email-form.js.map +1 -1
- package/dist/components/profile/verify-change-phone-form.js +24 -27
- package/dist/components/profile/verify-change-phone-form.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1897 -821
- package/dist/index.js.map +1 -1
- package/dist/pages/auth/forgot-password.d.ts +7 -0
- package/dist/pages/auth/forgot-password.js +784 -0
- package/dist/pages/auth/forgot-password.js.map +1 -0
- package/dist/pages/auth/layout.d.ts +8 -0
- package/dist/pages/auth/layout.js +562 -0
- package/dist/pages/auth/layout.js.map +1 -0
- package/dist/pages/auth/reset-password.d.ts +10 -0
- package/dist/pages/auth/reset-password.js +913 -0
- package/dist/pages/auth/reset-password.js.map +1 -0
- package/dist/pages/auth/set-password.d.ts +10 -0
- package/dist/pages/auth/set-password.js +946 -0
- package/dist/pages/auth/set-password.js.map +1 -0
- package/dist/pages/auth/sign-in.d.ts +10 -0
- package/dist/pages/auth/sign-in.js +984 -0
- package/dist/pages/auth/sign-in.js.map +1 -0
- package/dist/pages/auth/sign-up.d.ts +10 -0
- package/dist/pages/auth/sign-up.js +940 -0
- package/dist/pages/auth/sign-up.js.map +1 -0
- package/dist/pages/auth/verify-email.d.ts +10 -0
- package/dist/pages/auth/verify-email.js +950 -0
- package/dist/pages/auth/verify-email.js.map +1 -0
- package/dist/pages/auth/verify-phone.d.ts +10 -0
- package/dist/pages/auth/verify-phone.js +964 -0
- package/dist/pages/auth/verify-phone.js.map +1 -0
- package/dist/pages/iam/permissions.d.ts +5 -0
- package/dist/pages/iam/permissions.js +308 -0
- package/dist/pages/iam/permissions.js.map +1 -0
- package/dist/pages/iam/role-detail-layout.d.ts +12 -0
- package/dist/pages/iam/role-detail-layout.js +145 -0
- package/dist/pages/iam/role-detail-layout.js.map +1 -0
- package/dist/pages/iam/role-detail.d.ts +12 -0
- package/dist/pages/iam/role-detail.js +241 -0
- package/dist/pages/iam/role-detail.js.map +1 -0
- package/dist/pages/iam/role-permissions.d.ts +12 -0
- package/dist/pages/iam/role-permissions.js +409 -0
- package/dist/pages/iam/role-permissions.js.map +1 -0
- package/dist/pages/iam/role-users.d.ts +12 -0
- package/dist/pages/iam/role-users.js +825 -0
- package/dist/pages/iam/role-users.js.map +1 -0
- package/dist/pages/iam/roles.d.ts +5 -0
- package/dist/pages/iam/roles.js +684 -0
- package/dist/pages/iam/roles.js.map +1 -0
- package/dist/pages/iam/sessions.d.ts +5 -0
- package/dist/pages/iam/sessions.js +315 -0
- package/dist/pages/iam/sessions.js.map +1 -0
- package/dist/pages/iam/tenant-detail.d.ts +10 -0
- package/dist/pages/iam/tenant-detail.js +186 -0
- package/dist/pages/iam/tenant-detail.js.map +1 -0
- package/dist/pages/iam/tenants.d.ts +5 -0
- package/dist/pages/iam/tenants.js +610 -0
- package/dist/pages/iam/tenants.js.map +1 -0
- package/dist/pages/iam/user-activity.d.ts +10 -0
- package/dist/pages/iam/user-activity.js +850 -0
- package/dist/pages/iam/user-activity.js.map +1 -0
- package/dist/pages/iam/user-detail-layout.d.ts +12 -0
- package/dist/pages/iam/user-detail-layout.js +106 -0
- package/dist/pages/iam/user-detail-layout.js.map +1 -0
- package/dist/pages/iam/user-detail.d.ts +10 -0
- package/dist/pages/iam/user-detail.js +102 -0
- package/dist/pages/iam/user-detail.js.map +1 -0
- package/dist/pages/iam/users.d.ts +5 -0
- package/dist/pages/iam/users.js +1275 -0
- package/dist/pages/iam/users.js.map +1 -0
- package/dist/pages/profile/account.d.ts +5 -0
- package/dist/pages/profile/account.js +182 -0
- package/dist/pages/profile/account.js.map +1 -0
- package/dist/pages/profile/layout.d.ts +8 -0
- package/dist/pages/profile/layout.js +133 -0
- package/dist/pages/profile/layout.js.map +1 -0
- package/dist/pages/profile/security.d.ts +5 -0
- package/dist/pages/profile/security.js +1539 -0
- package/dist/pages/profile/security.js.map +1 -0
- package/dist/{types-vcfvnAzQ.d.ts → types-g9QcNRxT.d.ts} +13 -7
- package/package.json +102 -3
|
@@ -146,7 +146,11 @@ var AUTH_ERROR_MAPPING = {
|
|
|
146
146
|
},
|
|
147
147
|
HAS_NO_PASSWORD: {
|
|
148
148
|
title: "No Password Set",
|
|
149
|
-
description: "Your account does not have a password
|
|
149
|
+
description: "Your account does not have a password yet. Continue to set a password before signing in."
|
|
150
|
+
},
|
|
151
|
+
PASSWORD_ALREADY_SET: {
|
|
152
|
+
title: "Password Already Set",
|
|
153
|
+
description: "This account already has a password. Use the normal sign-in form instead."
|
|
150
154
|
}
|
|
151
155
|
};
|
|
152
156
|
var validCodes = Object.keys(AUTH_ERROR_MAPPING);
|
|
@@ -237,25 +241,28 @@ var AuthLayout = ({
|
|
|
237
241
|
logoImage
|
|
238
242
|
}) => {
|
|
239
243
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
240
|
-
/* @__PURE__ */ jsx2("div", { className: "flex size-8 mb-6 w-full items-center justify-center rounded-md", children: /* @__PURE__ */ jsx2(
|
|
244
|
+
/* @__PURE__ */ jsx2("div", { className: "flex size-8 mb-6 w-full items-center justify-center rounded-md", children: /* @__PURE__ */ jsx2(
|
|
245
|
+
"img",
|
|
246
|
+
{
|
|
247
|
+
src: logoImage || "",
|
|
248
|
+
alt: title,
|
|
249
|
+
width: 42,
|
|
250
|
+
height: 42
|
|
251
|
+
}
|
|
252
|
+
) }),
|
|
241
253
|
/* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
242
254
|
/* @__PURE__ */ jsx2("h1", { className: "text-2xl font-bold tracking-tight", children: title }),
|
|
243
255
|
description && /* @__PURE__ */ jsx2("p", { className: "mt-2 text-sm text-muted-foreground", children: description })
|
|
244
256
|
] }),
|
|
245
257
|
children,
|
|
246
|
-
/* @__PURE__ */ jsx2("div", { className: "mt-2 w-full", children:
|
|
258
|
+
footer && /* @__PURE__ */ jsx2("div", { className: "mt-2 w-full", children: /* @__PURE__ */ jsx2("div", { className: "w-full text-center text-sm text-muted-foreground", children: footer }) })
|
|
247
259
|
] });
|
|
248
260
|
};
|
|
249
261
|
|
|
250
262
|
// src/components/auth/sign-in.tsx
|
|
251
263
|
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
252
264
|
var isPhone = (s) => /^\+?[0-9()[\]\s-]{6,}$/.test(s);
|
|
253
|
-
function PasswordInput({
|
|
254
|
-
field,
|
|
255
|
-
show,
|
|
256
|
-
onToggle,
|
|
257
|
-
placeholder
|
|
258
|
-
}) {
|
|
265
|
+
function PasswordInput({ field, show, onToggle }) {
|
|
259
266
|
const { formItemId, error } = useFormField();
|
|
260
267
|
return /* @__PURE__ */ jsxs2("div", { className: "relative", children: [
|
|
261
268
|
/* @__PURE__ */ jsx3(
|
|
@@ -264,7 +271,6 @@ function PasswordInput({
|
|
|
264
271
|
...field,
|
|
265
272
|
id: formItemId,
|
|
266
273
|
type: show ? "text" : "password",
|
|
267
|
-
placeholder,
|
|
268
274
|
autoComplete: "current-password",
|
|
269
275
|
"aria-invalid": !!error,
|
|
270
276
|
className: "pr-10"
|
|
@@ -316,6 +322,7 @@ var SignIn = ({ redirectUrl } = {}) => {
|
|
|
316
322
|
const defaultRedirect = redirectUrl || config.navigation?.defaultRedirectUrl || "/dashboard";
|
|
317
323
|
const forgotPasswordLink = config.navigation?.links?.forgotPassword || "/auth/forgot-password";
|
|
318
324
|
const signUpLink = config.navigation?.links?.signUp || "/auth/sign-up";
|
|
325
|
+
const setPasswordLink = config.navigation?.links?.setPassword || "/auth/set-password";
|
|
319
326
|
const onNavigate = config.navigation?.onNavigate || ((path) => {
|
|
320
327
|
if (typeof window !== "undefined") {
|
|
321
328
|
window.location.href = path;
|
|
@@ -325,7 +332,7 @@ var SignIn = ({ redirectUrl } = {}) => {
|
|
|
325
332
|
const form = useForm({
|
|
326
333
|
resolver: zodResolver(signInSchema(t, phoneRegex)),
|
|
327
334
|
defaultValues: { username: "", password: "" },
|
|
328
|
-
mode: "
|
|
335
|
+
mode: "onBlur"
|
|
329
336
|
});
|
|
330
337
|
useEffect(() => {
|
|
331
338
|
if (error) {
|
|
@@ -344,16 +351,26 @@ var SignIn = ({ redirectUrl } = {}) => {
|
|
|
344
351
|
}
|
|
345
352
|
});
|
|
346
353
|
if (result.exists) {
|
|
354
|
+
if (result.requiresPasswordSetup) {
|
|
355
|
+
const redirectParam = defaultRedirect ? `&redirect=${encodeURIComponent(defaultRedirect)}` : "";
|
|
356
|
+
onNavigate(
|
|
357
|
+
`${setPasswordLink}?identifier=${encodeURIComponent(normalizedUsername)}${redirectParam}`
|
|
358
|
+
);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
347
361
|
setUsername(normalizedUsername);
|
|
348
362
|
form.setValue("username", normalizedUsername);
|
|
349
363
|
setShowPasswordField(true);
|
|
350
364
|
} else {
|
|
351
365
|
const email = isPhone(normalizedUsername) ? "" : normalizedUsername;
|
|
366
|
+
const redirectParam = defaultRedirect ? `&redirect=${encodeURIComponent(defaultRedirect)}` : "";
|
|
352
367
|
if (email) {
|
|
353
|
-
onNavigate(
|
|
368
|
+
onNavigate(
|
|
369
|
+
`${signUpLink}?email=${encodeURIComponent(email)}${redirectParam}`
|
|
370
|
+
);
|
|
354
371
|
} else {
|
|
355
372
|
onNavigate(
|
|
356
|
-
`${signUpLink}?phone=${encodeURIComponent(normalizedUsername)}`
|
|
373
|
+
`${signUpLink}?phone=${encodeURIComponent(normalizedUsername)}${redirectParam}`
|
|
357
374
|
);
|
|
358
375
|
}
|
|
359
376
|
}
|
|
@@ -386,7 +403,8 @@ var SignIn = ({ redirectUrl } = {}) => {
|
|
|
386
403
|
}
|
|
387
404
|
});
|
|
388
405
|
if ("verificationId" in res && res.verificationId) {
|
|
389
|
-
const
|
|
406
|
+
const redirectParam = defaultRedirect ? `&redirect=${encodeURIComponent(defaultRedirect)}` : "";
|
|
407
|
+
const verifyPath = isPhone(username) ? `/auth/verify-phone?context=sign-in&verificationId=${res.verificationId}&identifier=${encodeURIComponent(username)}${redirectParam}` : `/auth/verify-email?verificationId=${res.verificationId}${redirectParam}`;
|
|
390
408
|
onNavigate(verifyPath);
|
|
391
409
|
return;
|
|
392
410
|
}
|
|
@@ -395,6 +413,15 @@ var SignIn = ({ redirectUrl } = {}) => {
|
|
|
395
413
|
}
|
|
396
414
|
onNavigate(defaultRedirect);
|
|
397
415
|
} catch (err) {
|
|
416
|
+
const authError = err;
|
|
417
|
+
const errorCode = authError.code || authError.message;
|
|
418
|
+
if (errorCode === "HAS_NO_PASSWORD") {
|
|
419
|
+
const redirectParam = defaultRedirect ? `&redirect=${encodeURIComponent(defaultRedirect)}` : "";
|
|
420
|
+
onNavigate(
|
|
421
|
+
`${setPasswordLink}?identifier=${encodeURIComponent(username)}${redirectParam}`
|
|
422
|
+
);
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
398
425
|
handleError(err, setError, t);
|
|
399
426
|
} finally {
|
|
400
427
|
setIsLoading(false);
|
|
@@ -449,6 +476,7 @@ var SignIn = ({ redirectUrl } = {}) => {
|
|
|
449
476
|
id: "sign-in-username",
|
|
450
477
|
type: "text",
|
|
451
478
|
value: username,
|
|
479
|
+
autoComplete: "username",
|
|
452
480
|
disabled: true
|
|
453
481
|
}
|
|
454
482
|
)
|
|
@@ -465,8 +493,7 @@ var SignIn = ({ redirectUrl } = {}) => {
|
|
|
465
493
|
{
|
|
466
494
|
field: { ...field, value: field.value ?? "" },
|
|
467
495
|
show: showPassword,
|
|
468
|
-
onToggle: () => setShowPassword(!showPassword)
|
|
469
|
-
placeholder: t("form.passwordPlaceholder")
|
|
496
|
+
onToggle: () => setShowPassword(!showPassword)
|
|
470
497
|
}
|
|
471
498
|
),
|
|
472
499
|
/* @__PURE__ */ jsx3(FormMessage, {})
|
|
@@ -480,15 +507,7 @@ var SignIn = ({ redirectUrl } = {}) => {
|
|
|
480
507
|
name: "username",
|
|
481
508
|
render: ({ field }) => /* @__PURE__ */ jsxs2(FormItem, { children: [
|
|
482
509
|
/* @__PURE__ */ jsx3(FormLabel, { children: t("form.accountLabel") }),
|
|
483
|
-
/* @__PURE__ */ jsx3(FormControl, { children: /* @__PURE__ */ jsx3(
|
|
484
|
-
Input,
|
|
485
|
-
{
|
|
486
|
-
...field,
|
|
487
|
-
type: "text",
|
|
488
|
-
placeholder: t("form.accountPlaceholder"),
|
|
489
|
-
autoComplete: "username"
|
|
490
|
-
}
|
|
491
|
-
) }),
|
|
510
|
+
/* @__PURE__ */ jsx3(FormControl, { children: /* @__PURE__ */ jsx3(Input, { ...field, type: "text", autoComplete: "username" }) }),
|
|
492
511
|
/* @__PURE__ */ jsx3(FormMessage, {})
|
|
493
512
|
] })
|
|
494
513
|
}
|
|
@@ -509,7 +528,7 @@ var SignIn = ({ redirectUrl } = {}) => {
|
|
|
509
528
|
return /* @__PURE__ */ jsx3("div", { className: "space-y-4", children: /* @__PURE__ */ jsxs2(
|
|
510
529
|
AuthLayout,
|
|
511
530
|
{
|
|
512
|
-
title:
|
|
531
|
+
title: config.ui.name,
|
|
513
532
|
description: t("description"),
|
|
514
533
|
logoImage,
|
|
515
534
|
footer: showPasswordField ? /* @__PURE__ */ jsx3("div", { className: "flex items-center justify-center w-full", children: Link ? /* @__PURE__ */ jsx3(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/auth/sign-in.tsx","../../../src/hooks/use-translator.ts","../../../src/lib/translations.ts","../../../src/provider.tsx","../../../src/utils/cookie.ts","../../../src/constants/auth.error.codes.ts","../../../src/utils/handle-error.ts","../../../src/utils/normalize-phone.ts","../../../src/components/auth/auth-layout.tsx"],"sourcesContent":["'use client';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport {\n Alert,\n AlertDescription,\n AlertTitle,\n Button,\n Form,\n FormControl,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n Input,\n useFormField,\n} from '@mesob/ui/components';\nimport { useMesob } from '@mesob/ui/providers';\nimport { IconAlertCircle, IconEye, IconEyeOff } from '@tabler/icons-react';\nimport type { ChangeEvent, ComponentProps } from 'react';\nimport { useEffect, useState } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { toast } from 'sonner';\nimport { z } from 'zod';\nimport { useTranslator } from '../../hooks/use-translator';\nimport { useApi, useConfig } from '../../provider';\nimport type { AuthErrorContent } from '../../utils/handle-error';\nimport { handleError } from '../../utils/handle-error';\nimport { normalizePhone } from '../../utils/normalize-phone';\nimport { AuthLayout } from './auth-layout';\n\nconst isPhone = (s: string) => /^\\+?[0-9()[\\]\\s-]{6,}$/.test(s);\n\ntype PasswordInputProps = {\n field: ComponentProps<'input'> & {\n value: string;\n onChange: (e: ChangeEvent<HTMLInputElement>) => void;\n onBlur: () => void;\n };\n show: boolean;\n onToggle: () => void;\n placeholder: string;\n};\n\nfunction PasswordInput({\n field,\n show,\n onToggle,\n placeholder,\n}: PasswordInputProps) {\n const { formItemId, error } = useFormField();\n return (\n <div className=\"relative\">\n <Input\n {...field}\n id={formItemId}\n type={show ? 'text' : 'password'}\n placeholder={placeholder}\n autoComplete=\"current-password\"\n aria-invalid={!!error}\n className=\"pr-10\"\n />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n className=\"absolute right-0 top-0 h-full px-3 text-muted-foreground hover:text-foreground\"\n onClick={onToggle}\n aria-label={show ? 'Hide password' : 'Show password'}\n >\n {show ? (\n <IconEyeOff className=\"h-4 w-4\" />\n ) : (\n <IconEye className=\"h-4 w-4\" />\n )}\n </Button>\n </div>\n );\n}\n\ntype SignInProps = {\n redirectUrl?: string;\n};\n\nconst signInSchema = (t: (key: string) => string, phoneRegex: RegExp) =>\n z.object({\n username: z\n .string()\n .trim()\n .min(1, { message: t('errors.requiredField') })\n .refine(\n (val) => {\n const isEmail = z.email().safeParse(val).success;\n const isPhone = phoneRegex.test(val);\n return isEmail || isPhone;\n },\n { message: t('errors.invalidEmailOrPhone') },\n ),\n password: z\n .union([\n z.literal(''),\n z\n .string()\n .min(8, t('errors.passwordLength'))\n .max(128, t('errors.longPasswordError')),\n ])\n .optional(),\n });\n\ntype SignInFormValues = z.infer<ReturnType<typeof signInSchema>>;\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: multi-step form with two form contexts\nexport const SignIn = ({ redirectUrl }: SignInProps = {}) => {\n const { hooks, setAuth } = useApi();\n const { config } = useConfig();\n const mesob = useMesob();\n const t = useTranslator('Auth.signIn');\n const Link = mesob?.navigation?.Link;\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<AuthErrorContent | null>(null);\n const [showPasswordField, setShowPasswordField] = useState(false);\n const [showPassword, setShowPassword] = useState(false);\n const [username, setUsername] = useState('');\n const [isChecking, setIsChecking] = useState(false);\n\n const checkUserMutation = hooks.useMutation('post', '/check-account');\n const signInMutation = hooks.useMutation('post', '/sign-in');\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 defaultRedirect =\n redirectUrl || config.navigation?.defaultRedirectUrl || '/dashboard';\n const forgotPasswordLink =\n config.navigation?.links?.forgotPassword || '/auth/forgot-password';\n const signUpLink = config.navigation?.links?.signUp || '/auth/sign-up';\n const onNavigate =\n config.navigation?.onNavigate ||\n ((path: string) => {\n if (typeof window !== 'undefined') {\n window.location.href = path;\n }\n });\n const logoImage = config.ui.logoImage;\n\n const form = useForm<SignInFormValues>({\n resolver: zodResolver(signInSchema(t, phoneRegex)),\n defaultValues: { username: '', password: '' },\n mode: 'onChange',\n });\n\n useEffect(() => {\n if (error) {\n toast.error(error.title || 'Error', {\n description: error.description,\n });\n }\n }, [error]);\n\n const handleCheckAccount = async (usernameValue: string) => {\n setIsChecking(true);\n try {\n const normalizedUsername = phoneRegex.test(usernameValue)\n ? normalizePhone(usernameValue)\n : usernameValue;\n\n const result = await checkUserMutation.mutateAsync({\n body: {\n username: normalizedUsername,\n },\n });\n\n if (result.exists) {\n setUsername(normalizedUsername);\n form.setValue('username', normalizedUsername);\n setShowPasswordField(true);\n } else {\n const email = isPhone(normalizedUsername) ? '' : normalizedUsername;\n if (email) {\n onNavigate(`${signUpLink}?email=${encodeURIComponent(email)}`);\n } else {\n onNavigate(\n `${signUpLink}?phone=${encodeURIComponent(normalizedUsername)}`,\n );\n }\n }\n } catch {\n form.setError('username', { message: t('errors.checkAccountFailed') });\n } finally {\n setIsChecking(false);\n }\n };\n\n const onSubmit = async (values: SignInFormValues) => {\n if (showPasswordField) {\n const pwd = values.password;\n if (!pwd || pwd.length < 8) {\n form.setError('password', { message: t('errors.passwordLength') });\n return;\n }\n await handlePasswordSubmit({ password: pwd });\n } else {\n await handleCheckAccount(values.username);\n }\n };\n\n const handlePasswordSubmit = async (values: { password: string }) => {\n setIsLoading(true);\n setError(null);\n\n try {\n const res = await signInMutation.mutateAsync({\n body: {\n identifier: username,\n password: values.password,\n },\n });\n\n if ('verificationId' in res && res.verificationId) {\n const verifyPath = isPhone(username)\n ? `/auth/verify-phone?context=sign-in&verificationId=${res.verificationId}&identifier=${encodeURIComponent(username)}`\n : `/auth/verify-email?verificationId=${res.verificationId}`;\n onNavigate(verifyPath);\n return;\n }\n\n if ('user' in res && 'session' in res) {\n setAuth(res);\n }\n onNavigate(defaultRedirect);\n } catch (err) {\n handleError(err, setError, t);\n } finally {\n setIsLoading(false);\n }\n };\n\n const handleBack = () => {\n setShowPasswordField(false);\n setUsername('');\n form.setValue('password', '');\n };\n\n const isSubmitting =\n isLoading ||\n checkUserMutation.isPending ||\n signInMutation.isPending ||\n isChecking;\n\n let submitLabel = t('form.continue');\n if (isSubmitting) {\n submitLabel = showPasswordField ? t('form.submitting') : t('form.checking');\n } else if (showPasswordField) {\n submitLabel = t('form.submit');\n }\n\n let errorContent: AuthErrorContent | null = null;\n if (error) {\n if (typeof error === 'string') {\n errorContent = { title: 'Error', description: error };\n } else {\n errorContent = error;\n }\n }\n\n const formContent = (\n <Form {...form}>\n <form\n id=\"sign-in-form\"\n onSubmit={form.handleSubmit(onSubmit)}\n className=\"space-y-4\"\n >\n {showPasswordField ? (\n <>\n <FormItem>\n <FormLabel className=\"flex justify-between items-center\">\n {t('form.accountLabel')}\n <Button\n type=\"button\"\n variant=\"link\"\n size=\"sm\"\n className=\"p-0 m-0 h-auto\"\n onClick={handleBack}\n >\n {t('changeAccount')}\n </Button>\n </FormLabel>\n <Input\n id=\"sign-in-username\"\n type=\"text\"\n value={username}\n disabled\n />\n </FormItem>\n <FormField\n control={form.control}\n name=\"password\"\n render={({ field }) => (\n <FormItem>\n <FormLabel>{t('form.passwordLabel')}</FormLabel>\n <PasswordInput\n field={{ ...field, value: field.value ?? '' }}\n show={showPassword}\n onToggle={() => setShowPassword(!showPassword)}\n placeholder={t('form.passwordPlaceholder')}\n />\n <FormMessage />\n </FormItem>\n )}\n />\n </>\n ) : (\n <FormField\n control={form.control}\n name=\"username\"\n render={({ field }) => (\n <FormItem>\n <FormLabel>{t('form.accountLabel')}</FormLabel>\n <FormControl>\n <Input\n {...field}\n type=\"text\"\n placeholder={t('form.accountPlaceholder')}\n autoComplete=\"username\"\n />\n </FormControl>\n <FormMessage />\n </FormItem>\n )}\n />\n )}\n <Button\n type=\"submit\"\n className=\"w-full\"\n disabled={isSubmitting}\n loading={isSubmitting}\n >\n {submitLabel}\n </Button>\n </form>\n </Form>\n );\n\n return (\n <div className=\"space-y-4\">\n <AuthLayout\n title={t('title')}\n description={t('description')}\n logoImage={logoImage}\n footer={\n showPasswordField ? (\n <div className=\"flex items-center justify-center w-full\">\n {Link ? (\n <Link\n href={forgotPasswordLink}\n className=\"text-primary inline-block hover:underline\"\n >\n {t('footer.forgotPassword')}\n </Link>\n ) : (\n <a\n href={forgotPasswordLink}\n onClick={(e) => {\n e.preventDefault();\n onNavigate(forgotPasswordLink);\n }}\n className=\"text-primary inline-block hover:underline\"\n >\n {t('footer.forgotPassword')}\n </a>\n )}\n </div>\n ) : undefined\n }\n >\n {formContent}\n {errorContent && (\n <Alert variant=\"destructive\" className=\"mt-4\">\n <IconAlertCircle className=\"h-4 w-4\" />\n <AlertTitle>{errorContent.title}</AlertTitle>\n <AlertDescription>{errorContent.description}</AlertDescription>\n </Alert>\n )}\n </AuthLayout>\n </div>\n );\n};\n","import { useMesob } from '@mesob/ui/providers';\nimport { createTranslator } from '../lib/translations';\nimport { useConfig } from '../provider';\n\nexport function useTranslator(namespace?: string) {\n const mesob = useMesob();\n const { config } = useConfig();\n\n if (mesob?.t) {\n return (key: string, params?: Record<string, string | number>): string => {\n const fullKey = namespace ? `${namespace}.${key}` : key;\n return mesob.t?.(fullKey, params) ?? fullKey;\n };\n }\n\n return createTranslator(config.messages || {}, namespace);\n}\n","type Messages = Record<string, unknown>;\n\nexport function createTranslator(messages: Messages, namespace?: string) {\n return (key: string, params?: Record<string, string | number>): string => {\n const fullKey = namespace ? `${namespace}.${key}` : key;\n const keys = fullKey.split('.');\n\n let value: unknown = messages;\n for (const k of keys) {\n if (value && typeof value === 'object' && value !== null) {\n value = (value as Record<string, unknown>)[k];\n } else {\n return fullKey;\n }\n }\n\n if (typeof value !== 'string') {\n return fullKey;\n }\n\n // Simple parameter replacement\n if (params) {\n return value.replace(/\\{(\\w+)\\}/g, (_, param) =>\n String(params[param] ?? `{${param}}`),\n );\n }\n\n return value;\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 const AUTH_ERROR_MAPPING: Record<\n string,\n { title: string; description: string }\n> = {\n USER_NOT_FOUND: {\n title: 'Account Not Found',\n description:\n 'We could not find an account with that identifier. Please check your spelling or sign up.',\n },\n INVALID_PASSWORD: {\n title: 'Invalid Password',\n description: 'The password you entered is incorrect. Please try again.',\n },\n USER_EXISTS: {\n title: 'Account Already Exists',\n description:\n 'An account with this identifier already exists. Please sign in instead.',\n },\n VERIFICATION_EXPIRED: {\n title: 'Verification Expired',\n description:\n 'The verification code or link has expired. Please request a new one.',\n },\n VERIFICATION_MISMATCH: {\n title: 'Invalid Code',\n description:\n 'The verification code you entered is invalid. Please double-check and try again.',\n },\n VERIFICATION_NOT_FOUND: {\n title: 'Verification Not Found',\n description:\n 'We could not find a pending verification request. Please restart the process.',\n },\n TOO_MANY_ATTEMPTS: {\n title: 'Too Many Attempts',\n description:\n 'You have made too many requests recently. Please wait a moment before trying again.',\n },\n REQUIRES_VERIFICATION: {\n title: 'Verification Required',\n description:\n 'You need to verify your account before you can continue. Please check your email or phone.',\n },\n UNAUTHORIZED: {\n title: 'Unauthorized',\n description:\n 'You are not authorized to perform this action. Please sign in again.',\n },\n ACCESS_DENIED: {\n title: 'Access Denied',\n description:\n 'You do not have permission to access this resource. Please contact support if you believe this is an error.',\n },\n HAS_NO_PASSWORD: {\n title: 'No Password Set',\n description:\n 'Your account does not have a password set (e.g. social login). Please sign in with your provider or reset your password.',\n },\n};\n\nexport const validCodes = Object.keys(AUTH_ERROR_MAPPING);\n","import { AUTH_ERROR_MAPPING, validCodes } from '../constants/auth.error.codes';\nimport type { AuthError } from '../types';\n\nexport type AuthErrorContent = {\n title: string;\n description: string;\n};\n\ntype TranslatorFunction = (\n key: string,\n params?: Record<string, string | number>,\n) => string;\n\n// Type guard to check if error is an AuthError\nfunction isAuthError(err: unknown): err is AuthError {\n return (\n typeof err === 'object' &&\n err !== null &&\n 'message' in err &&\n typeof (err as { message: unknown }).message === 'string'\n );\n}\n\nfunction extractErrorCode(err: AuthError): string {\n if (err.code && validCodes.includes(err.code)) {\n return err.code;\n }\n if (err.message) {\n const messageUpper = err.message.toUpperCase().trim();\n if (validCodes.includes(messageUpper)) {\n return messageUpper;\n }\n }\n return '';\n}\n\nfunction sanitizeErrorMessage(message: string): string {\n const lowerMessage = message.toLowerCase();\n const isDatabaseError =\n lowerMessage.includes('failed query') ||\n lowerMessage.includes('select') ||\n lowerMessage.includes('insert') ||\n lowerMessage.includes('update') ||\n lowerMessage.includes('delete') ||\n lowerMessage.includes('from') ||\n lowerMessage.includes('where') ||\n lowerMessage.includes('limit') ||\n lowerMessage.includes('params:') ||\n lowerMessage.includes('query') ||\n message.includes('\"iam\".') ||\n message.includes('\"tenants\"') ||\n message.includes('\"users\"') ||\n message.includes('\"sessions\"') ||\n message.includes('\"accounts\"') ||\n lowerMessage.includes('relation') ||\n lowerMessage.includes('column') ||\n lowerMessage.includes('syntax error') ||\n lowerMessage.includes('database') ||\n lowerMessage.includes('postgres') ||\n lowerMessage.includes('sql');\n\n if (isDatabaseError) {\n return 'An error occurred while processing your request';\n }\n\n return message;\n}\n\nfunction handleAuthError(\n err: AuthError,\n setError: (error: AuthErrorContent | null) => void,\n t: TranslatorFunction,\n) {\n const errorCode = extractErrorCode(err);\n\n if (errorCode && AUTH_ERROR_MAPPING[errorCode]) {\n const mapping = AUTH_ERROR_MAPPING[errorCode];\n setError({\n title: mapping.title,\n description: mapping.description,\n });\n return;\n }\n\n const sanitizedMessage = sanitizeErrorMessage(\n err.message || t('errors.fallback'),\n );\n setError({\n title: t('errors.fallback'),\n description: sanitizedMessage,\n });\n}\n\nfunction handleGenericError(\n err: unknown,\n setError: (error: AuthErrorContent | null) => void,\n t: TranslatorFunction,\n) {\n const rawMessage = err instanceof Error ? err.message : t('errors.fallback');\n const sanitizedMessage = sanitizeErrorMessage(rawMessage);\n setError({\n title: 'Error',\n description: sanitizedMessage,\n });\n}\n\nexport const handleError = (\n err: unknown,\n setError: (error: AuthErrorContent | null) => void,\n t: TranslatorFunction,\n) => {\n if (isAuthError(err)) {\n handleAuthError(err, setError, t);\n } else {\n handleGenericError(err, setError, t);\n }\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","'use client';\n\nimport type { ReactNode } from 'react';\n\ntype AuthLayoutProps = {\n title: string;\n description?: string;\n children: ReactNode;\n footer?: ReactNode;\n logoImage?: string;\n};\n\nexport const AuthLayout = ({\n title,\n description,\n children,\n footer,\n logoImage,\n}: AuthLayoutProps) => {\n return (\n <div className=\"space-y-4\">\n <div className=\"flex size-8 mb-6 w-full items-center justify-center rounded-md\">\n {/** biome-ignore lint/performance/noImgElement: logo image */}\n <img src={logoImage || ''} alt=\"Mesob\" width={42} height={42} />\n </div>\n <div className=\"text-center\">\n <h1 className=\"text-2xl font-bold tracking-tight\">{title}</h1>\n {description && (\n <p className=\"mt-2 text-sm text-muted-foreground\">{description}</p>\n )}\n </div>\n\n {children}\n\n <div className=\"mt-2 w-full\">\n {footer && (\n <div className=\"w-full text-center text-sm text-muted-foreground\">\n {footer}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;AAEA,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,YAAAA,iBAAgB;AACzB,SAAS,iBAAiB,SAAS,kBAAkB;AAErD,SAAS,WAAW,YAAAC,iBAAgB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB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A,UAChC,gBAAAA,KAAC,oBAAkB,uBAAa,aAAY;AAAA,WAC9C;AAAA;AAAA;AAAA,EAEJ,GACF;AAEJ;","names":["useMesob","useState","jsx","jsx","jsxs","isPhone","useMesob","useState"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/auth/sign-in.tsx","../../../src/hooks/use-translator.ts","../../../src/lib/translations.ts","../../../src/provider.tsx","../../../src/utils/cookie.ts","../../../src/constants/auth.error.codes.ts","../../../src/utils/handle-error.ts","../../../src/utils/normalize-phone.ts","../../../src/components/auth/auth-layout.tsx"],"sourcesContent":["'use client';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport {\n Alert,\n AlertDescription,\n AlertTitle,\n Button,\n Form,\n FormControl,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n Input,\n useFormField,\n} from '@mesob/ui/components';\nimport { useMesob } from '@mesob/ui/providers';\nimport { IconAlertCircle, IconEye, IconEyeOff } from '@tabler/icons-react';\nimport type { ChangeEvent, ComponentProps } from 'react';\nimport { useEffect, useState } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { toast } from 'sonner';\nimport { z } from 'zod';\nimport { useTranslator } from '../../hooks/use-translator';\nimport { useApi, useConfig } from '../../provider';\nimport type { AuthErrorContent } from '../../utils/handle-error';\nimport { handleError } from '../../utils/handle-error';\nimport { normalizePhone } from '../../utils/normalize-phone';\nimport { AuthLayout } from './auth-layout';\n\nconst isPhone = (s: string) => /^\\+?[0-9()[\\]\\s-]{6,}$/.test(s);\n\ntype PasswordInputProps = {\n field: ComponentProps<'input'> & {\n value: string;\n onChange: (e: ChangeEvent<HTMLInputElement>) => void;\n onBlur: () => void;\n };\n show: boolean;\n onToggle: () => void;\n};\n\nfunction PasswordInput({ field, show, onToggle }: PasswordInputProps) {\n const { formItemId, error } = useFormField();\n return (\n <div className=\"relative\">\n <Input\n {...field}\n id={formItemId}\n type={show ? 'text' : 'password'}\n autoComplete=\"current-password\"\n aria-invalid={!!error}\n className=\"pr-10\"\n />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n className=\"absolute right-0 top-0 h-full px-3 text-muted-foreground hover:text-foreground\"\n onClick={onToggle}\n aria-label={show ? 'Hide password' : 'Show password'}\n >\n {show ? (\n <IconEyeOff className=\"h-4 w-4\" />\n ) : (\n <IconEye className=\"h-4 w-4\" />\n )}\n </Button>\n </div>\n );\n}\n\ntype SignInProps = {\n redirectUrl?: string;\n};\n\nconst signInSchema = (t: (key: string) => string, phoneRegex: RegExp) =>\n z.object({\n username: z\n .string()\n .trim()\n .min(1, { message: t('errors.requiredField') })\n .refine(\n (val) => {\n const isEmail = z.email().safeParse(val).success;\n const isPhone = phoneRegex.test(val);\n return isEmail || isPhone;\n },\n { message: t('errors.invalidEmailOrPhone') },\n ),\n password: z\n .union([\n z.literal(''),\n z\n .string()\n .min(8, t('errors.passwordLength'))\n .max(128, t('errors.longPasswordError')),\n ])\n .optional(),\n });\n\ntype SignInFormValues = z.infer<ReturnType<typeof signInSchema>>;\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: multi-step form with two form contexts\nexport const SignIn = ({ redirectUrl }: SignInProps = {}) => {\n const { hooks, setAuth } = useApi();\n const { config } = useConfig();\n const mesob = useMesob();\n const t = useTranslator('Auth.signIn');\n const Link = mesob?.navigation?.Link;\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<AuthErrorContent | null>(null);\n const [showPasswordField, setShowPasswordField] = useState(false);\n const [showPassword, setShowPassword] = useState(false);\n const [username, setUsername] = useState('');\n const [isChecking, setIsChecking] = useState(false);\n\n const checkUserMutation = hooks.useMutation('post', '/check-account');\n const signInMutation = hooks.useMutation('post', '/sign-in');\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 defaultRedirect =\n redirectUrl || config.navigation?.defaultRedirectUrl || '/dashboard';\n const forgotPasswordLink =\n config.navigation?.links?.forgotPassword || '/auth/forgot-password';\n const signUpLink = config.navigation?.links?.signUp || '/auth/sign-up';\n const setPasswordLink =\n config.navigation?.links?.setPassword || '/auth/set-password';\n const onNavigate =\n config.navigation?.onNavigate ||\n ((path: string) => {\n if (typeof window !== 'undefined') {\n window.location.href = path;\n }\n });\n const logoImage = config.ui.logoImage;\n\n const form = useForm<SignInFormValues>({\n resolver: zodResolver(signInSchema(t, phoneRegex)),\n defaultValues: { username: '', password: '' },\n mode: 'onBlur',\n });\n\n useEffect(() => {\n if (error) {\n toast.error(error.title || 'Error', {\n description: error.description,\n });\n }\n }, [error]);\n\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: auth branching is intentional\n const handleCheckAccount = async (usernameValue: string) => {\n setIsChecking(true);\n try {\n const normalizedUsername = phoneRegex.test(usernameValue)\n ? normalizePhone(usernameValue)\n : usernameValue;\n\n const result = await checkUserMutation.mutateAsync({\n body: {\n username: normalizedUsername,\n },\n });\n\n if (result.exists) {\n if (result.requiresPasswordSetup) {\n const redirectParam = defaultRedirect\n ? `&redirect=${encodeURIComponent(defaultRedirect)}`\n : '';\n onNavigate(\n `${setPasswordLink}?identifier=${encodeURIComponent(normalizedUsername)}${redirectParam}`,\n );\n return;\n }\n setUsername(normalizedUsername);\n form.setValue('username', normalizedUsername);\n setShowPasswordField(true);\n } else {\n const email = isPhone(normalizedUsername) ? '' : normalizedUsername;\n const redirectParam = defaultRedirect\n ? `&redirect=${encodeURIComponent(defaultRedirect)}`\n : '';\n if (email) {\n onNavigate(\n `${signUpLink}?email=${encodeURIComponent(email)}${redirectParam}`,\n );\n } else {\n onNavigate(\n `${signUpLink}?phone=${encodeURIComponent(normalizedUsername)}${redirectParam}`,\n );\n }\n }\n } catch {\n form.setError('username', { message: t('errors.checkAccountFailed') });\n } finally {\n setIsChecking(false);\n }\n };\n\n const onSubmit = async (values: SignInFormValues) => {\n if (showPasswordField) {\n const pwd = values.password;\n if (!pwd || pwd.length < 8) {\n form.setError('password', { message: t('errors.passwordLength') });\n return;\n }\n await handlePasswordSubmit({ password: pwd });\n } else {\n await handleCheckAccount(values.username);\n }\n };\n\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: auth branching is intentional\n const handlePasswordSubmit = async (values: { password: string }) => {\n setIsLoading(true);\n setError(null);\n\n try {\n const res = await signInMutation.mutateAsync({\n body: {\n identifier: username,\n password: values.password,\n },\n });\n\n if ('verificationId' in res && res.verificationId) {\n const redirectParam = defaultRedirect\n ? `&redirect=${encodeURIComponent(defaultRedirect)}`\n : '';\n const verifyPath = isPhone(username)\n ? `/auth/verify-phone?context=sign-in&verificationId=${res.verificationId}&identifier=${encodeURIComponent(username)}${redirectParam}`\n : `/auth/verify-email?verificationId=${res.verificationId}${redirectParam}`;\n onNavigate(verifyPath);\n return;\n }\n\n if ('user' in res && 'session' in res) {\n setAuth(res);\n }\n onNavigate(defaultRedirect);\n } catch (err) {\n const authError = err as { code?: string; message?: string };\n const errorCode = authError.code || authError.message;\n if (errorCode === 'HAS_NO_PASSWORD') {\n const redirectParam = defaultRedirect\n ? `&redirect=${encodeURIComponent(defaultRedirect)}`\n : '';\n onNavigate(\n `${setPasswordLink}?identifier=${encodeURIComponent(username)}${redirectParam}`,\n );\n return;\n }\n handleError(err, setError, t);\n } finally {\n setIsLoading(false);\n }\n };\n\n const handleBack = () => {\n setShowPasswordField(false);\n setUsername('');\n form.setValue('password', '');\n };\n\n const isSubmitting =\n isLoading ||\n checkUserMutation.isPending ||\n signInMutation.isPending ||\n isChecking;\n\n let submitLabel = t('form.continue');\n if (isSubmitting) {\n submitLabel = showPasswordField ? t('form.submitting') : t('form.checking');\n } else if (showPasswordField) {\n submitLabel = t('form.submit');\n }\n\n let errorContent: AuthErrorContent | null = null;\n if (error) {\n if (typeof error === 'string') {\n errorContent = { title: 'Error', description: error };\n } else {\n errorContent = error;\n }\n }\n\n const formContent = (\n <Form {...form}>\n <form\n id=\"sign-in-form\"\n onSubmit={form.handleSubmit(onSubmit)}\n className=\"space-y-4\"\n >\n {showPasswordField ? (\n <>\n <FormItem>\n <FormLabel className=\"flex justify-between items-center\">\n {t('form.accountLabel')}\n <Button\n type=\"button\"\n variant=\"link\"\n size=\"sm\"\n className=\"p-0 m-0 h-auto\"\n onClick={handleBack}\n >\n {t('changeAccount')}\n </Button>\n </FormLabel>\n <Input\n id=\"sign-in-username\"\n type=\"text\"\n value={username}\n autoComplete=\"username\"\n disabled\n />\n </FormItem>\n <FormField\n control={form.control}\n name=\"password\"\n render={({ field }) => (\n <FormItem>\n <FormLabel>{t('form.passwordLabel')}</FormLabel>\n <PasswordInput\n field={{ ...field, value: field.value ?? '' }}\n show={showPassword}\n onToggle={() => setShowPassword(!showPassword)}\n />\n <FormMessage />\n </FormItem>\n )}\n />\n </>\n ) : (\n <FormField\n control={form.control}\n name=\"username\"\n render={({ field }) => (\n <FormItem>\n <FormLabel>{t('form.accountLabel')}</FormLabel>\n <FormControl>\n <Input {...field} type=\"text\" autoComplete=\"username\" />\n </FormControl>\n <FormMessage />\n </FormItem>\n )}\n />\n )}\n <Button\n type=\"submit\"\n className=\"w-full\"\n disabled={isSubmitting}\n loading={isSubmitting}\n >\n {submitLabel}\n </Button>\n </form>\n </Form>\n );\n\n return (\n <div className=\"space-y-4\">\n <AuthLayout\n title={config.ui.name}\n description={t('description')}\n logoImage={logoImage}\n footer={\n showPasswordField ? (\n <div className=\"flex items-center justify-center w-full\">\n {Link ? (\n <Link\n href={forgotPasswordLink}\n className=\"text-primary inline-block hover:underline\"\n >\n {t('footer.forgotPassword')}\n </Link>\n ) : (\n <a\n href={forgotPasswordLink}\n onClick={(e) => {\n e.preventDefault();\n onNavigate(forgotPasswordLink);\n }}\n className=\"text-primary inline-block hover:underline\"\n >\n {t('footer.forgotPassword')}\n </a>\n )}\n </div>\n ) : undefined\n }\n >\n {formContent}\n {errorContent && (\n <Alert variant=\"destructive\" className=\"mt-4\">\n <IconAlertCircle className=\"h-4 w-4\" />\n <AlertTitle>{errorContent.title}</AlertTitle>\n <AlertDescription>{errorContent.description}</AlertDescription>\n </Alert>\n )}\n </AuthLayout>\n </div>\n );\n};\n","import { useMesob } from '@mesob/ui/providers';\nimport { createTranslator } from '../lib/translations';\nimport { useConfig } from '../provider';\n\nexport function useTranslator(namespace?: string) {\n const mesob = useMesob();\n const { config } = useConfig();\n\n if (mesob?.t) {\n return (key: string, params?: Record<string, string | number>): string => {\n const fullKey = namespace ? `${namespace}.${key}` : key;\n return mesob.t?.(fullKey, params) ?? fullKey;\n };\n }\n\n return createTranslator(config.messages || {}, namespace);\n}\n","type Messages = Record<string, unknown>;\n\nexport function createTranslator(messages: Messages, namespace?: string) {\n return (key: string, params?: Record<string, string | number>): string => {\n const fullKey = namespace ? `${namespace}.${key}` : key;\n const keys = fullKey.split('.');\n\n let value: unknown = messages;\n for (const k of keys) {\n if (value && typeof value === 'object' && value !== null) {\n value = (value as Record<string, unknown>)[k];\n } else {\n return fullKey;\n }\n }\n\n if (typeof value !== 'string') {\n return fullKey;\n }\n\n // Simple parameter replacement\n if (params) {\n return value.replace(/\\{(\\w+)\\}/g, (_, param) =>\n String(params[param] ?? `{${param}}`),\n );\n }\n\n return value;\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 const AUTH_ERROR_MAPPING: Record<\n string,\n { title: string; description: string }\n> = {\n USER_NOT_FOUND: {\n title: 'Account Not Found',\n description:\n 'We could not find an account with that identifier. Please check your spelling or sign up.',\n },\n INVALID_PASSWORD: {\n title: 'Invalid Password',\n description: 'The password you entered is incorrect. Please try again.',\n },\n USER_EXISTS: {\n title: 'Account Already Exists',\n description:\n 'An account with this identifier already exists. Please sign in instead.',\n },\n VERIFICATION_EXPIRED: {\n title: 'Verification Expired',\n description:\n 'The verification code or link has expired. Please request a new one.',\n },\n VERIFICATION_MISMATCH: {\n title: 'Invalid Code',\n description:\n 'The verification code you entered is invalid. Please double-check and try again.',\n },\n VERIFICATION_NOT_FOUND: {\n title: 'Verification Not Found',\n description:\n 'We could not find a pending verification request. Please restart the process.',\n },\n TOO_MANY_ATTEMPTS: {\n title: 'Too Many Attempts',\n description:\n 'You have made too many requests recently. Please wait a moment before trying again.',\n },\n REQUIRES_VERIFICATION: {\n title: 'Verification Required',\n description:\n 'You need to verify your account before you can continue. Please check your email or phone.',\n },\n UNAUTHORIZED: {\n title: 'Unauthorized',\n description:\n 'You are not authorized to perform this action. Please sign in again.',\n },\n ACCESS_DENIED: {\n title: 'Access Denied',\n description:\n 'You do not have permission to access this resource. Please contact support if you believe this is an error.',\n },\n HAS_NO_PASSWORD: {\n title: 'No Password Set',\n description:\n 'Your account does not have a password yet. Continue to set a password before signing in.',\n },\n PASSWORD_ALREADY_SET: {\n title: 'Password Already Set',\n description:\n 'This account already has a password. Use the normal sign-in form instead.',\n },\n};\n\nexport const validCodes = Object.keys(AUTH_ERROR_MAPPING);\n","import { AUTH_ERROR_MAPPING, validCodes } from '../constants/auth.error.codes';\nimport type { AuthError } from '../types';\n\nexport type AuthErrorContent = {\n title: string;\n description: string;\n};\n\ntype TranslatorFunction = (\n key: string,\n params?: Record<string, string | number>,\n) => string;\n\n// Type guard to check if error is an AuthError\nfunction isAuthError(err: unknown): err is AuthError {\n return (\n typeof err === 'object' &&\n err !== null &&\n 'message' in err &&\n typeof (err as { message: unknown }).message === 'string'\n );\n}\n\nfunction extractErrorCode(err: AuthError): string {\n if (err.code && validCodes.includes(err.code)) {\n return err.code;\n }\n if (err.message) {\n const messageUpper = err.message.toUpperCase().trim();\n if (validCodes.includes(messageUpper)) {\n return messageUpper;\n }\n }\n return '';\n}\n\nfunction sanitizeErrorMessage(message: string): string {\n const lowerMessage = message.toLowerCase();\n const isDatabaseError =\n lowerMessage.includes('failed query') ||\n lowerMessage.includes('select') ||\n lowerMessage.includes('insert') ||\n lowerMessage.includes('update') ||\n lowerMessage.includes('delete') ||\n lowerMessage.includes('from') ||\n lowerMessage.includes('where') ||\n lowerMessage.includes('limit') ||\n lowerMessage.includes('params:') ||\n lowerMessage.includes('query') ||\n message.includes('\"iam\".') ||\n message.includes('\"tenants\"') ||\n message.includes('\"users\"') ||\n message.includes('\"sessions\"') ||\n message.includes('\"accounts\"') ||\n lowerMessage.includes('relation') ||\n lowerMessage.includes('column') ||\n lowerMessage.includes('syntax error') ||\n lowerMessage.includes('database') ||\n lowerMessage.includes('postgres') ||\n lowerMessage.includes('sql');\n\n if (isDatabaseError) {\n return 'An error occurred while processing your request';\n }\n\n return message;\n}\n\nfunction handleAuthError(\n err: AuthError,\n setError: (error: AuthErrorContent | null) => void,\n t: TranslatorFunction,\n) {\n const errorCode = extractErrorCode(err);\n\n if (errorCode && AUTH_ERROR_MAPPING[errorCode]) {\n const mapping = AUTH_ERROR_MAPPING[errorCode];\n setError({\n title: mapping.title,\n description: mapping.description,\n });\n return;\n }\n\n const sanitizedMessage = sanitizeErrorMessage(\n err.message || t('errors.fallback'),\n );\n setError({\n title: t('errors.fallback'),\n description: sanitizedMessage,\n });\n}\n\nfunction handleGenericError(\n err: unknown,\n setError: (error: AuthErrorContent | null) => void,\n t: TranslatorFunction,\n) {\n const rawMessage = err instanceof Error ? err.message : t('errors.fallback');\n const sanitizedMessage = sanitizeErrorMessage(rawMessage);\n setError({\n title: 'Error',\n description: sanitizedMessage,\n });\n}\n\nexport const handleError = (\n err: unknown,\n setError: (error: AuthErrorContent | null) => void,\n t: TranslatorFunction,\n) => {\n if (isAuthError(err)) {\n handleAuthError(err, setError, t);\n } else {\n handleGenericError(err, setError, t);\n }\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","'use client';\n\nimport type { ReactNode } from 'react';\n\ntype AuthLayoutProps = {\n title: ReactNode;\n description?: string;\n children: ReactNode;\n footer?: ReactNode;\n logoImage?: string;\n};\n\nexport const AuthLayout = ({\n title,\n description,\n children,\n footer,\n logoImage,\n}: AuthLayoutProps) => {\n return (\n <div className=\"space-y-4\">\n <div className=\"flex size-8 mb-6 w-full items-center justify-center rounded-md\">\n {/** biome-ignore lint/performance/noImgElement: logo image */}\n <img\n src={logoImage || ''}\n alt={title as string}\n width={42}\n height={42}\n />\n </div>\n <div className=\"text-center\">\n <h1 className=\"text-2xl font-bold tracking-tight\">{title}</h1>\n {description && (\n <p className=\"mt-2 text-sm text-muted-foreground\">{description}</p>\n )}\n </div>\n\n {children}\n\n {footer && (\n <div className=\"mt-2 w-full\">\n <div className=\"w-full text-center text-sm text-muted-foreground\">\n {footer}\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;AAEA,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,YAAAA,iBAAgB;AACzB,SAAS,iBAAiB,SAAS,kBAAkB;AAErD,SAAS,WAAW,YAAAC,iBAAgB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,SAAS;;;ACvBlB,SAAS,gBAAgB;;;ACElB,SAAS,iBAAiB,UAAoB,WAAoB;AACvE,SAAO,CAAC,KAAa,WAAqD;AACxE,UAAM,UAAU,YAAY,GAAG,SAAS,IAAI,GAAG,KAAK;AACpD,UAAM,OAAO,QAAQ,MAAM,GAAG;AAE9B,QAAI,QAAiB;AACrB,eAAW,KAAK,MAAM;AACpB,UAAI,SAAS,OAAO,UAAU,YAAY,UAAU,MAAM;AACxD,gBAAS,MAAkC,CAAC;AAAA,MAC9C,OAAO;AACL,eAAO;AAAA,MACT;AAAA,IACF;AAEA,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,IACT;AAGA,QAAI,QAAQ;AACV,aAAO,MAAM;AAAA,QAAQ;AAAA,QAAc,CAAC,GAAG,UACrC,OAAO,OAAO,KAAK,KAAK,IAAI,KAAK,GAAG;AAAA,MACtC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;;;AC3BA,SAAS,aAAa,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AAA,UAChC,gBAAAA,KAAC,oBAAkB,uBAAa,aAAY;AAAA,WAC9C;AAAA;AAAA;AAAA,EAEJ,GACF;AAEJ;","names":["useMesob","useState","jsx","jsx","jsxs","isPhone","useMesob","useState"]}
|
|
@@ -146,7 +146,11 @@ var AUTH_ERROR_MAPPING = {
|
|
|
146
146
|
},
|
|
147
147
|
HAS_NO_PASSWORD: {
|
|
148
148
|
title: "No Password Set",
|
|
149
|
-
description: "Your account does not have a password
|
|
149
|
+
description: "Your account does not have a password yet. Continue to set a password before signing in."
|
|
150
|
+
},
|
|
151
|
+
PASSWORD_ALREADY_SET: {
|
|
152
|
+
title: "Password Already Set",
|
|
153
|
+
description: "This account already has a password. Use the normal sign-in form instead."
|
|
150
154
|
}
|
|
151
155
|
};
|
|
152
156
|
var validCodes = Object.keys(AUTH_ERROR_MAPPING);
|
|
@@ -219,25 +223,28 @@ var AuthLayout = ({
|
|
|
219
223
|
logoImage
|
|
220
224
|
}) => {
|
|
221
225
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
222
|
-
/* @__PURE__ */ jsx2("div", { className: "flex size-8 mb-6 w-full items-center justify-center rounded-md", children: /* @__PURE__ */ jsx2(
|
|
226
|
+
/* @__PURE__ */ jsx2("div", { className: "flex size-8 mb-6 w-full items-center justify-center rounded-md", children: /* @__PURE__ */ jsx2(
|
|
227
|
+
"img",
|
|
228
|
+
{
|
|
229
|
+
src: logoImage || "",
|
|
230
|
+
alt: title,
|
|
231
|
+
width: 42,
|
|
232
|
+
height: 42
|
|
233
|
+
}
|
|
234
|
+
) }),
|
|
223
235
|
/* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
224
236
|
/* @__PURE__ */ jsx2("h1", { className: "text-2xl font-bold tracking-tight", children: title }),
|
|
225
237
|
description && /* @__PURE__ */ jsx2("p", { className: "mt-2 text-sm text-muted-foreground", children: description })
|
|
226
238
|
] }),
|
|
227
239
|
children,
|
|
228
|
-
/* @__PURE__ */ jsx2("div", { className: "mt-2 w-full", children:
|
|
240
|
+
footer && /* @__PURE__ */ jsx2("div", { className: "mt-2 w-full", children: /* @__PURE__ */ jsx2("div", { className: "w-full text-center text-sm text-muted-foreground", children: footer }) })
|
|
229
241
|
] });
|
|
230
242
|
};
|
|
231
243
|
|
|
232
244
|
// src/components/auth/sign-up.tsx
|
|
233
245
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
234
246
|
var isPhone = (s) => /^\+?[0-9()[\]\s-]{6,}$/.test(s);
|
|
235
|
-
function PasswordInput({
|
|
236
|
-
field,
|
|
237
|
-
show,
|
|
238
|
-
onToggle,
|
|
239
|
-
placeholder
|
|
240
|
-
}) {
|
|
247
|
+
function PasswordInput({ field, show, onToggle }) {
|
|
241
248
|
const { formItemId, error } = useFormField();
|
|
242
249
|
return /* @__PURE__ */ jsxs2("div", { className: "relative", children: [
|
|
243
250
|
/* @__PURE__ */ jsx3(
|
|
@@ -246,7 +253,6 @@ function PasswordInput({
|
|
|
246
253
|
...field,
|
|
247
254
|
id: formItemId,
|
|
248
255
|
type: show ? "text" : "password",
|
|
249
|
-
placeholder,
|
|
250
256
|
"aria-invalid": !!error,
|
|
251
257
|
className: "pr-10"
|
|
252
258
|
}
|
|
@@ -338,23 +344,22 @@ var SignUp = ({
|
|
|
338
344
|
body: usingPhone ? {
|
|
339
345
|
phone: identifier,
|
|
340
346
|
password: values.password,
|
|
341
|
-
fullName: values.fullName
|
|
342
|
-
handle: values.handle
|
|
347
|
+
fullName: values.fullName
|
|
343
348
|
} : {
|
|
344
349
|
email: identifier,
|
|
345
350
|
password: values.password,
|
|
346
|
-
fullName: values.fullName
|
|
347
|
-
handle: values.handle
|
|
351
|
+
fullName: values.fullName
|
|
348
352
|
}
|
|
349
353
|
});
|
|
350
354
|
if ("verificationId" in res && res.verificationId) {
|
|
355
|
+
const redirectParam = defaultRedirect ? `&redirect=${encodeURIComponent(defaultRedirect)}` : "";
|
|
351
356
|
if (usingPhone) {
|
|
352
357
|
onNavigate(
|
|
353
|
-
`/auth/verify-phone?context=sign-up&verificationId=${res.verificationId}&phone=${encodeURIComponent(identifier)}`
|
|
358
|
+
`/auth/verify-phone?context=sign-up&verificationId=${res.verificationId}&phone=${encodeURIComponent(identifier)}${redirectParam}`
|
|
354
359
|
);
|
|
355
360
|
} else {
|
|
356
361
|
onNavigate(
|
|
357
|
-
`/auth/verify-email?verificationId=${res.verificationId}&email=${encodeURIComponent(identifier)}`
|
|
362
|
+
`/auth/verify-email?verificationId=${res.verificationId}&email=${encodeURIComponent(identifier)}${redirectParam}`
|
|
358
363
|
);
|
|
359
364
|
}
|
|
360
365
|
return;
|
|
@@ -390,7 +395,7 @@ var SignUp = ({
|
|
|
390
395
|
return /* @__PURE__ */ jsxs2(
|
|
391
396
|
AuthLayout,
|
|
392
397
|
{
|
|
393
|
-
title:
|
|
398
|
+
title: config.ui.name,
|
|
394
399
|
description: t("description"),
|
|
395
400
|
logoImage,
|
|
396
401
|
footer: /* @__PURE__ */ jsxs2("p", { children: [
|
|
@@ -418,13 +423,7 @@ var SignUp = ({
|
|
|
418
423
|
name: "fullName",
|
|
419
424
|
render: ({ field }) => /* @__PURE__ */ jsxs2(FormItem, { children: [
|
|
420
425
|
/* @__PURE__ */ jsx3(FormLabel, { children: t("form.fullNameLabel") }),
|
|
421
|
-
/* @__PURE__ */ jsx3(FormControl, { children: /* @__PURE__ */ jsx3(
|
|
422
|
-
Input,
|
|
423
|
-
{
|
|
424
|
-
...field,
|
|
425
|
-
placeholder: t("form.fullNamePlaceholder")
|
|
426
|
-
}
|
|
427
|
-
) }),
|
|
426
|
+
/* @__PURE__ */ jsx3(FormControl, { children: /* @__PURE__ */ jsx3(Input, { ...field }) }),
|
|
428
427
|
/* @__PURE__ */ jsx3(FormMessage, {})
|
|
429
428
|
] })
|
|
430
429
|
}
|
|
@@ -447,7 +446,6 @@ var SignUp = ({
|
|
|
447
446
|
{
|
|
448
447
|
...field,
|
|
449
448
|
type: field.value.includes("@") ? "email" : "tel",
|
|
450
|
-
placeholder: hasInitialIdentifier ? void 0 : t("form.accountPlaceholder") || "Email or phone number",
|
|
451
449
|
disabled: hasInitialIdentifier
|
|
452
450
|
}
|
|
453
451
|
) }),
|
|
@@ -467,8 +465,7 @@ var SignUp = ({
|
|
|
467
465
|
{
|
|
468
466
|
field,
|
|
469
467
|
show: showPassword,
|
|
470
|
-
onToggle: () => setShowPassword(!showPassword)
|
|
471
|
-
placeholder: t("form.passwordPlaceholder")
|
|
468
|
+
onToggle: () => setShowPassword(!showPassword)
|
|
472
469
|
}
|
|
473
470
|
),
|
|
474
471
|
/* @__PURE__ */ jsx3(FormMessage, {})
|
|
@@ -487,8 +484,7 @@ var SignUp = ({
|
|
|
487
484
|
{
|
|
488
485
|
field,
|
|
489
486
|
show: showConfirmPassword,
|
|
490
|
-
onToggle: () => setShowConfirmPassword(!showConfirmPassword)
|
|
491
|
-
placeholder: t("form.passwordPlaceholder")
|
|
487
|
+
onToggle: () => setShowConfirmPassword(!showConfirmPassword)
|
|
492
488
|
}
|
|
493
489
|
),
|
|
494
490
|
/* @__PURE__ */ jsx3(FormMessage, {})
|