@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.
Files changed (294) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +74 -0
  3. package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +74 -0
  4. package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +37 -0
  5. package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +37 -0
  6. package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.js +1 -2
  7. package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.tsx +1 -1
  8. package/dist/better-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.d.ts +74 -0
  9. package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +74 -0
  10. package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +37 -0
  11. package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +74 -0
  12. package/dist/better-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.js +1 -2
  13. package/dist/better-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.tsx +1 -1
  14. package/dist/better-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +37 -0
  15. package/dist/better-auth/core/node.js +7 -8
  16. package/dist/better-auth/generators/fastify/better-auth-admin-module/generated/index.d.ts +1 -0
  17. package/dist/better-auth/generators/fastify/better-auth-admin-module/generated/ts-import-providers.d.ts +1 -0
  18. package/dist/better-auth/generators/fastify/better-auth-admin-module/generated/ts-import-providers.js +1 -0
  19. package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.d.ts +20 -3
  20. package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.js +5 -24
  21. package/dist/better-auth/generators/fastify/better-auth-module/generated/index.d.ts +40 -2
  22. package/dist/better-auth/generators/fastify/better-auth-module/generated/template-renderers.d.ts +19 -1
  23. package/dist/better-auth/generators/fastify/better-auth-module/generated/template-renderers.js +6 -2
  24. package/dist/better-auth/generators/fastify/better-auth-module/generated/ts-import-providers.d.ts +1 -0
  25. package/dist/better-auth/generators/fastify/better-auth-module/generated/ts-import-providers.js +1 -0
  26. package/dist/better-auth/generators/fastify/better-auth-module/generated/typed-templates.d.ts +20 -1
  27. package/dist/better-auth/generators/fastify/better-auth-module/generated/typed-templates.js +4 -1
  28. package/dist/better-auth/generators/fastify/better-auth-module/templates/module/services/auth.ts +16 -8
  29. package/dist/better-auth/generators/react/better-auth-hooks/better-auth-hooks.generator.d.ts +1 -1
  30. package/dist/better-auth/generators/react/better-auth-hooks/generated/index.d.ts +5 -4
  31. package/dist/better-auth/generators/react/better-auth-hooks/generated/template-paths.d.ts +1 -1
  32. package/dist/better-auth/generators/react/better-auth-hooks/generated/template-paths.js +1 -1
  33. package/dist/better-auth/generators/react/better-auth-hooks/generated/ts-import-providers.d.ts +2 -1
  34. package/dist/better-auth/generators/react/better-auth-hooks/generated/ts-import-providers.js +2 -1
  35. package/dist/better-auth/generators/react/better-auth-hooks/generated/typed-templates.d.ts +6 -6
  36. package/dist/better-auth/generators/react/better-auth-hooks/generated/typed-templates.js +13 -13
  37. 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
  38. package/dist/better-auth/generators/react/better-auth-pages/better-auth-pages.generator.d.ts +37 -0
  39. package/dist/better-auth/generators/react/better-auth-pages/generated/index.d.ts +222 -0
  40. package/dist/better-auth/generators/react/better-auth-pages/generated/template-renderers.d.ts +37 -0
  41. package/dist/better-auth/generators/react/better-auth-pages/generated/typed-templates.d.ts +370 -0
  42. package/dist/better-auth/generators/react/better-auth-pages/templates/routes/forgot-password.tsx +1 -4
  43. package/dist/better-auth/generators/react/react-better-auth/generated/index.d.ts +77 -2
  44. package/dist/better-auth/generators/react/react-better-auth/generated/template-renderers.d.ts +38 -1
  45. package/dist/better-auth/generators/react/react-better-auth/generated/ts-import-providers.d.ts +1 -0
  46. package/dist/better-auth/generators/react/react-better-auth/generated/ts-import-providers.js +1 -0
  47. package/dist/better-auth/generators/react/react-better-auth/generated/typed-templates.d.ts +38 -1
  48. package/dist/better-auth/generators/react/react-better-auth/react-better-auth.generator.d.ts +38 -1
  49. package/dist/better-auth/generators/react/react-better-auth/templates/src/app/auth-loaded-gate.tsx +12 -3
  50. package/dist/local-auth/admin/common.js +6 -0
  51. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/admin-crud-invite-user-action.generator.d.ts +593 -0
  52. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/admin-crud-invite-user-action.generator.js +119 -0
  53. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/index.d.ts +602 -0
  54. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/index.js +11 -0
  55. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-paths.d.ts +12 -0
  56. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-paths.js +24 -0
  57. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-renderers.d.ts +307 -0
  58. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-renderers.js +45 -0
  59. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/typed-templates.d.ts +294 -0
  60. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/typed-templates.js +21 -0
  61. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/index.d.ts +2 -0
  62. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/index.js +2 -0
  63. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.d.ts +21 -0
  64. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.js +68 -0
  65. package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.tsx +122 -0
  66. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +74 -0
  67. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +74 -0
  68. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +37 -0
  69. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +37 -0
  70. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.js +1 -2
  71. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.tsx +1 -1
  72. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.d.ts +74 -0
  73. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +74 -0
  74. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +37 -0
  75. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +74 -0
  76. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.js +1 -2
  77. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.tsx +1 -1
  78. package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +37 -0
  79. package/dist/local-auth/admin/node.js +13 -0
  80. package/dist/local-auth/admin/schema/invite-user-action.d.ts +12 -0
  81. package/dist/local-auth/admin/schema/invite-user-action.js +6 -0
  82. package/dist/local-auth/admin/web.js +8 -0
  83. package/dist/local-auth/core/common.js +7 -2
  84. package/dist/local-auth/core/components/local-auth-definition-editor.js +2 -1
  85. package/dist/local-auth/core/components/local-auth-web-app-settings-form.d.ts +9 -0
  86. package/dist/local-auth/core/components/local-auth-web-app-settings-form.js +11 -0
  87. package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.d.ts +16 -7
  88. package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.js +73 -16
  89. package/dist/local-auth/core/generators/auth-email-password/generated/index.d.ts +222 -7
  90. package/dist/local-auth/core/generators/auth-email-password/generated/template-paths.d.ts +5 -0
  91. package/dist/local-auth/core/generators/auth-email-password/generated/template-paths.js +5 -0
  92. package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.d.ts +27 -0
  93. package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.js +71 -4
  94. package/dist/local-auth/core/generators/auth-email-password/generated/ts-import-providers.d.ts +1 -3
  95. package/dist/local-auth/core/generators/auth-email-password/generated/ts-import-providers.js +1 -2
  96. package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.d.ts +226 -10
  97. package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.js +91 -7
  98. package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/otp.constants.d.ts +19 -0
  99. package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/otp.constants.js +20 -0
  100. package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/otp.constants.ts +22 -0
  101. package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/password.constants.d.ts +12 -0
  102. package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/password.constants.js +12 -0
  103. package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/password.constants.ts +14 -0
  104. package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/email-otp.mutations.d.ts +2 -0
  105. package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/email-otp.mutations.js +30 -0
  106. package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/email-otp.mutations.ts +38 -0
  107. package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/invite.mutations.d.ts +2 -0
  108. package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/invite.mutations.js +42 -0
  109. package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/invite.mutations.ts +54 -0
  110. package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/user-password.mutations.js +2 -19
  111. package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/user-password.mutations.ts +1 -22
  112. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-otp.service.d.ts +37 -0
  113. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-otp.service.js +225 -0
  114. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-otp.service.ts +333 -0
  115. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.js +2 -3
  116. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.ts +5 -3
  117. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/invite.service.d.ts +39 -0
  118. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/invite.service.js +142 -0
  119. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/invite.service.ts +221 -0
  120. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.js +5 -6
  121. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.ts +8 -5
  122. package/dist/local-auth/core/generators/auth-email-templates/auth-email-templates.generator.d.ts +3 -1
  123. package/dist/local-auth/core/generators/auth-email-templates/auth-email-templates.generator.js +18 -3
  124. package/dist/local-auth/core/generators/auth-email-templates/generated/index.d.ts +40 -0
  125. package/dist/local-auth/core/generators/auth-email-templates/generated/template-paths.d.ts +2 -0
  126. package/dist/local-auth/core/generators/auth-email-templates/generated/template-paths.js +2 -0
  127. package/dist/local-auth/core/generators/auth-email-templates/generated/template-renderers.d.ts +6 -0
  128. package/dist/local-auth/core/generators/auth-email-templates/generated/template-renderers.js +20 -0
  129. package/dist/local-auth/core/generators/auth-email-templates/generated/typed-templates.d.ts +40 -0
  130. package/dist/local-auth/core/generators/auth-email-templates/generated/typed-templates.js +24 -0
  131. package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/email-otp.email.d.ts +3 -0
  132. package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/email-otp.email.js +18 -0
  133. package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/email-otp.email.tsx +57 -0
  134. package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/invite.email.d.ts +3 -0
  135. package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/invite.email.js +14 -0
  136. package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/invite.email.tsx +47 -0
  137. package/dist/local-auth/core/generators/auth-hooks/auth-hooks.generator.d.ts +272 -1
  138. package/dist/local-auth/core/generators/auth-hooks/generated/index.d.ts +547 -4
  139. package/dist/local-auth/core/generators/auth-hooks/generated/template-paths.d.ts +1 -1
  140. package/dist/local-auth/core/generators/auth-hooks/generated/template-paths.js +1 -1
  141. package/dist/local-auth/core/generators/auth-hooks/generated/template-renderers.d.ts +271 -0
  142. package/dist/local-auth/core/generators/auth-hooks/generated/template-renderers.js +4 -2
  143. package/dist/local-auth/core/generators/auth-hooks/generated/ts-import-providers.d.ts +2 -1
  144. package/dist/local-auth/core/generators/auth-hooks/generated/ts-import-providers.js +2 -1
  145. package/dist/local-auth/core/generators/auth-hooks/generated/typed-templates.d.ts +548 -6
  146. package/dist/local-auth/core/generators/auth-hooks/generated/typed-templates.js +15 -14
  147. package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-log-out.js +1 -1
  148. package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-log-out.ts +1 -1
  149. package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-session.d.ts +7 -0
  150. package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-session.ts +7 -0
  151. package/dist/local-auth/core/generators/auth-module/auth-module.generator.d.ts +23 -7
  152. package/dist/local-auth/core/generators/auth-module/auth-module.generator.js +7 -26
  153. package/dist/local-auth/core/generators/auth-module/generated/index.d.ts +65 -4
  154. package/dist/local-auth/core/generators/auth-module/generated/template-paths.d.ts +1 -1
  155. package/dist/local-auth/core/generators/auth-module/generated/template-paths.js +1 -1
  156. package/dist/local-auth/core/generators/auth-module/generated/template-renderers.d.ts +22 -1
  157. package/dist/local-auth/core/generators/auth-module/generated/template-renderers.js +19 -2
  158. package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.d.ts +10 -0
  159. package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.js +7 -0
  160. package/dist/local-auth/core/generators/auth-module/generated/typed-templates.d.ts +42 -4
  161. package/dist/local-auth/core/generators/auth-module/generated/typed-templates.js +24 -13
  162. package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.d.ts +4 -0
  163. package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.js +1 -1
  164. package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.ts +1 -1
  165. package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.d.ts +67 -0
  166. package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.js +140 -0
  167. package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.ts +191 -0
  168. package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.js +8 -9
  169. package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.ts +10 -11
  170. package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.d.ts +39 -0
  171. package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.js +38 -5
  172. package/dist/local-auth/core/generators/auth-routes/generated/index.d.ts +1089 -268
  173. package/dist/local-auth/core/generators/auth-routes/generated/template-paths.d.ts +3 -0
  174. package/dist/local-auth/core/generators/auth-routes/generated/template-paths.js +3 -0
  175. package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.d.ts +49 -0
  176. package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.js +51 -0
  177. package/dist/local-auth/core/generators/auth-routes/generated/ts-import-providers.d.ts +1 -0
  178. package/dist/local-auth/core/generators/auth-routes/generated/ts-import-providers.js +1 -0
  179. package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.d.ts +918 -283
  180. package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.js +69 -23
  181. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.d.ts +9 -0
  182. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.js +10 -0
  183. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.ts +11 -0
  184. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.d.ts +7 -0
  185. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.js +155 -0
  186. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.tsx +274 -0
  187. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/forgot-password.js +1 -2
  188. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/forgot-password.tsx +1 -1
  189. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login-otp.d.ts +7 -0
  190. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login-otp.js +184 -0
  191. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login-otp.tsx +312 -0
  192. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js +5 -5
  193. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.tsx +6 -12
  194. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.js +4 -4
  195. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.tsx +4 -3
  196. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/reset-password.js +1 -2
  197. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/reset-password.tsx +1 -1
  198. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/verify-email.js +1 -2
  199. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/verify-email.tsx +1 -1
  200. package/dist/local-auth/core/generators/react-session/generated/index.d.ts +90 -7
  201. package/dist/local-auth/core/generators/react-session/generated/template-renderers.d.ts +38 -1
  202. package/dist/local-auth/core/generators/react-session/generated/ts-import-providers.d.ts +1 -0
  203. package/dist/local-auth/core/generators/react-session/generated/ts-import-providers.js +1 -0
  204. package/dist/local-auth/core/generators/react-session/generated/typed-templates.d.ts +102 -12
  205. package/dist/local-auth/core/generators/react-session/generated/typed-templates.js +5 -2
  206. package/dist/local-auth/core/generators/react-session/react-session.generator.d.ts +54 -1
  207. package/dist/local-auth/core/generators/react-session/react-session.generator.js +35 -1
  208. package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.js +17 -44
  209. package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.tsx +21 -49
  210. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.d.ts +43 -34
  211. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.js +96 -80
  212. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.ts +148 -82
  213. package/dist/local-auth/core/generators/seed-initial-user/generated/index.d.ts +0 -2
  214. package/dist/local-auth/core/generators/seed-initial-user/generated/template-renderers.d.ts +0 -1
  215. package/dist/local-auth/core/generators/seed-initial-user/generated/typed-templates.d.ts +0 -1
  216. package/dist/local-auth/core/generators/seed-initial-user/seed-initial-user.generator.d.ts +0 -1
  217. package/dist/local-auth/core/node.js +30 -12
  218. package/dist/local-auth/core/schema/migrations.d.ts +3 -0
  219. package/dist/local-auth/core/schema/migrations.js +36 -0
  220. package/dist/local-auth/core/schema/models.js +8 -0
  221. package/dist/local-auth/core/schema/plugin-definition.d.ts +1 -0
  222. package/dist/local-auth/core/schema/plugin-definition.js +1 -0
  223. package/dist/local-auth/core/schema/web-app-schema.d.ts +15 -0
  224. package/dist/local-auth/core/schema/web-app-schema.js +16 -0
  225. package/dist/local-auth/core/web.js +8 -1
  226. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/index.d.ts +4 -3
  227. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/template-paths.d.ts +1 -1
  228. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/template-paths.js +1 -1
  229. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/ts-import-providers.d.ts +2 -1
  230. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/ts-import-providers.js +2 -1
  231. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/typed-templates.d.ts +4 -4
  232. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/generated/typed-templates.js +13 -13
  233. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/placeholder-auth-hooks.generator.d.ts +1 -1
  234. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-session.d.ts +1 -0
  235. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-session.ts +2 -0
  236. package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/index.d.ts +1 -2
  237. package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/template-renderers.d.ts +0 -1
  238. package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/ts-import-providers.d.ts +1 -0
  239. package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/ts-import-providers.js +1 -0
  240. package/dist/placeholder-auth/core/generators/placeholder-auth-module/generated/typed-templates.d.ts +0 -1
  241. package/dist/placeholder-auth/core/generators/placeholder-auth-module/placeholder-auth-module.generator.d.ts +0 -1
  242. 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
  243. 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
  244. 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
  245. 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
  246. 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
  247. package/dist/web/assets/auth-DR6QxrAW.js +1 -0
  248. package/dist/web/assets/{common-iHaemino.js → common-BsyRiQi3.js} +6 -6
  249. package/dist/web/assets/{common-TDf_PrjX.js → common-CRwNlCMn.js} +10 -10
  250. package/dist/web/assets/{common-ByxS61u8.js → common-CvqlRZC9.js} +12 -12
  251. package/dist/web/assets/common-D3atSs7O.js +70 -0
  252. package/dist/web/assets/common-DuFyXa6l.js +36 -0
  253. package/dist/web/assets/common-islduJTj.js +43 -0
  254. package/dist/web/assets/{dist-CrLSslv6.js → dist-DQd1TAJX.js} +273 -132
  255. package/dist/web/assets/{get-auth-plugin-definition-kDCtXq_6.js → get-auth-plugin-definition-BgWWHl_Y.js} +3 -3
  256. package/dist/web/assets/{hostInit-Cruek6c6.js → hostInit-DNA4kLRY.js} +32 -5
  257. package/dist/web/assets/{mf-entry-bootstrap-0-dfed0275.js → mf-entry-bootstrap-0-ea77c09b.js} +2 -1
  258. package/dist/web/assets/{mf-entry-bootstrap-1-5275674a.js → mf-entry-bootstrap-1-9dee3d8d.js} +3 -2
  259. package/dist/web/assets/{mf-entry-bootstrap-2-39fb9255.js → mf-entry-bootstrap-2-3179040b.js} +3 -2
  260. package/dist/web/assets/{mf-entry-bootstrap-3-49e64336.js → mf-entry-bootstrap-3-370d200d.js} +3 -2
  261. package/dist/web/assets/{models-DSvs_3bA.js → models-BOeSYfRn.js} +4 -5
  262. package/dist/web/assets/{models-BZmCbizK.js → models-DF6DoXt6.js} +11 -6
  263. package/dist/web/assets/{plugin-definition-CYj29S3q.js → plugin-definition--k0VAeK3.js} +9 -10
  264. package/dist/web/assets/plugin-definition-CMwSlxsJ.js +10 -0
  265. package/dist/web/assets/{styles-yjbHBTlw.js → styles-BQEcQHoR.js} +9 -10
  266. package/dist/web/assets/{virtualExposes-CbPBmicF.js → virtualExposes-C7fDiAmS.js} +1 -1
  267. package/dist/web/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-BZBRyml2.js +747 -0
  268. 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
  269. package/dist/web/assets/web-8wz0ad-V.js +59 -0
  270. package/dist/web/assets/{web-CXAHKjIY.js → web-BGixH_gT.js} +27 -27
  271. package/dist/web/assets/{web-1eTcxMhf.js → web-BxIwkN3O.js} +6 -6
  272. package/dist/web/assets/{web-VqBA3jxZ.js → web-CQMfABjr.js} +24 -24
  273. package/dist/web/assets/{web-CDAKPPK9.js → web-CcNpItSu.js} +22 -22
  274. package/dist/web/assets/web-CypPeiVv.js +148 -0
  275. package/dist/web/assets/{web-D0MSKfyv.js → web-CzK_la2_.js} +53 -53
  276. package/dist/web/index.html +5 -5
  277. package/dist/web/remoteEntry.js +1 -1
  278. package/package.json +14 -14
  279. package/dist/local-auth/core/generators/auth-module/templates/module/utils/cookie-signer.d.ts +0 -38
  280. package/dist/local-auth/core/generators/auth-module/templates/module/utils/cookie-signer.js +0 -71
  281. package/dist/local-auth/core/generators/auth-module/templates/module/utils/cookie-signer.ts +0 -77
  282. 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
  283. package/dist/web/assets/_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare__zod__loadShare__.js-BEZ7A-cz.js +0 -13566
  284. package/dist/web/assets/auth-BxAE0rgh.js +0 -1
  285. package/dist/web/assets/common-CKl_XlvH.js +0 -37
  286. package/dist/web/assets/common-UpVCKZeW.js +0 -41
  287. package/dist/web/assets/common-crSwCD36.js +0 -37
  288. package/dist/web/assets/model-utils-C0WDb_Ec.js +0 -1599
  289. package/dist/web/assets/plugin-definition-DOMmPL2Z.js +0 -11
  290. package/dist/web/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-XM6iYVxf.js +0 -259
  291. package/dist/web/assets/virtual_mf-exposes-ssr___mfe_internal__plugin-auth__remoteEntry_js-DGjg7Brm.js +0 -129
  292. package/dist/web/assets/web-DbeAaDTV.js +0 -118
  293. package/dist/web/assets/web-miDovYk_.js +0 -46
  294. package/dist/web/remoteEntry.ssr.js +0 -43
