@baseplate-dev/plugin-auth 0.6.18 → 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 +34 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +62 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +62 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +31 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +31 -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 +62 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +62 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +31 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +62 -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 +31 -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 +31 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/index.d.ts +186 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-renderers.d.ts +31 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/typed-templates.d.ts +310 -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 +65 -2
- package/dist/better-auth/generators/react/react-better-auth/generated/template-renderers.d.ts +32 -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 +32 -1
- package/dist/better-auth/generators/react/react-better-auth/react-better-auth.generator.d.ts +32 -1
- package/dist/better-auth/generators/react/react-better-auth/templates/src/app/auth-loaded-gate.tsx +12 -3
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/admin-crud-invite-user-action.generator.d.ts +62 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/index.d.ts +62 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-renderers.d.ts +31 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/typed-templates.d.ts +31 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.js +1 -2
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.tsx +1 -1
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +62 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +62 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +31 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +31 -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 +62 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +62 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +31 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +62 -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 +31 -0
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.d.ts +10 -7
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.js +8 -11
- package/dist/local-auth/core/generators/auth-email-password/generated/index.d.ts +40 -13
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.d.ts +9 -0
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.js +6 -5
- 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 +40 -16
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.js +11 -8
- 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.js +17 -13
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/invite.service.ts +25 -13
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.js +2 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.ts +5 -3
- 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 +19 -7
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.js +3 -26
- package/dist/local-auth/core/generators/auth-module/generated/index.d.ts +48 -7
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.d.ts +0 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.js +0 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.d.ts +19 -1
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.js +7 -3
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.d.ts +1 -0
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.js +1 -0
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.d.ts +28 -7
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.js +5 -14
- package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.d.ts +7 -6
- package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.js +23 -17
- package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.ts +25 -18
- 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 +31 -0
- package/dist/local-auth/core/generators/auth-routes/generated/index.d.ts +249 -0
- package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.d.ts +31 -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 +310 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.js +12 -5
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.tsx +14 -4
- 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.js +4 -4
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login-otp.tsx +4 -3
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js +4 -4
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.tsx +4 -3
- 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 +78 -7
- package/dist/local-auth/core/generators/react-session/generated/template-renderers.d.ts +32 -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 +90 -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 +48 -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 +7 -7
- 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__mf_owner__1-CKKmnLep.js → _virtual_mf-localSharedImportMap___mfe_internal__plugin_mf_2_auth__mf_owner__1-DUupKqD4.js} +14 -14
- package/dist/web/assets/{_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-Cx7TvZ_H.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} +198 -66
- package/dist/web/assets/{_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-D3Nvasea.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} +1 -1
- package/dist/web/assets/{_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-C2GDE8Py.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} +2517 -1545
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__mf_owner__1__loadShare___mf_0_tanstack_mf_1_react_mf_2_router__loadShare__.js-CiccpWjh.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} +2 -2
- package/dist/web/assets/auth-DR6QxrAW.js +1 -0
- package/dist/web/assets/{common-CoLuMS7U.js → common-BsyRiQi3.js} +6 -6
- package/dist/web/assets/{common-N3skPbzk.js → common-CRwNlCMn.js} +10 -10
- package/dist/web/assets/{common-Co5lW_TK.js → common-CvqlRZC9.js} +12 -12
- package/dist/web/assets/{common-C8_sC5pp.js → common-D3atSs7O.js} +15 -15
- package/dist/web/assets/common-DuFyXa6l.js +36 -0
- package/dist/web/assets/common-islduJTj.js +43 -0
- package/dist/web/assets/{get-auth-plugin-definition-DyokUVjX.js → get-auth-plugin-definition-BgWWHl_Y.js} +3 -3
- package/dist/web/assets/{hostInit-BCYmw0H5.js → hostInit-DNA4kLRY.js} +1 -1
- package/dist/web/assets/{mf-entry-bootstrap-0-3ede9334.js → mf-entry-bootstrap-0-ea77c09b.js} +1 -1
- package/dist/web/assets/{mf-entry-bootstrap-1-3da85eea.js → mf-entry-bootstrap-1-9dee3d8d.js} +2 -2
- package/dist/web/assets/{mf-entry-bootstrap-2-32e24e11.js → mf-entry-bootstrap-2-3179040b.js} +1 -1
- package/dist/web/assets/{mf-entry-bootstrap-3-a3cfea9d.js → mf-entry-bootstrap-3-370d200d.js} +2 -2
- package/dist/web/assets/{models-BcPOQC5p.js → models-BOeSYfRn.js} +4 -4
- package/dist/web/assets/{models-BcUgOGGn.js → models-DF6DoXt6.js} +4 -4
- package/dist/web/assets/{plugin-definition-D1EImXIf.js → plugin-definition--k0VAeK3.js} +9 -9
- package/dist/web/assets/{plugin-definition-lw-gB4hU.js → plugin-definition-CMwSlxsJ.js} +3 -3
- package/dist/web/assets/{styles-EOyEbGA4.js → styles-BQEcQHoR.js} +8 -8
- package/dist/web/assets/{virtualExposes-DWORnjyA.js → virtualExposes-C7fDiAmS.js} +1 -1
- package/dist/web/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-t-KnBiUh.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-BZBRyml2.js} +3 -3
- package/dist/web/assets/{virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-DZfE3QCR.js → virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-6SjVUCs8.js} +13 -13
- package/dist/web/assets/{web-kaD9AzNS.js → web-8wz0ad-V.js} +8 -8
- package/dist/web/assets/{web-EDeSquSP.js → web-BGixH_gT.js} +19 -19
- package/dist/web/assets/{web-PqAcfBSy.js → web-BxIwkN3O.js} +7 -7
- package/dist/web/assets/{web-CBVepebK.js → web-CQMfABjr.js} +19 -19
- package/dist/web/assets/{web-RhChfBw_.js → web-CcNpItSu.js} +17 -17
- package/dist/web/assets/{web-xJ-GnSkC.js → web-CypPeiVv.js} +25 -25
- package/dist/web/assets/{web-Dgb85jhs.js → web-CzK_la2_.js} +41 -41
- package/dist/web/index.html +4 -4
- package/dist/web/remoteEntry.js +1 -1
- package/package.json +12 -12
- 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/auth-CsHp2bQi.js +0 -1
- package/dist/web/assets/common-BGTuTgx7.js +0 -43
- package/dist/web/assets/common-Dueu_1NG.js +0 -36
package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.js
CHANGED
|
@@ -1,103 +1,119 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { getSafeLocalStorage } from '%reactUtilsImports';
|
|
3
|
+
const USER_ID_STORAGE_KEY = 'APP_USER_ID';
|
|
4
|
+
const PUBLIC_SESSION = {
|
|
5
|
+
userId: undefined,
|
|
6
|
+
isAuthenticated: false,
|
|
7
|
+
roles: ['public'],
|
|
8
|
+
isPending: false,
|
|
9
|
+
};
|
|
10
|
+
function areSessionsEqual(a, b) {
|
|
11
|
+
return (a.userId === b.userId &&
|
|
12
|
+
a.isPending === b.isPending &&
|
|
13
|
+
a.roles.length === b.roles.length &&
|
|
14
|
+
a.roles.every((role, idx) => role === b.roles[idx]));
|
|
15
|
+
}
|
|
3
16
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
17
|
+
* Creates the client-side source of truth for the current user session.
|
|
18
|
+
*
|
|
19
|
+
* The session is published synchronously when it is known locally (sign in / sign
|
|
20
|
+
* out) and refined asynchronously when the server confirms it. It is deliberately
|
|
21
|
+
* not derived from the Apollo cache, since signing in clears that cache.
|
|
22
|
+
*
|
|
23
|
+
* The user ID is persisted to localStorage for cold starts and cross-tab
|
|
24
|
+
* synchronisation. Roles are never persisted — they are only ever trusted from the
|
|
25
|
+
* server, and are enforced there regardless.
|
|
6
26
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
constructor() {
|
|
13
|
-
// Initialize storage listener for cross-tab synchronization
|
|
14
|
-
this.setupStorageListener();
|
|
27
|
+
export function createUserSessionClient() {
|
|
28
|
+
const storage = getSafeLocalStorage();
|
|
29
|
+
const callbacks = new Set();
|
|
30
|
+
function getPersistedUserId() {
|
|
31
|
+
return storage.getItem(USER_ID_STORAGE_KEY) ?? undefined;
|
|
15
32
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
33
|
+
// A persisted user ID means we expect a session, so hold off publishing until the
|
|
34
|
+
// server confirms it. With no persisted user ID there is nothing to wait for and
|
|
35
|
+
// the public session can be published immediately.
|
|
36
|
+
let session = getPersistedUserId()
|
|
37
|
+
? undefined
|
|
38
|
+
: PUBLIC_SESSION;
|
|
39
|
+
function publish(newSession) {
|
|
40
|
+
if (session && areSessionsEqual(session, newSession)) {
|
|
41
|
+
return;
|
|
25
42
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
signOut() {
|
|
31
|
-
const existingUserId = this.getUserId();
|
|
32
|
-
this.setUserId(null);
|
|
33
|
-
if (existingUserId) {
|
|
34
|
-
this.notifyCallbacks();
|
|
43
|
+
session = newSession;
|
|
44
|
+
for (const callback of callbacks) {
|
|
45
|
+
callback();
|
|
35
46
|
}
|
|
36
47
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* @param callback - Function to call when user ID changes
|
|
40
|
-
* @returns Cleanup function to unsubscribe
|
|
41
|
-
*/
|
|
42
|
-
onUserIdChange(callback) {
|
|
43
|
-
this.callbacks.add(callback);
|
|
44
|
-
return () => {
|
|
45
|
-
this.callbacks.delete(callback);
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Clean up resources when the client is no longer needed
|
|
50
|
-
*/
|
|
51
|
-
destroy() {
|
|
52
|
-
this.cleanupListener?.();
|
|
53
|
-
this.callbacks.clear();
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Get the current user ID from storage
|
|
57
|
-
* @returns User ID or null if not authenticated
|
|
58
|
-
*/
|
|
59
|
-
getUserId() {
|
|
60
|
-
return (this.storage.getItem(UserSessionClient.USER_ID_STORAGE_KEY) ?? undefined);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Set the user ID in storage
|
|
64
|
-
* @param userId - User ID to store, or null to clear
|
|
65
|
-
*/
|
|
66
|
-
setUserId(userId) {
|
|
67
|
-
const currentUserId = this.getUserId();
|
|
68
|
-
const userIdChanged = userId !== currentUserId;
|
|
69
|
-
if (!userIdChanged) {
|
|
48
|
+
function persistUserId(userId) {
|
|
49
|
+
if (userId === getPersistedUserId()) {
|
|
70
50
|
return;
|
|
71
51
|
}
|
|
72
52
|
if (userId) {
|
|
73
|
-
|
|
53
|
+
storage.setItem(USER_ID_STORAGE_KEY, userId);
|
|
74
54
|
}
|
|
75
55
|
else {
|
|
76
|
-
|
|
56
|
+
storage.removeItem(USER_ID_STORAGE_KEY);
|
|
77
57
|
}
|
|
78
58
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.notifyCallbacks();
|
|
86
|
-
}
|
|
59
|
+
function signIn(userId, roles) {
|
|
60
|
+
publish({
|
|
61
|
+
userId,
|
|
62
|
+
isAuthenticated: true,
|
|
63
|
+
roles,
|
|
64
|
+
isPending: false,
|
|
87
65
|
});
|
|
66
|
+
persistUserId(userId);
|
|
88
67
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
notifyCallbacks() {
|
|
93
|
-
const userId = this.getUserId();
|
|
94
|
-
for (const callback of this.callbacks) {
|
|
95
|
-
callback(userId);
|
|
96
|
-
}
|
|
68
|
+
function signOut() {
|
|
69
|
+
publish(PUBLIC_SESSION);
|
|
70
|
+
persistUserId(undefined);
|
|
97
71
|
}
|
|
72
|
+
const cleanupListener = storage.addEventListener((key, newValue) => {
|
|
73
|
+
if (key !== USER_ID_STORAGE_KEY) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const userId = newValue ?? undefined;
|
|
77
|
+
// Writes from this tab publish the session themselves before persisting it, so
|
|
78
|
+
// anything already matching is our own write echoing back. A session that is
|
|
79
|
+
// not known yet never matches, since no session has been published.
|
|
80
|
+
if (session && userId === session.userId) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Another tab changed the identity. Publish it right away so we never render
|
|
84
|
+
// one user's identity with another's data, with roles marked pending until the
|
|
85
|
+
// server confirms them.
|
|
86
|
+
publish(userId
|
|
87
|
+
? { userId, isAuthenticated: true, roles: [], isPending: true }
|
|
88
|
+
: PUBLIC_SESSION);
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
getSession: () => session,
|
|
92
|
+
subscribe(callback) {
|
|
93
|
+
callbacks.add(callback);
|
|
94
|
+
return () => {
|
|
95
|
+
callbacks.delete(callback);
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
signIn,
|
|
99
|
+
signOut,
|
|
100
|
+
setServerSession(serverSession) {
|
|
101
|
+
if (serverSession) {
|
|
102
|
+
signIn(serverSession.userId, serverSession.roles);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
signOut();
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
getPersistedUserId,
|
|
109
|
+
destroy() {
|
|
110
|
+
cleanupListener();
|
|
111
|
+
callbacks.clear();
|
|
112
|
+
},
|
|
113
|
+
};
|
|
98
114
|
}
|
|
99
115
|
/**
|
|
100
116
|
* Global user session client instance
|
|
101
117
|
*/
|
|
102
|
-
export const userSessionClient =
|
|
118
|
+
export const userSessionClient = createUserSessionClient();
|
|
103
119
|
//# sourceMappingURL=user-session-client.js.map
|
package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.ts
CHANGED
|
@@ -1,122 +1,188 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
|
|
3
|
+
import type { SessionData } from '%authHooksImports';
|
|
4
|
+
import type { AuthRole } from '%graphqlImports';
|
|
5
|
+
|
|
3
6
|
import { getSafeLocalStorage } from '%reactUtilsImports';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
|
-
* Callback function for
|
|
9
|
+
* Callback function for session change events
|
|
7
10
|
*/
|
|
8
|
-
type
|
|
11
|
+
type SessionChangeCallback = () => void;
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
const USER_ID_STORAGE_KEY = 'APP_USER_ID';
|
|
14
|
+
|
|
15
|
+
const PUBLIC_SESSION: SessionData = {
|
|
16
|
+
userId: undefined,
|
|
17
|
+
isAuthenticated: false,
|
|
18
|
+
roles: ['public'],
|
|
19
|
+
isPending: false,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function areSessionsEqual(a: SessionData, b: SessionData): boolean {
|
|
23
|
+
return (
|
|
24
|
+
a.userId === b.userId &&
|
|
25
|
+
a.isPending === b.isPending &&
|
|
26
|
+
a.roles.length === b.roles.length &&
|
|
27
|
+
a.roles.every((role, idx) => role === b.roles[idx])
|
|
28
|
+
);
|
|
29
|
+
}
|
|
24
30
|
|
|
31
|
+
export interface UserSessionClient {
|
|
25
32
|
/**
|
|
26
|
-
*
|
|
33
|
+
* Get the current session, or `undefined` if it is not known yet.
|
|
34
|
+
*
|
|
35
|
+
* Returns a stable reference that only changes when the session itself changes,
|
|
36
|
+
* so it is safe to use as a `useSyncExternalStore` snapshot.
|
|
37
|
+
*/
|
|
38
|
+
getSession: () => SessionData | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Subscribe to session changes
|
|
41
|
+
* @param callback - Function to call when the session changes
|
|
42
|
+
* @returns Cleanup function to unsubscribe
|
|
43
|
+
*/
|
|
44
|
+
subscribe: (callback: SessionChangeCallback) => () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Sign in a user with a session the server has already returned
|
|
27
47
|
* @param userId - The user ID to sign in
|
|
48
|
+
* @param roles - The roles the server issued alongside the session
|
|
28
49
|
*/
|
|
29
|
-
signIn(userId: string
|
|
30
|
-
const existingUserId = this.getUserId();
|
|
31
|
-
this.setUserId(userId);
|
|
32
|
-
if (existingUserId !== userId) {
|
|
33
|
-
this.notifyCallbacks();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
50
|
+
signIn: (userId: string, roles: AuthRole[]) => void;
|
|
37
51
|
/**
|
|
38
52
|
* Sign out the current user
|
|
39
53
|
*/
|
|
40
|
-
signOut()
|
|
41
|
-
const existingUserId = this.getUserId();
|
|
42
|
-
this.setUserId(null);
|
|
43
|
-
if (existingUserId) {
|
|
44
|
-
this.notifyCallbacks();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
54
|
+
signOut: () => void;
|
|
48
55
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @
|
|
56
|
+
* Apply the session reported by the server, confirming or replacing whatever was
|
|
57
|
+
* published locally
|
|
58
|
+
* @param session - The session from the server, or undefined if signed out
|
|
52
59
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.callbacks.delete(callback);
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
+
setServerSession: (
|
|
61
|
+
session: { userId: string; roles: AuthRole[] } | undefined,
|
|
62
|
+
) => void;
|
|
60
63
|
/**
|
|
61
|
-
*
|
|
64
|
+
* Get the user ID persisted in storage, which may not be confirmed yet
|
|
65
|
+
* @returns User ID or undefined if not signed in
|
|
62
66
|
*/
|
|
63
|
-
|
|
64
|
-
this.cleanupListener?.();
|
|
65
|
-
this.callbacks.clear();
|
|
66
|
-
}
|
|
67
|
-
|
|
67
|
+
getPersistedUserId: () => string | undefined;
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
70
|
-
* @returns User ID or null if not authenticated
|
|
69
|
+
* Clean up resources when the client is no longer needed
|
|
71
70
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
destroy: () => void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates the client-side source of truth for the current user session.
|
|
76
|
+
*
|
|
77
|
+
* The session is published synchronously when it is known locally (sign in / sign
|
|
78
|
+
* out) and refined asynchronously when the server confirms it. It is deliberately
|
|
79
|
+
* not derived from the Apollo cache, since signing in clears that cache.
|
|
80
|
+
*
|
|
81
|
+
* The user ID is persisted to localStorage for cold starts and cross-tab
|
|
82
|
+
* synchronisation. Roles are never persisted — they are only ever trusted from the
|
|
83
|
+
* server, and are enforced there regardless.
|
|
84
|
+
*/
|
|
85
|
+
export function createUserSessionClient(): UserSessionClient {
|
|
86
|
+
const storage = getSafeLocalStorage();
|
|
87
|
+
const callbacks = new Set<SessionChangeCallback>();
|
|
88
|
+
|
|
89
|
+
function getPersistedUserId(): string | undefined {
|
|
90
|
+
return storage.getItem(USER_ID_STORAGE_KEY) ?? undefined;
|
|
76
91
|
}
|
|
77
92
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
// A persisted user ID means we expect a session, so hold off publishing until the
|
|
94
|
+
// server confirms it. With no persisted user ID there is nothing to wait for and
|
|
95
|
+
// the public session can be published immediately.
|
|
96
|
+
let session: SessionData | undefined = getPersistedUserId()
|
|
97
|
+
? undefined
|
|
98
|
+
: PUBLIC_SESSION;
|
|
99
|
+
|
|
100
|
+
function publish(newSession: SessionData): void {
|
|
101
|
+
if (session && areSessionsEqual(session, newSession)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
session = newSession;
|
|
105
|
+
for (const callback of callbacks) {
|
|
106
|
+
callback();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
85
109
|
|
|
86
|
-
|
|
110
|
+
function persistUserId(userId: string | undefined): void {
|
|
111
|
+
if (userId === getPersistedUserId()) {
|
|
87
112
|
return;
|
|
88
113
|
}
|
|
89
114
|
|
|
90
115
|
if (userId) {
|
|
91
|
-
|
|
116
|
+
storage.setItem(USER_ID_STORAGE_KEY, userId);
|
|
92
117
|
} else {
|
|
93
|
-
|
|
118
|
+
storage.removeItem(USER_ID_STORAGE_KEY);
|
|
94
119
|
}
|
|
95
120
|
}
|
|
96
121
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.notifyCallbacks();
|
|
104
|
-
}
|
|
122
|
+
function signIn(userId: string, roles: AuthRole[]): void {
|
|
123
|
+
publish({
|
|
124
|
+
userId,
|
|
125
|
+
isAuthenticated: true,
|
|
126
|
+
roles,
|
|
127
|
+
isPending: false,
|
|
105
128
|
});
|
|
129
|
+
persistUserId(userId);
|
|
106
130
|
}
|
|
107
131
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
private notifyCallbacks(): void {
|
|
112
|
-
const userId = this.getUserId();
|
|
113
|
-
for (const callback of this.callbacks) {
|
|
114
|
-
callback(userId);
|
|
115
|
-
}
|
|
132
|
+
function signOut(): void {
|
|
133
|
+
publish(PUBLIC_SESSION);
|
|
134
|
+
persistUserId(undefined);
|
|
116
135
|
}
|
|
136
|
+
|
|
137
|
+
const cleanupListener = storage.addEventListener((key, newValue) => {
|
|
138
|
+
if (key !== USER_ID_STORAGE_KEY) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const userId = newValue ?? undefined;
|
|
143
|
+
// Writes from this tab publish the session themselves before persisting it, so
|
|
144
|
+
// anything already matching is our own write echoing back. A session that is
|
|
145
|
+
// not known yet never matches, since no session has been published.
|
|
146
|
+
if (session && userId === session.userId) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Another tab changed the identity. Publish it right away so we never render
|
|
151
|
+
// one user's identity with another's data, with roles marked pending until the
|
|
152
|
+
// server confirms them.
|
|
153
|
+
publish(
|
|
154
|
+
userId
|
|
155
|
+
? { userId, isAuthenticated: true, roles: [], isPending: true }
|
|
156
|
+
: PUBLIC_SESSION,
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
getSession: () => session,
|
|
162
|
+
subscribe(callback) {
|
|
163
|
+
callbacks.add(callback);
|
|
164
|
+
return () => {
|
|
165
|
+
callbacks.delete(callback);
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
signIn,
|
|
169
|
+
signOut,
|
|
170
|
+
setServerSession(serverSession) {
|
|
171
|
+
if (serverSession) {
|
|
172
|
+
signIn(serverSession.userId, serverSession.roles);
|
|
173
|
+
} else {
|
|
174
|
+
signOut();
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
getPersistedUserId,
|
|
178
|
+
destroy() {
|
|
179
|
+
cleanupListener();
|
|
180
|
+
callbacks.clear();
|
|
181
|
+
},
|
|
182
|
+
};
|
|
117
183
|
}
|
|
118
184
|
|
|
119
185
|
/**
|
|
120
186
|
* Global user session client instance
|
|
121
187
|
*/
|
|
122
|
-
export const userSessionClient =
|
|
188
|
+
export const userSessionClient = createUserSessionClient();
|
|
@@ -14,7 +14,6 @@ export declare const LOCAL_AUTH_CORE_SEED_INITIAL_USER_GENERATED: {
|
|
|
14
14
|
}, {
|
|
15
15
|
authEmailPasswordImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
16
16
|
authenticateUserWithEmailAndPassword: {};
|
|
17
|
-
cleanupExpiredPasswordResetTokens: {};
|
|
18
17
|
completePasswordReset: {};
|
|
19
18
|
createUserWithEmailAndPassword: {};
|
|
20
19
|
PASSWORD_MAX_LENGTH: {};
|
|
@@ -54,7 +53,6 @@ export declare const LOCAL_AUTH_CORE_SEED_INITIAL_USER_GENERATED: {
|
|
|
54
53
|
}, {
|
|
55
54
|
authEmailPasswordImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
56
55
|
authenticateUserWithEmailAndPassword: {};
|
|
57
|
-
cleanupExpiredPasswordResetTokens: {};
|
|
58
56
|
completePasswordReset: {};
|
|
59
57
|
createUserWithEmailAndPassword: {};
|
|
60
58
|
PASSWORD_MAX_LENGTH: {};
|
|
@@ -13,7 +13,6 @@ export declare const LOCAL_AUTH_CORE_SEED_INITIAL_USER_RENDERERS: {
|
|
|
13
13
|
}, {
|
|
14
14
|
authEmailPasswordImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
15
15
|
authenticateUserWithEmailAndPassword: {};
|
|
16
|
-
cleanupExpiredPasswordResetTokens: {};
|
|
17
16
|
completePasswordReset: {};
|
|
18
17
|
createUserWithEmailAndPassword: {};
|
|
19
18
|
PASSWORD_MAX_LENGTH: {};
|
|
@@ -4,7 +4,6 @@ export declare const LOCAL_AUTH_CORE_SEED_INITIAL_USER_TEMPLATES: {
|
|
|
4
4
|
}, {
|
|
5
5
|
authEmailPasswordImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
6
6
|
authenticateUserWithEmailAndPassword: {};
|
|
7
|
-
cleanupExpiredPasswordResetTokens: {};
|
|
8
7
|
completePasswordReset: {};
|
|
9
8
|
createUserWithEmailAndPassword: {};
|
|
10
9
|
PASSWORD_MAX_LENGTH: {};
|
|
@@ -14,7 +14,6 @@ export declare const seedInitialUserGenerator: import("@baseplate-dev/sync").Gen
|
|
|
14
14
|
}, {
|
|
15
15
|
authEmailPasswordImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
16
16
|
authenticateUserWithEmailAndPassword: {};
|
|
17
|
-
cleanupExpiredPasswordResetTokens: {};
|
|
18
17
|
completePasswordReset: {};
|
|
19
18
|
createUserWithEmailAndPassword: {};
|
|
20
19
|
PASSWORD_MAX_LENGTH: {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { appModuleGenerator, passwordHasherServiceGenerator, } from '@baseplate-dev/fastify-generators';
|
|
2
2
|
import { emailTemplateSpec } from '@baseplate-dev/plugin-email';
|
|
3
|
-
import { appCompilerSpec, backendAppEntryType, createPluginModule, pluginAppCompiler, PluginUtils, webAppEntryType, } from '@baseplate-dev/project-builder-lib';
|
|
3
|
+
import { appCompilerSpec, backendAppEntryType, createPluginModule, getAppUrls, pluginAppCompiler, PluginUtils, webAppEntryType, } from '@baseplate-dev/project-builder-lib';
|
|
4
4
|
import { getAuthPluginDefinition } from '#src/auth/index.js';
|
|
5
5
|
import { authApolloGenerator } from './generators/auth-apollo/auth-apollo.generator.js';
|
|
6
6
|
import { authEmailPasswordGenerator } from './generators/auth-email-password/auth-email-password.generator.js';
|
|
@@ -30,11 +30,12 @@ export default createPluginModule({
|
|
|
30
30
|
compile: ({ projectDefinition, definitionContainer, appCompiler }) => {
|
|
31
31
|
const localAuthDefinition = PluginUtils.configByKeyOrThrow(projectDefinition, pluginKey);
|
|
32
32
|
const authDefinition = getAuthPluginDefinition(projectDefinition);
|
|
33
|
-
// Get web app ports
|
|
34
33
|
const webApps = projectDefinition.apps.filter((app) => app.type === 'web');
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
34
|
+
const { webApps: webAppUrls } = getAppUrls(projectDefinition);
|
|
35
|
+
const authWebApp = webAppUrls.find((app) => app.isDefault);
|
|
36
|
+
if (!authWebApp) {
|
|
37
|
+
throw new Error('Unable to determine which web app auth emails should link to');
|
|
38
|
+
}
|
|
38
39
|
// The register mutation is shared by every web app on this
|
|
39
40
|
// backend, so it can only be dropped once none of them allow
|
|
40
41
|
// self-service registration.
|
|
@@ -50,7 +51,6 @@ export default createPluginModule({
|
|
|
50
51
|
}),
|
|
51
52
|
authModule: authModuleGenerator({
|
|
52
53
|
userAdminRoles: adminRoles,
|
|
53
|
-
devWebPorts,
|
|
54
54
|
emailOtp: localAuthDefinition.emailOtp,
|
|
55
55
|
}),
|
|
56
56
|
emailPassword: appModuleGenerator({
|
|
@@ -59,7 +59,7 @@ export default createPluginModule({
|
|
|
59
59
|
children: {
|
|
60
60
|
module: authEmailPasswordGenerator({
|
|
61
61
|
adminRoles,
|
|
62
|
-
|
|
62
|
+
webAppName: authWebApp.name,
|
|
63
63
|
requireNameOnRegistration: localAuthDefinition.requireNameOnRegistration,
|
|
64
64
|
emailOtp: localAuthDefinition.emailOtp,
|
|
65
65
|
disableRegistration,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export declare const PLACEHOLDER_AUTH_CORE_PLACEHOLDER_AUTH_HOOKS_GENERATED: {
|
|
2
2
|
imports: {
|
|
3
|
+
generatorName: string;
|
|
3
4
|
task: import("@baseplate-dev/sync").GeneratorTask<{
|
|
4
5
|
authHooksImports: import("@baseplate-dev/sync").ProviderExport<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
5
6
|
SessionData: {
|
|
6
7
|
isTypeOnly: true;
|
|
7
8
|
};
|
|
8
9
|
useLogOut: {};
|
|
9
|
-
useRequiredUserId: {};
|
|
10
10
|
useSession: {};
|
|
11
|
+
useUserIdOrThrow: {};
|
|
11
12
|
AuthRole: {
|
|
12
13
|
isTypeOnly: true;
|
|
13
14
|
};
|
|
@@ -36,10 +37,10 @@ export declare const PLACEHOLDER_AUTH_CORE_PLACEHOLDER_AUTH_HOOKS_GENERATED: {
|
|
|
36
37
|
templates: {
|
|
37
38
|
hooksGroup: {
|
|
38
39
|
useLogOut: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
39
|
-
|
|
40
|
+
useSession: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
41
|
+
useUserIdOrThrow: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, {
|
|
40
42
|
useSession: {};
|
|
41
43
|
}>;
|
|
42
|
-
useSession: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
43
44
|
};
|
|
44
45
|
};
|
|
45
46
|
};
|
package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/template-paths.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface PlaceholderAuthCorePlaceholderAuthHooksPaths {
|
|
2
2
|
useLogOut: string;
|
|
3
|
-
useRequiredUserId: string;
|
|
4
3
|
useSession: string;
|
|
4
|
+
useUserIdOrThrow: string;
|
|
5
5
|
}
|
|
6
6
|
export declare const PLACEHOLDER_AUTH_CORE_PLACEHOLDER_AUTH_HOOKS_PATHS: {
|
|
7
7
|
provider: import("@baseplate-dev/sync").ProviderType<PlaceholderAuthCorePlaceholderAuthHooksPaths>;
|
package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/template-paths.js
CHANGED
|
@@ -12,8 +12,8 @@ const placeholderAuthCorePlaceholderAuthHooksPathsTask = createGeneratorTask({
|
|
|
12
12
|
providers: {
|
|
13
13
|
placeholderAuthCorePlaceholderAuthHooksPaths: {
|
|
14
14
|
useLogOut: `${srcRoot}/hooks/use-log-out.ts`,
|
|
15
|
-
useRequiredUserId: `${srcRoot}/hooks/use-user-id-or-throw.ts`,
|
|
16
15
|
useSession: `${srcRoot}/hooks/use-session.ts`,
|
|
16
|
+
useUserIdOrThrow: `${srcRoot}/hooks/use-user-id-or-throw.ts`,
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export declare const PLACEHOLDER_AUTH_CORE_PLACEHOLDER_AUTH_HOOKS_IMPORTS: {
|
|
2
|
+
generatorName: string;
|
|
2
3
|
task: import("@baseplate-dev/sync").GeneratorTask<{
|
|
3
4
|
authHooksImports: import("@baseplate-dev/sync").ProviderExport<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
4
5
|
SessionData: {
|
|
5
6
|
isTypeOnly: true;
|
|
6
7
|
};
|
|
7
8
|
useLogOut: {};
|
|
8
|
-
useRequiredUserId: {};
|
|
9
9
|
useSession: {};
|
|
10
|
+
useUserIdOrThrow: {};
|
|
10
11
|
AuthRole: {
|
|
11
12
|
isTypeOnly: true;
|
|
12
13
|
};
|
|
@@ -14,14 +14,15 @@ const placeholderAuthCorePlaceholderAuthHooksImportsTask = createGeneratorTask({
|
|
|
14
14
|
AuthRole: paths.useSession,
|
|
15
15
|
SessionData: paths.useSession,
|
|
16
16
|
useLogOut: paths.useLogOut,
|
|
17
|
-
useRequiredUserId: paths.useRequiredUserId,
|
|
18
17
|
useSession: paths.useSession,
|
|
18
|
+
useUserIdOrThrow: paths.useUserIdOrThrow,
|
|
19
19
|
}),
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
24
|
export const PLACEHOLDER_AUTH_CORE_PLACEHOLDER_AUTH_HOOKS_IMPORTS = {
|
|
25
|
+
generatorName: '@baseplate-dev/plugin-auth#placeholder-auth/core/placeholder-auth-hooks',
|
|
25
26
|
task: placeholderAuthCorePlaceholderAuthHooksImportsTask,
|
|
26
27
|
};
|
|
27
28
|
//# sourceMappingURL=ts-import-providers.js.map
|
package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/typed-templates.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export declare const hooksGroup: {
|
|
2
2
|
useLogOut: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
3
|
-
|
|
3
|
+
useSession: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
4
|
+
useUserIdOrThrow: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, {
|
|
4
5
|
useSession: {};
|
|
5
6
|
}>;
|
|
6
|
-
useSession: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
7
7
|
};
|
|
8
8
|
export declare const PLACEHOLDER_AUTH_CORE_PLACEHOLDER_AUTH_HOOKS_TEMPLATES: {
|
|
9
9
|
hooksGroup: {
|
|
10
10
|
useLogOut: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
11
|
-
|
|
11
|
+
useSession: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
12
|
+
useUserIdOrThrow: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, {
|
|
12
13
|
useSession: {};
|
|
13
14
|
}>;
|
|
14
|
-
useSession: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
//# sourceMappingURL=typed-templates.d.ts.map
|