@yimingliao/cms 0.0.90 → 0.0.93

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.
@@ -1,18 +1,17 @@
1
- import { z as Translation, R as Result, S as SuccessResult, d as ErrorResult, g as AdminFull, D as DeviceInfo, j as AdminSafe } from '../types-BGsFazJr.js';
1
+ import { z as Translation, R as Result, S as SuccessResult, d as ErrorResult, g as AdminFull, D as DeviceInfo } from '../types-BGsFazJr.js';
2
2
  import { Logger } from 'logry';
3
3
  import * as _tanstack_react_query from '@tanstack/react-query';
4
4
  import { QueryClient, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
5
5
  import * as _tanstack_query_core from '@tanstack/query-core';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
- import { c as createSchemas, A as ActionContext } from '../action-context-yvi5OrMJ.js';
7
+ import { c as createVerifyAction, a as createSignInAction, b as createVerifyEmailAction, d as createEmailUnverifiedAction, e as createForgotPasswordAction, f as createResetPasswordAction, g as createChangePasswordAction } from '../create-reset-password-action-D6aTuuqO.js';
8
8
  import * as React$1 from 'react';
9
9
  import { ComponentProps, ReactNode, HTMLAttributes } from 'react';
10
10
  import { L as LabelProps, B as ButtonProps$1 } from '../label-BF4qxS03.js';
11
11
  import { LucideIcon } from 'lucide-react';
12
- import * as zod from 'zod';
13
- import zod__default from 'zod';
14
- import * as zod_v4_core from 'zod/v4/core';
15
12
  import { ClassValue } from 'clsx';
13
+ import 'zod';
14
+ import 'zod/v4/core';
16
15
  import '../types-J25u1G6t.js';
17
16
  import '../types-0oS1A2K5.js';
18
17
  import 'jsonwebtoken';
@@ -344,75 +343,6 @@ declare function AdminProvider({ children }: {
344
343
  }): react_jsx_runtime.JSX.Element;
345
344
  declare function useAdmin(): AdminContextValue;
346
345
 
347
- declare const signInValidator: (schemas: ReturnType<typeof createSchemas>) => zod__default.ZodObject<{
348
- email: zod__default.ZodEmail;
349
- password: zod__default.ZodString;
350
- }, zod__default.core.$strip>;
351
-
352
- type SignInFormData = zod__default.infer<ReturnType<typeof signInValidator>>;
353
- declare function createSignInAction(ctx: ActionContext): ({ formData, deviceInfo, }: {
354
- formData: SignInFormData;
355
- deviceInfo: DeviceInfo;
356
- }) => Promise<Result<{
357
- admin: AdminFull;
358
- }>>;
359
-
360
- declare function createVerifyAction(ctx: ActionContext): () => Promise<Result<{
361
- admin: AdminFull;
362
- }>>;
363
-
364
- declare const changePasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
365
- password: zod.ZodString;
366
- newPassword: zod.ZodString;
367
- newPasswordConfirm: zod.ZodString;
368
- }, zod_v4_core.$strip>;
369
-
370
- type ChangePasswordFormData = zod__default.infer<ReturnType<typeof changePasswordValidator>>;
371
- declare function createChangePasswordAction(ctx: ActionContext): ({ formData, }: {
372
- formData: ChangePasswordFormData;
373
- }) => Promise<Result<void>>;
374
-
375
- declare const verifyEmailValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
376
- email: zod.ZodEmail;
377
- emailVerificationToken: zod.ZodString;
378
- }, zod_v4_core.$strip>;
379
-
380
- type VerifyEmailFormData = zod__default.infer<ReturnType<typeof verifyEmailValidator>>;
381
- declare function createVerifyEmailAction(ctx: ActionContext): ({ formData, }: {
382
- formData: VerifyEmailFormData;
383
- }) => Promise<Result<{
384
- admin: AdminSafe;
385
- }>>;
386
-
387
- declare const emailUnverifiedValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
388
- email: zod.ZodEmail;
389
- }, zod_v4_core.$strip>;
390
-
391
- type EmailUnverifiedFormData = zod__default.infer<ReturnType<typeof emailUnverifiedValidator>>;
392
- declare function createEmailUnverifiedAction(ctx: ActionContext): ({ formData, }: {
393
- formData: EmailUnverifiedFormData;
394
- }) => Promise<Result<void>>;
395
-
396
- declare const forgetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
397
- email: zod.ZodEmail;
398
- }, zod_v4_core.$strip>;
399
-
400
- type ForgotPasswordFormData = zod__default.infer<ReturnType<typeof forgetPasswordValidator>>;
401
- declare function createForgotPasswordAction(ctx: ActionContext): ({ formData, }: {
402
- formData: ForgotPasswordFormData;
403
- }) => Promise<Result<void>>;
404
-
405
- declare const resetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
406
- passwordResetToken: zod.ZodString;
407
- newPassword: zod.ZodString;
408
- newPasswordConfirm: zod.ZodString;
409
- }, zod_v4_core.$strip>;
410
-
411
- type ResetPasswordFormData = zod__default.infer<ReturnType<typeof resetPasswordValidator>>;
412
- declare function createResetPasswordAction(ctx: ActionContext): ({ formData, }: {
413
- formData: ResetPasswordFormData;
414
- }) => Promise<Result<void>>;
415
-
416
346
  declare function createAdminInitializer({ useAdmin, useQuery, verifyAction, }: {
417
347
  useAdmin: () => AdminContextValue;
418
348
  useQuery: ReturnType<typeof createUseQuery>;
@@ -475,48 +475,56 @@ function createSignInPage({
475
475
  }),
476
476
  { onSuccess: (data) => setAdmin(data?.admin || null) }
477
477
  );
478
- return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
479
- /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.sign-in.text") }) }),
480
- /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
481
- /* @__PURE__ */ jsx(Field, { htmlFor: "email", label: t("auth.sign-in.email.text"), children: /* @__PURE__ */ jsx(
482
- Input,
483
- {
484
- id: "email",
485
- type: "email",
486
- placeholder: t("auth.sign-in.email.placeholder.text"),
487
- autoComplete: "email",
488
- fieldName: "email",
489
- value: formData.email,
490
- setFormData,
491
- isDisabled: isRedirecting,
492
- isError: errors.includes("email")
493
- }
494
- ) }),
495
- /* @__PURE__ */ jsx(Field, { htmlFor: "password", label: t("auth.sign-in.password.text"), children: /* @__PURE__ */ jsx(
496
- PasswordInput,
497
- {
498
- id: "password",
499
- placeholder: t("auth.sign-in.password.placeholder.text"),
500
- fieldName: "password",
501
- value: formData.password,
502
- setFormData,
503
- isDisabled: isRedirecting,
504
- isError: errors.includes("password")
505
- }
506
- ) }),
507
- /* @__PURE__ */ jsx(
508
- Button2,
509
- {
510
- size: "xs",
511
- variant: "link",
512
- className: "w-fit",
513
- isDisabled: isRedirecting,
514
- children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.forgotPassword.path, children: t("auth.sign-in.anchor.text") })
515
- }
516
- ),
517
- /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.sign-in.button.text") })
518
- ] })
519
- ] }) });
478
+ return /* @__PURE__ */ jsx(
479
+ Form,
480
+ {
481
+ className: "mx-auto w-96",
482
+ style: { marginTop: "56px" },
483
+ onSubmit: () => void execute(),
484
+ children: /* @__PURE__ */ jsxs(Card, { children: [
485
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.sign-in.text") }) }),
486
+ /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
487
+ /* @__PURE__ */ jsx(Field, { htmlFor: "email", label: t("auth.sign-in.email.text"), children: /* @__PURE__ */ jsx(
488
+ Input,
489
+ {
490
+ id: "email",
491
+ type: "email",
492
+ placeholder: t("auth.sign-in.email.placeholder.text"),
493
+ autoComplete: "email",
494
+ fieldName: "email",
495
+ value: formData.email,
496
+ setFormData,
497
+ isDisabled: isRedirecting,
498
+ isError: errors.includes("email")
499
+ }
500
+ ) }),
501
+ /* @__PURE__ */ jsx(Field, { htmlFor: "password", label: t("auth.sign-in.password.text"), children: /* @__PURE__ */ jsx(
502
+ PasswordInput,
503
+ {
504
+ id: "password",
505
+ placeholder: t("auth.sign-in.password.placeholder.text"),
506
+ fieldName: "password",
507
+ value: formData.password,
508
+ setFormData,
509
+ isDisabled: isRedirecting,
510
+ isError: errors.includes("password")
511
+ }
512
+ ) }),
513
+ /* @__PURE__ */ jsx(
514
+ Button2,
515
+ {
516
+ size: "xs",
517
+ variant: "link",
518
+ className: "w-fit",
519
+ isDisabled: isRedirecting,
520
+ children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.forgotPassword.path, children: t("auth.sign-in.anchor.text") })
521
+ }
522
+ ),
523
+ /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.sign-in.button.text") })
524
+ ] })
525
+ ] })
526
+ }
527
+ );
520
528
  };