@@ -0,0 +1,142 @@
1
+ // @ts-nocheck
2
+ import { AUTH_TOKEN_MAX_LENGTH, INVITE_TOKEN_EXPIRY_SEC, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, } from '$constantsPassword';
3
+ import { getWebUrl } from '%appUrlsImports';
4
+ import { createAuthVerification, validateAuthVerification, } from '%authModuleImports';
5
+ import { BadRequestError, handleZodRequestValidationError, NotFoundError, } from '%errorHandlerServiceImports';
6
+ import { createPasswordHash } from '%passwordHasherServiceImports';
7
+ import { prisma } from '%prismaImports';
8
+ import z from 'zod';
9
+ const PROVIDER_ID = 'email-password';
10
+ const INVITE_TYPE = 'invite';
11
+ /**
12
+ * Sends an invite email so a user can set their password and sign in.
13
+ * Admin-triggered, so unlike password reset requests, it does not need
14
+ * anti-enumeration rate limiting.
15
+ */
16
+ export async function inviteUser({ userId, context, }) {
17
+ const { services } = context;
18
+ const user = await prisma.user.findUnique({ where: { id: userId } });
19
+ if (!user) {
20
+ throw new NotFoundError('User not found', 'user-not-found');
21
+ }
22
+ if (!user.email) {
23
+ throw new BadRequestError('User has no email', 'user-has-no-email');
24
+ }
25
+ const existingAccount = await prisma.userAccount.findUnique({
26
+ where: {
27
+ accountId_providerId: {
28
+ accountId: user.email,
29
+ providerId: PROVIDER_ID,
30
+ },
31
+ },
32
+ });
33
+ if (existingAccount) {
34
+ throw new BadRequestError('User already has a password set', 'user-already-has-account');
35
+ }
36
+ const { token } = await createAuthVerification({
37
+ type: INVITE_TYPE,
38
+ userId: user.id,
39
+ expiresInSec: INVITE_TOKEN_EXPIRY_SEC,
40
+ });
41
+ const acceptLink = getWebUrl(TPL_AUTH_WEB_APP, `/auth/accept-invite?token=${encodeURIComponent(token)}`);
42
+ await services.email.send(TPL_INVITE_EMAIL, {
43
+ to: user.email,
44
+ data: { acceptLink },
45
+ });
46
+ return { user };
47
+ }
48
+ const validateTokenSchema = z.object({
49
+ token: z.string().min(1).max(AUTH_TOKEN_MAX_LENGTH),
50
+ });
51
+ /**
52
+ * Validates an invite token without consuming it.
53
+ * Used by the frontend to verify the token is valid and to show the
54
+ * invited email before displaying the set-password form.
55
+ *
56
+ * @throws BadRequestError with code 'invalid-token' if the token is invalid or expired
57
+ */
58
+ export async function validateInviteToken({ token: rawToken, }) {
59
+ const { token } = await validateTokenSchema
60
+ .parseAsync({ token: rawToken })
61
+ .catch(handleZodRequestValidationError);
62
+ const record = await validateAuthVerification({
63
+ type: INVITE_TYPE,
64
+ token,
65
+ });
66
+ if (!record?.userId) {
67
+ throw new BadRequestError('Invalid or expired token', 'invalid-token');
68
+ }
69
+ const user = await prisma.user.findUniqueOrThrow({
70
+ where: { id: record.userId },
71
+ select: { email: true },
72
+ });
73
+ if (!user.email) {
74
+ throw new BadRequestError('User has no email', 'user-has-no-email');
75
+ }
76
+ return { email: user.email };
77
+ }
78
+ const acceptInviteSchema = z.object({
79
+ token: z.string().min(1).max(AUTH_TOKEN_MAX_LENGTH),
80
+ newPassword: z.string().min(PASSWORD_MIN_LENGTH).max(PASSWORD_MAX_LENGTH),
81
+ });
82
+ /**
83
+ * Completes the invite flow by setting the invited user's password and
84
+ * signing them in. Token is single-use (deleted after acceptance, along
85
+ * with any other pending invite tokens for the user).
86
+ */
87
+ export async function acceptInvite({ token: rawToken, newPassword: rawNewPassword, context, }) {
88
+ const { token, newPassword } = await acceptInviteSchema
89
+ .parseAsync({
90
+ token: rawToken,
91
+ newPassword: rawNewPassword,
92
+ })
93
+ .catch(handleZodRequestValidationError);
94
+ const record = await validateAuthVerification({
95
+ type: INVITE_TYPE,
96
+ token,
97
+ });
98
+ if (!record?.userId) {
99
+ throw new BadRequestError('Invalid or expired token', 'invalid-token');
100
+ }
101
+ const user = await prisma.user.findUniqueOrThrow({
102
+ where: { id: record.userId },
103
+ select: { id: true, email: true },
104
+ });
105
+ if (!user.email) {
106
+ throw new BadRequestError('User has no email', 'user-has-no-email');
107
+ }
108
+ // The invite token outlives the check in `inviteUser`, so the user may have
109
+ // registered in the meantime.
110
+ const existingAccount = await prisma.userAccount.findUnique({
111
+ where: {
112
+ accountId_providerId: {
113
+ accountId: user.email,
114
+ providerId: PROVIDER_ID,
115
+ },
116
+ },
117
+ });
118
+ if (existingAccount) {
119
+ throw new BadRequestError('User already has a password set', 'user-already-has-account');
120
+ }
121
+ const passwordHash = await createPasswordHash(newPassword);
122
+ await prisma.$transaction([
123
+ prisma.authVerification.deleteMany({
124
+ where: { type: INVITE_TYPE, userId: user.id },
125
+ }),
126
+ prisma.userAccount.create({
127
+ data: {
128
+ userId: user.id,
129
+ accountId: user.email,
130
+ providerId: PROVIDER_ID,
131
+ password: passwordHash,
132
+ },
133
+ }),
134
+ prisma.user.update({
135
+ where: { id: user.id },
136
+ data: { emailVerified: true },
137
+ }),
138
+ ]);
139
+ const session = await context.services.userSession.createSession(user.id, context);
140
+ return { session };
141
+ }
142
+ //# sourceMappingURL=invite.service.js.map
@@ -0,0 +1,221 @@
1
+ // @ts-nocheck
2
+
3
+ import type { User } from '%prismaGeneratedImports';
4
+ import type {
5
+ RequestServiceContext,
6
+ RequestServiceContextWith,
7
+ } from '%requestServiceContextImports';
8
+ import type { UserSessionPayload } from '%userSessionTypesImports';
9
+
10
+ import {
11
+ AUTH_TOKEN_MAX_LENGTH,
12
+ INVITE_TOKEN_EXPIRY_SEC,
13
+ PASSWORD_MAX_LENGTH,
14
+ PASSWORD_MIN_LENGTH,
15
+ } from '$constantsPassword';
16
+ import { getWebUrl } from '%appUrlsImports';
17
+ import {
18
+ createAuthVerification,
19
+ validateAuthVerification,
20
+ } from '%authModuleImports';
21
+ import {
22
+ BadRequestError,
23
+ handleZodRequestValidationError,
24
+ NotFoundError,
25
+ } from '%errorHandlerServiceImports';
26
+ import { createPasswordHash } from '%passwordHasherServiceImports';
27
+ import { prisma } from '%prismaImports';
28
+ import z from 'zod';
29
+
30
+ const PROVIDER_ID = 'email-password';
31
+ const INVITE_TYPE = 'invite';
32
+
33
+ /**
34
+ * Sends an invite email so a user can set their password and sign in.
35
+ * Admin-triggered, so unlike password reset requests, it does not need
36
+ * anti-enumeration rate limiting.
37
+ */
38
+ export async function inviteUser({
39
+ userId,
40
+ context,
41
+ }: {
42
+ userId: string;
43
+ context: RequestServiceContextWith<'email'>;
44
+ }): Promise<{ user: User }> {
45
+ const { services } = context;
46
+
47
+ const user = await prisma.user.findUnique({ where: { id: userId } });
48
+
49
+ if (!user) {
50
+ throw new NotFoundError('User not found', 'user-not-found');
51
+ }
52
+
53
+ if (!user.email) {
54
+ throw new BadRequestError('User has no email', 'user-has-no-email');
55
+ }
56
+
57
+ const existingAccount = await prisma.userAccount.findUnique({
58
+ where: {
59
+ accountId_providerId: {
60
+ accountId: user.email,
61
+ providerId: PROVIDER_ID,
62
+ },
63
+ },
64
+ });
65
+
66
+ if (existingAccount) {
67
+ throw new BadRequestError(
68
+ 'User already has a password set',
69
+ 'user-already-has-account',
70
+ );
71
+ }
72
+
73
+ const { token } = await createAuthVerification({
74
+ type: INVITE_TYPE,
75
+ userId: user.id,
76
+ expiresInSec: INVITE_TOKEN_EXPIRY_SEC,
77
+ });
78
+
79
+ const acceptLink = getWebUrl(
80
+ TPL_AUTH_WEB_APP,
81
+ `/auth/accept-invite?token=${encodeURIComponent(token)}`,
82
+ );
83
+
84
+ await services.email.send(TPL_INVITE_EMAIL, {
85
+ to: user.email,
86
+ data: { acceptLink },
87
+ });
88
+
89
+ return { user };
90
+ }
91
+
92
+ const validateTokenSchema = z.object({
93
+ token: z.string().min(1).max(AUTH_TOKEN_MAX_LENGTH),
94
+ });
95
+
96
+ /**
97
+ * Validates an invite token without consuming it.
98
+ * Used by the frontend to verify the token is valid and to show the
99
+ * invited email before displaying the set-password form.
100
+ *
101
+ * @throws BadRequestError with code 'invalid-token' if the token is invalid or expired
102
+ */
103
+ export async function validateInviteToken({
104
+ token: rawToken,
105
+ }: {
106
+ token: string;
107
+ }): Promise<{ email: string }> {
108
+ const { token } = await validateTokenSchema
109
+ .parseAsync({ token: rawToken })
110
+ .catch(handleZodRequestValidationError);
111
+
112
+ const record = await validateAuthVerification({
113
+ type: INVITE_TYPE,
114
+ token,
115
+ });
116
+
117
+ if (!record?.userId) {
118
+ throw new BadRequestError('Invalid or expired token', 'invalid-token');
119
+ }
120
+
121
+ const user = await prisma.user.findUniqueOrThrow({
122
+ where: { id: record.userId },
123
+ select: { email: true },
124
+ });
125
+
126
+ if (!user.email) {
127
+ throw new BadRequestError('User has no email', 'user-has-no-email');
128
+ }
129
+
130
+ return { email: user.email };
131
+ }
132
+
133
+ const acceptInviteSchema = z.object({
134
+ token: z.string().min(1).max(AUTH_TOKEN_MAX_LENGTH),
135
+ newPassword: z.string().min(PASSWORD_MIN_LENGTH).max(PASSWORD_MAX_LENGTH),
136
+ });
137
+
138
+ /**
139
+ * Completes the invite flow by setting the invited user's password and
140
+ * signing them in. Token is single-use (deleted after acceptance, along
141
+ * with any other pending invite tokens for the user).
142
+ */
143
+ export async function acceptInvite({
144
+ token: rawToken,
145
+ newPassword: rawNewPassword,
146
+ context,
147
+ }: {
148
+ token: string;
149
+ newPassword: string;
150
+ context: RequestServiceContext;
151
+ }): Promise<{ session: UserSessionPayload }> {
152
+ const { token, newPassword } = await acceptInviteSchema
153
+ .parseAsync({
154
+ token: rawToken,
155
+ newPassword: rawNewPassword,
156
+ })
157
+ .catch(handleZodRequestValidationError);
158
+
159
+ const record = await validateAuthVerification({
160
+ type: INVITE_TYPE,
161
+ token,
162
+ });
163
+
164
+ if (!record?.userId) {
165
+ throw new BadRequestError('Invalid or expired token', 'invalid-token');
166
+ }
167
+
168
+ const user = await prisma.user.findUniqueOrThrow({
169
+ where: { id: record.userId },
170
+ select: { id: true, email: true },
171
+ });
172
+
173
+ if (!user.email) {
174
+ throw new BadRequestError('User has no email', 'user-has-no-email');
175
+ }
176
+
177
+ // The invite token outlives the check in `inviteUser`, so the user may have
178
+ // registered in the meantime.
179
+ const existingAccount = await prisma.userAccount.findUnique({
180
+ where: {
181
+ accountId_providerId: {
182
+ accountId: user.email,
183
+ providerId: PROVIDER_ID,
184
+ },
185
+ },
186
+ });
187
+
188
+ if (existingAccount) {
189
+ throw new BadRequestError(
190
+ 'User already has a password set',
191
+ 'user-already-has-account',
192
+ );
193
+ }
194
+
195
+ const passwordHash = await createPasswordHash(newPassword);
196
+
197
+ await prisma.$transaction([
198
+ prisma.authVerification.deleteMany({
199
+ where: { type: INVITE_TYPE, userId: user.id },
200
+ }),
201
+ prisma.userAccount.create({
202
+ data: {
203
+ userId: user.id,
204
+ accountId: user.email,
205
+ providerId: PROVIDER_ID,
206
+ password: passwordHash,
207
+ },
208
+ }),
209
+ prisma.user.update({
210
+ where: { id: user.id },
211
+ data: { emailVerified: true },
212
+ }),
213
+ ]);
214
+
215
+ const session = await context.services.userSession.createSession(
216
+ user.id,
217
+ context,
218
+ );
219
+
220
+ return { session };
221
+ }
@@ -1,8 +1,8 @@
1
1
  // @ts-nocheck
