@baseplate-dev/plugin-auth 0.6.17 → 0.6.19
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 +54 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +74 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +74 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +37 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +37 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.js +1 -2
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.tsx +1 -1
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.d.ts +74 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +74 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +37 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +74 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.js +1 -2
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.tsx +1 -1
- package/dist/better-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +37 -0
- package/dist/better-auth/core/node.js +7 -8
- package/dist/better-auth/generators/fastify/better-auth-admin-module/generated/index.d.ts +1 -0
- package/dist/better-auth/generators/fastify/better-auth-admin-module/generated/ts-import-providers.d.ts +1 -0
- package/dist/better-auth/generators/fastify/better-auth-admin-module/generated/ts-import-providers.js +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.d.ts +20 -3
- package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.js +5 -24
- package/dist/better-auth/generators/fastify/better-auth-module/generated/index.d.ts +40 -2
- package/dist/better-auth/generators/fastify/better-auth-module/generated/template-renderers.d.ts +19 -1
- 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 +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/ts-import-providers.js +1 -0
- package/dist/better-auth/generators/fastify/better-auth-module/generated/typed-templates.d.ts +20 -1
- package/dist/better-auth/generators/fastify/better-auth-module/generated/typed-templates.js +4 -1
- package/dist/better-auth/generators/fastify/better-auth-module/templates/module/services/auth.ts +16 -8
- package/dist/better-auth/generators/react/better-auth-hooks/better-auth-hooks.generator.d.ts +1 -1
- package/dist/better-auth/generators/react/better-auth-hooks/generated/index.d.ts +5 -4
- package/dist/better-auth/generators/react/better-auth-hooks/generated/template-paths.d.ts +1 -1
- package/dist/better-auth/generators/react/better-auth-hooks/generated/template-paths.js +1 -1
- package/dist/better-auth/generators/react/better-auth-hooks/generated/ts-import-providers.d.ts +2 -1
- package/dist/better-auth/generators/react/better-auth-hooks/generated/ts-import-providers.js +2 -1
- package/dist/better-auth/generators/react/better-auth-hooks/generated/typed-templates.d.ts +6 -6
- package/dist/better-auth/generators/react/better-auth-hooks/generated/typed-templates.js +13 -13
- package/dist/better-auth/generators/react/better-auth-hooks/templates/src/hooks/{use-required-user-id.ts → use-user-id-or-throw.ts} +1 -1
- package/dist/better-auth/generators/react/better-auth-pages/better-auth-pages.generator.d.ts +37 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/index.d.ts +222 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-renderers.d.ts +37 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/typed-templates.d.ts +370 -0
- package/dist/better-auth/generators/react/better-auth-pages/templates/routes/forgot-password.tsx +1 -4
- package/dist/better-auth/generators/react/react-better-auth/generated/index.d.ts +77 -2
- package/dist/better-auth/generators/react/react-better-auth/generated/template-renderers.d.ts +38 -1
- package/dist/better-auth/generators/react/react-better-auth/generated/ts-import-providers.d.ts +1 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/ts-import-providers.js +1 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/typed-templates.d.ts +38 -1
- package/dist/better-auth/generators/react/react-better-auth/react-better-auth.generator.d.ts +38 -1
- package/dist/better-auth/generators/react/react-better-auth/templates/src/app/auth-loaded-gate.tsx +12 -3
- package/dist/local-auth/admin/common.js +6 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/admin-crud-invite-user-action.generator.d.ts +593 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/admin-crud-invite-user-action.generator.js +119 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/index.d.ts +602 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/index.js +11 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-paths.d.ts +12 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-paths.js +24 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-renderers.d.ts +307 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-renderers.js +45 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/typed-templates.d.ts +294 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/typed-templates.js +21 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/index.d.ts +2 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/index.js +2 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.d.ts +21 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.js +68 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.tsx +122 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +74 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +74 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +37 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +37 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.js +1 -2
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.tsx +1 -1
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.d.ts +74 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +74 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +37 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +74 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.js +1 -2
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.tsx +1 -1
- package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +37 -0
- package/dist/local-auth/admin/node.js +13 -0
- package/dist/local-auth/admin/schema/invite-user-action.d.ts +12 -0
- package/dist/local-auth/admin/schema/invite-user-action.js +6 -0
- package/dist/local-auth/admin/web.js +8 -0
- package/dist/local-auth/core/common.js +7 -2
- package/dist/local-auth/core/components/local-auth-definition-editor.js +2 -1
- package/dist/local-auth/core/components/local-auth-web-app-settings-form.d.ts +9 -0
- package/dist/local-auth/core/components/local-auth-web-app-settings-form.js +11 -0
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.d.ts +16 -7
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.js +73 -16
- package/dist/local-auth/core/generators/auth-email-password/generated/index.d.ts +222 -7
- package/dist/local-auth/core/generators/auth-email-password/generated/template-paths.d.ts +5 -0
- package/dist/local-auth/core/generators/auth-email-password/generated/template-paths.js +5 -0
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.d.ts +27 -0
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.js +71 -4
- package/dist/local-auth/core/generators/auth-email-password/generated/ts-import-providers.d.ts +1 -3
- package/dist/local-auth/core/generators/auth-email-password/generated/ts-import-providers.js +1 -2
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.d.ts +226 -10
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.js +91 -7
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/otp.constants.d.ts +19 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/otp.constants.js +20 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/otp.constants.ts +22 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/password.constants.d.ts +12 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/password.constants.js +12 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/password.constants.ts +14 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/email-otp.mutations.d.ts +2 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/email-otp.mutations.js +30 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/email-otp.mutations.ts +38 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/invite.mutations.d.ts +2 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/invite.mutations.js +42 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/invite.mutations.ts +54 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/user-password.mutations.js +2 -19
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/user-password.mutations.ts +1 -22
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-otp.service.d.ts +37 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-otp.service.js +225 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-otp.service.ts +333 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.js +2 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.ts +5 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/invite.service.d.ts +39 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/invite.service.js +142 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/invite.service.ts +221 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.js +5 -6
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.ts +8 -5
- package/dist/local-auth/core/generators/auth-email-templates/auth-email-templates.generator.d.ts +3 -1
- package/dist/local-auth/core/generators/auth-email-templates/auth-email-templates.generator.js +18 -3
- package/dist/local-auth/core/generators/auth-email-templates/generated/index.d.ts +40 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/template-paths.d.ts +2 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/template-paths.js +2 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/template-renderers.d.ts +6 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/template-renderers.js +20 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/typed-templates.d.ts +40 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/typed-templates.js +24 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/email-otp.email.d.ts +3 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/email-otp.email.js +18 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/email-otp.email.tsx +57 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/invite.email.d.ts +3 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/invite.email.js +14 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/invite.email.tsx +47 -0
- package/dist/local-auth/core/generators/auth-hooks/auth-hooks.generator.d.ts +272 -1
- package/dist/local-auth/core/generators/auth-hooks/generated/index.d.ts +547 -4
- package/dist/local-auth/core/generators/auth-hooks/generated/template-paths.d.ts +1 -1
- package/dist/local-auth/core/generators/auth-hooks/generated/template-paths.js +1 -1
- package/dist/local-auth/core/generators/auth-hooks/generated/template-renderers.d.ts +271 -0
- package/dist/local-auth/core/generators/auth-hooks/generated/template-renderers.js +4 -2
- package/dist/local-auth/core/generators/auth-hooks/generated/ts-import-providers.d.ts +2 -1
- package/dist/local-auth/core/generators/auth-hooks/generated/ts-import-providers.js +2 -1
- package/dist/local-auth/core/generators/auth-hooks/generated/typed-templates.d.ts +548 -6
- package/dist/local-auth/core/generators/auth-hooks/generated/typed-templates.js +15 -14
- package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-log-out.js +1 -1
- package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-log-out.ts +1 -1
- package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-session.d.ts +7 -0
- package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-session.ts +7 -0
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.d.ts +23 -7
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.js +7 -26
- package/dist/local-auth/core/generators/auth-module/generated/index.d.ts +65 -4
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.d.ts +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.js +1 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.d.ts +22 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.js +19 -2
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.d.ts +10 -0
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.js +7 -0
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.d.ts +42 -4
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.js +24 -13
- package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.d.ts +4 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.js +1 -1
- package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.ts +1 -1
- package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.d.ts +67 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.js +140 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.ts +191 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.js +8 -9
- package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.ts +10 -11
- package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.d.ts +39 -0
- package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.js +38 -5
- package/dist/local-auth/core/generators/auth-routes/generated/index.d.ts +1089 -268
- package/dist/local-auth/core/generators/auth-routes/generated/template-paths.d.ts +3 -0
- package/dist/local-auth/core/generators/auth-routes/generated/template-paths.js +3 -0
- package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.d.ts +49 -0
- package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.js +51 -0
- package/dist/local-auth/core/generators/auth-routes/generated/ts-import-providers.d.ts +1 -0
- package/dist/local-auth/core/generators/auth-routes/generated/ts-import-providers.js +1 -0
- package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.d.ts +918 -283
- package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.js +69 -23
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.d.ts +9 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.js +10 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.ts +11 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.d.ts +7 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.js +155 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.tsx +274 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/forgot-password.js +1 -2
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/forgot-password.tsx +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login-otp.d.ts +7 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login-otp.js +184 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login-otp.tsx +312 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js +5 -5
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.tsx +6 -12
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.js +4 -4
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.tsx +4 -3
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/reset-password.js +1 -2
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/reset-password.tsx +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/verify-email.js +1 -2
- 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 +90 -7
- package/dist/local-auth/core/generators/react-session/generated/template-renderers.d.ts +38 -1
- package/dist/local-auth/core/generators/react-session/generated/ts-import-providers.d.ts +1 -0
- package/dist/local-auth/core/generators/react-session/generated/ts-import-providers.js +1 -0
- package/dist/local-auth/core/generators/react-session/generated/typed-templates.d.ts +102 -12
- package/dist/local-auth/core/generators/react-session/generated/typed-templates.js +5 -2
- package/dist/local-auth/core/generators/react-session/react-session.generator.d.ts +54 -1
- package/dist/local-auth/core/generators/react-session/react-session.generator.js +35 -1
- package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.js +17 -44
- package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.tsx +21 -49
- package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.d.ts +43 -34
- package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.js +96 -80
- package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.ts +148 -82
- package/dist/local-auth/core/generators/seed-initial-user/generated/index.d.ts +0 -2
- package/dist/local-auth/core/generators/seed-initial-user/generated/template-renderers.d.ts +0 -1
- package/dist/local-auth/core/generators/seed-initial-user/generated/typed-templates.d.ts +0 -1
- package/dist/local-auth/core/generators/seed-initial-user/seed-initial-user.generator.d.ts +0 -1
- package/dist/local-auth/core/node.js +30 -12
- package/dist/local-auth/core/schema/migrations.d.ts +3 -0
- package/dist/local-auth/core/schema/migrations.js +36 -0
- package/dist/local-auth/core/schema/models.js +8 -0
- package/dist/local-auth/core/schema/plugin-definition.d.ts +1 -0
- package/dist/local-auth/core/schema/plugin-definition.js +1 -0
- package/dist/local-auth/core/schema/web-app-schema.d.ts +15 -0
- package/dist/local-auth/core/schema/web-app-schema.js +16 -0
- package/dist/local-auth/core/web.js +8 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/index.d.ts +4 -3
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/template-paths.d.ts +1 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/template-paths.js +1 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/ts-import-providers.d.ts +2 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/ts-import-providers.js +2 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/typed-templates.d.ts +4 -4
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/typed-templates.js +13 -13
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/placeholder-auth-hooks.generator.d.ts +1 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-session.d.ts +1 -0
- package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-session.ts +2 -0
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/index.d.ts +1 -2
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/template-renderers.d.ts +0 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/ts-import-providers.d.ts +1 -0
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/ts-import-providers.js +1 -0
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/typed-templates.d.ts +0 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/placeholder-auth-module.generator.d.ts +0 -1
- package/dist/web/assets/{_virtual_mf-localSharedImportMap___mfe_internal__plugin_mf_2_auth-ChkXxpXe.js → _virtual_mf-localSharedImportMap___mfe_internal__plugin_mf_2_auth__mf_owner__1-DUupKqD4.js} +42 -34
- package/dist/web/assets/{dist-DY7ZXvq4.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__mf_owner__1__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib__loadShare__.js-DE4rTqEA.js} +16857 -381
- 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-37vlYRxk.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__mf_owner__1__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib_mf_1_web__loadShare__.js-mszeXpf-.js} +90 -38
- 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-DRSNXPPo.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__mf_owner__1__loadShare___mf_0_baseplate_mf_2_dev_mf_1_ui_mf_2_components__loadShare__.js-CtIleM_e.js} +4095 -2399
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_tanstack_mf_1_react_mf_2_router__loadShare__.js-DfiQqvVC.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__mf_owner__1__loadShare___mf_0_tanstack_mf_1_react_mf_2_router__loadShare__.js-BckLhSjF.js} +212 -57
- package/dist/web/assets/auth-DR6QxrAW.js +1 -0
- package/dist/web/assets/{common-iHaemino.js → common-BsyRiQi3.js} +6 -6
- package/dist/web/assets/{common-TDf_PrjX.js → common-CRwNlCMn.js} +10 -10
- package/dist/web/assets/{common-ByxS61u8.js → common-CvqlRZC9.js} +12 -12
- package/dist/web/assets/common-D3atSs7O.js +70 -0
- package/dist/web/assets/common-DuFyXa6l.js +36 -0
- package/dist/web/assets/common-islduJTj.js +43 -0
- package/dist/web/assets/{dist-CrLSslv6.js → dist-DQd1TAJX.js} +273 -132
- package/dist/web/assets/{get-auth-plugin-definition-kDCtXq_6.js → get-auth-plugin-definition-BgWWHl_Y.js} +3 -3
- package/dist/web/assets/{hostInit-Cruek6c6.js → hostInit-DNA4kLRY.js} +32 -5
- package/dist/web/assets/{mf-entry-bootstrap-0-dfed0275.js → mf-entry-bootstrap-0-ea77c09b.js} +2 -1
- package/dist/web/assets/{mf-entry-bootstrap-1-5275674a.js → mf-entry-bootstrap-1-9dee3d8d.js} +3 -2
- package/dist/web/assets/{mf-entry-bootstrap-2-39fb9255.js → mf-entry-bootstrap-2-3179040b.js} +3 -2
- package/dist/web/assets/{mf-entry-bootstrap-3-49e64336.js → mf-entry-bootstrap-3-370d200d.js} +3 -2
- package/dist/web/assets/{models-DSvs_3bA.js → models-BOeSYfRn.js} +4 -5
- package/dist/web/assets/{models-BZmCbizK.js → models-DF6DoXt6.js} +11 -6
- package/dist/web/assets/{plugin-definition-CYj29S3q.js → plugin-definition--k0VAeK3.js} +9 -10
- package/dist/web/assets/plugin-definition-CMwSlxsJ.js +10 -0
- package/dist/web/assets/{styles-yjbHBTlw.js → styles-BQEcQHoR.js} +9 -10
- package/dist/web/assets/{virtualExposes-CbPBmicF.js → virtualExposes-C7fDiAmS.js} +1 -1
- package/dist/web/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-BZBRyml2.js +747 -0
- package/dist/web/assets/{virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-B6BXIeF1.js → virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-6SjVUCs8.js} +13 -13
- package/dist/web/assets/web-8wz0ad-V.js +59 -0
- package/dist/web/assets/{web-CXAHKjIY.js → web-BGixH_gT.js} +27 -27
- package/dist/web/assets/{web-1eTcxMhf.js → web-BxIwkN3O.js} +6 -6
- package/dist/web/assets/{web-VqBA3jxZ.js → web-CQMfABjr.js} +24 -24
- package/dist/web/assets/{web-CDAKPPK9.js → web-CcNpItSu.js} +22 -22
- package/dist/web/assets/web-CypPeiVv.js +148 -0
- package/dist/web/assets/{web-D0MSKfyv.js → web-CzK_la2_.js} +53 -53
- package/dist/web/index.html +5 -5
- package/dist/web/remoteEntry.js +1 -1
- package/package.json +14 -14
- package/dist/local-auth/core/generators/auth-module/templates/module/utils/cookie-signer.d.ts +0 -38
- package/dist/local-auth/core/generators/auth-module/templates/module/utils/cookie-signer.js +0 -71
- package/dist/local-auth/core/generators/auth-module/templates/module/utils/cookie-signer.ts +0 -77
- 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-CO5Pvo0y.js +0 -384
- package/dist/web/assets/_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare__zod__loadShare__.js-BEZ7A-cz.js +0 -13566
- package/dist/web/assets/auth-BxAE0rgh.js +0 -1
- package/dist/web/assets/common-CKl_XlvH.js +0 -37
- package/dist/web/assets/common-UpVCKZeW.js +0 -41
- package/dist/web/assets/common-crSwCD36.js +0 -37
- package/dist/web/assets/model-utils-C0WDb_Ec.js +0 -1599
- package/dist/web/assets/plugin-definition-DOMmPL2Z.js +0 -11
- package/dist/web/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-XM6iYVxf.js +0 -259
- package/dist/web/assets/virtual_mf-exposes-ssr___mfe_internal__plugin-auth__remoteEntry_js-DGjg7Brm.js +0 -129
- package/dist/web/assets/web-DbeAaDTV.js +0 -118
- package/dist/web/assets/web-miDovYk_.js +0 -46
- package/dist/web/remoteEntry.ssr.js +0 -43
|
@@ -2,6 +2,38 @@ import { createTsTemplateFile } from '@baseplate-dev/core-generators';
|
|
|
2
2
|
import { apolloErrorImportsProvider, graphqlImportsProvider, reactComponentsImportsProvider, reactErrorImportsProvider, } from '@baseplate-dev/react-generators';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { reactSessionImportsProvider } from '#src/local-auth/core/generators/react-session/generated/ts-import-providers.js';
|
|
5
|
+
const acceptInvite = createTsTemplateFile({
|
|
6
|
+
fileOptions: { kind: 'singleton' },
|
|
7
|
+
importMapProviders: {
|
|
8
|
+
apolloErrorImports: apolloErrorImportsProvider,
|
|
9
|
+
graphqlImports: graphqlImportsProvider,
|
|
10
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
11
|
+
reactErrorImports: reactErrorImportsProvider,
|
|
12
|
+
reactSessionImports: reactSessionImportsProvider,
|
|
13
|
+
},
|
|
14
|
+
name: 'accept-invite',
|
|
15
|
+
referencedGeneratorTemplates: { constants: {} },
|
|
16
|
+
source: {
|
|
17
|
+
path: path.join(import.meta.dirname, '../templates/routes/auth_/accept-invite.tsx'),
|
|
18
|
+
},
|
|
19
|
+
variables: {},
|
|
20
|
+
});
|
|
21
|
+
const loginOtp = createTsTemplateFile({
|
|
22
|
+
fileOptions: { kind: 'singleton' },
|
|
23
|
+
importMapProviders: {
|
|
24
|
+
apolloErrorImports: apolloErrorImportsProvider,
|
|
25
|
+
graphqlImports: graphqlImportsProvider,
|
|
26
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
27
|
+
reactErrorImports: reactErrorImportsProvider,
|
|
28
|
+
reactSessionImports: reactSessionImportsProvider,
|
|
29
|
+
},
|
|
30
|
+
name: 'login-otp',
|
|
31
|
+
referencedGeneratorTemplates: { otpConstants: {} },
|
|
32
|
+
source: {
|
|
33
|
+
path: path.join(import.meta.dirname, '../templates/routes/auth_/login-otp.tsx'),
|
|
34
|
+
},
|
|
35
|
+
variables: {},
|
|
36
|
+
});
|
|
5
37
|
const constants = createTsTemplateFile({
|
|
6
38
|
fileOptions: { kind: 'singleton' },
|
|
7
39
|
group: 'main',
|
|
@@ -46,27 +78,7 @@ const login = createTsTemplateFile({
|
|
|
46
78
|
source: {
|
|
47
79
|
path: path.join(import.meta.dirname, '../templates/routes/auth_/login.tsx'),
|
|
48
80
|
},
|
|
49
|
-
variables: {},
|
|
50
|
-
});
|
|
51
|
-
const register = createTsTemplateFile({
|
|
52
|
-
fileOptions: { kind: 'singleton' },
|
|
53
|
-
group: 'main',
|
|
54
|
-
importMapProviders: {
|
|
55
|
-
apolloErrorImports: apolloErrorImportsProvider,
|
|
56
|
-
graphqlImports: graphqlImportsProvider,
|
|
57
|
-
reactComponentsImports: reactComponentsImportsProvider,
|
|
58
|
-
reactErrorImports: reactErrorImportsProvider,
|
|
59
|
-
reactSessionImports: reactSessionImportsProvider,
|
|
60
|
-
},
|
|
61
|
-
name: 'register',
|
|
62
|
-
source: {
|
|
63
|
-
path: path.join(import.meta.dirname, '../templates/routes/auth_/register.tsx'),
|
|
64
|
-
},
|
|
65
|
-
variables: {
|
|
66
|
-
TPL_NAME_FORM_CONTROL: {},
|
|
67
|
-
TPL_REGISTER_INPUT: {},
|
|
68
|
-
TPL_REGISTER_SCHEMA: {},
|
|
69
|
-
},
|
|
81
|
+
variables: { TPL_OTP_LOGIN_LINK: {}, TPL_REGISTER_LINK: {} },
|
|
70
82
|
});
|
|
71
83
|
const resetPassword = createTsTemplateFile({
|
|
72
84
|
fileOptions: { kind: 'singleton' },
|
|
@@ -98,10 +110,37 @@ export const mainGroup = {
|
|
|
98
110
|
constants,
|
|
99
111
|
forgotPassword,
|
|
100
112
|
login,
|
|
101
|
-
register,
|
|
102
113
|
resetPassword,
|
|
103
114
|
route,
|
|
104
115
|
};
|
|
116
|
+
const otpConstants = createTsTemplateFile({
|
|
117
|
+
fileOptions: { kind: 'singleton' },
|
|
118
|
+
importMapProviders: {},
|
|
119
|
+
name: 'otp-constants',
|
|
120
|
+
source: {
|
|
121
|
+
path: path.join(import.meta.dirname, '../templates/routes/auth_/-otp-constants.ts'),
|
|
122
|
+
},
|
|
123
|
+
variables: {},
|
|
124
|
+
});
|
|
125
|
+
const register = createTsTemplateFile({
|
|
126
|
+
fileOptions: { kind: 'singleton' },
|
|
127
|
+
importMapProviders: {
|
|
128
|
+
apolloErrorImports: apolloErrorImportsProvider,
|
|
129
|
+
graphqlImports: graphqlImportsProvider,
|
|
130
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
131
|
+
reactErrorImports: reactErrorImportsProvider,
|
|
132
|
+
reactSessionImports: reactSessionImportsProvider,
|
|
133
|
+
},
|
|
134
|
+
name: 'register',
|
|
135
|
+
source: {
|
|
136
|
+
path: path.join(import.meta.dirname, '../templates/routes/auth_/register.tsx'),
|
|
137
|
+
},
|
|
138
|
+
variables: {
|
|
139
|
+
TPL_NAME_FORM_CONTROL: {},
|
|
140
|
+
TPL_REGISTER_INPUT: {},
|
|
141
|
+
TPL_REGISTER_SCHEMA: {},
|
|
142
|
+
},
|
|
143
|
+
});
|
|
105
144
|
const verifyEmail = createTsTemplateFile({
|
|
106
145
|
fileOptions: { kind: 'singleton' },
|
|
107
146
|
importMapProviders: {
|
|
@@ -116,5 +155,12 @@ const verifyEmail = createTsTemplateFile({
|
|
|
116
155
|
},
|
|
117
156
|
variables: {},
|
|
118
157
|
});
|
|
119
|
-
export const AUTH_CORE_AUTH_ROUTES_TEMPLATES = {
|
|
158
|
+
export const AUTH_CORE_AUTH_ROUTES_TEMPLATES = {
|
|
159
|
+
acceptInvite,
|
|
160
|
+
loginOtp,
|
|
161
|
+
mainGroup,
|
|
162
|
+
otpConstants,
|
|
163
|
+
register,
|
|
164
|
+
verifyEmail,
|
|
165
|
+
};
|
|
120
166
|
//# sourceMappingURL=typed-templates.js.map
|
package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Number of digits in an emailed sign-in code (matches backend validation)
|
|
3
|
+
*/
|
|
4
|
+
export declare const EMAIL_OTP_LENGTH = 6;
|
|
5
|
+
/**
|
|
6
|
+
* Seconds to wait before another sign-in code can be requested
|
|
7
|
+
*/
|
|
8
|
+
export declare const EMAIL_OTP_RESEND_COOLDOWN_SEC = 60;
|
|
9
|
+
//# sourceMappingURL=-otp-constants.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Number of digits in an emailed sign-in code (matches backend validation)
|
|
4
|
+
*/
|
|
5
|
+
export const EMAIL_OTP_LENGTH = 6;
|
|
6
|
+
/**
|
|
7
|
+
* Seconds to wait before another sign-in code can be requested
|
|
8
|
+
*/
|
|
9
|
+
export const EMAIL_OTP_RESEND_COOLDOWN_SEC = 60;
|
|
10
|
+
//# sourceMappingURL=-otp-constants.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Number of digits in an emailed sign-in code (matches backend validation)
|
|
5
|
+
*/
|
|
6
|
+
export const EMAIL_OTP_LENGTH = 6;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Seconds to wait before another sign-in code can be requested
|
|
10
|
+
*/
|
|
11
|
+
export const EMAIL_OTP_RESEND_COOLDOWN_SEC = 60;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Route: import("@tanstack/router-core").Route<import("@tanstack/react-router").Register, never, never, never, never, never, z.ZodObject<{
|
|
3
|
+
token: z.ZodOptional<z.ZodString>;
|
|
4
|
+
}, z.core.$strip>, import("@tanstack/react-router").ResolveParams<never>, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, ({ search: { token }, context: { userId } }: import("@tanstack/react-router").BeforeLoadContextOptions<import("@tanstack/react-router").Register, never, z.ZodObject<{
|
|
5
|
+
token: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strip>, import("@tanstack/react-router").ResolveParams<never>, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, never, unknown, undefined>) => void, {}, undefined, unknown, unknown, unknown, unknown, undefined>;
|
|
7
|
+
//# sourceMappingURL=accept-invite.d.ts.map
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import { PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH } from '$constants';
|
|
4
|
+
import { getApolloErrorCode } from '%apolloErrorImports';
|
|
5
|
+
import { graphql } from '%graphqlImports';
|
|
6
|
+
import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, InputFieldController, toast, } from '%reactComponentsImports';
|
|
7
|
+
import { logAndFormatError, logError } from '%reactErrorImports';
|
|
8
|
+
import { userSessionClient } from '%reactSessionImports';
|
|
9
|
+
import { useMutation } from '@apollo/client/react';
|
|
10
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
11
|
+
import { createFileRoute, Link, redirect, useNavigate, } from '@tanstack/react-router';
|
|
12
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
13
|
+
import { useForm } from 'react-hook-form';
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
export const Route = createFileRoute('/auth_/accept-invite')({
|
|
16
|
+
validateSearch: z.object({
|
|
17
|
+
token: z.string().optional(),
|
|
18
|
+
}),
|
|
19
|
+
component: AcceptInvitePage,
|
|
20
|
+
beforeLoad: ({ search: { token }, context: { userId } }) => {
|
|
21
|
+
if (userId) {
|
|
22
|
+
throw redirect({ to: '/' });
|
|
23
|
+
}
|
|
24
|
+
if (!token) {
|
|
25
|
+
throw redirect({ to: '/auth/login' });
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
const formSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
newPassword: z
|
|
32
|
+
.string()
|
|
33
|
+
.min(PASSWORD_MIN_LENGTH, `Password must be at least ${PASSWORD_MIN_LENGTH} characters`)
|
|
34
|
+
.max(PASSWORD_MAX_LENGTH),
|
|
35
|
+
confirmPassword: z.string(),
|
|
36
|
+
})
|
|
37
|
+
.refine((data) => data.newPassword === data.confirmPassword, {
|
|
38
|
+
message: 'Passwords do not match',
|
|
39
|
+
path: ['confirmPassword'],
|
|
40
|
+
});
|
|
41
|
+
const validateInviteTokenMutation = graphql(`
|
|
42
|
+
mutation ValidateInviteToken($input: ValidateInviteTokenInput!) {
|
|
43
|
+
validateInviteToken(input: $input) {
|
|
44
|
+
email
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`);
|
|
48
|
+
const acceptInviteMutation = graphql(`
|
|
49
|
+
mutation AcceptInvite($input: AcceptInviteInput!) {
|
|
50
|
+
acceptInvite(input: $input) {
|
|
51
|
+
session {
|
|
52
|
+
userId
|
|
53
|
+
roles
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`);
|
|
58
|
+
function AcceptInvitePage() {
|
|
59
|
+
const { token } = Route.useSearch();
|
|
60
|
+
const navigate = useNavigate();
|
|
61
|
+
const [tokenValid, setTokenValid] = useState(null);
|
|
62
|
+
const [email, setEmail] = useState(null);
|
|
63
|
+
const [validationError, setValidationError] = useState(null);
|
|
64
|
+
const [validateInviteToken] = useMutation(validateInviteTokenMutation);
|
|
65
|
+
const [acceptInvite, { loading }] = useMutation(acceptInviteMutation);
|
|
66
|
+
const { control, handleSubmit } = useForm({
|
|
67
|
+
resolver: zodResolver(formSchema),
|
|
68
|
+
reValidateMode: 'onBlur',
|
|
69
|
+
});
|
|
70
|
+
const runTokenValidation = useCallback(() => {
|
|
71
|
+
if (!token)
|
|
72
|
+
return;
|
|
73
|
+
setTokenValid(null);
|
|
74
|
+
setValidationError(null);
|
|
75
|
+
validateInviteToken({
|
|
76
|
+
variables: { input: { token } },
|
|
77
|
+
})
|
|
78
|
+
.then(({ data }) => {
|
|
79
|
+
setTokenValid(true);
|
|
80
|
+
setEmail(data?.validateInviteToken.email ?? null);
|
|
81
|
+
})
|
|
82
|
+
.catch((err) => {
|
|
83
|
+
const errorCode = getApolloErrorCode(err, ['invalid-token']);
|
|
84
|
+
switch (errorCode) {
|
|
85
|
+
case 'invalid-token': {
|
|
86
|
+
setTokenValid(false);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case null: {
|
|
90
|
+
setValidationError(logAndFormatError(err, 'Sorry, we could not validate your invite link.'));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}, [token, validateInviteToken]);
|
|
95
|
+
// Validate token on mount
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
runTokenValidation();
|
|
98
|
+
}, [runTokenValidation]);
|
|
99
|
+
const onSubmit = (data) => {
|
|
100
|
+
if (!token)
|
|
101
|
+
return;
|
|
102
|
+
acceptInvite({
|
|
103
|
+
variables: {
|
|
104
|
+
input: {
|
|
105
|
+
token,
|
|
106
|
+
newPassword: data.newPassword,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
.then(({ data }) => {
|
|
111
|
+
if (!data) {
|
|
112
|
+
throw new Error('No data returned from accept invite mutation');
|
|
113
|
+
}
|
|
114
|
+
const { userId, roles } = data.acceptInvite.session;
|
|
115
|
+
userSessionClient.signIn(userId, roles);
|
|
116
|
+
navigate({ to: '/', replace: true }).catch(logError);
|
|
117
|
+
})
|
|
118
|
+
.catch((err) => {
|
|
119
|
+
const errorCode = getApolloErrorCode(err, [
|
|
120
|
+
'invalid-token',
|
|
121
|
+
'user-already-has-account',
|
|
122
|
+
]);
|
|
123
|
+
switch (errorCode) {
|
|
124
|
+
case 'invalid-token': {
|
|
125
|
+
setTokenValid(false);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case 'user-already-has-account': {
|
|
129
|
+
toast.error('You already have a password set. Please sign in instead.');
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case null: {
|
|
133
|
+
toast.error(logAndFormatError(err, 'Sorry, we could not accept your invite.'));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
// Loading state
|
|
139
|
+
if (tokenValid === null && !validationError) {
|
|
140
|
+
return (_jsx(Card, { children: _jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Validating..." }), _jsx(CardDescription, { children: "Please wait while we verify your invite link." })] }) }));
|
|
141
|
+
}
|
|
142
|
+
// Validation error state (transient failures, not invalid token)
|
|
143
|
+
if (validationError) {
|
|
144
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Something Went Wrong" }), _jsx(CardDescription, { children: validationError })] }), _jsx(CardContent, { children: _jsx(Button, { variant: "secondary", className: "w-full", onClick: runTokenValidation, children: "Try Again" }) })] }));
|
|
145
|
+
}
|
|
146
|
+
// Invalid token state
|
|
147
|
+
if (!tokenValid) {
|
|
148
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Invalid or Expired Invite" }), _jsx(CardDescription, { children: "This invite link is invalid or has expired. Please ask an admin to send you a new one." })] }), _jsx(CardContent, { children: _jsx(Link, { to: "/auth/login", children: _jsx(Button, { variant: "secondary", className: "w-full", children: "Back to Login" }) }) })] }));
|
|
149
|
+
}
|
|
150
|
+
// Set password form
|
|
151
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Set your password" }), _jsx(CardDescription, { children: email
|
|
152
|
+
? `Choose a password to finish setting up ${email}.`
|
|
153
|
+
: 'Choose a password to finish setting up your account.' })] }), _jsx(CardContent, { children: _jsx("form", { onSubmit: handleSubmit(onSubmit), children: _jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(InputFieldController, { control: control, name: "newPassword", label: "Password", type: "password", autoComplete: "new-password", placeholder: "Enter a password" }), _jsx(InputFieldController, { control: control, name: "confirmPassword", label: "Confirm Password", type: "password", autoComplete: "new-password", placeholder: "Confirm your password" }), _jsx(Button, { type: "submit", className: "w-full", disabled: loading, children: "Get Started" })] }) }) })] }));
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=accept-invite.js.map
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
import { PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH } from '$constants';
|
|
4
|
+
import { getApolloErrorCode } from '%apolloErrorImports';
|
|
5
|
+
import { graphql } from '%graphqlImports';
|
|
6
|
+
import {
|
|
7
|
+
Button,
|
|
8
|
+
Card,
|
|
9
|
+
CardContent,
|
|
10
|
+
CardDescription,
|
|
11
|
+
CardHeader,
|
|
12
|
+
CardTitle,
|
|
13
|
+
InputFieldController,
|
|
14
|
+
toast,
|
|
15
|
+
} from '%reactComponentsImports';
|
|
16
|
+
import { logAndFormatError, logError } from '%reactErrorImports';
|
|
17
|
+
import { userSessionClient } from '%reactSessionImports';
|
|
18
|
+
import { useMutation } from '@apollo/client/react';
|
|
19
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
20
|
+
import {
|
|
21
|
+
createFileRoute,
|
|
22
|
+
Link,
|
|
23
|
+
redirect,
|
|
24
|
+
useNavigate,
|
|
25
|
+
} from '@tanstack/react-router';
|
|
26
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
27
|
+
import { useForm } from 'react-hook-form';
|
|
28
|
+
import { z } from 'zod';
|
|
29
|
+
|
|
30
|
+
export const Route = createFileRoute('/auth_/accept-invite')({
|
|
31
|
+
validateSearch: z.object({
|
|
32
|
+
token: z.string().optional(),
|
|
33
|
+
}),
|
|
34
|
+
component: AcceptInvitePage,
|
|
35
|
+
beforeLoad: ({ search: { token }, context: { userId } }) => {
|
|
36
|
+
if (userId) {
|
|
37
|
+
throw redirect({ to: '/' });
|
|
38
|
+
}
|
|
39
|
+
if (!token) {
|
|
40
|
+
throw redirect({ to: '/auth/login' });
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const formSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
newPassword: z
|
|
48
|
+
.string()
|
|
49
|
+
.min(
|
|
50
|
+
PASSWORD_MIN_LENGTH,
|
|
51
|
+
`Password must be at least ${PASSWORD_MIN_LENGTH} characters`,
|
|
52
|
+
)
|
|
53
|
+
.max(PASSWORD_MAX_LENGTH),
|
|
54
|
+
confirmPassword: z.string(),
|
|
55
|
+
})
|
|
56
|
+
.refine((data) => data.newPassword === data.confirmPassword, {
|
|
57
|
+
message: 'Passwords do not match',
|
|
58
|
+
path: ['confirmPassword'],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
type FormData = z.infer<typeof formSchema>;
|
|
62
|
+
|
|
63
|
+
const validateInviteTokenMutation = graphql(`
|
|
64
|
+
mutation ValidateInviteToken($input: ValidateInviteTokenInput!) {
|
|
65
|
+
validateInviteToken(input: $input) {
|
|
66
|
+
email
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`);
|
|
70
|
+
|
|
71
|
+
const acceptInviteMutation = graphql(`
|
|
72
|
+
mutation AcceptInvite($input: AcceptInviteInput!) {
|
|
73
|
+
acceptInvite(input: $input) {
|
|
74
|
+
session {
|
|
75
|
+
userId
|
|
76
|
+
roles
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`);
|
|
81
|
+
|
|
82
|
+
function AcceptInvitePage(): React.JSX.Element {
|
|
83
|
+
const { token } = Route.useSearch();
|
|
84
|
+
const navigate = useNavigate();
|
|
85
|
+
const [tokenValid, setTokenValid] = useState<boolean | null>(null);
|
|
86
|
+
const [email, setEmail] = useState<string | null>(null);
|
|
87
|
+
const [validationError, setValidationError] = useState<string | null>(null);
|
|
88
|
+
|
|
89
|
+
const [validateInviteToken] = useMutation(validateInviteTokenMutation);
|
|
90
|
+
const [acceptInvite, { loading }] = useMutation(acceptInviteMutation);
|
|
91
|
+
|
|
92
|
+
const { control, handleSubmit } = useForm<FormData>({
|
|
93
|
+
resolver: zodResolver(formSchema),
|
|
94
|
+
reValidateMode: 'onBlur',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const runTokenValidation = useCallback(() => {
|
|
98
|
+
if (!token) return;
|
|
99
|
+
|
|
100
|
+
setTokenValid(null);
|
|
101
|
+
setValidationError(null);
|
|
102
|
+
|
|
103
|
+
validateInviteToken({
|
|
104
|
+
variables: { input: { token } },
|
|
105
|
+
})
|
|
106
|
+
.then(({ data }) => {
|
|
107
|
+
setTokenValid(true);
|
|
108
|
+
setEmail(data?.validateInviteToken.email ?? null);
|
|
109
|
+
})
|
|
110
|
+
.catch((err: unknown) => {
|
|
111
|
+
const errorCode = getApolloErrorCode(err, ['invalid-token'] as const);
|
|
112
|
+
switch (errorCode) {
|
|
113
|
+
case 'invalid-token': {
|
|
114
|
+
setTokenValid(false);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case null: {
|
|
118
|
+
setValidationError(
|
|
119
|
+
logAndFormatError(
|
|
120
|
+
err,
|
|
121
|
+
'Sorry, we could not validate your invite link.',
|
|
122
|
+
),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}, [token, validateInviteToken]);
|
|
128
|
+
|
|
129
|
+
// Validate token on mount
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
runTokenValidation();
|
|
132
|
+
}, [runTokenValidation]);
|
|
133
|
+
|
|
134
|
+
const onSubmit = (data: FormData): void => {
|
|
135
|
+
if (!token) return;
|
|
136
|
+
|
|
137
|
+
acceptInvite({
|
|
138
|
+
variables: {
|
|
139
|
+
input: {
|
|
140
|
+
token,
|
|
141
|
+
newPassword: data.newPassword,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
})
|
|
145
|
+
.then(({ data }) => {
|
|
146
|
+
if (!data) {
|
|
147
|
+
throw new Error('No data returned from accept invite mutation');
|
|
148
|
+
}
|
|
149
|
+
const { userId, roles } = data.acceptInvite.session;
|
|
150
|
+
userSessionClient.signIn(userId, roles);
|
|
151
|
+
|
|
152
|
+
navigate({ to: '/', replace: true }).catch(logError);
|
|
153
|
+
})
|
|
154
|
+
.catch((err: unknown) => {
|
|
155
|
+
const errorCode = getApolloErrorCode(err, [
|
|
156
|
+
'invalid-token',
|
|
157
|
+
'user-already-has-account',
|
|
158
|
+
] as const);
|
|
159
|
+
switch (errorCode) {
|
|
160
|
+
case 'invalid-token': {
|
|
161
|
+
setTokenValid(false);
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case 'user-already-has-account': {
|
|
165
|
+
toast.error(
|
|
166
|
+
'You already have a password set. Please sign in instead.',
|
|
167
|
+
);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
case null: {
|
|
171
|
+
toast.error(
|
|
172
|
+
logAndFormatError(err, 'Sorry, we could not accept your invite.'),
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Loading state
|
|
180
|
+
if (tokenValid === null && !validationError) {
|
|
181
|
+
return (
|
|
182
|
+
<Card>
|
|
183
|
+
<CardHeader>
|
|
184
|
+
<CardTitle>Validating...</CardTitle>
|
|
185
|
+
<CardDescription>
|
|
186
|
+
Please wait while we verify your invite link.
|
|
187
|
+
</CardDescription>
|
|
188
|
+
</CardHeader>
|
|
189
|
+
</Card>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Validation error state (transient failures, not invalid token)
|
|
194
|
+
if (validationError) {
|
|
195
|
+
return (
|
|
196
|
+
<Card>
|
|
197
|
+
<CardHeader>
|
|
198
|
+
<CardTitle>Something Went Wrong</CardTitle>
|
|
199
|
+
<CardDescription>{validationError}</CardDescription>
|
|
200
|
+
</CardHeader>
|
|
201
|
+
<CardContent>
|
|
202
|
+
<Button
|
|
203
|
+
variant="secondary"
|
|
204
|
+
className="w-full"
|
|
205
|
+
onClick={runTokenValidation}
|
|
206
|
+
>
|
|
207
|
+
Try Again
|
|
208
|
+
</Button>
|
|
209
|
+
</CardContent>
|
|
210
|
+
</Card>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Invalid token state
|
|
215
|
+
if (!tokenValid) {
|
|
216
|
+
return (
|
|
217
|
+
<Card>
|
|
218
|
+
<CardHeader>
|
|
219
|
+
<CardTitle>Invalid or Expired Invite</CardTitle>
|
|
220
|
+
<CardDescription>
|
|
221
|
+
This invite link is invalid or has expired. Please ask an admin to
|
|
222
|
+
send you a new one.
|
|
223
|
+
</CardDescription>
|
|
224
|
+
</CardHeader>
|
|
225
|
+
<CardContent>
|
|
226
|
+
<Link to="/auth/login">
|
|
227
|
+
<Button variant="secondary" className="w-full">
|
|
228
|
+
Back to Login
|
|
229
|
+
</Button>
|
|
230
|
+
</Link>
|
|
231
|
+
</CardContent>
|
|
232
|
+
</Card>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Set password form
|
|
237
|
+
return (
|
|
238
|
+
<Card>
|
|
239
|
+
<CardHeader>
|
|
240
|
+
<CardTitle>Set your password</CardTitle>
|
|
241
|
+
<CardDescription>
|
|
242
|
+
{email
|
|
243
|
+
? `Choose a password to finish setting up ${email}.`
|
|
244
|
+
: 'Choose a password to finish setting up your account.'}
|
|
245
|
+
</CardDescription>
|
|
246
|
+
</CardHeader>
|
|
247
|
+
<CardContent>
|
|
248
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
249
|
+
<div className="flex flex-col gap-6">
|
|
250
|
+
<InputFieldController
|
|
251
|
+
control={control}
|
|
252
|
+
name="newPassword"
|
|
253
|
+
label="Password"
|
|
254
|
+
type="password"
|
|
255
|
+
autoComplete="new-password"
|
|
256
|
+
placeholder="Enter a password"
|
|
257
|
+
/>
|
|
258
|
+
<InputFieldController
|
|
259
|
+
control={control}
|
|
260
|
+
name="confirmPassword"
|
|
261
|
+
label="Confirm Password"
|
|
262
|
+
type="password"
|
|
263
|
+
autoComplete="new-password"
|
|
264
|
+
placeholder="Confirm your password"
|
|
265
|
+
/>
|
|
266
|
+
<Button type="submit" className="w-full" disabled={loading}>
|
|
267
|
+
Get Started
|
|
268
|
+
</Button>
|
|
269
|
+
</div>
|
|
270
|
+
</form>
|
|
271
|
+
</CardContent>
|
|
272
|
+
</Card>
|
|
273
|
+
);
|
|
274
|
+
}
|
package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/forgot-password.js
CHANGED
|
@@ -2,14 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
// @ts-nocheck
|
|
3
3
|
import { PASSWORD_MAX_LENGTH } from '$constants';
|
|
4
4
|
import { graphql } from '%graphqlImports';
|
|
5
|
-
import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, InputFieldController, } from '%reactComponentsImports';
|
|
5
|
+
import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, InputFieldController, toast, } from '%reactComponentsImports';
|
|
6
6
|
import { logAndFormatError } from '%reactErrorImports';
|
|
7
7
|
import { useMutation } from '@apollo/client/react';
|
|
8
8
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
9
9
|
import { createFileRoute, Link, redirect } from '@tanstack/react-router';
|
|
10
10
|
import { useState } from 'react';
|
|
11
11
|
import { useForm } from 'react-hook-form';
|
|
12
|
-
import { toast } from 'sonner';
|
|
13
12
|
import { z } from 'zod';
|
|
14
13
|
export const Route = createFileRoute('/auth_/forgot-password')({
|
|
15
14
|
component: ForgotPasswordPage,
|
package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/forgot-password.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
CardHeader,
|
|
11
11
|
CardTitle,
|
|
12
12
|
InputFieldController,
|
|
13
|
+
toast,
|
|
13
14
|
} from '%reactComponentsImports';
|
|
14
15
|
import { logAndFormatError } from '%reactErrorImports';
|
|
15
16
|
import { useMutation } from '@apollo/client/react';
|
|
@@ -17,7 +18,6 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
|
|
17
18
|
import { createFileRoute, Link, redirect } from '@tanstack/react-router';
|
|
18
19
|
import { useState } from 'react';
|
|
19
20
|
import { useForm } from 'react-hook-form';
|
|
20
|
-
import { toast } from 'sonner';
|
|
21
21
|
import { z } from 'zod';
|
|
22
22
|
|
|
23
23
|
export const Route = createFileRoute('/auth_/forgot-password')({
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Route: import("@tanstack/router-core").Route<import("@tanstack/react-router").Register, never, never, never, never, never, z.ZodObject<{
|
|
3
|
+
return_to: z.ZodOptional<z.ZodString>;
|
|
4
|
+
}, z.core.$strip>, import("@tanstack/react-router").ResolveParams<never>, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, ({ search: { return_to }, context: { userId } }: import("@tanstack/react-router").BeforeLoadContextOptions<import("@tanstack/react-router").Register, never, z.ZodObject<{
|
|
5
|
+
return_to: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strip>, import("@tanstack/react-router").ResolveParams<never>, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, never, unknown, undefined>) => void, {}, undefined, unknown, unknown, unknown, unknown, undefined>;
|
|
7
|
+
//# sourceMappingURL=login-otp.d.ts.map
|