521
529
  }
522
530
  function createVerifyEmailPage({
@@ -576,33 +584,41 @@ function createEmailUnverifiedPage({
576
584
  "\xA0",
577
585
  t("auth.email-unverified.button.send-again.text")
578
586
  ] });
579
- return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
580
- /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.email-unverified.text") }) }),
581
- /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
582
- /* @__PURE__ */ jsxs(InputGroup, { children: [
583
- /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Label, { htmlFor: "email", className: "text-foreground", children: /* @__PURE__ */ jsx(Mail, { className: "size-4" }) }) }),
584
- isLoading ? /* @__PURE__ */ jsx("div", { className: "px-2", children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(
585
- InputGroupInput,
586
- {
587
- id: "email",
588
- placeholder: "shadcn@vercel.com",
589
- disabled: true,
590
- value: admin?.email
591
- }
592
- )
593
- ] }),
594
- /* @__PURE__ */ jsx(CardDescription, { children: /* @__PURE__ */ jsx("p", { className: "text-sm whitespace-pre-line", children: t("auth.email-unverified.notice.text") }) }),
595
- /* @__PURE__ */ jsx(
596
- Button2,
597
- {
598
- type: "submit",
599
- isLoading: isLoading || isPending,
600
- isDisabled: isCounting,
601
- children: buttonText
602
- }
603
- )
604
- ] })
605
- ] }) });
587
+ return /* @__PURE__ */ jsx(
588
+ Form,
589
+ {
590
+ className: "mx-auto w-96",
591
+ style: { marginTop: "56px" },
592
+ onSubmit: () => void execute(),
593
+ children: /* @__PURE__ */ jsxs(Card, { children: [
594
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.email-unverified.text") }) }),
595
+ /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
596
+ /* @__PURE__ */ jsxs(InputGroup, { children: [
597
+ /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Label, { htmlFor: "email", className: "text-foreground", children: /* @__PURE__ */ jsx(Mail, { className: "size-4" }) }) }),
598
+ isLoading ? /* @__PURE__ */ jsx("div", { className: "px-2", children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(
599
+ InputGroupInput,
600
+ {
601
+ id: "email",
602
+ placeholder: "shadcn@vercel.com",
603
+ disabled: true,
604
+ value: admin?.email
605
+ }
606
+ )
607
+ ] }),
608
+ /* @__PURE__ */ jsx(CardDescription, { children: /* @__PURE__ */ jsx("p", { className: "text-sm whitespace-pre-line", children: t("auth.email-unverified.notice.text") }) }),
609
+ /* @__PURE__ */ jsx(
610
+ Button2,
611
+ {
612
+ type: "submit",
613
+ isLoading: isLoading || isPending,
614
+ isDisabled: isCounting,
615
+ children: buttonText
616
+ }
617
+ )
618
+ ] })
619
+ ] })
620
+ }
621
+ );
606
622
  };
607
623
  }