2
- import { PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PASSWORD_RESET_TOKEN_EXPIRY_SEC, } from '$constantsPassword';
2
+ import { AUTH_TOKEN_MAX_LENGTH, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PASSWORD_RESET_TOKEN_EXPIRY_SEC, } from '$constantsPassword';
3
3
  import { resetLoginRateLimits } from '$servicesUserPassword';
4
+ import { getWebAppForUrl, getWebUrl } from '%appUrlsImports';
4
5
  import { createAuthVerification, validateAuthVerification, } from '%authModuleImports';
5
- import { getConfig } from '%configServiceImports';
6
6
  import { BadRequestError, handleZodRequestValidationError, } from '%errorHandlerServiceImports';
7
7
  import { createPasswordHash } from '%passwordHasherServiceImports';
8
8
  import { prisma } from '%prismaImports';
@@ -58,8 +58,7 @@ export async function requestPasswordReset({ email: rawEmail, context, }) {
58
58
  userId: user.id,
59
59
  expiresInSec: PASSWORD_RESET_TOKEN_EXPIRY_SEC,
60
60
  });
61
- // Construct reset URL using configured domain
62
- const resetLink = `${getConfig().AUTH_FRONTEND_URL}/auth/reset-password?token=${encodeURIComponent(token)}`;
61
+ const resetLink = getWebUrl(getWebAppForUrl(context.reqInfo.headers.origin) ?? TPL_AUTH_WEB_APP, `/auth/reset-password?token=${encodeURIComponent(token)}`);
63
62
  // Send email asynchronously (queue-based)
