@baseplate-dev/plugin-auth 0.6.11 → 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 +40 -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 +29 -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 +37 -66
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.js +5 -6
- 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-DEljr3MS.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-B6a7L2-k.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-JKpdJ1L0.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-CTWnBc6I.js → common-B4cD6OfF.js} +6 -6
- package/dist/web/assets/{common-g_Gn0v5J.js → common-B9LNVIXT.js} +4 -4
- package/dist/web/assets/{common-kfSP8YQO.js → common-B9sZoKR5.js} +6 -6
- package/dist/web/assets/{common-CzNLnT_1.js → common-DF9FD3lJ.js} +4 -4
- package/dist/web/assets/{common-zfktVQvk.js → common-S36tY-P3.js} +3 -3
- package/dist/web/assets/{common-B3OG-gju.js → common-sMUs9FmV.js} +3 -3
- package/dist/web/assets/{dist-C6kDPCTC.js → dist-CtqdAorB.js} +376 -256
- package/dist/web/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-Bt9-dftr.js → dist-SBfmsOB2.js} +43 -359
- package/dist/web/assets/{get-auth-plugin-definition-2vFJROjB.js → get-auth-plugin-definition-Bs9C6JrS.js} +2 -2
- package/dist/web/assets/hostInit-BtfjN9sB.js +99 -0
- package/dist/web/assets/{index-Cr47LBtj.js → index-DVCa_MuH.js} +2 -2
- package/dist/web/assets/{mf-entry-bootstrap-0-13480d2a.js → mf-entry-bootstrap-0-31a63adb.js} +5 -2
- package/dist/web/assets/{model-utils-ZF_FVZ_o.js → model-utils-BDM6ILfO.js} +43 -15
- package/dist/web/assets/{models-DPPMgQz_.js → models-1c2urnle.js} +3 -3
- package/dist/web/assets/{models-CORL4i-6.js → models-DGhhwO8Q.js} +3 -3
- package/dist/web/assets/{plugin-definition-UAfMRa7u.js → plugin-definition-B-HRncfN.js} +3 -3
- package/dist/web/assets/{plugin-definition-mNNM2hOB.js → plugin-definition-Dluw2inU.js} +3 -3
- package/dist/web/assets/{styles-DNVWarsT.js → styles-BTmSBHAy.js} +15 -12
- package/dist/web/assets/{virtualExposes-CZsMFYa2.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-DC8YPV1Z.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-CmilMd0E.js → virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-DotA2McS.js} +50 -15
- package/dist/web/assets/{web-CNMEeTj-.js → web-B2REeIGU.js} +3 -3
- package/dist/web/assets/{web-BldKZtQd.js → web-BEOhczx1.js} +16 -16
- package/dist/web/assets/{web-y8E7eNgy.js → web-Bh_3N1sv.js} +17 -17
- package/dist/web/assets/{web-DiGj_0d0.js → web-CiuxQhgn.js} +20 -20
- package/dist/web/assets/{web-OntIhIfe.js → web-DGv5-Arz.js} +35 -35
- package/dist/web/assets/{web-BbqWFVPH.js → web-jcCkQISW.js} +31 -18
- package/dist/web/assets/{web-CnsQCdFE.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-YjeUffyx.js +0 -1
- package/dist/web/assets/hostInit-35H-qR11.js +0 -119
|
@@ -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
|
);
|
|
@@ -25,6 +25,7 @@ export declare const LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_GENERATED: {
|
|
|
25
25
|
};
|
|
26
26
|
EmailLayout: {};
|
|
27
27
|
Heading: {};
|
|
28
|
+
Link: {};
|
|
28
29
|
renderEmail: {};
|
|
29
30
|
Section: {};
|
|
30
31
|
Text: {};
|
|
@@ -47,6 +48,7 @@ export declare const LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_GENERATED: {
|
|
|
47
48
|
};
|
|
48
49
|
EmailLayout: {};
|
|
49
50
|
Heading: {};
|
|
51
|
+
Link: {};
|
|
50
52
|
renderEmail: {};
|
|
51
53
|
Section: {};
|
|
52
54
|
Text: {};
|
|
@@ -66,6 +68,7 @@ export declare const LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_GENERATED: {
|
|
|
66
68
|
};
|
|
67
69
|
EmailLayout: {};
|
|
68
70
|
Heading: {};
|
|
71
|
+
Link: {};
|
|
69
72
|
renderEmail: {};
|
|
70
73
|
Section: {};
|
|
71
74
|
Text: {};
|
|
@@ -85,6 +88,7 @@ export declare const LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_GENERATED: {
|
|
|
85
88
|
};
|
|
86
89
|
EmailLayout: {};
|
|
87
90
|
Heading: {};
|
|
91
|
+
Link: {};
|
|
88
92
|
renderEmail: {};
|
|
89
93
|
Section: {};
|
|
90
94
|
Text: {};
|
|
@@ -12,6 +12,7 @@ export declare const LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES: {
|
|
|
12
12
|
};
|
|
13
13
|
EmailLayout: {};
|
|
14
14
|
Heading: {};
|
|
15
|
+
Link: {};
|
|
15
16
|
renderEmail: {};
|
|
16
17
|
Section: {};
|
|
17
18
|
Text: {};
|
|
@@ -31,6 +32,7 @@ export declare const LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES: {
|
|
|
31
32
|
};
|
|
32
33
|
EmailLayout: {};
|
|
33
34
|
Heading: {};
|
|
35
|
+
Link: {};
|
|
34
36
|
renderEmail: {};
|
|
35
37
|
Section: {};
|
|
36
38
|
Text: {};
|
|
@@ -50,6 +52,7 @@ export declare const LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES: {
|
|
|
50
52
|
};
|
|
51
53
|
EmailLayout: {};
|
|
52
54
|
Heading: {};
|
|
55
|
+
Link: {};
|
|
53
56
|
renderEmail: {};
|
|
54
57
|
Section: {};
|
|
55
58
|
Text: {};
|
|
@@ -9,14 +9,14 @@ export declare const authModuleGenerator: import("@baseplate-dev/sync").Generato
|
|
|
9
9
|
}, undefined>;
|
|
10
10
|
imports: import("@baseplate-dev/sync").GeneratorTask<{
|
|
11
11
|
authModuleImports: import("@baseplate-dev/sync").ProviderExport<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
12
|
+
cleanupAuthVerificationQueue: {};
|
|
13
|
+
cleanupAuthVerificationWorker: {};
|
|
12
14
|
cleanupExpiredAuthVerifications: {};
|
|
15
|
+
CookieUserSessionService: {};
|
|
13
16
|
createAuthVerification: {};
|
|
14
17
|
userSessionPayload: {};
|
|
15
18
|
validateAuthVerification: {};
|
|
16
19
|
}>>;
|
|
17
|
-
userSessionServiceImports: import("@baseplate-dev/sync").ProviderExport<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
18
|
-
userSessionService: {};
|
|
19
|
-
}>>;
|
|
20
20
|
}, {
|
|
21
21
|
paths: import("@baseplate-dev/sync").ProviderType<import("./generated/template-paths.js").LocalAuthCoreAuthModulePaths>;
|
|
22
22
|
}, undefined>;
|
|
@@ -60,6 +60,7 @@ export declare const authModuleGenerator: import("@baseplate-dev/sync").Generato
|
|
|
60
60
|
InternalServerError: {};
|
|
61
61
|
logError: {};
|
|
62
62
|
NotFoundError: {};
|
|
63
|
+
throwIfPrismaNotFound: {};
|
|
63
64
|
TooManyRequestsError: {};
|
|
64
65
|
UnauthorizedError: {};
|
|
65
66
|
}>>;
|
|
@@ -76,14 +77,60 @@ export declare const authModuleGenerator: import("@baseplate-dev/sync").Generato
|
|
|
76
77
|
prismaImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
77
78
|
prisma: {};
|
|
78
79
|
}>>;
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
queuesImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
81
|
+
bindQueueHandler: {};
|
|
82
|
+
defineQueue: {};
|
|
83
|
+
EnqueueOptions: {
|
|
84
|
+
isTypeOnly: true;
|
|
85
|
+
};
|
|
86
|
+
QueueHandlerBinding: {
|
|
87
|
+
isTypeOnly: true;
|
|
88
|
+
};
|
|
89
|
+
QueueHandlerBindingConfig: {
|
|
90
|
+
isTypeOnly: true;
|
|
91
|
+
};
|
|
92
|
+
QueueHandlerBindingInput: {
|
|
93
|
+
isTypeOnly: true;
|
|
94
|
+
};
|
|
95
|
+
QueueInfo: {
|
|
96
|
+
isTypeOnly: true;
|
|
97
|
+
};
|
|
98
|
+
QueueIntrospection: {
|
|
99
|
+
isTypeOnly: true;
|
|
100
|
+
};
|
|
101
|
+
QueueJob: {
|
|
102
|
+
isTypeOnly: true;
|
|
103
|
+
};
|
|
104
|
+
QueueJobHandler: {
|
|
105
|
+
isTypeOnly: true;
|
|
106
|
+
};
|
|
107
|
+
QueueRuntime: {
|
|
108
|
+
isTypeOnly: true;
|
|
109
|
+
};
|
|
110
|
+
QueueService: {
|
|
111
|
+
isTypeOnly: true;
|
|
112
|
+
};
|
|
113
|
+
QueueToken: {
|
|
114
|
+
isTypeOnly: true;
|
|
115
|
+
};
|
|
116
|
+
QueueWorkers: {
|
|
117
|
+
isTypeOnly: true;
|
|
118
|
+
};
|
|
119
|
+
RepeatableConfig: {
|
|
120
|
+
isTypeOnly: true;
|
|
121
|
+
};
|
|
122
|
+
ScheduledJob: {
|
|
123
|
+
isTypeOnly: true;
|
|
124
|
+
};
|
|
81
125
|
}>>;
|
|
82
126
|
requestServiceContextImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
83
127
|
createContextFromRequest: {};
|
|
84
128
|
RequestServiceContext: {
|
|
85
129
|
isTypeOnly: true;
|
|
86
130
|
};
|
|
131
|
+
RequestServiceContextWith: {
|
|
132
|
+
isTypeOnly: true;
|
|
133
|
+
};
|
|
87
134
|
}>>;
|
|
88
135
|
typescriptFile: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").TypescriptFileProvider>;
|
|
89
136
|
userSessionTypesImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
@@ -108,9 +155,16 @@ export declare const authModuleGenerator: import("@baseplate-dev/sync").Generato
|
|
|
108
155
|
prismaOutput: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/fastify-generators").PrismaOutputProvider>;
|
|
109
156
|
renderers: import("@baseplate-dev/sync").ProviderType<import("./generated/template-renderers.js").LocalAuthCoreAuthModuleRenderers>;
|
|
110
157
|
userObjectType: import("@baseplate-dev/sync").ProviderDependency<import("@baseplate-dev/fastify-generators").PothosTypeOutputProvider>;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
158
|
+
appModule: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/fastify-generators").AppModuleProvider>;
|
|
159
|
+
paths: import("@baseplate-dev/sync").ProviderType<import("./generated/template-paths.js").LocalAuthCoreAuthModulePaths>;
|
|
160
|
+
}, any>;
|
|
161
|
+
appRuntimeConfig: import("@baseplate-dev/sync").GeneratorTask<any, {
|
|
162
|
+
appRuntimeConfig: import("@baseplate-dev/sync").ProviderType<Omit<import("@baseplate-dev/utils").FieldMap<{
|
|
163
|
+
services: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/core-generators").TsCodeFragment>;
|
|
164
|
+
construction: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/fastify-generators").AppRuntimeConstructionEntry>;
|
|
165
|
+
flattenedModuleFields: import("@baseplate-dev/utils").MapContainer<string, string>;
|
|
166
|
+
usesBackgroundServices: import("@baseplate-dev/utils").ScalarContainer<boolean | undefined>;
|
|
167
|
+
}>, "getValues">>;
|
|
114
168
|
paths: import("@baseplate-dev/sync").ProviderType<import("./generated/template-paths.js").LocalAuthCoreAuthModulePaths>;
|
|
115
169
|
}, any>;
|
|
116
170
|
}>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { tsCodeFragment, TsCodeUtils } from '@baseplate-dev/core-generators';
|
|
2
|
-
import { appModuleProvider, configServiceProvider, createPothosPrismaObjectTypeOutputName, pothosTypeOutputProvider, prismaOutputProvider, } from '@baseplate-dev/fastify-generators';
|
|
3
|
-
import { queueConfigProvider } from '@baseplate-dev/plugin-queue';
|
|
1
|
+
import { tsCodeFragment, TsCodeUtils, tsTypeImportBuilder, } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { appModuleProvider, appRuntimeConfigProvider, configServiceProvider, createPothosPrismaObjectTypeOutputName, pothosTypeOutputProvider, prismaOutputProvider, } from '@baseplate-dev/fastify-generators';
|
|
4
3
|
import { createGenerator, createGeneratorTask, createProviderTask, } from '@baseplate-dev/sync';
|
|
5
4
|
import { quot } from '@baseplate-dev/utils';
|
|
6
5
|
import { z } from 'zod';
|
|
@@ -56,10 +55,10 @@ export const authModuleGenerator = createGenerator({
|
|
|
56
55
|
userObjectType: pothosTypeOutputProvider
|
|
57
56
|
.dependency()
|
|
58
57
|
.reference(createPothosPrismaObjectTypeOutputName(LOCAL_AUTH_MODELS.user)),
|
|
59
|
-
|
|
58
|
+
appModule: appModuleProvider,
|
|
60
59
|
paths: GENERATED_TEMPLATES.paths.provider,
|
|
61
60
|
},
|
|
62
|
-
run({ prismaOutput, renderers, userObjectType,
|
|
61
|
+
run({ prismaOutput, renderers, userObjectType, appModule, paths }) {
|
|
63
62
|
return {
|
|
64
63
|
providers: {
|
|
65
64
|
authModule: {},
|
|
@@ -88,16 +87,27 @@ export const authModuleGenerator = createGenerator({
|
|
|
88
87
|
},
|
|
89
88
|
},
|
|
90
89
|
}));
|
|
91
|
-
// Render queue
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
90
|
+
// Render queue
|
|
91
|
+
await builder.apply(renderers.queuesCleanupAuthVerification.render({}));
|
|
92
|
+
await builder.apply(renderers.queuesCleanupAuthVerificationWorker.render({}));
|
|
93
|
+
// Register with the app module's queues field
|
|
94
|
+
appModule.moduleFields.set('queues', 'cleanupAuthVerificationWorker', TsCodeUtils.importFragment('cleanupAuthVerificationWorker', paths.queuesCleanupAuthVerificationWorker));
|
|
97
95
|
},
|
|
98
96
|
};
|
|
99
97
|
},
|
|
100
98
|
}),
|
|
99
|
+
appRuntimeConfig: createGeneratorTask({
|
|
100
|
+
dependencies: {
|
|
101
|
+
appRuntimeConfig: appRuntimeConfigProvider,
|
|
102
|
+
paths: GENERATED_TEMPLATES.paths.provider,
|
|
103
|
+
},
|
|
104
|
+
run({ appRuntimeConfig, paths }) {
|
|
105
|
+
appRuntimeConfig.services.set('userSession', tsCodeFragment('CookieUserSessionService', tsTypeImportBuilder(['CookieUserSessionService']).from(paths.userSessionService)));
|
|
106
|
+
appRuntimeConfig.construction.set('userSession', {
|
|
107
|
+
fragment: TsCodeUtils.template `new ${TsCodeUtils.importFragment('CookieUserSessionService', paths.userSessionService)}()`,
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
101
111
|
}),
|
|
102
112
|
});
|
|
103
113
|
//# sourceMappingURL=auth-module.generator.js.map
|