608
624
  function createForgotPasswordPage({
@@ -627,35 +643,43 @@ function createForgotPasswordPage({
627
643
  "\xA0",
628
644
  t("auth.forgot-password.button.send-again.text")
629
645
  ] });
630
- return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
631
- /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.forgot-password.text") }) }),
632
- /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
633
- /* @__PURE__ */ jsx(Field, { htmlFor: "email", label: t("auth.forgot-password.email.text"), children: /* @__PURE__ */ jsx(
634
- Input,
635
- {
636
- id: "email",
637
- placeholder: t("auth.forgot-password.email.placeholder.text"),
638
- autoComplete: "email",
639
- fieldName: "email",
640
- value: formData.email,
641
- setFormData,
642
- isDisabled: isPending || isCounting,
643
- isError: errors.includes("email")
644
- }
645
- ) }),
646
- /* @__PURE__ */ jsx(
647
- Button2,
648
- {
649
- size: "xs",
650
- variant: "link",
651
- className: "w-fit",
652
- isDisabled: isPending,
653
- children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.signIn.path, children: t("auth.forgot-password.anchor.text") })
654
- }
655
- ),
656
- /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isPending, isDisabled: isCounting, children: buttonText })
657
- ] })
658
- ] }) });
646
+ return /* @__PURE__ */ jsx(
647
+ Form,
648
+ {
649
+ className: "mx-auto w-96",
650
+ style: { marginTop: "56px" },
651
+ onSubmit: () => void execute(),
652
+ children: /* @__PURE__ */ jsxs(Card, { children: [
653
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.forgot-password.text") }) }),
654
+ /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
655
+ /* @__PURE__ */ jsx(Field, { htmlFor: "email", label: t("auth.forgot-password.email.text"), children: /* @__PURE__ */ jsx(
656
+ Input,
657
+ {
658
+ id: "email",
659
+ placeholder: t("auth.forgot-password.email.placeholder.text"),
660
+ autoComplete: "email",
661
+ fieldName: "email",
662
+ value: formData.email,
663
+ setFormData,
664
+ isDisabled: isPending || isCounting,
665
+ isError: errors.includes("email")
666
+ }
667
+ ) }),
668
+ /* @__PURE__ */ jsx(
669
+ Button2,
670
+ {
671
+ size: "xs",
672
+ variant: "link",
673
+ className: "w-fit",
674
+ isDisabled: isPending,
675
+ children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.signIn.path, children: t("auth.forgot-password.anchor.text") })
676
+ }
677
+ ),
678
+ /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isPending, isDisabled: isCounting, children: buttonText })
679
+ ] })
680
+ ] })
681
+ }
682
+ );
659
683
  };
660
684
  }
661
685
  function createResetPasswordPage({
@@ -674,64 +698,72 @@ function createResetPasswordPage({
674
698
  () => resetPasswordAction({ formData: { passwordResetToken, ...formData } }),
675
699
  { onSuccess: () => router.push(PATHS.auth.signIn.path) }
676
700
  );
677
- return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
678
- /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.reset-password.text") }) }),
679
- /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
680
- /* @__PURE__ */ jsx(
681
- Field,
682
- {
683
- htmlFor: "newPassword",
684
- label: t("auth.reset-password.new-password.text"),
685
- children: /* @__PURE__ */ jsx(
686
- PasswordInput,
701
+ return /* @__PURE__ */ jsx(
702
+ Form,
703
+ {
704
+ className: "mx-auto w-96",
705
+ style: { marginTop: "56px" },
706
+ onSubmit: () => void execute(),
707
+ children: /* @__PURE__ */ jsxs(Card, { children: [
708
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.reset-password.text") }) }),
709
+ /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
710
+ /* @__PURE__ */ jsx(
711
+ Field,
687
712
  {
688
- id: "newPassword",
689
- placeholder: t(
690
- "auth.reset-password.new-password.placeholder.text"
691
- ),
692
- fieldName: "newPassword",
693
- value: formData.newPassword,
694
- setFormData,
695
- isDisabled: isRedirecting,
696
- isError: errors.includes("newPassword")
713
+ htmlFor: "newPassword",
714
+ label: t("auth.reset-password.new-password.text"),
715
+ children: /* @__PURE__ */ jsx(
716
+ PasswordInput,
717
+ {
718
+ id: "newPassword",
719
+ placeholder: t(
720
+ "auth.reset-password.new-password.placeholder.text"
721
+ ),
722
+ fieldName: "newPassword",
723
+ value: formData.newPassword,
724
+ setFormData,
725
+ isDisabled: isRedirecting,
726
+ isError: errors.includes("newPassword")
727
+ }
728
+ )
697
729
  }
698
- )
699
- }
700
- ),
701
- /* @__PURE__ */ jsx(
702
- Field,
703
- {
704
- htmlFor: "newPasswordConfirm",
705
- label: t("auth.reset-password.new-password-confirm.text"),
706
- children: /* @__PURE__ */ jsx(
707
- PasswordInput,
730
+ ),
731
+ /* @__PURE__ */ jsx(
732
+ Field,
708
733
  {
709
- id: "newPasswordConfirm",
710
- placeholder: t(
711
- `auth.reset-password.new-password-confirm.placeholder.text`
712
- ),
713
- fieldName: "newPasswordConfirm",
714
- value: formData.newPasswordConfirm,
715
- setFormData,
734
+ htmlFor: "newPasswordConfirm",
735
+ label: t("auth.reset-password.new-password-confirm.text"),
736
+ children: /* @__PURE__ */ jsx(
737
+ PasswordInput,
738
+ {
739
+ id: "newPasswordConfirm",
740
+ placeholder: t(
741
+ `auth.reset-password.new-password-confirm.placeholder.text`
742
+ ),
743
+ fieldName: "newPasswordConfirm",
744
+ value: formData.newPasswordConfirm,
745
+ setFormData,
746
+ isDisabled: isRedirecting,
747
+ isError: errors.includes("newPasswordConfirm")
748
+ }
749
+ )
750
+ }
751
+ ),
752
+ /* @__PURE__ */ jsx(
753
+ Button2,
754
+ {
755
+ size: "xs",
756
+ variant: "link",
757
+ className: "w-fit",
716
758
  isDisabled: isRedirecting,
717
- isError: errors.includes("newPasswordConfirm")
759
+ children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.signIn.path, children: t("auth.reset-password.anchor.text") })
718
760
  }
719
- )
720
- }
721
- ),
722
- /* @__PURE__ */ jsx(
723
- Button2,
724
- {
725
- size: "xs",
726
- variant: "link",
727
- className: "w-fit",
728
- isDisabled: isRedirecting,
729
- children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.signIn.path, children: t("auth.reset-password.anchor.text") })
730
- }
731
- ),
732
- /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.reset-password.button.text") })
733
- ] })
734
- ] }) });
761
+ ),
762
+ /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.reset-password.button.text") })
763
+ ] })
764
+ ] })
765
+ }
766
+ );
735
767
  };
736
768
  }
