@baseplate-dev/plugin-auth 0.6.12 → 0.6.13
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/CHANGELOG.md +24 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +14 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +14 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +7 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +7 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.d.ts +14 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +14 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +7 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +14 -0
- package/dist/better-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +7 -0
- package/dist/better-auth/constants/packages.d.ts +1 -1
- package/dist/better-auth/constants/packages.js +1 -1
- package/dist/better-auth/generators/fastify/better-auth-admin-module/better-auth-admin-module.generator.d.ts +1 -0
- package/dist/better-auth/generators/fastify/better-auth-admin-module/generated/index.d.ts +2 -0
- package/dist/better-auth/generators/fastify/better-auth-admin-module/generated/template-renderers.d.ts +1 -0
- package/dist/better-auth/generators/fastify/better-auth-admin-module/generated/typed-templates.d.ts +1 -0
- package/dist/better-auth/generators/fastify/better-auth-email-templates/better-auth-email-templates.generator.d.ts +1 -0
- package/dist/better-auth/generators/fastify/better-auth-email-templates/generated/index.d.ts +4 -0
- package/dist/better-auth/generators/fastify/better-auth-email-templates/generated/template-renderers.d.ts +1 -0
- package/dist/better-auth/generators/fastify/better-auth-email-templates/generated/typed-templates.d.ts +3 -0
- package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.d.ts +43 -6
- package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.js +21 -2
- package/dist/better-auth/generators/fastify/better-auth-module/generated/index.d.ts +46 -10
- package/dist/better-auth/generators/fastify/better-auth-module/generated/template-renderers.d.ts +18 -2
- package/dist/better-auth/generators/fastify/better-auth-module/generated/template-renderers.js +6 -2
- package/dist/better-auth/generators/fastify/better-auth-module/generated/ts-import-providers.d.ts +24 -6
- package/dist/better-auth/generators/fastify/better-auth-module/generated/ts-import-providers.js +8 -5
- package/dist/better-auth/generators/fastify/better-auth-module/generated/typed-templates.d.ts +20 -4
- package/dist/better-auth/generators/fastify/better-auth-module/generated/typed-templates.js +10 -5
- package/dist/better-auth/generators/fastify/better-auth-module/templates/module/plugins/better-auth.plugin.ts +7 -4
- package/dist/better-auth/generators/fastify/better-auth-module/templates/module/services/auth.ts +76 -59
- package/dist/better-auth/generators/fastify/better-auth-module/templates/module/services/user-session.service.ts +58 -46
- package/dist/better-auth/generators/react/better-auth-pages/better-auth-pages.generator.d.ts +7 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/index.d.ts +42 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-renderers.d.ts +7 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/typed-templates.d.ts +70 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/index.d.ts +14 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/template-renderers.d.ts +7 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/typed-templates.d.ts +7 -0
- package/dist/better-auth/generators/react/react-better-auth/react-better-auth.generator.d.ts +7 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +14 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +14 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +7 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +7 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.d.ts +14 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +14 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +7 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +14 -0
- package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +7 -0
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.d.ts +7 -23
- package/dist/local-auth/core/generators/auth-email-password/generated/index.d.ts +28 -66
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.d.ts +7 -23
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.js +2 -8
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.d.ts +35 -66
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.js +1 -5
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.d.ts +2 -2
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.js +2 -2
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.ts +8 -4
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.d.ts +3 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.js +4 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.ts +9 -6
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.js +2 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.ts +5 -3
- package/dist/local-auth/core/generators/auth-email-templates/auth-email-templates.generator.d.ts +1 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/index.d.ts +4 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/template-renderers.d.ts +1 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/typed-templates.d.ts +3 -0
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.d.ts +62 -8
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.js +21 -11
- package/dist/local-auth/core/generators/auth-module/generated/index.d.ts +152 -10
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.d.ts +1 -0
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.js +1 -0
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.d.ts +52 -2
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.js +14 -4
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.d.ts +9 -3
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.js +6 -3
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.d.ts +102 -8
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.js +19 -5
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.queue.d.ts +0 -4
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.queue.js +2 -15
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.queue.ts +2 -16
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.worker.d.ts +6 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.worker.js +18 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/queues/cleanup-auth-verification.worker.ts +22 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/schema/user-session.mutations.js +1 -2
- package/dist/local-auth/core/generators/auth-module/templates/module/schema/user-session.mutations.ts +4 -2
- package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.d.ts +0 -1
- package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.js +0 -1
- package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.ts +0 -2
- package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.d.ts +9 -0
- package/dist/local-auth/core/generators/auth-routes/generated/index.d.ts +52 -0
- package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.d.ts +9 -0
- package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.d.ts +77 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.tsx +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.js +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.tsx +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/reset-password.js +2 -2
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/reset-password.tsx +2 -2
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/verify-email.js +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/verify-email.tsx +1 -1
- package/dist/local-auth/core/generators/react-session/generated/index.d.ts +14 -0
- package/dist/local-auth/core/generators/react-session/generated/template-renderers.d.ts +7 -0
- package/dist/local-auth/core/generators/react-session/generated/typed-templates.d.ts +14 -0
- package/dist/local-auth/core/generators/react-session/react-session.generator.d.ts +7 -0
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/index.d.ts +2 -2
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/ts-import-providers.d.ts +10 -2
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/ts-import-providers.js +8 -5
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/typed-templates.js +1 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/index.d.ts +3 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/index.js +2 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/{auth-module.generator.d.ts → placeholder-auth-module.generator.d.ts} +20 -3
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/{auth-module.generator.js → placeholder-auth-module.generator.js} +16 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/templates/module/services/user-session.service.d.ts +5 -21
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/templates/module/services/user-session.service.js +17 -26
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/templates/module/services/user-session.service.ts +21 -31
- package/dist/web/assets/{_virtual_mf-localSharedImportMap___mfe_internal__plugin_mf_2_auth-Bd_uRhIr.js → _virtual_mf-localSharedImportMap___mfe_internal__plugin_mf_2_auth-DxRuC5lD.js} +89 -73
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib__loadShare__.js-BX1_Ngjt.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib__loadShare__.js-Dbjihoi-.js} +50 -13
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib_mf_1_web__loadShare__.js-CQuBII8a.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib_mf_1_web__loadShare__.js-CpEOtTmq.js} +50 -14
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_ui_mf_2_components__loadShare__.js-DsLoA9K7.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_ui_mf_2_components__loadShare__.js-BTSgZGcl.js} +6932 -6106
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_tanstack_mf_1_react_mf_2_router__loadShare__.js-CGsbw2Lx.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_tanstack_mf_1_react_mf_2_router__loadShare__.js-CJ027_El.js} +72 -151
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare__zod__loadShare__.js-DE4UUe5K.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare__zod__loadShare__.js-Do-7VDVw.js} +30 -247
- package/dist/web/assets/auth-gRzmaSZc.js +1 -0
- package/dist/web/assets/{common-ooa00sM_.js → common-B4cD6OfF.js} +6 -6
- package/dist/web/assets/{common-C0Hur22D.js → common-B9LNVIXT.js} +4 -4
- package/dist/web/assets/{common-BFKR_7HQ.js → common-B9sZoKR5.js} +6 -6
- package/dist/web/assets/{common-B8Z1_D6-.js → common-DF9FD3lJ.js} +4 -4
- package/dist/web/assets/{common-CLtpg163.js → common-S36tY-P3.js} +3 -3
- package/dist/web/assets/{common-CTYcv1u_.js → common-sMUs9FmV.js} +3 -3
- package/dist/web/assets/{dist-DicVrB_Z.js → dist-CtqdAorB.js} +374 -254
- package/dist/web/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-CtbvyMZJ.js → dist-SBfmsOB2.js} +43 -359
- package/dist/web/assets/{get-auth-plugin-definition-DBdchbBZ.js → get-auth-plugin-definition-Bs9C6JrS.js} +2 -2
- package/dist/web/assets/hostInit-BtfjN9sB.js +99 -0
- package/dist/web/assets/{index-CR54yoeW.js → index-DVCa_MuH.js} +2 -2
- package/dist/web/assets/{mf-entry-bootstrap-0-4f84e81c.js → mf-entry-bootstrap-0-31a63adb.js} +5 -2
- package/dist/web/assets/{model-utils-CQpTF3uf.js → model-utils-BDM6ILfO.js} +42 -14
- package/dist/web/assets/{models-Bc3L4Vsl.js → models-1c2urnle.js} +3 -3
- package/dist/web/assets/{models-BIKzGkW3.js → models-DGhhwO8Q.js} +3 -3
- package/dist/web/assets/{plugin-definition-BhNnSvrD.js → plugin-definition-B-HRncfN.js} +3 -3
- package/dist/web/assets/{plugin-definition-33i4r91s.js → plugin-definition-Dluw2inU.js} +3 -3
- package/dist/web/assets/{styles-BT_OTXuv.js → styles-BTmSBHAy.js} +15 -12
- package/dist/web/assets/{virtualExposes-B_hX31Ln.js → virtualExposes-C1o-SyCQ.js} +1 -1
- package/dist/web/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-Bs76by83.js +259 -0
- package/dist/web/assets/{virtual_mf-exposes-ssr___mfe_internal__plugin-auth__remoteEntry_js-BVNjo6R7.js → virtual_mf-exposes-ssr___mfe_internal__plugin-auth__remoteEntry_js-B5SkIaaz.js} +13 -13
- package/dist/web/assets/{virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-B_7IVc8D.js → virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-DotA2McS.js} +50 -15
- package/dist/web/assets/{web-CJlCNegu.js → web-B2REeIGU.js} +3 -3
- package/dist/web/assets/{web-aKoJoBnQ.js → web-BEOhczx1.js} +16 -16
- package/dist/web/assets/{web-Dso6eI9u.js → web-Bh_3N1sv.js} +17 -17
- package/dist/web/assets/{web-BXB-pvWJ.js → web-CiuxQhgn.js} +20 -20
- package/dist/web/assets/{web-DYbNyLPi.js → web-DGv5-Arz.js} +35 -35
- package/dist/web/assets/{web-BDeHApaZ.js → web-jcCkQISW.js} +31 -18
- package/dist/web/assets/{web-BC9MejP0.js → web-wBaHshVG.js} +3 -3
- package/dist/web/index.html +2 -2
- package/dist/web/remoteEntry.js +1 -1
- package/dist/web/remoteEntry.ssr.js +1 -1
- package/package.json +26 -26
- package/dist/web/assets/auth-DS8ZnZZr.js +0 -1
- package/dist/web/assets/hostInit-CDVLjNbq.js +0 -119
package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.d.ts
CHANGED
|
@@ -18,7 +18,10 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_RENDERERS: {
|
|
|
18
18
|
localAuthCoreAuthEmailPasswordRenderers: import("@baseplate-dev/sync").ProviderExport<LocalAuthCoreAuthEmailPasswordRenderers>;
|
|
19
19
|
}, {
|
|
20
20
|
authModuleImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
21
|
+
cleanupAuthVerificationQueue: {};
|
|
22
|
+
cleanupAuthVerificationWorker: {};
|
|
21
23
|
cleanupExpiredAuthVerifications: {};
|
|
24
|
+
CookieUserSessionService: {};
|
|
22
25
|
createAuthVerification: {};
|
|
23
26
|
userSessionPayload: {};
|
|
24
27
|
validateAuthVerification: {};
|
|
@@ -26,26 +29,6 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_RENDERERS: {
|
|
|
26
29
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
27
30
|
config: {};
|
|
28
31
|
}>>;
|
|
29
|
-
emailModuleImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
30
|
-
EmailAdapter: {
|
|
31
|
-
isTypeOnly: true;
|
|
32
|
-
};
|
|
33
|
-
EmailAttachment: {
|
|
34
|
-
isTypeOnly: true;
|
|
35
|
-
};
|
|
36
|
-
EmailRawOptions: {
|
|
37
|
-
isTypeOnly: true;
|
|
38
|
-
};
|
|
39
|
-
EmailSendOptions: {
|
|
40
|
-
isTypeOnly: true;
|
|
41
|
-
};
|
|
42
|
-
sendEmail: {};
|
|
43
|
-
sendEmailQueue: {};
|
|
44
|
-
sendRawEmail: {};
|
|
45
|
-
TransformedEmailMessage: {
|
|
46
|
-
isTypeOnly: true;
|
|
47
|
-
};
|
|
48
|
-
}>>;
|
|
49
32
|
errorHandlerServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
50
33
|
BadRequestError: {};
|
|
51
34
|
ForbiddenError: {};
|
|
@@ -54,6 +37,7 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_RENDERERS: {
|
|
|
54
37
|
InternalServerError: {};
|
|
55
38
|
logError: {};
|
|
56
39
|
NotFoundError: {};
|
|
40
|
+
throwIfPrismaNotFound: {};
|
|
57
41
|
TooManyRequestsError: {};
|
|
58
42
|
UnauthorizedError: {};
|
|
59
43
|
}>>;
|
|
@@ -92,11 +76,11 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_RENDERERS: {
|
|
|
92
76
|
RequestServiceContext: {
|
|
93
77
|
isTypeOnly: true;
|
|
94
78
|
};
|
|
79
|
+
RequestServiceContextWith: {
|
|
80
|
+
isTypeOnly: true;
|
|
81
|
+
};
|
|
95
82
|
}>>;
|
|
96
83
|
typescriptFile: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").TypescriptFileProvider>;
|
|
97
|
-
userSessionServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
98
|
-
userSessionService: {};
|
|
99
|
-
}>>;
|
|
100
84
|
userSessionTypesImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
101
85
|
UserSessionPayload: {
|
|
102
86
|
isTypeOnly: true;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { typescriptFileProvider } from '@baseplate-dev/core-generators';
|
|
2
|
-
import { configServiceImportsProvider, errorHandlerServiceImportsProvider, passwordHasherServiceImportsProvider, pothosImportsProvider, prismaGeneratedImportsProvider, prismaImportsProvider, requestServiceContextImportsProvider,
|
|
3
|
-
import { emailModuleImportsProvider } from '@baseplate-dev/plugin-email';
|
|
2
|
+
import { configServiceImportsProvider, errorHandlerServiceImportsProvider, passwordHasherServiceImportsProvider, pothosImportsProvider, prismaGeneratedImportsProvider, prismaImportsProvider, requestServiceContextImportsProvider, userSessionTypesImportsProvider, } from '@baseplate-dev/fastify-generators';
|
|
4
3
|
import { rateLimitImportsProvider } from '@baseplate-dev/plugin-rate-limit';
|
|
5
4
|
import { createGeneratorTask, createProviderType } from '@baseplate-dev/sync';
|
|
6
5
|
import { authModuleImportsProvider } from '#src/local-auth/core/generators/auth-module/generated/ts-import-providers.js';
|
|
@@ -11,7 +10,6 @@ const localAuthCoreAuthEmailPasswordRenderersTask = createGeneratorTask({
|
|
|
11
10
|
dependencies: {
|
|
12
11
|
authModuleImports: authModuleImportsProvider,
|
|
13
12
|
configServiceImports: configServiceImportsProvider,
|
|
14
|
-
emailModuleImports: emailModuleImportsProvider,
|
|
15
13
|
errorHandlerServiceImports: errorHandlerServiceImportsProvider,
|
|
16
14
|
passwordHasherServiceImports: passwordHasherServiceImportsProvider,
|
|
17
15
|
paths: LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_PATHS.provider,
|
|
@@ -21,13 +19,12 @@ const localAuthCoreAuthEmailPasswordRenderersTask = createGeneratorTask({
|
|
|
21
19
|
rateLimitImports: rateLimitImportsProvider,
|
|
22
20
|
requestServiceContextImports: requestServiceContextImportsProvider,
|
|
23
21
|
typescriptFile: typescriptFileProvider,
|
|
24
|
-
userSessionServiceImports: userSessionServiceImportsProvider,
|
|
25
22
|
userSessionTypesImports: userSessionTypesImportsProvider,
|
|
26
23
|
},
|
|
27
24
|
exports: {
|
|
28
25
|
localAuthCoreAuthEmailPasswordRenderers: localAuthCoreAuthEmailPasswordRenderers.export(),
|
|
29
26
|
},
|
|
30
|
-
run({ authModuleImports, configServiceImports,
|
|
27
|
+
run({ authModuleImports, configServiceImports, errorHandlerServiceImports, passwordHasherServiceImports, paths, pothosImports, prismaGeneratedImports, prismaImports, rateLimitImports, requestServiceContextImports, typescriptFile, userSessionTypesImports, }) {
|
|
31
28
|
return {
|
|
32
29
|
providers: {
|
|
33
30
|
localAuthCoreAuthEmailPasswordRenderers: {
|
|
@@ -38,7 +35,6 @@ const localAuthCoreAuthEmailPasswordRenderersTask = createGeneratorTask({
|
|
|
38
35
|
importMapProviders: {
|
|
39
36
|
authModuleImports,
|
|
40
37
|
configServiceImports,
|
|
41
|
-
emailModuleImports,
|
|
42
38
|
errorHandlerServiceImports,
|
|
43
39
|
passwordHasherServiceImports,
|
|
44
40
|
pothosImports,
|
|
@@ -46,7 +42,6 @@ const localAuthCoreAuthEmailPasswordRenderersTask = createGeneratorTask({
|
|
|
46
42
|
prismaImports,
|
|
47
43
|
rateLimitImports,
|
|
48
44
|
requestServiceContextImports,
|
|
49
|
-
userSessionServiceImports,
|
|
50
45
|
userSessionTypesImports,
|
|
51
46
|
},
|
|
52
47
|
generatorPaths: paths,
|
|
@@ -71,7 +66,6 @@ const localAuthCoreAuthEmailPasswordRenderersTask = createGeneratorTask({
|
|
|
71
66
|
importMapProviders: {
|
|
72
67
|
authModuleImports,
|
|
73
68
|
configServiceImports,
|
|
74
|
-
emailModuleImports,
|
|
75
69
|
errorHandlerServiceImports,
|
|
76
70
|
prismaImports,
|
|
77
71
|
rateLimitImports,
|
|
@@ -12,7 +12,10 @@ export declare const moduleGroup: {
|
|
|
12
12
|
TPL_USER_OBJECT_TYPE: {};
|
|
13
13
|
}, {
|
|
14
14
|
authModuleImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
15
|
+
cleanupAuthVerificationQueue: {};
|
|
16
|
+
cleanupAuthVerificationWorker: {};
|
|
15
17
|
cleanupExpiredAuthVerifications: {};
|
|
18
|
+
CookieUserSessionService: {};
|
|
16
19
|
createAuthVerification: {};
|
|
17
20
|
userSessionPayload: {};
|
|
18
21
|
validateAuthVerification: {};
|
|
@@ -28,7 +31,10 @@ export declare const moduleGroup: {
|
|
|
28
31
|
TPL_PASSWORD_RESET_EMAIL: {};
|
|
29
32
|
}, {
|
|
30
33
|
authModuleImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
34
|
+
cleanupAuthVerificationQueue: {};
|
|
35
|
+
cleanupAuthVerificationWorker: {};
|
|
31
36
|
cleanupExpiredAuthVerifications: {};
|
|
37
|
+
CookieUserSessionService: {};
|
|
32
38
|
createAuthVerification: {};
|
|
33
39
|
userSessionPayload: {};
|
|
34
40
|
validateAuthVerification: {};
|
|
@@ -36,26 +42,6 @@ export declare const moduleGroup: {
|
|
|
36
42
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
37
43
|
config: {};
|
|
38
44
|
}>>;
|
|
39
|
-
emailModuleImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
40
|
-
EmailAdapter: {
|
|
41
|
-
isTypeOnly: true;
|
|
42
|
-
};
|
|
43
|
-
EmailAttachment: {
|
|
44
|
-
isTypeOnly: true;
|
|
45
|
-
};
|
|
46
|
-
EmailRawOptions: {
|
|
47
|
-
isTypeOnly: true;
|
|
48
|
-
};
|
|
49
|
-
EmailSendOptions: {
|
|
50
|
-
isTypeOnly: true;
|
|
51
|
-
};
|
|
52
|
-
sendEmail: {};
|
|
53
|
-
sendEmailQueue: {};
|
|
54
|
-
sendRawEmail: {};
|
|
55
|
-
TransformedEmailMessage: {
|
|
56
|
-
isTypeOnly: true;
|
|
57
|
-
};
|
|
58
|
-
}>>;
|
|
59
45
|
errorHandlerServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
60
46
|
BadRequestError: {};
|
|
61
47
|
ForbiddenError: {};
|
|
@@ -64,6 +50,7 @@ export declare const moduleGroup: {
|
|
|
64
50
|
InternalServerError: {};
|
|
65
51
|
logError: {};
|
|
66
52
|
NotFoundError: {};
|
|
53
|
+
throwIfPrismaNotFound: {};
|
|
67
54
|
TooManyRequestsError: {};
|
|
68
55
|
UnauthorizedError: {};
|
|
69
56
|
}>>;
|
|
@@ -92,6 +79,9 @@ export declare const moduleGroup: {
|
|
|
92
79
|
RequestServiceContext: {
|
|
93
80
|
isTypeOnly: true;
|
|
94
81
|
};
|
|
82
|
+
RequestServiceContextWith: {
|
|
83
|
+
isTypeOnly: true;
|
|
84
|
+
};
|
|
95
85
|
}>>;
|
|
96
86
|
}, {
|
|
97
87
|
constantsPassword: {};
|
|
@@ -108,6 +98,7 @@ export declare const moduleGroup: {
|
|
|
108
98
|
InternalServerError: {};
|
|
109
99
|
logError: {};
|
|
110
100
|
NotFoundError: {};
|
|
101
|
+
throwIfPrismaNotFound: {};
|
|
111
102
|
TooManyRequestsError: {};
|
|
112
103
|
UnauthorizedError: {};
|
|
113
104
|
}>>;
|
|
@@ -142,9 +133,9 @@ export declare const moduleGroup: {
|
|
|
142
133
|
RequestServiceContext: {
|
|
143
134
|
isTypeOnly: true;
|
|
144
135
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
136
|
+
RequestServiceContextWith: {
|
|
137
|
+
isTypeOnly: true;
|
|
138
|
+
};
|
|
148
139
|
}>>;
|
|
149
140
|
userSessionTypesImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
150
141
|
UserSessionPayload: {
|
|
@@ -174,7 +165,10 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
174
165
|
TPL_USER_OBJECT_TYPE: {};
|
|
175
166
|
}, {
|
|
176
167
|
authModuleImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
168
|
+
cleanupAuthVerificationQueue: {};
|
|
169
|
+
cleanupAuthVerificationWorker: {};
|
|
177
170
|
cleanupExpiredAuthVerifications: {};
|
|
171
|
+
CookieUserSessionService: {};
|
|
178
172
|
createAuthVerification: {};
|
|
179
173
|
userSessionPayload: {};
|
|
180
174
|
validateAuthVerification: {};
|
|
@@ -190,7 +184,10 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
190
184
|
TPL_PASSWORD_RESET_EMAIL: {};
|
|
191
185
|
}, {
|
|
192
186
|
authModuleImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
187
|
+
cleanupAuthVerificationQueue: {};
|
|
188
|
+
cleanupAuthVerificationWorker: {};
|
|
193
189
|
cleanupExpiredAuthVerifications: {};
|
|
190
|
+
CookieUserSessionService: {};
|
|
194
191
|
createAuthVerification: {};
|
|
195
192
|
userSessionPayload: {};
|
|
196
193
|
validateAuthVerification: {};
|
|
@@ -198,26 +195,6 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
198
195
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
199
196
|
config: {};
|
|
200
197
|
}>>;
|
|
201
|
-
emailModuleImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
202
|
-
EmailAdapter: {
|
|
203
|
-
isTypeOnly: true;
|
|
204
|
-
};
|
|
205
|
-
EmailAttachment: {
|
|
206
|
-
isTypeOnly: true;
|
|
207
|
-
};
|
|
208
|
-
EmailRawOptions: {
|
|
209
|
-
isTypeOnly: true;
|
|
210
|
-
};
|
|
211
|
-
EmailSendOptions: {
|
|
212
|
-
isTypeOnly: true;
|
|
213
|
-
};
|
|
214
|
-
sendEmail: {};
|
|
215
|
-
sendEmailQueue: {};
|
|
216
|
-
sendRawEmail: {};
|
|
217
|
-
TransformedEmailMessage: {
|
|
218
|
-
isTypeOnly: true;
|
|
219
|
-
};
|
|
220
|
-
}>>;
|
|
221
198
|
errorHandlerServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
222
199
|
BadRequestError: {};
|
|
223
200
|
ForbiddenError: {};
|
|
@@ -226,6 +203,7 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
226
203
|
InternalServerError: {};
|
|
227
204
|
logError: {};
|
|
228
205
|
NotFoundError: {};
|
|
206
|
+
throwIfPrismaNotFound: {};
|
|
229
207
|
TooManyRequestsError: {};
|
|
230
208
|
UnauthorizedError: {};
|
|
231
209
|
}>>;
|
|
@@ -254,6 +232,9 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
254
232
|
RequestServiceContext: {
|
|
255
233
|
isTypeOnly: true;
|
|
256
234
|
};
|
|
235
|
+
RequestServiceContextWith: {
|
|
236
|
+
isTypeOnly: true;
|
|
237
|
+
};
|
|
257
238
|
}>>;
|
|
258
239
|
}, {
|
|
259
240
|
constantsPassword: {};
|
|
@@ -270,6 +251,7 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
270
251
|
InternalServerError: {};
|
|
271
252
|
logError: {};
|
|
272
253
|
NotFoundError: {};
|
|
254
|
+
throwIfPrismaNotFound: {};
|
|
273
255
|
TooManyRequestsError: {};
|
|
274
256
|
UnauthorizedError: {};
|
|
275
257
|
}>>;
|
|
@@ -304,9 +286,9 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
304
286
|
RequestServiceContext: {
|
|
305
287
|
isTypeOnly: true;
|
|
306
288
|
};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
289
|
+
RequestServiceContextWith: {
|
|
290
|
+
isTypeOnly: true;
|
|
291
|
+
};
|
|
310
292
|
}>>;
|
|
311
293
|
userSessionTypesImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
312
294
|
UserSessionPayload: {
|
|
@@ -332,7 +314,10 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
332
314
|
TPL_ACCOUNT_VERIFICATION_EMAIL: {};
|
|
333
315
|
}, {
|
|
334
316
|
authModuleImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
317
|
+
cleanupAuthVerificationQueue: {};
|
|
318
|
+
cleanupAuthVerificationWorker: {};
|
|
335
319
|
cleanupExpiredAuthVerifications: {};
|
|
320
|
+
CookieUserSessionService: {};
|
|
336
321
|
createAuthVerification: {};
|
|
337
322
|
userSessionPayload: {};
|
|
338
323
|
validateAuthVerification: {};
|
|
@@ -340,26 +325,6 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
340
325
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
341
326
|
config: {};
|
|
342
327
|
}>>;
|
|
343
|
-
emailModuleImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
344
|
-
EmailAdapter: {
|
|
345
|
-
isTypeOnly: true;
|
|
346
|
-
};
|
|
347
|
-
EmailAttachment: {
|
|
348
|
-
isTypeOnly: true;
|
|
349
|
-
};
|
|
350
|
-
EmailRawOptions: {
|
|
351
|
-
isTypeOnly: true;
|
|
352
|
-
};
|
|
353
|
-
EmailSendOptions: {
|
|
354
|
-
isTypeOnly: true;
|
|
355
|
-
};
|
|
356
|
-
sendEmail: {};
|
|
357
|
-
sendEmailQueue: {};
|
|
358
|
-
sendRawEmail: {};
|
|
359
|
-
TransformedEmailMessage: {
|
|
360
|
-
isTypeOnly: true;
|
|
361
|
-
};
|
|
362
|
-
}>>;
|
|
363
328
|
errorHandlerServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
364
329
|
BadRequestError: {};
|
|
365
330
|
ForbiddenError: {};
|
|
@@ -368,6 +333,7 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
368
333
|
InternalServerError: {};
|
|
369
334
|
logError: {};
|
|
370
335
|
NotFoundError: {};
|
|
336
|
+
throwIfPrismaNotFound: {};
|
|
371
337
|
TooManyRequestsError: {};
|
|
372
338
|
UnauthorizedError: {};
|
|
373
339
|
}>>;
|
|
@@ -392,6 +358,9 @@ export declare const LOCAL_AUTH_CORE_AUTH_EMAIL_PASSWORD_TEMPLATES: {
|
|
|
392
358
|
RequestServiceContext: {
|
|
393
359
|
isTypeOnly: true;
|
|
394
360
|
};
|
|
361
|
+
RequestServiceContextWith: {
|
|
362
|
+
isTypeOnly: true;
|
|
363
|
+
};
|
|
395
364
|
}>>;
|
|
396
365
|
}, {
|
|
397
366
|
constantsPassword: {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createTsTemplateFile } from '@baseplate-dev/core-generators';
|
|
2
|
-
import { configServiceImportsProvider, errorHandlerServiceImportsProvider, passwordHasherServiceImportsProvider, pothosImportsProvider, prismaGeneratedImportsProvider, prismaImportsProvider, requestServiceContextImportsProvider,
|
|
3
|
-
import { emailModuleImportsProvider } from '@baseplate-dev/plugin-email';
|
|
2
|
+
import { configServiceImportsProvider, errorHandlerServiceImportsProvider, passwordHasherServiceImportsProvider, pothosImportsProvider, prismaGeneratedImportsProvider, prismaImportsProvider, requestServiceContextImportsProvider, userSessionTypesImportsProvider, } from '@baseplate-dev/fastify-generators';
|
|
4
3
|
import { rateLimitImportsProvider } from '@baseplate-dev/plugin-rate-limit';
|
|
5
4
|
import path from 'node:path';
|
|
6
5
|
import { authModuleImportsProvider } from '#src/local-auth/core/generators/auth-module/generated/ts-import-providers.js';
|
|
@@ -50,7 +49,6 @@ const servicesPasswordReset = createTsTemplateFile({
|
|
|
50
49
|
importMapProviders: {
|
|
51
50
|
authModuleImports: authModuleImportsProvider,
|
|
52
51
|
configServiceImports: configServiceImportsProvider,
|
|
53
|
-
emailModuleImports: emailModuleImportsProvider,
|
|
54
52
|
errorHandlerServiceImports: errorHandlerServiceImportsProvider,
|
|
55
53
|
passwordHasherServiceImports: passwordHasherServiceImportsProvider,
|
|
56
54
|
prismaImports: prismaImportsProvider,
|
|
@@ -83,7 +81,6 @@ const servicesUserPassword = createTsTemplateFile({
|
|
|
83
81
|
prismaImports: prismaImportsProvider,
|
|
84
82
|
rateLimitImports: rateLimitImportsProvider,
|
|
85
83
|
requestServiceContextImports: requestServiceContextImportsProvider,
|
|
86
|
-
userSessionServiceImports: userSessionServiceImportsProvider,
|
|
87
84
|
userSessionTypesImports: userSessionTypesImportsProvider,
|
|
88
85
|
},
|
|
89
86
|
name: 'services-user-password',
|
|
@@ -123,7 +120,6 @@ const servicesEmailVerification = createTsTemplateFile({
|
|
|
123
120
|
importMapProviders: {
|
|
124
121
|
authModuleImports: authModuleImportsProvider,
|
|
125
122
|
configServiceImports: configServiceImportsProvider,
|
|
126
|
-
emailModuleImports: emailModuleImportsProvider,
|
|
127
123
|
errorHandlerServiceImports: errorHandlerServiceImportsProvider,
|
|
128
124
|
prismaImports: prismaImportsProvider,
|
|
129
125
|
rateLimitImports: rateLimitImportsProvider,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { RequestServiceContext } from '%requestServiceContextImports';
|
|
1
|
+
import type { RequestServiceContext, RequestServiceContextWith } from '%requestServiceContextImports';
|
|
2
2
|
/**
|
|
3
3
|
* Request an email verification for the authenticated user.
|
|
4
4
|
* Sends a verification email with a link to verify.
|
|
5
5
|
*/
|
|
6
6
|
export declare function requestEmailVerification({ userId, context, }: {
|
|
7
7
|
userId: string;
|
|
8
|
-
context:
|
|
8
|
+
context: RequestServiceContextWith<'email'>;
|
|
9
9
|
}): Promise<{
|
|
10
10
|
success: true;
|
|
11
11
|
}>;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { EMAIL_VERIFICATION_TOKEN_EXPIRY_SEC } from '$constantsPassword';
|
|
3
3
|
import { createAuthVerification, validateAuthVerification, } from '%authModuleImports';
|
|
4
4
|
import { config } from '%configServiceImports';
|
|
5
|
-
import { sendEmail } from '%emailModuleImports';
|
|
6
5
|
import { BadRequestError } from '%errorHandlerServiceImports';
|
|
7
6
|
import { prisma } from '%prismaImports';
|
|
8
7
|
import { memoizeRateLimiter } from '%rateLimitImports';
|
|
@@ -30,6 +29,7 @@ const getVerifyEmailIpLimiter = memoizeRateLimiter('verify-email-ip', {
|
|
|
30
29
|
* Sends a verification email with a link to verify.
|
|
31
30
|
*/
|
|
32
31
|
export async function requestEmailVerification({ userId, context, }) {
|
|
32
|
+
const { services } = context;
|
|
33
33
|
await Promise.all([
|
|
34
34
|
getRequestEmailVerificationIpLimiter().consumeOrThrow(context.reqInfo.ip, 'Too many verification attempts. Please try again later.', 'too-many-requests'),
|
|
35
35
|
getRequestEmailVerificationUserLimiter().consumeOrThrow(userId, 'Too many verification attempts. Please try again later.', 'too-many-requests'),
|
|
@@ -51,7 +51,7 @@ export async function requestEmailVerification({ userId, context, }) {
|
|
|
51
51
|
});
|
|
52
52
|
// Construct verification URL using configured domain
|
|
53
53
|
const verifyLink = `${config.AUTH_FRONTEND_URL}/auth/verify-email?token=${encodeURIComponent(token)}`;
|
|
54
|
-
await
|
|
54
|
+
await services.email.send(TPL_ACCOUNT_VERIFICATION_EMAIL, {
|
|
55
55
|
to: user.email,
|
|
56
56
|
data: { verifyLink },
|
|
57
57
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
RequestServiceContext,
|
|
5
|
+
RequestServiceContextWith,
|
|
6
|
+
} from '%requestServiceContextImports';
|
|
4
7
|
|
|
5
8
|
import { EMAIL_VERIFICATION_TOKEN_EXPIRY_SEC } from '$constantsPassword';
|
|
6
9
|
import {
|
|
@@ -8,7 +11,6 @@ import {
|
|
|
8
11
|
validateAuthVerification,
|
|
9
12
|
} from '%authModuleImports';
|
|
10
13
|
import { config } from '%configServiceImports';
|
|
11
|
-
import { sendEmail } from '%emailModuleImports';
|
|
12
14
|
import { BadRequestError } from '%errorHandlerServiceImports';
|
|
13
15
|
import { prisma } from '%prismaImports';
|
|
14
16
|
import { memoizeRateLimiter } from '%rateLimitImports';
|
|
@@ -52,8 +54,10 @@ export async function requestEmailVerification({
|
|
|
52
54
|
context,
|
|
53
55
|
}: {
|
|
54
56
|
userId: string;
|
|
55
|
-
context:
|
|
57
|
+
context: RequestServiceContextWith<'email'>;
|
|
56
58
|
}): Promise<{ success: true }> {
|
|
59
|
+
const { services } = context;
|
|
60
|
+
|
|
57
61
|
await Promise.all([
|
|
58
62
|
getRequestEmailVerificationIpLimiter().consumeOrThrow(
|
|
59
63
|
context.reqInfo.ip,
|
|
@@ -89,7 +93,7 @@ export async function requestEmailVerification({
|
|
|
89
93
|
// Construct verification URL using configured domain
|
|
90
94
|
const verifyLink = `${config.AUTH_FRONTEND_URL}/auth/verify-email?token=${encodeURIComponent(token)}`;
|
|
91
95
|
|
|
92
|
-
await
|
|
96
|
+
await services.email.send(TPL_ACCOUNT_VERIFICATION_EMAIL, {
|
|
93
97
|
to: user.email,
|
|
94
98
|
data: { verifyLink },
|
|
95
99
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RequestServiceContextWith } from '%requestServiceContextImports';
|
|
2
2
|
/**
|
|
3
3
|
* Request a password reset for the given email.
|
|
4
4
|
*/
|
|
5
5
|
export declare function requestPasswordReset({ email: rawEmail, context, }: {
|
|
6
6
|
email: string;
|
|
7
|
-
context:
|
|
7
|
+
context: RequestServiceContextWith<'email'>;
|
|
8
8
|
}): Promise<{
|
|
9
9
|
success: true;
|
|
10
10
|
}>;
|
|
@@ -31,7 +31,7 @@ export declare function validatePasswordResetToken({ token: rawToken, }: {
|
|
|
31
31
|
export declare function completePasswordReset({ token: rawToken, newPassword: rawNewPassword, context, }: {
|
|
32
32
|
token: string;
|
|
33
33
|
newPassword: string;
|
|
34
|
-
context:
|
|
34
|
+
context: RequestServiceContextWith<'email'>;
|
|
35
35
|
}): Promise<{
|
|
36
36
|
success: true;
|
|
37
37
|
}>;
|
|
@@ -3,7 +3,6 @@ import { PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PASSWORD_RESET_TOKEN_EXPIRY_S
|
|
|
3
3
|
import { resetLoginRateLimits } from '$servicesUserPassword';
|
|
4
4
|
import { createAuthVerification, validateAuthVerification, } from '%authModuleImports';
|
|
5
5
|
import { config } from '%configServiceImports';
|
|
6
|
-
import { sendEmail } from '%emailModuleImports';
|
|
7
6
|
import { BadRequestError, handleZodRequestValidationError, } from '%errorHandlerServiceImports';
|
|
8
7
|
import { createPasswordHash } from '%passwordHasherServiceImports';
|
|
9
8
|
import { prisma } from '%prismaImports';
|
|
@@ -39,6 +38,7 @@ const requestPasswordResetSchema = z.object({
|
|
|
39
38
|
* Request a password reset for the given email.
|
|
40
39
|
*/
|
|
41
40
|
export async function requestPasswordReset({ email: rawEmail, context, }) {
|
|
41
|
+
const { services } = context;
|
|
42
42
|
const { email } = await requestPasswordResetSchema
|
|
43
43
|
.parseAsync({ email: rawEmail })
|
|
44
44
|
.catch(handleZodRequestValidationError);
|
|
@@ -61,7 +61,7 @@ export async function requestPasswordReset({ email: rawEmail, context, }) {
|
|
|
61
61
|
// Construct reset URL using configured domain
|
|
62
62
|
const resetLink = `${config.AUTH_FRONTEND_URL}/auth/reset-password?token=${encodeURIComponent(token)}`;
|
|
63
63
|
// Send email asynchronously (queue-based)
|
|
64
|
-
await
|
|
64
|
+
await services.email.send(TPL_PASSWORD_RESET_EMAIL, {
|
|
65
65
|
to: user.email,
|
|
66
66
|
data: { resetLink },
|
|
67
67
|
});
|
|
@@ -105,6 +105,7 @@ const completePasswordResetSchema = z.object({
|
|
|
105
105
|
* - All remaining password-reset tokens for this user are deleted
|
|
106
106
|
*/
|
|
107
107
|
export async function completePasswordReset({ token: rawToken, newPassword: rawNewPassword, context, }) {
|
|
108
|
+
const { services } = context;
|
|
108
109
|
const { token, newPassword } = await completePasswordResetSchema
|
|
109
110
|
.parseAsync({
|
|
110
111
|
token: rawToken,
|
|
@@ -155,7 +156,7 @@ export async function completePasswordReset({ token: rawToken, newPassword: rawN
|
|
|
155
156
|
// Reset login rate limits so the user can log in with their new password
|
|
156
157
|
await resetLoginRateLimits({ email: user.email, ip: context.reqInfo.ip });
|
|
157
158
|
// Send password changed confirmation email
|
|
158
|
-
await
|
|
159
|
+
await services.email.send(TPL_PASSWORD_CHANGED_EMAIL, {
|
|
159
160
|
to: user.email,
|
|
160
161
|
data: {},
|
|
161
162
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { RequestServiceContextWith } from '%requestServiceContextImports';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
PASSWORD_MAX_LENGTH,
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
validateAuthVerification,
|
|
14
14
|
} from '%authModuleImports';
|
|
15
15
|
import { config } from '%configServiceImports';
|
|
16
|
-
import { sendEmail } from '%emailModuleImports';
|
|
17
16
|
import {
|
|
18
17
|
BadRequestError,
|
|
19
18
|
handleZodRequestValidationError,
|
|
@@ -69,8 +68,10 @@ export async function requestPasswordReset({
|
|
|
69
68
|
context,
|
|
70
69
|
}: {
|
|
71
70
|
email: string;
|
|
72
|
-
context:
|
|
71
|
+
context: RequestServiceContextWith<'email'>;
|
|
73
72
|
}): Promise<{ success: true }> {
|
|
73
|
+
const { services } = context;
|
|
74
|
+
|
|
74
75
|
const { email } = await requestPasswordResetSchema
|
|
75
76
|
.parseAsync({ email: rawEmail })
|
|
76
77
|
.catch(handleZodRequestValidationError);
|
|
@@ -110,7 +111,7 @@ export async function requestPasswordReset({
|
|
|
110
111
|
const resetLink = `${config.AUTH_FRONTEND_URL}/auth/reset-password?token=${encodeURIComponent(token)}`;
|
|
111
112
|
|
|
112
113
|
// Send email asynchronously (queue-based)
|
|
113
|
-
await
|
|
114
|
+
await services.email.send(TPL_PASSWORD_RESET_EMAIL, {
|
|
114
115
|
to: user.email,
|
|
115
116
|
data: { resetLink },
|
|
116
117
|
});
|
|
@@ -172,8 +173,10 @@ export async function completePasswordReset({
|
|
|
172
173
|
}: {
|
|
173
174
|
token: string;
|
|
174
175
|
newPassword: string;
|
|
175
|
-
context:
|
|
176
|
+
context: RequestServiceContextWith<'email'>;
|
|
176
177
|
}): Promise<{ success: true }> {
|
|
178
|
+
const { services } = context;
|
|
179
|
+
|
|
177
180
|
const { token, newPassword } = await completePasswordResetSchema
|
|
178
181
|
.parseAsync({
|
|
179
182
|
token: rawToken,
|
|
@@ -232,7 +235,7 @@ export async function completePasswordReset({
|
|
|
232
235
|
await resetLoginRateLimits({ email: user.email, ip: context.reqInfo.ip });
|
|
233
236
|
|
|
234
237
|
// Send password changed confirmation email
|
|
235
|
-
await
|
|
238
|
+
await services.email.send(TPL_PASSWORD_CHANGED_EMAIL, {
|
|
236
239
|
to: user.email,
|
|
237
240
|
data: {},
|
|
238
241
|
});
|
|
@@ -5,7 +5,6 @@ import { BadRequestError, handleZodRequestValidationError, logError, NotFoundErr
|
|
|
5
5
|
import { createPasswordHash, verifyPasswordHash, } from '%passwordHasherServiceImports';
|
|
6
6
|
import { prisma } from '%prismaImports';
|
|
7
7
|
import { memoizeRateLimiter } from '%rateLimitImports';
|
|
8
|
-
import { userSessionService } from '%userSessionServiceImports';
|
|
9
8
|
import z from 'zod';
|
|
10
9
|
const PROVIDER_ID = 'email-password';
|
|
11
10
|
const emailPasswordSchema = z.object({
|
|
@@ -82,7 +81,7 @@ export async function registerUserWithEmailAndPassword({ input, context, }) {
|
|
|
82
81
|
// Rate limit registration by IP
|
|
83
82
|
await getRegistrationLimiter().consumeOrThrow(context.reqInfo.ip, 'Too many registration attempts. Please try again later.', 'registration-rate-limited');
|
|
84
83
|
const user = await createUserWithEmailAndPassword({ input });
|
|
85
|
-
const session = await
|
|
84
|
+
const session = await context.services.userSession.createSession(user.id, context);
|
|
86
85
|
// Send verification email (fire-and-forget, don't block registration)
|
|
87
86
|
requestEmailVerification({ userId: user.id, context }).catch(logError);
|
|
88
87
|
return { session, user };
|
|
@@ -122,7 +121,7 @@ export async function authenticateUserWithEmailAndPassword({ input, context, })
|
|
|
122
121
|
}
|
|
123
122
|
// Reset consecutive failures on successful login
|
|
124
123
|
await getLoginConsecutiveFailsLimiter().delete(emailIpKey);
|
|
125
|
-
const session = await
|
|
124
|
+
const session = await context.services.userSession.createSession(userAccount.userId, context);
|
|
126
125
|
return { session };
|
|
127
126
|
}
|
|
128
127
|
const changePasswordSchema = z.object({
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
} from '%passwordHasherServiceImports';
|
|
20
20
|
import { prisma } from '%prismaImports';
|
|
21
21
|
import { memoizeRateLimiter } from '%rateLimitImports';
|
|
22
|
-
import { userSessionService } from '%userSessionServiceImports';
|
|
23
22
|
import z from 'zod';
|
|
24
23
|
|
|
25
24
|
const PROVIDER_ID = 'email-password';
|
|
@@ -140,7 +139,10 @@ export async function registerUserWithEmailAndPassword({
|
|
|
140
139
|
);
|
|
141
140
|
|
|
142
141
|
const user = await createUserWithEmailAndPassword({ input });
|
|
143
|
-
const session = await
|
|
142
|
+
const session = await context.services.userSession.createSession(
|
|
143
|
+
user.id,
|
|
144
|
+
context,
|
|
145
|
+
);
|
|
144
146
|
|
|
145
147
|
// Send verification email (fire-and-forget, don't block registration)
|
|
146
148
|
requestEmailVerification({ userId: user.id, context }).catch(logError);
|
|
@@ -215,7 +217,7 @@ export async function authenticateUserWithEmailAndPassword({
|
|
|
215
217
|
// Reset consecutive failures on successful login
|
|
216
218
|
await getLoginConsecutiveFailsLimiter().delete(emailIpKey);
|
|
217
219
|
|
|
218
|
-
const session = await
|
|
220
|
+
const session = await context.services.userSession.createSession(
|
|
219
221
|
userAccount.userId,
|
|
220
222
|
context,
|
|
221
223
|
);
|