64
63
  await services.email.send(TPL_PASSWORD_RESET_EMAIL, {
65
64
  to: user.email,
@@ -70,7 +69,7 @@ export async function requestPasswordReset({ email: rawEmail, context, }) {
70
69
  return { success: true };
71
70
  }
72
71
  const validateTokenSchema = z.object({
73
- token: z.string().min(1).max(PASSWORD_MAX_LENGTH),
72
+ token: z.string().min(1).max(AUTH_TOKEN_MAX_LENGTH),
74
73
  });
75
74
  /**
76
75
  * Validates a password reset token without consuming it.
@@ -92,7 +91,7 @@ export async function validatePasswordResetToken({ token: rawToken, }) {
92
91
  return { success: true };
93
92
  }
94
93
  const completePasswordResetSchema = z.object({
95
- token: z.string().min(1).max(PASSWORD_MAX_LENGTH),
94
+ token: z.string().min(1).max(AUTH_TOKEN_MAX_LENGTH),
96
95
  newPassword: z.string().min(PASSWORD_MIN_LENGTH).max(PASSWORD_MAX_LENGTH),
97
96
  });
98
97
  /**
@@ -3,16 +3,17 @@
3
3
  import type { RequestServiceContextWith } from '%requestServiceContextImports';
4
4
 
5
5
  import {
6
+ AUTH_TOKEN_MAX_LENGTH,
6
7
  PASSWORD_MAX_LENGTH,
7
8
  PASSWORD_MIN_LENGTH,
8
9
  PASSWORD_RESET_TOKEN_EXPIRY_SEC,
9
10
  } from '$constantsPassword';
10
11
  import { resetLoginRateLimits } from '$servicesUserPassword';
12
+ import { getWebAppForUrl, getWebUrl } from '%appUrlsImports';
11
13
  import {
12
14
  createAuthVerification,
13
15
  validateAuthVerification,
14
16
  } from '%authModuleImports';
15
- import { getConfig } from '%configServiceImports';
16
17
  import {
17
18
  BadRequestError,
18
19
  handleZodRequestValidationError,
@@ -107,8 +108,10 @@ export async function requestPasswordReset({
107
108
  expiresInSec: PASSWORD_RESET_TOKEN_EXPIRY_SEC,
108
109
  });
109
110
 
110
- // Construct reset URL using configured domain
111
- const resetLink = `${getConfig().AUTH_FRONTEND_URL}/auth/reset-password?token=${encodeURIComponent(token)}`;
111
+ const resetLink = getWebUrl(
112
+ getWebAppForUrl(context.reqInfo.headers.origin) ?? TPL_AUTH_WEB_APP,
113
+ `/auth/reset-password?token=${encodeURIComponent(token)}`,
114
+ );
112
115
 
113
116
  // Send email asynchronously (queue-based)
114
117
  await services.email.send(TPL_PASSWORD_RESET_EMAIL, {
@@ -122,7 +125,7 @@ export async function requestPasswordReset({
122
125
  }
123
126
 
124
127
  const validateTokenSchema = z.object({
125
- token: z.string().min(1).max(PASSWORD_MAX_LENGTH),
128
+ token: z.string().min(1).max(AUTH_TOKEN_MAX_LENGTH),
126
129
  });
127
130
 
128
131
  /**
@@ -153,7 +156,7 @@ export async function validatePasswordResetToken({
153
156
  }
154
157
 
155
158
  const completePasswordResetSchema = z.object({
156
- token: z.string().min(1).max(PASSWORD_MAX_LENGTH),
159
+ token: z.string().min(1).max(AUTH_TOKEN_MAX_LENGTH),
157
160
  newPassword: z.string().min(PASSWORD_MIN_LENGTH).max(PASSWORD_MAX_LENGTH),
158
161
  });
159
162
 
@@ -5,7 +5,9 @@
5
5
  * account verification) with the transactional email library and generates
6
6
  * the corresponding .tsx template files.
7
7
  */
8
- export declare const authEmailTemplatesGenerator: import("@baseplate-dev/sync").GeneratorBundleCreator<Record<string, never>, {
8
+ export declare const authEmailTemplatesGenerator: import("@baseplate-dev/sync").GeneratorBundleCreator<{
9
+ emailOtp?: boolean | undefined;
10
+ }, {
9
11
  paths: import("@baseplate-dev/sync").GeneratorTask<{
10
12
  localAuthAuthEmailTemplatesPaths: import("@baseplate-dev/sync").ProviderExport<import("./generated/template-paths.js").LocalAuthAuthEmailTemplatesPaths>;
11
13
  }, {
@@ -2,7 +2,9 @@ import { emailTemplatesProvider } from '@baseplate-dev/plugin-email';
2
2
  import { createGenerator, createGeneratorTask } from '@baseplate-dev/sync';
3
3
  import { z } from 'zod';
4
4
  import { LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_GENERATED as GENERATED_TEMPLATES } from './generated/index.js';
5
- const descriptorSchema = z.object({});
5
+ const descriptorSchema = z.object({
6
+ emailOtp: z.boolean().default(false),
7
+ });
6
8
  /**
7
9
  * Generator for auth email templates.
8
10
  *
@@ -14,7 +16,7 @@ export const authEmailTemplatesGenerator = createGenerator({
14
16
  name: 'local-auth/auth-email-templates',
15
17
  generatorFileUrl: import.meta.url,
16
18
  descriptorSchema,
17
- buildTasks: () => ({
19
+ buildTasks: ({ emailOtp }) => ({
18
20
  paths: GENERATED_TEMPLATES.paths.task,
19
21
  renderers: GENERATED_TEMPLATES.renderers.task,
20
22
  main: createGeneratorTask({
@@ -36,9 +38,22 @@ export const authEmailTemplatesGenerator = createGenerator({
36
38
  exportName: 'PasswordResetEmail',
37
39
  exportPath: paths.passwordResetEmail,
38
40
  });
41
+ emailTemplates.registerExport({
42
+ exportName: 'InviteEmail',
43
+ exportPath: paths.inviteEmail,
44
+ });
45
+ if (emailOtp) {
46
+ emailTemplates.registerExport({
47
+ exportName: 'EmailOtpEmail',
48
+ exportPath: paths.emailOtpEmail,
49
+ });
50
+ }
39
51
  return {
40
52
  build: async (builder) => {
41
- await builder.apply(renderers.accountVerificationEmail.render({}), renderers.passwordChangedEmail.render({}), renderers.passwordResetEmail.render({}));
53
+ await builder.apply(renderers.accountVerificationEmail.render({}), renderers.passwordChangedEmail.render({}), renderers.passwordResetEmail.render({}), renderers.inviteEmail.render({}));
54
+ if (emailOtp) {
55
+ await builder.apply(renderers.emailOtpEmail.render({}));
56
+ }
42
57
  },
43
58
  };
44
59
  },
@@ -55,6 +55,46 @@ export declare const LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_GENERATED: {
55
55
  theme: {};
56
56
  }>>;
57
57
  }, Record<never, Record<never, never>>>;
58
+ emailOtpEmail: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
59
+ transactionalLibImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
60
+ Button: {};
61
+ defineEmail: {};
62
+ DefineEmailOptions: {
63
+ isTypeOnly: true;
64
+ };
65
+ Divider: {};
66
+ EmailComponent: {
67
+ isTypeOnly: true;
68
+ };
69
+ EmailLayout: {};
70
+ Heading: {};
71
+ Link: {};
72
+ renderEmail: {};
73
+ Section: {};
74
+ Text: {};
75
+ theme: {};
76
+ }>>;
77
+ }, Record<never, Record<never, never>>>;
78
+ inviteEmail: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
79
+ transactionalLibImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
80
+ Button: {};
81
+ defineEmail: {};
82
+ DefineEmailOptions: {
83
+ isTypeOnly: true;
84
+ };
85
+ Divider: {};
86
+ EmailComponent: {
87
+ isTypeOnly: true;
88
+ };
89
+ EmailLayout: {};
90
+ Heading: {};
91
+ Link: {};
92
+ renderEmail: {};
93
+ Section: {};
94
+ Text: {};
95
+ theme: {};
96
+ }>>;
97
+ }, Record<never, Record<never, never>>>;
58
98
  passwordChangedEmail: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
59
99
  transactionalLibImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
60
100
  Button: {};
@@ -1,5 +1,7 @@
1
1
  export interface LocalAuthAuthEmailTemplatesPaths {
2
2
  accountVerificationEmail: string;
3
+ emailOtpEmail: string;
4
+ inviteEmail: string;
3
5
  passwordChangedEmail: string;
4
6
  passwordResetEmail: string;
5
7
  }
@@ -12,6 +12,8 @@ const localAuthAuthEmailTemplatesPathsTask = createGeneratorTask({
12
12
  providers: {
13
13
  localAuthAuthEmailTemplatesPaths: {
14
14
  accountVerificationEmail: `${srcRoot}/emails/auth/account-verification.email.tsx`,
15
+ emailOtpEmail: `${srcRoot}/emails/auth/email-otp.email.tsx`,
16
+ inviteEmail: `${srcRoot}/emails/auth/invite.email.tsx`,
15
17
  passwordChangedEmail: `${srcRoot}/emails/auth/password-changed.email.tsx`,
16
18
  passwordResetEmail: `${srcRoot}/emails/auth/password-reset.email.tsx`,
17
19
  },
@@ -5,6 +5,12 @@ export interface LocalAuthAuthEmailTemplatesRenderers {
5
5
  accountVerificationEmail: {
6
6
  render: (options: Omit<RenderTsTemplateFileActionInput<typeof LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES.accountVerificationEmail>, 'destination' | 'importMapProviders' | 'template' | 'generatorPaths'>) => BuilderAction;
7
7
  };
8
+ emailOtpEmail: {
9
+ render: (options: Omit<RenderTsTemplateFileActionInput<typeof LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES.emailOtpEmail>, 'destination' | 'importMapProviders' | 'template' | 'generatorPaths'>) => BuilderAction;
10
+ };
11
+ inviteEmail: {
12
+ render: (options: Omit<RenderTsTemplateFileActionInput<typeof LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES.inviteEmail>, 'destination' | 'importMapProviders' | 'template' | 'generatorPaths'>) => BuilderAction;
13
+ };
8
14
  passwordChangedEmail: {
9
15
  render: (options: Omit<RenderTsTemplateFileActionInput<typeof LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES.passwordChangedEmail>, 'destination' | 'importMapProviders' | 'template' | 'generatorPaths'>) => BuilderAction;
10
16
  };
@@ -27,6 +27,26 @@ const localAuthAuthEmailTemplatesRenderersTask = createGeneratorTask({
27
27
  ...options,
28
28
  }),
29
29
  },
30
+ emailOtpEmail: {
31
+ render: (options) => typescriptFile.renderTemplateFile({
32
+ template: LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES.emailOtpEmail,
33
+ destination: paths.emailOtpEmail,
34
+ importMapProviders: {
35
+ transactionalLibImports,
36
+ },
37
+ ...options,
38
+ }),
39
+ },
40
+ inviteEmail: {
41
+ render: (options) => typescriptFile.renderTemplateFile({
42
+ template: LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES.inviteEmail,
43
+ destination: paths.inviteEmail,
44
+ importMapProviders: {
45
+ transactionalLibImports,
46
+ },
47
+ ...options,
48
+ }),
49
+ },
30
50
  passwordChangedEmail: {
31
51
  render: (options) => typescriptFile.renderTemplateFile({
32
52
  template: LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES.passwordChangedEmail,
@@ -19,6 +19,46 @@ export declare const LOCAL_AUTH_AUTH_EMAIL_TEMPLATES_TEMPLATES: {
19
19
  theme: {};
20
20
  }>>;
21
21
  }, Record<never, Record<never, never>>>;
22
+ emailOtpEmail: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
23
+ transactionalLibImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
24
+ Button: {};
25
+ defineEmail: {};
26
+ DefineEmailOptions: {
27
+ isTypeOnly: true;
28
+ };
29
+ Divider: {};
30
+ EmailComponent: {
31
+ isTypeOnly: true;
32
+ };
33
+ EmailLayout: {};
34
+ Heading: {};
35
+ Link: {};
36
+ renderEmail: {};
37
+ Section: {};
38
+ Text: {};
39
+ theme: {};
40
+ }>>;
41
+ }, Record<never, Record<never, never>>>;
42
+ inviteEmail: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
43
+ transactionalLibImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
44
+ Button: {};
45
+ defineEmail: {};
46
+ DefineEmailOptions: {
47
+ isTypeOnly: true;
48
+ };
49
+ Divider: {};
50
+ EmailComponent: {
51
+ isTypeOnly: true;
52
+ };
53
+ EmailLayout: {};
54
+ Heading: {};
55
+ Link: {};
56
+ renderEmail: {};
57
+ Section: {};
58
+ Text: {};
59
+ theme: {};
60
+ }>>;
61
+ }, Record<never, Record<never, never>>>;
22
62
  passwordChangedEmail: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
23
63
  transactionalLibImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
24
64
  Button: {};