737
769
  function createChangePasswordPage({
@@ -756,86 +788,94 @@ function createChangePasswordPage({
756
788
  }),
757
789
  { onSuccess: () => router.push(PATHS.main.dashboard.path) }
758
790
  );
759
- return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
760
- /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.change-password.text") }) }),
761
- /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
762
- /* @__PURE__ */ jsx(
763
- Field,
764
- {
765
- htmlFor: "password",
766
- label: t("auth.change-password.password.text"),
767
- children: /* @__PURE__ */ jsx(
768
- PasswordInput,
791
+ return /* @__PURE__ */ jsx(
792
+ Form,
793
+ {
794
+ className: "mx-auto w-96",
795
+ style: { marginTop: "56px" },
796
+ onSubmit: () => void execute(),
797
+ children: /* @__PURE__ */ jsxs(Card, { children: [
798
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.change-password.text") }) }),
799
+ /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
800
+ /* @__PURE__ */ jsx(
801
+ Field,
769
802
  {
770
- id: "password",
771
- placeholder: t(
772
- "auth.change-password.password.placeholder.text"
773
- ),
774
- fieldName: "password",
775
- value: formData.password,
776
- setFormData,
777
- isDisabled: isRedirecting,
778
- isError: errors.includes("password")
803
+ htmlFor: "password",
804
+ label: t("auth.change-password.password.text"),
805
+ children: /* @__PURE__ */ jsx(
806
+ PasswordInput,
807
+ {
808
+ id: "password",
809
+ placeholder: t(
810
+ "auth.change-password.password.placeholder.text"
811
+ ),
812
+ fieldName: "password",
813
+ value: formData.password,
814
+ setFormData,
815
+ isDisabled: isRedirecting,
816
+ isError: errors.includes("password")
817
+ }
818
+ )
779
819
  }
780
- )
781
- }
782
- ),
783
- /* @__PURE__ */ jsx(
784
- Field,
785
- {
786
- htmlFor: "newPassword",
787
- label: t("auth.change-password.new-password.text"),
788
- children: /* @__PURE__ */ jsx(
789
- PasswordInput,
820
+ ),
821
+ /* @__PURE__ */ jsx(
822
+ Field,
790
823
  {
791
- id: "newPassword",
792
- placeholder: t(
793
- "auth.change-password.new-password.placeholder.text"
794
- ),
795
- fieldName: "newPassword",
796
- value: formData.newPassword,
797
- setFormData,
798
- isDisabled: isRedirecting,
799
- isError: errors.includes("newPassword")
824
+ htmlFor: "newPassword",
825
+ label: t("auth.change-password.new-password.text"),
826
+ children: /* @__PURE__ */ jsx(
827
+ PasswordInput,
828
+ {
829
+ id: "newPassword",
830
+ placeholder: t(
831
+ "auth.change-password.new-password.placeholder.text"
832
+ ),
833
+ fieldName: "newPassword",
834
+ value: formData.newPassword,
835
+ setFormData,
836
+ isDisabled: isRedirecting,
837
+ isError: errors.includes("newPassword")
838
+ }
839
+ )
800
840
  }
801
- )
802
- }
803
- ),
804
- /* @__PURE__ */ jsx(
805
- Field,
806
- {
807
- htmlFor: "newPasswordConfirm",
808
- label: t("auth.change-password.new-password-confirm.text"),
809
- children: /* @__PURE__ */ jsx(
810
- PasswordInput,
841
+ ),
842
+ /* @__PURE__ */ jsx(
843
+ Field,
811
844
  {
812
- id: "newPasswordConfirm",
813
- placeholder: t(
814
- "auth.change-password.new-password-confirm.placeholder.text"
815
- ),
816
- fieldName: "newPasswordConfirm",
817
- value: formData.newPasswordConfirm,
818
- setFormData,
845
+ htmlFor: "newPasswordConfirm",
846
+ label: t("auth.change-password.new-password-confirm.text"),
847
+ children: /* @__PURE__ */ jsx(
848
+ PasswordInput,
849
+ {
850
+ id: "newPasswordConfirm",
851
+ placeholder: t(
852
+ "auth.change-password.new-password-confirm.placeholder.text"
853
+ ),
854
+ fieldName: "newPasswordConfirm",
855
+ value: formData.newPasswordConfirm,
856
+ setFormData,
857
+ isDisabled: isRedirecting,
858
+ isError: errors.includes("newPasswordConfirm")
859
+ }
860
+ )
861
+ }
862
+ ),
863
+ /* @__PURE__ */ jsx(
864
+ Button2,
865
+ {
866
+ size: "xs",
867
+ variant: "link",
868
+ className: "w-fit",
819
869
  isDisabled: isRedirecting,
820
- isError: errors.includes("newPasswordConfirm")
870
+ children: /* @__PURE__ */ jsx(Link, { href: PATHS.main.dashboard.path, children: t("auth.change-password.anchor.text") })
821
871
  }
822
- )
823
- }
824
- ),
825
- /* @__PURE__ */ jsx(
826
- Button2,
827
- {
828
- size: "xs",
829
- variant: "link",
830
- className: "w-fit",
831
- isDisabled: isRedirecting,
832
- children: /* @__PURE__ */ jsx(Link, { href: PATHS.main.dashboard.path, children: t("auth.change-password.anchor.text") })
833
- }
834
- ),
835
- /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.change-password.button.text") }),
836
- " "
837
- ] })
838
- ] }) });
872
+ ),
873
+ /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.change-password.button.text") }),
874
+ " "
875
+ ] })
876
+ ] })
877
+ }
878
+ );
839
879
  };
840
880
  }
841
881
 
@@ -1,15 +1,16 @@
1
- import { S as StorageService } from './types-J25u1G6t.js';
2
1
  import { T as TocItem, i as AdminRole, y as SingleItem, B as BaseTranslation, e as Admin, g as AdminFull, j as AdminSafe, D as DeviceInfo, h as AdminRefreshToken, p as File, b as FileFull, r as FileType, a as Folder, F as FolderFull, M as MultiItems, m as ExternalLink, o as Faq, t as Post, w as PostType, u as PostListCard, v as PostTranslation, P as PostFull, l as Alternate, S as SuccessResult, R as Result } from './types-BGsFazJr.js';
2
+ import * as zod from 'zod';
3
+ import zod__default, { z, ZodType } from 'zod';
4
+ import * as zod_v4_core from 'zod/v4/core';
5
+ import { S as StorageService } from './types-J25u1G6t.js';
3
6
  import jwt from 'jsonwebtoken';
4
7
  import { BinaryLike } from 'node:crypto';
5
8
  import { cookies } from 'next/headers';
6
9
  import { PrismaClient } from '@prisma/client';
