@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
@@ -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 user ID change events
9
+ * Callback function for session change events
7
10
  */
8
- type UserIdChangeCallback = (userId: string | undefined) => void;
11
+ type SessionChangeCallback = () => void;
9
12
 
10
- /**
11
- * User session client for managing session persistence using localStorage
12
- * Handles session state persistence and cross-tab synchronization
13
- */
14
- export class UserSessionClient {
15
- private static readonly USER_ID_STORAGE_KEY = 'APP_USER_ID';
16
- private readonly storage = getSafeLocalStorage();
17
- private readonly callbacks = new Set<UserIdChangeCallback>();
18
- private cleanupListener?: () => void;
19
-
20
- constructor() {
21
- // Initialize storage listener for cross-tab synchronization
22
- this.setupStorageListener();
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
- * Sign in a user with the given user ID
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): void {
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(): void {
41
- const existingUserId = this.getUserId();
42
- this.setUserId(null);
43
- if (existingUserId) {
44
- this.notifyCallbacks();
45
- }
46
- }
47
-
54
+ signOut: () => void;
48
55
  /**
49
- * Subscribe to user ID changes
50
- * @param callback - Function to call when user ID changes
51
- * @returns Cleanup function to unsubscribe
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
- onUserIdChange(callback: UserIdChangeCallback): () => void {
54
- this.callbacks.add(callback);
55
- return () => {
56
- this.callbacks.delete(callback);
57
- };
58
- }
59
-
60
+ setServerSession: (
61
+ session: { userId: string; roles: AuthRole[] } | undefined,
62
+ ) => void;
60
63
  /**
61
- * Clean up resources when the client is no longer needed
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
- destroy(): void {
64
- this.cleanupListener?.();
65
- this.callbacks.clear();
66
- }
67
-
67
+ getPersistedUserId: () => string | undefined;
68
68
  /**
69
- * Get the current user ID from storage
70
- * @returns User ID or null if not authenticated
69
+ * Clean up resources when the client is no longer needed
71
70
  */
72
- getUserId(): string | undefined {
73
- return (
74
- this.storage.getItem(UserSessionClient.USER_ID_STORAGE_KEY) ?? undefined
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
- * Set the user ID in storage
80
- * @param userId - User ID to store, or null to clear
81
- */
82
- private setUserId(userId: string | null): void {
83
- const currentUserId = this.getUserId();
84
- const userIdChanged = userId !== currentUserId;
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
- if (!userIdChanged) {
110
+ function persistUserId(userId: string | undefined): void {
111
+ if (userId === getPersistedUserId()) {
87
112
  return;
88
113
  }
89
114
 
90
115
  if (userId) {
91
- this.storage.setItem(UserSessionClient.USER_ID_STORAGE_KEY, userId);
116
+ storage.setItem(USER_ID_STORAGE_KEY, userId);
92
117
  } else {
93
- this.storage.removeItem(UserSessionClient.USER_ID_STORAGE_KEY);
118
+ storage.removeItem(USER_ID_STORAGE_KEY);
94
119
  }
95
120
  }
96
121
 
97
- /**
98
- * Set up storage listener for cross-tab synchronization
99
- */
100
- private setupStorageListener(): void {
101
- this.cleanupListener = this.storage.addEventListener((key) => {
102
- if (key === UserSessionClient.USER_ID_STORAGE_KEY) {
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
- * Notify all registered callbacks of session changes
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 = new 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, 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';
@@ -9,6 +9,7 @@ import { authHooksGenerator } from './generators/auth-hooks/auth-hooks.generator
9
9
  import { authRoutesGenerator } from './generators/auth-routes/auth-routes.generator.js';
10
10
  import { authModuleGenerator, reactAuthGenerator, seedInitialUserGenerator, } from './generators/index.js';
11
11
  import { reactSessionGenerator } from './generators/react-session/react-session.generator.js';
12
+ import { getLocalAuthWebAppData } from './schema/web-app-schema.js';
12
13
  export default createPluginModule({
13
14
  name: 'node',
14
15
  dependencies: {
@@ -16,8 +17,12 @@ export default createPluginModule({
16
17
  emailTemplate: emailTemplateSpec,
17
18
  },
18
19
  initialize: ({ appCompiler, emailTemplate }, { pluginKey }) => {
19
- // Register auth email templates with the transactional lib
20
- emailTemplate.generators.push(authEmailTemplatesGenerator({}));
20
+ // Register auth email templates with the transactional lib. Resolved lazily
21
+ // so the sign-in code email is only emitted when that flow is enabled.
22
+ emailTemplate.generators.push(({ projectDefinition }) => {
23
+ const { emailOtp } = PluginUtils.configByKeyOrThrow(projectDefinition, pluginKey);
24
+ return authEmailTemplatesGenerator({ emailOtp });
25
+ });
21
26
  // register backend compiler
22
27
  appCompiler.compilers.push({
23
28
  pluginKey,
@@ -25,11 +30,18 @@ export default createPluginModule({
25
30
  compile: ({ projectDefinition, definitionContainer, appCompiler }) => {
26
31
  const localAuthDefinition = PluginUtils.configByKeyOrThrow(projectDefinition, pluginKey);
27
32
  const authDefinition = getAuthPluginDefinition(projectDefinition);
28
- // Get web app ports
29
33
  const webApps = projectDefinition.apps.filter((app) => app.type === 'web');
30
- const devWebPorts = webApps.map((app) => app.devPort);
31
- const devWebDomainPort = devWebPorts[0] ??
32
- projectDefinition.settings.general.portOffset + 30;
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
+ }
39
+ // The register mutation is shared by every web app on this
40
+ // backend, so it can only be dropped once none of them allow
41
+ // self-service registration.
42
+ const disableRegistration = webApps.length > 0 &&
43
+ webApps.every((app) => getLocalAuthWebAppData(app, pluginKey)?.disableRegistration ??
44
+ false);
33
45
  const additionalAdminRoles = localAuthDefinition.additionalUserAdminRoles.map((role) => definitionContainer.nameFromId(role));
34
46
  // 'admin' is always included since it is now a built-in role guaranteed to exist
35
47
  const adminRoles = [...new Set(['admin', ...additionalAdminRoles])];
@@ -39,7 +51,7 @@ export default createPluginModule({
39
51
  }),
40
52
  authModule: authModuleGenerator({
41
53
  userAdminRoles: adminRoles,
42
- devWebPorts,
54
+ emailOtp: localAuthDefinition.emailOtp,
43
55
  }),
44
56
  emailPassword: appModuleGenerator({
45
57
  id: 'email-password',
@@ -47,19 +59,23 @@ export default createPluginModule({
47
59
  children: {
48
60
  module: authEmailPasswordGenerator({
49
61
  adminRoles,
50
- devWebDomainPort,
62
+ webAppName: authWebApp.name,
51
63
  requireNameOnRegistration: localAuthDefinition.requireNameOnRegistration,
64
+ emailOtp: localAuthDefinition.emailOtp,
65
+ disableRegistration,
52
66
  }),
53
67
  hasher: passwordHasherServiceGenerator({}),
54
68
  },
55
69
  }),
56
70
  });
57
71
  },
58
- }, {
72
+ }, pluginAppCompiler({
59
73
  pluginKey,
60
74
  appType: webAppEntryType,
61
- compile: ({ projectDefinition, appCompiler }) => {
75
+ compile: ({ projectDefinition, appDefinition, appCompiler }) => {
62
76
  const localAuthDefinition = PluginUtils.configByKeyOrThrow(projectDefinition, pluginKey);
77
+ const disableRegistration = getLocalAuthWebAppData(appDefinition, pluginKey)
78
+ ?.disableRegistration ?? false;
63
79
  appCompiler.addRootChildren({
64
80
  authApollo: authApolloGenerator({}),
65
81
  reactAuth: reactAuthGenerator({}),
@@ -67,10 +83,12 @@ export default createPluginModule({
67
83
  reactSession: reactSessionGenerator({}),
68
84
  authRoutes: authRoutesGenerator({
69
85
  requireNameOnRegistration: localAuthDefinition.requireNameOnRegistration,
86
+ emailOtp: localAuthDefinition.emailOtp,
87
+ disableRegistration,
70
88
  }),
71
89
  });
72
90
  },
73
- });
91
+ }));
74
92
  },
75
93
  });
76
94
  //# sourceMappingURL=node.js.map
@@ -0,0 +1,3 @@
1
+ import type { PluginConfigMigration } from '@baseplate-dev/project-builder-lib';
2
+ export declare const LOCAL_AUTH_PLUGIN_CONFIG_MIGRATIONS: PluginConfigMigration[];
3
+ //# sourceMappingURL=migrations.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { modelScalarFieldEntityType } from '@baseplate-dev/project-builder-lib';
2
+ import { LOCAL_AUTH_MODELS } from '#src/local-auth/constants/model-names.js';
3
+ export const LOCAL_AUTH_PLUGIN_CONFIG_MIGRATIONS = [
4
+ {
5
+ name: 'add-auth-verification-attempts',
6
+ version: 1,
7
+ // Emailed sign-in codes count failed guesses in a column so the counter can
8
+ // be incremented in the database. The field is added for every project, not
9
+ // just those with the flow enabled, because migrations run on a version
10
+ // bump rather than when the setting is toggled — gating it here would break
11
+ // anyone who turns the flow on later.
12
+ migrate: () => ({
13
+ updateProjectDefinition: (draft) => {
14
+ const draftDef = draft;
15
+ const authVerification = draftDef.models?.find((model) => model.name === LOCAL_AUTH_MODELS.authVerification);
16
+ const fields = authVerification?.model?.fields;
17
+ // Projects created after this change are seeded with the field already.
18
+ if (!fields || fields.some((field) => field.name === 'attempts')) {
19
+ return;
20
+ }
21
+ // Ahead of expiresAt/createdAt, matching the seeded field order so a
22
+ // migrated definition and a fresh one produce the same schema.
23
+ const timestampIndex = fields.findIndex((field) => field.name === 'expiresAt');
24
+ const insertAt = timestampIndex === -1 ? fields.length : timestampIndex;
25
+ fields.splice(insertAt, 0, {
26
+ id: modelScalarFieldEntityType.generateNewId(),
27
+ name: 'attempts',
28
+ type: 'int',
29
+ isOptional: false,
30
+ options: { default: '0' },
31
+ });
32
+ },
33
+ }),
34
+ },
35
+ ];
36
+ //# sourceMappingURL=migrations.js.map
@@ -247,6 +247,14 @@ export function createLocalAuthPartialDefinition(authFeatureName, accountsFeatur
247
247
  type: 'json',
248
248
  isOptional: true,
249
249
  },
250
+ // Failed guesses against a short code. Only the emailed-code flow
251
+ // uses this; split-token rows leave it at 0, since their verifier
252
+ // is random enough that a single miss deletes the record outright.
253
+ {
254
+ name: 'attempts',
255
+ type: 'int',
256
+ options: { default: '0' },
257
+ },
250
258
  {
251
259
  name: 'expiresAt',
252
260
  type: 'dateTime',
@@ -3,6 +3,7 @@ import { z } from 'zod';
3
3
  export declare const createLocalAuthPluginDefinitionSchema: (context: import("@baseplate-dev/project-builder-lib").DefinitionSchemaParserContext) => z.ZodObject<{
4
4
  additionalUserAdminRoles: z.ZodPrefault<z.ZodArray<z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>>;
5
5
  requireNameOnRegistration: z.ZodDefault<z.ZodBoolean>;
6
+ emailOtp: z.ZodDefault<z.ZodBoolean>;
6
7
  }, z.core.$strip>;
7
8
  export type LocalAuthPluginDefinition = def.InferOutput<typeof createLocalAuthPluginDefinitionSchema>;
8
9
  export type LocalAuthPluginDefinitionInput = def.InferInput<typeof createLocalAuthPluginDefinitionSchema>;
@@ -6,5 +6,6 @@ export const createLocalAuthPluginDefinitionSchema = definitionSchema((ctx) => z
6
6
  onDelete: 'DELETE',
7
7
  })), []),
8
8
  requireNameOnRegistration: z.boolean().default(false),
9
+ emailOtp: z.boolean().default(false),
9
10
  }));
10
11
  //# sourceMappingURL=plugin-definition.js.map
@@ -0,0 +1,15 @@
1
+ import type { def, WebAppConfigWithPluginData } from '@baseplate-dev/project-builder-lib';
2
+ import z from 'zod';
3
+ /**
4
+ * Per-app local-auth settings contributed to the web app config via
5
+ * `webAppSchemaExtensionSpec`, stored under `pluginData[localAuthPluginKey]`.
6
+ */
7
+ export declare const createLocalAuthWebAppSchema: (context: import("@baseplate-dev/project-builder-lib").DefinitionSchemaParserContext) => z.ZodObject<{
8
+ disableRegistration: z.ZodPrefault<z.ZodBoolean>;
9
+ }, z.z.core.$strip>;
10
+ export type LocalAuthWebAppData = def.InferOutput<typeof createLocalAuthWebAppSchema>;
11
+ /**
12
+ * Reads the local-auth per-app settings slice from a web app config.
13
+ */
14
+ export declare function getLocalAuthWebAppData(webApp: WebAppConfigWithPluginData, pluginKey: string): LocalAuthWebAppData | undefined;
15
+ //# sourceMappingURL=web-app-schema.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { definitionSchema, getWebAppPluginData, } from '@baseplate-dev/project-builder-lib';
2
+ import z from 'zod';
3
+ /**
4
+ * Per-app local-auth settings contributed to the web app config via
5
+ * `webAppSchemaExtensionSpec`, stored under `pluginData[localAuthPluginKey]`.
6
+ */
7
+ export const createLocalAuthWebAppSchema = definitionSchema((ctx) => z.object({
8
+ disableRegistration: ctx.withDefault(z.boolean(), false),
9
+ }));
10
+ /**
11
+ * Reads the local-auth per-app settings slice from a web app config.
12
+ */
13
+ export function getLocalAuthWebAppData(webApp, pluginKey) {
14
+ return getWebAppPluginData(webApp, pluginKey);
15
+ }
16
+ //# sourceMappingURL=web-app-schema.js.map
@@ -1,5 +1,7 @@
1
1
  import { createPluginModule, FeatureUtils, pluginDefaultsSpec, webConfigSpec, } from '@baseplate-dev/project-builder-lib';
2
+ import { createWebAppSettingsWebConfig, webAppSchemaExtensionWebSpec, } from '@baseplate-dev/project-builder-lib/web';
2
3
  import { LocalAuthDefinitionEditor } from './components/local-auth-definition-editor.js';
4
+ import { LocalAuthWebAppSettingsForm } from './components/local-auth-web-app-settings-form.js';
3
5
  import { createLocalAuthPartialDefinition } from './schema/models.js';
4
6
  import '../../styles.css';
5
7
  const AUTH_FEATURE_NAME = 'accounts/auth';
@@ -9,9 +11,14 @@ export default createPluginModule({
9
11
  dependencies: {
10
12
  webConfig: webConfigSpec,
11
13
  pluginDefaults: pluginDefaultsSpec,
14
+ webAppSchemaExtensionWeb: webAppSchemaExtensionWebSpec,
12
15
  },
13
- initialize: ({ webConfig, pluginDefaults }, { pluginKey }) => {
16
+ initialize: ({ webConfig, pluginDefaults, webAppSchemaExtensionWeb }, { pluginKey }) => {
14
17
  webConfig.components.set(pluginKey, LocalAuthDefinitionEditor);
18
+ webAppSchemaExtensionWeb.configs.set(pluginKey, createWebAppSettingsWebConfig({
19
+ pluginKey,
20
+ Form: LocalAuthWebAppSettingsForm,
21
+ }));
15
22
  pluginDefaults.builders.set(pluginKey, ({ draft }) => {
16
23
  // Idempotent with the parent auth builder, which also ensures these.
17
24
  FeatureUtils.ensureFeatureByNameRecursively(draft, AUTH_FEATURE_NAME);
@@ -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
- useRequiredUserId: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, {
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
  };
@@ -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>;
@@ -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