7
- import zod__default, { z, ZodType } from 'zod';
8
10
  import { Transporter, SentMessageInfo } from 'nodemailer';
9
11
  import { Logger } from 'logry';
10
12
  import { BaseTranslator, LocaleMessages } from 'intor';
11
13
  import Keyv from 'keyv';
12
- import * as zod_v4_core from 'zod/v4/core';
13
14
 
14
15
  interface CreateJwtServiceParams {
15
16
  defaultSecret: string;
@@ -855,4 +856,73 @@ interface ActionContext {
855
856
  };
856
857
  }
857
858
 
858
- export { type ActionContext as A, createSendEmail as B, createSeoMetadataCommandRepository as C, createUnique as D, createVerifyAccessToken as E, createVerifyRefreshToken as F, normalizeCacheKey as G, type RawCacheKey as R, createZod as a, createTocItemSchema as b, createSchemas as c, createAdminCommandRepository as d, createAdminQueryRepository as e, createAdminRefreshTokenCommandRepository as f, createAdminRefreshTokenQueryRepository as g, createArgon2Service as h, createAuthMiddleware as i, createAuthUseCases as j, createCacheResult as k, createCookieService as l, createCryptoService as m, createEmailVerificationEmail as n, createExecuteAction as o, createExist as p, createFileCommandRepository as q, createFileQueryRepository as r, createFolderCommandRepository as s, createFolderQueryRepository as t, createForgotPasswordEmail as u, createIpRateLimiter as v, createJwtService as w, createPostCommandRepository as x, createPostQueryRepository as y, createRenderEmailTemplate as z };
859
+ declare const signInValidator: (schemas: ReturnType<typeof createSchemas>) => zod__default.ZodObject<{
860
+ email: zod__default.ZodEmail;
861
+ password: zod__default.ZodString;
862
+ }, zod__default.core.$strip>;
863
+
864
+ type SignInFormData = zod__default.infer<ReturnType<typeof signInValidator>>;
865
+ declare function createSignInAction(ctx: ActionContext): ({ formData, deviceInfo, }: {
866
+ formData: SignInFormData;
867
+ deviceInfo: DeviceInfo;
868
+ }) => Promise<Result<{
869
+ admin: AdminFull;
870
+ }>>;
871
+
872
+ declare function createVerifyAction(ctx: ActionContext): () => Promise<Result<{
873
+ admin: AdminFull;
874
+ }>>;
875
+
876
+ declare const changePasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
877
+ password: zod.ZodString;
878
+ newPassword: zod.ZodString;
879
+ newPasswordConfirm: zod.ZodString;
880
+ }, zod_v4_core.$strip>;
881
+
882
+ type ChangePasswordFormData = zod__default.infer<ReturnType<typeof changePasswordValidator>>;
883
+ declare function createChangePasswordAction(ctx: ActionContext): ({ formData, }: {
884
+ formData: ChangePasswordFormData;
885
+ }) => Promise<Result<void>>;
886
+
887
+ declare const verifyEmailValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
888
+ email: zod.ZodEmail;
889
+ emailVerificationToken: zod.ZodString;
890
+ }, zod_v4_core.$strip>;
891
+
892
+ type VerifyEmailFormData = zod__default.infer<ReturnType<typeof verifyEmailValidator>>;
893
+ declare function createVerifyEmailAction(ctx: ActionContext): ({ formData, }: {
894
+ formData: VerifyEmailFormData;
895
+ }) => Promise<Result<{
896
+ admin: AdminSafe;
897
+ }>>;
898
+
899
+ declare const emailUnverifiedValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
900
+ email: zod.ZodEmail;
901
+ }, zod_v4_core.$strip>;
902
+
903
+ type EmailUnverifiedFormData = zod__default.infer<ReturnType<typeof emailUnverifiedValidator>>;
904
+ declare function createEmailUnverifiedAction(ctx: ActionContext): ({ formData, }: {
905
+ formData: EmailUnverifiedFormData;
906
+ }) => Promise<Result<void>>;
907
+
908
+ declare const forgetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
909
+ email: zod.ZodEmail;
910
+ }, zod_v4_core.$strip>;
911
+
912
+ type ForgotPasswordFormData = zod__default.infer<ReturnType<typeof forgetPasswordValidator>>;
913
+ declare function createForgotPasswordAction(ctx: ActionContext): ({ formData, }: {
914
+ formData: ForgotPasswordFormData;
915
+ }) => Promise<Result<void>>;
916
+
917
+ declare const resetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
918
+ passwordResetToken: zod.ZodString;
919
+ newPassword: zod.ZodString;
920
+ newPasswordConfirm: zod.ZodString;
921
+ }, zod_v4_core.$strip>;
922
+
923
+ type ResetPasswordFormData = zod__default.infer<ReturnType<typeof resetPasswordValidator>>;
924
+ declare function createResetPasswordAction(ctx: ActionContext): ({ formData, }: {
925
+ formData: ResetPasswordFormData;
926
+ }) => Promise<Result<void>>;
927
+
928
+ export { type ActionContext as A, createFolderQueryRepository as B, createForgotPasswordEmail as C, createIpRateLimiter as D, createJwtService as E, createPostCommandRepository as F, createPostQueryRepository as G, createRenderEmailTemplate as H, createSendEmail as I, createSeoMetadataCommandRepository as J, createUnique as K, createVerifyAccessToken as L, createVerifyRefreshToken as M, normalizeCacheKey as N, type RawCacheKey as R, createSignInAction as a, createVerifyEmailAction as b, createVerifyAction as c, createEmailUnverifiedAction as d, createForgotPasswordAction as e, createResetPasswordAction as f, createChangePasswordAction as g, createZod as h, createSchemas as i, createTocItemSchema as j, createAdminCommandRepository as k, createAdminQueryRepository as l, createAdminRefreshTokenCommandRepository as m, createAdminRefreshTokenQueryRepository as n, createArgon2Service as o, createAuthMiddleware as p, createAuthUseCases as q, createCacheResult as r, createCookieService as s, createCryptoService as t, createEmailVerificationEmail as u, createExecuteAction as v, createExist as w, createFileCommandRepository as x, createFileQueryRepository as y, createFolderCommandRepository as z };
@@ -1,5 +1,5 @@
1
- import { a as createZod, c as createSchemas, A as ActionContext, b as createTocItemSchema } from '../action-context-yvi5OrMJ.js';
2
- export { R as RawCacheKey, d as createAdminCommandRepository, e as createAdminQueryRepository, f as createAdminRefreshTokenCommandRepository, g as createAdminRefreshTokenQueryRepository, h as createArgon2Service, i as createAuthMiddleware, j as createAuthUseCases, k as createCacheResult, l as createCookieService, m as createCryptoService, n as createEmailVerificationEmail, o as createExecuteAction, p as createExist, q as createFileCommandRepository, r as createFileQueryRepository, s as createFolderCommandRepository, t as createFolderQueryRepository, u as createForgotPasswordEmail, v as createIpRateLimiter, w as createJwtService, x as createPostCommandRepository, y as createPostQueryRepository, z as createRenderEmailTemplate, B as createSendEmail, C as createSeoMetadataCommandRepository, D as createUnique, E as createVerifyAccessToken, F as createVerifyRefreshToken, G as normalizeCacheKey } from '../action-context-yvi5OrMJ.js';
1
+ import { h as createZod, A as ActionContext, i as createSchemas, j as createTocItemSchema } from '../create-reset-password-action-D6aTuuqO.js';
2
+ export { R as RawCacheKey, k as createAdminCommandRepository, l as createAdminQueryRepository, m as createAdminRefreshTokenCommandRepository, n as createAdminRefreshTokenQueryRepository, o as createArgon2Service, p as createAuthMiddleware, q as createAuthUseCases, r as createCacheResult, g as createChangePasswordAction, s as createCookieService, t as createCryptoService, d as createEmailUnverifiedAction, u as createEmailVerificationEmail, v as createExecuteAction, w as createExist, x as createFileCommandRepository, y as createFileQueryRepository, z as createFolderCommandRepository, B as createFolderQueryRepository, e as createForgotPasswordAction, C as createForgotPasswordEmail, D as createIpRateLimiter, E as createJwtService, F as createPostCommandRepository, G as createPostQueryRepository, H as createRenderEmailTemplate, f as createResetPasswordAction, I as createSendEmail, J as createSeoMetadataCommandRepository, a as createSignInAction, K as createUnique, L as createVerifyAccessToken, c as createVerifyAction, b as createVerifyEmailAction, M as createVerifyRefreshToken, N as normalizeCacheKey } from '../create-reset-password-action-D6aTuuqO.js';
3
3
  import Keyv from 'keyv';
4
4
  import * as zod from 'zod';
5
5
  import zod__default from 'zod';
@@ -80,6 +80,8 @@ interface CreateExecuteApiParams {
80
80
  }
81
81
  declare function createExecuteApi({ initI18n, logger }: CreateExecuteApiParams): (fn: Api) => Promise<NextResponse<unknown>>;
82
82
 
83
+ declare function createSignOutAction(ctx: ActionContext): () => Promise<Result<void>>;
84
+
83
85
  declare const adminCreateValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
84
86
  role: zod.ZodEnum<{
85
87
  SUPER_ADMIN: "SUPER_ADMIN";
@@ -1541,4 +1543,4 @@ declare class ServerError extends Error {
1541
1543
  static internalServerError(): ServerError;
1542
1544
  }
1543
1545
 
1544
- export { ADMIN_ORDER_BY, ActionContext, type AdminCreateFormData, type AdminUpdateFormData, type FileCreateFormData, type FileCreateManyFormData, type FileUpdateFormData, type FolderCreateFormData, type FolderUpdateFormData, ORDER_BY, POST_ORDER_BY, type PostCreateFormData, type PostUpdateFormData, type SeoMetadataUpsertFormData, ServerError, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminUpdateAction, createCache, createExecuteApi, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderUpdateAction, createMultiFileSchema, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostUpdateAction, createSchemas, createSeoMetadataUpsertAction, createTocItemSchema, createTransporter, createZod };
1546
+ export { ADMIN_ORDER_BY, ActionContext, type AdminCreateFormData, type AdminUpdateFormData, type FileCreateFormData, type FileCreateManyFormData, type FileUpdateFormData, type FolderCreateFormData, type FolderUpdateFormData, ORDER_BY, POST_ORDER_BY, type PostCreateFormData, type PostUpdateFormData, type SeoMetadataUpsertFormData, ServerError, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminUpdateAction, createCache, createExecuteApi, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderUpdateAction, createMultiFileSchema, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostUpdateAction, createSchemas, createSeoMetadataUpsertAction, createSignOutAction, createTocItemSchema, createTransporter, createZod };
@@ -2095,6 +2095,313 @@ function createVerifyRefreshToken({
2095
2095
  };
2096
2096
  }
2097
2097
 
2098
+ // src/server/interfaces/actions/auth/sign-in/sign-in-validator.ts
2099
+ var signInValidator = (schemas) => schemas.z.object({
2100
+ email: schemas.email(),
2101
+ password: schemas.password()
2102
+ });
2103
+
2104
+ // src/server/interfaces/actions/auth/sign-in/create-sign-in-action.ts
2105
+ function createSignInAction(ctx) {
2106
+ return async function signInAction({
2107
+ formData,
2108
+ deviceInfo
2109
+ }) {
2110
+ const {
2111
+ repositories: {
2112
+ adminQueryRepository,
2113
+ adminRefreshTokenCommandRepository
2114
+ },
2115
+ useCases: { authUseCases },
2116
+ action: { executeAction, ipRateLimiter },
2117
+ http: { headers },
2118
+ schemas: { schemas }
2119
+ } = ctx;
2120
+ return executeAction(
2121
+ async () => {
2122
+ await ipRateLimiter({ key: ["sign-in"] });
2123
+ const { email, password } = await signInValidator(schemas).parseAsync(formData);
2124
+ const verified = await authUseCases.verifyCredentials({
2125
+ email,
2126
+ password
2127
+ });
2128
+ const admin = await adminQueryRepository.findFull({
2129
+ id: verified.id
2130
+ });
2131
+ if (!admin) throw ServerError.notFound();
2132
+ await authUseCases.refreshTokens({
2133
+ admin,
2134
+ deviceInfo,
2135
+ ip: (await headers()).get("x-forwarded-for") || "unknown"
2136
+ });
2137
+ await adminRefreshTokenCommandRepository.deleteManyByExpired();
2138
+ return {
2139
+ i18nKey: "ok.sign-in-ok",
2140
+ data: { admin }
2141
+ };
2142
+ },
2143
+ { type: "command" }
2144
+ );
2145
+ };
2146
+ }
2147
+
2148
+ // src/server/interfaces/actions/auth/sign-out/create-sign-out-action.ts
2149
+ function createSignOutAction(ctx) {
2150
+ const {
2151
+ services: { cryptoService, cookieService },
2152
+ repositories: { adminRefreshTokenCommandRepository },
2153
+ action: { executeAction },
2154
+ config: { accessTokenName, refreshTokenName }
2155
+ } = ctx;
2156
+ return async function signOutAction() {
2157
+ return executeAction(
2158
+ async () => {
2159
+ let token;
2160
+ try {
2161
+ token = await cookieService.getSignedCookie({
2162
+ name: refreshTokenName
2163
+ });
2164
+ } catch {
2165
+ }
2166
+ if (token) {
2167
+ await adminRefreshTokenCommandRepository.delete({
2168
+ tokenHash: cryptoService.hash(token)
2169
+ });
2170
+ }
2171
+ await cookieService.delete({ name: accessTokenName });
2172
+ await cookieService.delete({ name: refreshTokenName });
2173
+ return {
2174
+ i18nKey: "ok.sign-out-ok"
2175
+ };
2176
+ },
2177
+ { type: "command" }
2178
+ );
2179
+ };
2180
+ }
2181
+
2182
+ // src/server/interfaces/actions/auth/verify/create-verify-action.ts
2183
+ function createVerifyAction(ctx) {
2184
+ const {
2185
+ middlewares: { authMiddleware },
2186
+ action: { executeAction, ipRateLimiter }
2187
+ } = ctx;
2188
+ return async function verifyAction() {
2189
+ return executeAction(async () => {
2190
+ await ipRateLimiter({ key: ["verify"], maxAttempts: 60 });
2191
+ const admin = await authMiddleware.authenticate();
2192
+ return {
2193
+ data: { admin }
2194
+ };
2195
+ });
2196
+ };
2197
+ }
2198
+
2199
+ // src/server/interfaces/actions/auth/change-password/change-password-validator.ts
2200
+ var changePasswordValidator = (schemas) => schemas.z.object({
2201
+ password: schemas.password(),
2202
+ newPassword: schemas.password(),
2203
+ newPasswordConfirm: schemas.password()
2204
+ }).superRefine((data, ctx) => {
2205
+ if (data.newPassword !== data.newPasswordConfirm) {
2206
+ ctx.addIssue({
2207
+ code: "custom",
2208
+ params: { i18nKey: "validator.password-confirm" },
2209
+ path: ["newPassword"]
2210
+ });
2211
+ ctx.addIssue({
2212
+ code: "custom",
2213
+ params: { i18nKey: "validator.password-confirm" },
2214
+ path: ["newPasswordConfirm"]
2215
+ });
2216
+ }
2217
+ });
2218
+
2219
+ // src/server/interfaces/actions/auth/change-password/create-change-password-action.ts
2220
+ function createChangePasswordAction(ctx) {
2221
+ return async function changePasswordAction({
2222
+ formData
2223
+ }) {
2224
+ const {
2225
+ action: { executeAction, ipRateLimiter },
2226
+ useCases: { authUseCases },
2227
+ middlewares: { authMiddleware },
2228
+ schemas: { schemas }
2229
+ } = ctx;
2230
+ return executeAction(
2231
+ async () => {
2232
+ await ipRateLimiter({ key: ["change-password"] });
2233
+ const { email } = await authMiddleware.authenticate();
2234
+ const { password, newPassword } = await changePasswordValidator(schemas).parseAsync(formData);
2235
+ await authUseCases.verifyCredentials({ email, password });
2236
+ await authUseCases.updatePassword({ email, password: newPassword });
2237
+ return {
2238
+ i18nKey: "ok.change-password-ok"
2239
+ };
2240
+ },
2241
+ { type: "command" }
2242
+ );
2243
+ };
2244
+ }
2245
+
2246
+ // src/server/interfaces/actions/auth/verify-email/verify-email-validator.ts
2247
+ var verifyEmailValidator = (schemas) => schemas.z.object({
2248
+ email: schemas.email(),
2249
+ emailVerificationToken: schemas.z.string().trim().max(1e3)
2250
+ });
2251
+
2252
+ // src/server/interfaces/actions/auth/verify-email/create-verify-email-action.ts
2253
+ function createVerifyEmailAction(ctx) {
2254
+ return async function verifyEmailAction({
2255
+ formData
2256
+ }) {
2257
+ const {
2258
+ repositories: { adminQueryRepository },
2259
+ useCases: { authUseCases },
2260
+ action: { executeAction, ipRateLimiter },
2261
+ schemas: { schemas }
2262
+ } = ctx;
2263
+ return executeAction(
2264
+ async () => {
2265
+ await ipRateLimiter({ key: ["verify-email"] });
2266
+ const { email, emailVerificationToken } = await verifyEmailValidator(schemas).parseAsync(formData);
2267
+ const admin = await adminQueryRepository.find({ email });
2268
+ if (!admin) throw new ServerError({ i18nKey: "error.email-not-found" });
2269
+ await authUseCases.verifyEmailAndUpdate({
2270
+ token: emailVerificationToken || "",
2271
+ admin
2272
+ });
2273
+ return {
2274
+ i18nKey: "ok.verify-email-ok",
2275
+ data: { admin }
2276
+ };
2277
+ },
2278
+ { type: "command" }
2279
+ );
2280
+ };
2281
+ }
2282
+
2283
+ // src/server/interfaces/actions/auth/email-unverifired/email-unverifired-validator.ts
2284
+ var emailUnverifiedValidator = (schemas) => schemas.z.object({
2285
+ email: schemas.email()
2286
+ });
2287
+
2288
+ // src/server/interfaces/actions/auth/email-unverifired/create-email-unverifired-action.ts
2289
+ function createEmailUnverifiedAction(ctx) {
2290
+ return async function emailUnverifiedAction({
2291
+ formData
2292
+ }) {
2293
+ const {
2294
+ repositories: { adminQueryRepository },
2295
+ action: { executeAction, ipRateLimiter },
2296
+ emails: { emailVerificationEmail },
2297
+ schemas: { schemas }
2298
+ } = ctx;
2299
+ return executeAction(
2300
+ async (translator) => {
2301
+ await ipRateLimiter({
2302
+ key: ["email-unverified"],
2303
+ maxAttempts: 2,
2304
+ timeWindow: 60
2305
+ });
2306
+ const { email } = await emailUnverifiedValidator(schemas).parseAsync(formData);
2307
+ const admin = await adminQueryRepository.find({ email });
2308
+ if (!admin) throw new ServerError({ i18nKey: "error.email-not-found" });
2309
+ void emailVerificationEmail.send({ translator, admin });
2310
+ return {
2311
+ i18nKey: "ok.email-unverified-ok"
2312
+ };
2313
+ },
2314
+ { type: "command" }
2315
+ );
2316
+ };
2317
+ }
2318
+
2319
+ // src/server/interfaces/actions/auth/forgot-password/forgot-password-validator.ts
2320
+ var forgetPasswordValidator = (schemas) => schemas.z.object({
2321
+ email: schemas.email()
2322
+ });
2323
+
2324
+ // src/server/interfaces/actions/auth/forgot-password/create-forgot-password-action.ts
2325
+ function createForgotPasswordAction(ctx) {
2326
+ return async function forgotPasswordAction({
2327
+ formData
2328
+ }) {
2329
+ const {
2330
+ repositories: { adminQueryRepository },
2331
+ action: { executeAction, ipRateLimiter },
2332
+ emails: { forgotPasswordEmail },
2333
+ schemas: { schemas }
2334
+ } = ctx;
2335
+ return executeAction(
2336
+ async (translator) => {
2337
+ await ipRateLimiter({
2338
+ key: ["forget-password"],
2339
+ maxAttempts: 2,
2340
+ timeWindow: 60
2341
+ });
2342
+ const { email } = await forgetPasswordValidator(schemas).parseAsync(formData);
2343
+ const admin = await adminQueryRepository.find({ email });
2344
+ if (!admin) throw new ServerError({ i18nKey: "error.email-not-found" });
2345
+ void forgotPasswordEmail.send({ translator, admin });
2346
+ return {
2347
+ i18nKey: "ok.forgot-password-ok"
2348
+ };
2349
+ },
2350
+ { type: "command" }
2351
+ );
2352
+ };
2353
+ }
2354
+
2355
+ // src/server/interfaces/actions/auth/reset-password/reset-password-validator.ts
2356
+ var resetPasswordValidator = (schemas) => schemas.z.object({
2357
+ passwordResetToken: schemas.z.string().trim().max(1e3),
2358
+ newPassword: schemas.password(),
2359
+ newPasswordConfirm: schemas.password()
2360
+ }).superRefine((data, ctx) => {
2361
+ if (data.newPassword !== data.newPasswordConfirm) {
2362
+ ctx.addIssue({
2363
+ code: "custom",
2364
+ message: "custom.password-confirm",
2365
+ path: ["newPassword"]
2366
+ });
2367
+ ctx.addIssue({
2368
+ code: "custom",
2369
+ message: "custom.password-confirm",
2370
+ path: ["newPasswordConfirm"]
2371
+ });
2372
+ }
2373
+ });
2374
+
2375
+ // src/server/interfaces/actions/auth/reset-password/create-reset-password-action.ts
2376
+ function createResetPasswordAction(ctx) {
2377
+ return async function ResetPasswordAction({
2378
+ formData
2379
+ }) {
2380
+ const {
2381
+ useCases: { authUseCases },
2382
+ action: { executeAction, ipRateLimiter },
2383
+ schemas: { schemas }
2384
+ } = ctx;
2385
+ return executeAction(
2386
+ async () => {
2387
+ await ipRateLimiter({ key: ["reset-password"] });
2388
+ const { newPassword, passwordResetToken } = await resetPasswordValidator(schemas).parseAsync(formData);
2389
+ const decoded = authUseCases.verifyPasswordResetToken({
2390
+ token: passwordResetToken
2391
+ });
2392
+ await authUseCases.updatePassword({
2393
+ email: decoded.email,
2394
+ password: newPassword
2395
+ });
2396
+ return {
2397
+ i18nKey: "ok.reset-password-ok"
2398
+ };
2399
+ },
2400
+ { type: "command" }
2401
+ );
2402
+ };
2403
+ }
2404
+
2098
2405
  // src/server/interfaces/actions/resources/admin/commands/create/admin-create-validator.ts
2099
2406
  var adminCreateValidator = (schemas) => schemas.z.object({
2100
2407
  // core
@@ -4041,4 +4348,4 @@ function createForgotPasswordEmail({
4041
4348
  };
4042
4349
  }
4043
4350
 
4044
- export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, ServerError, createAdminCommandRepository, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminRefreshTokenQueryRepository, createAdminUpdateAction, createArgon2Service, createAuthMiddleware, createAuthUseCases, createCache, createCacheResult, createCookieService, createCryptoService, createEmailVerificationEmail, createExecuteAction, createExecuteApi, createExist, createFileCommandRepository, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileQueryRepository, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCommandRepository, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderQueryRepository, createFolderUpdateAction, createForgotPasswordEmail, createIpRateLimiter, createJwtService, createMultiFileSchema, createPostCommandRepository, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostQueryRepository, createPostUpdateAction, createRenderEmailTemplate, createSchemas, createSendEmail, createSeoMetadataCommandRepository, createSeoMetadataUpsertAction, createTocItemSchema, createTransporter, createUnique, createVerifyAccessToken, createVerifyRefreshToken, createZod, normalizeCacheKey };
4351
+ export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, ServerError, createAdminCommandRepository, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminRefreshTokenQueryRepository, createAdminUpdateAction, createArgon2Service, createAuthMiddleware, createAuthUseCases, createCache, createCacheResult, createChangePasswordAction, createCookieService, createCryptoService, createEmailUnverifiedAction, createEmailVerificationEmail, createExecuteAction, createExecuteApi, createExist, createFileCommandRepository, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileQueryRepository, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCommandRepository, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderQueryRepository, createFolderUpdateAction, createForgotPasswordAction, createForgotPasswordEmail, createIpRateLimiter, createJwtService, createMultiFileSchema, createPostCommandRepository, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostQueryRepository, createPostUpdateAction, createRenderEmailTemplate, createResetPasswordAction, createSchemas, createSendEmail, createSeoMetadataCommandRepository, createSeoMetadataUpsertAction, createSignInAction, createSignOutAction, createTocItemSchema, createTransporter, createUnique, createVerifyAccessToken, createVerifyAction, createVerifyEmailAction, createVerifyRefreshToken, createZod, normalizeCacheKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.90",
3
+ "version": "0.0.93",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",