@contember/engine-tenant-api 2.0.0-alpha.14 → 2.0.0-alpha.15

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 (526) hide show
  1. package/dist/development/index.cjs +18 -6
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +20 -8
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/TenantContainer.cjs +7 -1
  6. package/dist/development/src/TenantContainer.cjs.map +1 -1
  7. package/dist/development/src/TenantContainer.js +7 -1
  8. package/dist/development/src/TenantContainer.js.map +1 -1
  9. package/dist/development/src/migrations/2024-08-26-120000-passwordless.cjs +31 -0
  10. package/dist/development/src/migrations/2024-08-26-120000-passwordless.cjs.map +1 -0
  11. package/dist/development/src/migrations/2024-08-26-120000-passwordless.js +32 -0
  12. package/dist/development/src/migrations/2024-08-26-120000-passwordless.js.map +1 -0
  13. package/dist/development/src/migrations/runner.cjs +3 -1
  14. package/dist/development/src/migrations/runner.cjs.map +1 -1
  15. package/dist/development/src/migrations/runner.js +3 -1
  16. package/dist/development/src/migrations/runner.js.map +1 -1
  17. package/dist/development/src/migrations/snapshot.cjs +33 -5
  18. package/dist/development/src/migrations/snapshot.cjs.map +1 -1
  19. package/dist/development/src/migrations/snapshot.js +33 -5
  20. package/dist/development/src/migrations/snapshot.js.map +1 -1
  21. package/dist/development/src/model/authorization/PermissionActions.cjs +5 -0
  22. package/dist/development/src/model/authorization/PermissionActions.cjs.map +1 -1
  23. package/dist/development/src/model/authorization/PermissionActions.js +5 -0
  24. package/dist/development/src/model/authorization/PermissionActions.js.map +1 -1
  25. package/dist/development/src/model/authorization/PermissionsFactory.cjs +5 -0
  26. package/dist/development/src/model/authorization/PermissionsFactory.cjs.map +1 -1
  27. package/dist/development/src/model/authorization/PermissionsFactory.js +5 -0
  28. package/dist/development/src/model/authorization/PermissionsFactory.js.map +1 -1
  29. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.cjs +20 -0
  30. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.cjs.map +1 -0
  31. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.js +20 -0
  32. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.js.map +1 -0
  33. package/dist/development/src/model/commands/person/CreatePersonCommand.cjs +2 -1
  34. package/dist/development/src/model/commands/person/CreatePersonCommand.cjs.map +1 -1
  35. package/dist/development/src/model/commands/person/CreatePersonCommand.js +2 -1
  36. package/dist/development/src/model/commands/person/CreatePersonCommand.js.map +1 -1
  37. package/dist/development/src/model/commands/person/TogglePersonPasswordlessCommand.cjs +18 -0
  38. package/dist/development/src/model/commands/person/TogglePersonPasswordlessCommand.cjs.map +1 -0
  39. package/dist/development/src/model/commands/person/TogglePersonPasswordlessCommand.js +18 -0
  40. package/dist/development/src/model/commands/person/TogglePersonPasswordlessCommand.js.map +1 -0
  41. package/dist/development/src/model/commands/personToken/ActivateOtpCommand.cjs +20 -0
  42. package/dist/development/src/model/commands/personToken/ActivateOtpCommand.cjs.map +1 -0
  43. package/dist/development/src/model/commands/personToken/ActivateOtpCommand.js +20 -0
  44. package/dist/development/src/model/commands/personToken/ActivateOtpCommand.js.map +1 -0
  45. package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.cjs +33 -0
  46. package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.cjs.map +1 -0
  47. package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.js +33 -0
  48. package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.js.map +1 -0
  49. package/dist/development/src/model/commands/personToken/IncreaseOtpAttemptCommand.cjs +19 -0
  50. package/dist/development/src/model/commands/personToken/IncreaseOtpAttemptCommand.cjs.map +1 -0
  51. package/dist/development/src/model/commands/personToken/IncreaseOtpAttemptCommand.js +19 -0
  52. package/dist/development/src/model/commands/personToken/IncreaseOtpAttemptCommand.js.map +1 -0
  53. package/dist/development/src/model/commands/personToken/InvalidateTokenCommand.cjs +19 -0
  54. package/dist/development/src/model/commands/personToken/InvalidateTokenCommand.cjs.map +1 -0
  55. package/dist/development/src/model/commands/personToken/InvalidateTokenCommand.js +19 -0
  56. package/dist/development/src/model/commands/personToken/InvalidateTokenCommand.js.map +1 -0
  57. package/dist/development/src/model/commands/personToken/ResetPasswordCommand.cjs +28 -0
  58. package/dist/development/src/model/commands/personToken/ResetPasswordCommand.cjs.map +1 -0
  59. package/dist/development/src/model/commands/personToken/ResetPasswordCommand.js +28 -0
  60. package/dist/development/src/model/commands/personToken/ResetPasswordCommand.js.map +1 -0
  61. package/dist/development/src/model/commands/personToken/SavePersonTokenCommand.cjs +28 -0
  62. package/dist/development/src/model/commands/personToken/SavePersonTokenCommand.cjs.map +1 -0
  63. package/dist/development/src/model/commands/personToken/SavePersonTokenCommand.js +28 -0
  64. package/dist/development/src/model/commands/personToken/SavePersonTokenCommand.js.map +1 -0
  65. package/dist/development/src/model/consts/expirations.cjs +7 -0
  66. package/dist/development/src/model/consts/expirations.cjs.map +1 -0
  67. package/dist/development/src/model/consts/expirations.js +7 -0
  68. package/dist/development/src/model/consts/expirations.js.map +1 -0
  69. package/dist/development/src/model/mailing/UserMailer.cjs +10 -1
  70. package/dist/development/src/model/mailing/UserMailer.cjs.map +1 -1
  71. package/dist/development/src/model/mailing/UserMailer.js +10 -1
  72. package/dist/development/src/model/mailing/UserMailer.js.map +1 -1
  73. package/dist/development/src/model/mailing/templates/PasswordlessSignIn.mustache.cjs +17 -0
  74. package/dist/development/src/model/mailing/templates/PasswordlessSignIn.mustache.cjs.map +1 -0
  75. package/dist/development/src/model/mailing/templates/PasswordlessSignIn.mustache.js +18 -0
  76. package/dist/development/src/model/mailing/templates/PasswordlessSignIn.mustache.js.map +1 -0
  77. package/dist/development/src/model/mailing/type.cjs +9 -3
  78. package/dist/development/src/model/mailing/type.cjs.map +1 -1
  79. package/dist/development/src/model/mailing/type.js +9 -3
  80. package/dist/development/src/model/mailing/type.js.map +1 -1
  81. package/dist/development/src/model/queries/configuration/ConfigurationQuery.cjs +21 -0
  82. package/dist/development/src/model/queries/configuration/ConfigurationQuery.cjs.map +1 -0
  83. package/dist/development/src/model/queries/configuration/ConfigurationQuery.js +21 -0
  84. package/dist/development/src/model/queries/configuration/ConfigurationQuery.js.map +1 -0
  85. package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.cjs +1 -1
  86. package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.cjs.map +1 -1
  87. package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.js +1 -1
  88. package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.js.map +1 -1
  89. package/dist/development/src/model/queries/personToken/PersonTokenQuery.cjs +29 -0
  90. package/dist/development/src/model/queries/personToken/PersonTokenQuery.cjs.map +1 -0
  91. package/dist/development/src/model/queries/personToken/PersonTokenQuery.js +29 -0
  92. package/dist/development/src/model/queries/personToken/PersonTokenQuery.js.map +1 -0
  93. package/dist/development/src/model/service/ConfigurationManager.cjs +27 -0
  94. package/dist/development/src/model/service/ConfigurationManager.cjs.map +1 -0
  95. package/dist/development/src/model/service/ConfigurationManager.js +27 -0
  96. package/dist/development/src/model/service/ConfigurationManager.js.map +1 -0
  97. package/dist/development/src/model/service/InviteManager.cjs +7 -7
  98. package/dist/development/src/model/service/InviteManager.cjs.map +1 -1
  99. package/dist/development/src/model/service/InviteManager.js +6 -6
  100. package/dist/development/src/model/service/InviteManager.js.map +1 -1
  101. package/dist/development/src/model/service/PasswordChangeManager.cjs +1 -1
  102. package/dist/development/src/model/service/PasswordChangeManager.js +1 -1
  103. package/dist/development/src/model/service/PasswordResetManager.cjs +7 -15
  104. package/dist/development/src/model/service/PasswordResetManager.cjs.map +1 -1
  105. package/dist/development/src/model/service/PasswordResetManager.js +7 -15
  106. package/dist/development/src/model/service/PasswordResetManager.js.map +1 -1
  107. package/dist/development/src/model/service/PasswordlessSignInManager.cjs +135 -0
  108. package/dist/development/src/model/service/PasswordlessSignInManager.cjs.map +1 -0
  109. package/dist/development/src/model/service/PasswordlessSignInManager.js +135 -0
  110. package/dist/development/src/model/service/PasswordlessSignInManager.js.map +1 -0
  111. package/dist/development/src/model/service/PersonManager.cjs +7 -0
  112. package/dist/development/src/model/service/PersonManager.cjs.map +1 -1
  113. package/dist/development/src/model/service/PersonManager.js +7 -0
  114. package/dist/development/src/model/service/PersonManager.js.map +1 -1
  115. package/dist/development/src/model/service/ProjectManager.cjs +2 -2
  116. package/dist/development/src/model/service/ProjectManager.js +2 -2
  117. package/dist/development/src/model/service/RolesManager.cjs +1 -1
  118. package/dist/development/src/model/service/RolesManager.js +1 -1
  119. package/dist/development/src/model/service/SignUpManager.cjs +1 -1
  120. package/dist/development/src/model/service/SignUpManager.js +1 -1
  121. package/dist/development/src/model/service/helpers/getPreferredProject.cjs +13 -0
  122. package/dist/development/src/model/service/helpers/getPreferredProject.cjs.map +1 -0
  123. package/dist/development/src/model/service/helpers/getPreferredProject.js +13 -0
  124. package/dist/development/src/model/service/helpers/getPreferredProject.js.map +1 -0
  125. package/dist/development/src/model/service/idp/providers/OIDCProvider.cjs +2 -1
  126. package/dist/development/src/model/service/idp/providers/OIDCProvider.cjs.map +1 -1
  127. package/dist/development/src/model/service/idp/providers/OIDCProvider.js +2 -1
  128. package/dist/development/src/model/service/idp/providers/OIDCProvider.js.map +1 -1
  129. package/dist/development/src/model/service/idp/providers/OIDCTypes.cjs +2 -1
  130. package/dist/development/src/model/service/idp/providers/OIDCTypes.cjs.map +1 -1
  131. package/dist/development/src/model/service/idp/providers/OIDCTypes.js +2 -1
  132. package/dist/development/src/model/service/idp/providers/OIDCTypes.js.map +1 -1
  133. package/dist/development/src/model/utils/tokenUtils.cjs +39 -0
  134. package/dist/development/src/model/utils/tokenUtils.cjs.map +1 -1
  135. package/dist/development/src/model/utils/tokenUtils.js +40 -1
  136. package/dist/development/src/model/utils/tokenUtils.js.map +1 -1
  137. package/dist/development/src/resolvers/ResolverFactory.cjs +8 -1
  138. package/dist/development/src/resolvers/ResolverFactory.cjs.map +1 -1
  139. package/dist/development/src/resolvers/ResolverFactory.js +8 -1
  140. package/dist/development/src/resolvers/ResolverFactory.js.map +1 -1
  141. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs +41 -0
  142. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs.map +1 -0
  143. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js +41 -0
  144. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js.map +1 -0
  145. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs +83 -0
  146. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs.map +1 -0
  147. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.js +83 -0
  148. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.js.map +1 -0
  149. package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs.map +1 -1
  150. package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.js.map +1 -1
  151. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs +52 -0
  152. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs.map +1 -0
  153. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js +52 -0
  154. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js.map +1 -0
  155. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.cjs +34 -0
  156. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.cjs.map +1 -0
  157. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.js +34 -0
  158. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.js.map +1 -0
  159. package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.cjs +1 -0
  160. package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.cjs.map +1 -1
  161. package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.js +1 -0
  162. package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.js.map +1 -1
  163. package/dist/development/src/schema/tenant.graphql.cjs +161 -10
  164. package/dist/development/src/schema/tenant.graphql.cjs.map +1 -1
  165. package/dist/development/src/schema/tenant.graphql.js +161 -10
  166. package/dist/development/src/schema/tenant.graphql.js.map +1 -1
  167. package/dist/production/index.cjs +18 -6
  168. package/dist/production/index.cjs.map +1 -1
  169. package/dist/production/index.js +20 -8
  170. package/dist/production/index.js.map +1 -1
  171. package/dist/production/src/TenantContainer.cjs +7 -1
  172. package/dist/production/src/TenantContainer.cjs.map +1 -1
  173. package/dist/production/src/TenantContainer.js +7 -1
  174. package/dist/production/src/TenantContainer.js.map +1 -1
  175. package/dist/production/src/migrations/2024-08-26-120000-passwordless.cjs +31 -0
  176. package/dist/production/src/migrations/2024-08-26-120000-passwordless.cjs.map +1 -0
  177. package/dist/production/src/migrations/2024-08-26-120000-passwordless.js +32 -0
  178. package/dist/production/src/migrations/2024-08-26-120000-passwordless.js.map +1 -0
  179. package/dist/production/src/migrations/runner.cjs +3 -1
  180. package/dist/production/src/migrations/runner.cjs.map +1 -1
  181. package/dist/production/src/migrations/runner.js +3 -1
  182. package/dist/production/src/migrations/runner.js.map +1 -1
  183. package/dist/production/src/migrations/snapshot.cjs +33 -5
  184. package/dist/production/src/migrations/snapshot.cjs.map +1 -1
  185. package/dist/production/src/migrations/snapshot.js +33 -5
  186. package/dist/production/src/migrations/snapshot.js.map +1 -1
  187. package/dist/production/src/model/authorization/PermissionActions.cjs +5 -0
  188. package/dist/production/src/model/authorization/PermissionActions.cjs.map +1 -1
  189. package/dist/production/src/model/authorization/PermissionActions.js +5 -0
  190. package/dist/production/src/model/authorization/PermissionActions.js.map +1 -1
  191. package/dist/production/src/model/authorization/PermissionsFactory.cjs +5 -0
  192. package/dist/production/src/model/authorization/PermissionsFactory.cjs.map +1 -1
  193. package/dist/production/src/model/authorization/PermissionsFactory.js +5 -0
  194. package/dist/production/src/model/authorization/PermissionsFactory.js.map +1 -1
  195. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.cjs +20 -0
  196. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.cjs.map +1 -0
  197. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.js +20 -0
  198. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.js.map +1 -0
  199. package/dist/production/src/model/commands/person/CreatePersonCommand.cjs +2 -1
  200. package/dist/production/src/model/commands/person/CreatePersonCommand.cjs.map +1 -1
  201. package/dist/production/src/model/commands/person/CreatePersonCommand.js +2 -1
  202. package/dist/production/src/model/commands/person/CreatePersonCommand.js.map +1 -1
  203. package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.cjs +18 -0
  204. package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.cjs.map +1 -0
  205. package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.js +18 -0
  206. package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.js.map +1 -0
  207. package/dist/production/src/model/commands/personToken/ActivateOtpCommand.cjs +20 -0
  208. package/dist/production/src/model/commands/personToken/ActivateOtpCommand.cjs.map +1 -0
  209. package/dist/production/src/model/commands/personToken/ActivateOtpCommand.js +20 -0
  210. package/dist/production/src/model/commands/personToken/ActivateOtpCommand.js.map +1 -0
  211. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.cjs +33 -0
  212. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.cjs.map +1 -0
  213. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.js +33 -0
  214. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.js.map +1 -0
  215. package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.cjs +19 -0
  216. package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.cjs.map +1 -0
  217. package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.js +19 -0
  218. package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.js.map +1 -0
  219. package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.cjs +19 -0
  220. package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.cjs.map +1 -0
  221. package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.js +19 -0
  222. package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.js.map +1 -0
  223. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.cjs +28 -0
  224. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.cjs.map +1 -0
  225. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.js +28 -0
  226. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.js.map +1 -0
  227. package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.cjs +28 -0
  228. package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.cjs.map +1 -0
  229. package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.js +28 -0
  230. package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.js.map +1 -0
  231. package/dist/production/src/model/consts/expirations.cjs +7 -0
  232. package/dist/production/src/model/consts/expirations.cjs.map +1 -0
  233. package/dist/production/src/model/consts/expirations.js +7 -0
  234. package/dist/production/src/model/consts/expirations.js.map +1 -0
  235. package/dist/production/src/model/mailing/UserMailer.cjs +10 -1
  236. package/dist/production/src/model/mailing/UserMailer.cjs.map +1 -1
  237. package/dist/production/src/model/mailing/UserMailer.js +10 -1
  238. package/dist/production/src/model/mailing/UserMailer.js.map +1 -1
  239. package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.cjs +17 -0
  240. package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.cjs.map +1 -0
  241. package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.js +18 -0
  242. package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.js.map +1 -0
  243. package/dist/production/src/model/mailing/type.cjs +9 -3
  244. package/dist/production/src/model/mailing/type.cjs.map +1 -1
  245. package/dist/production/src/model/mailing/type.js +9 -3
  246. package/dist/production/src/model/mailing/type.js.map +1 -1
  247. package/dist/production/src/model/queries/configuration/ConfigurationQuery.cjs +21 -0
  248. package/dist/production/src/model/queries/configuration/ConfigurationQuery.cjs.map +1 -0
  249. package/dist/production/src/model/queries/configuration/ConfigurationQuery.js +21 -0
  250. package/dist/production/src/model/queries/configuration/ConfigurationQuery.js.map +1 -0
  251. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.cjs +1 -1
  252. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.cjs.map +1 -1
  253. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.js +1 -1
  254. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.js.map +1 -1
  255. package/dist/production/src/model/queries/personToken/PersonTokenQuery.cjs +29 -0
  256. package/dist/production/src/model/queries/personToken/PersonTokenQuery.cjs.map +1 -0
  257. package/dist/production/src/model/queries/personToken/PersonTokenQuery.js +29 -0
  258. package/dist/production/src/model/queries/personToken/PersonTokenQuery.js.map +1 -0
  259. package/dist/production/src/model/service/ConfigurationManager.cjs +27 -0
  260. package/dist/production/src/model/service/ConfigurationManager.cjs.map +1 -0
  261. package/dist/production/src/model/service/ConfigurationManager.js +27 -0
  262. package/dist/production/src/model/service/ConfigurationManager.js.map +1 -0
  263. package/dist/production/src/model/service/InviteManager.cjs +7 -7
  264. package/dist/production/src/model/service/InviteManager.cjs.map +1 -1
  265. package/dist/production/src/model/service/InviteManager.js +6 -6
  266. package/dist/production/src/model/service/InviteManager.js.map +1 -1
  267. package/dist/production/src/model/service/PasswordChangeManager.cjs +1 -1
  268. package/dist/production/src/model/service/PasswordChangeManager.js +1 -1
  269. package/dist/production/src/model/service/PasswordResetManager.cjs +7 -15
  270. package/dist/production/src/model/service/PasswordResetManager.cjs.map +1 -1
  271. package/dist/production/src/model/service/PasswordResetManager.js +7 -15
  272. package/dist/production/src/model/service/PasswordResetManager.js.map +1 -1
  273. package/dist/production/src/model/service/PasswordlessSignInManager.cjs +135 -0
  274. package/dist/production/src/model/service/PasswordlessSignInManager.cjs.map +1 -0
  275. package/dist/production/src/model/service/PasswordlessSignInManager.js +135 -0
  276. package/dist/production/src/model/service/PasswordlessSignInManager.js.map +1 -0
  277. package/dist/production/src/model/service/PersonManager.cjs +7 -0
  278. package/dist/production/src/model/service/PersonManager.cjs.map +1 -1
  279. package/dist/production/src/model/service/PersonManager.js +7 -0
  280. package/dist/production/src/model/service/PersonManager.js.map +1 -1
  281. package/dist/production/src/model/service/ProjectManager.cjs +2 -2
  282. package/dist/production/src/model/service/ProjectManager.js +2 -2
  283. package/dist/production/src/model/service/RolesManager.cjs +1 -1
  284. package/dist/production/src/model/service/RolesManager.js +1 -1
  285. package/dist/production/src/model/service/SignUpManager.cjs +1 -1
  286. package/dist/production/src/model/service/SignUpManager.js +1 -1
  287. package/dist/production/src/model/service/helpers/getPreferredProject.cjs +13 -0
  288. package/dist/production/src/model/service/helpers/getPreferredProject.cjs.map +1 -0
  289. package/dist/production/src/model/service/helpers/getPreferredProject.js +13 -0
  290. package/dist/production/src/model/service/helpers/getPreferredProject.js.map +1 -0
  291. package/dist/production/src/model/service/idp/providers/OIDCProvider.cjs +2 -1
  292. package/dist/production/src/model/service/idp/providers/OIDCProvider.cjs.map +1 -1
  293. package/dist/production/src/model/service/idp/providers/OIDCProvider.js +2 -1
  294. package/dist/production/src/model/service/idp/providers/OIDCProvider.js.map +1 -1
  295. package/dist/production/src/model/service/idp/providers/OIDCTypes.cjs +2 -1
  296. package/dist/production/src/model/service/idp/providers/OIDCTypes.cjs.map +1 -1
  297. package/dist/production/src/model/service/idp/providers/OIDCTypes.js +2 -1
  298. package/dist/production/src/model/service/idp/providers/OIDCTypes.js.map +1 -1
  299. package/dist/production/src/model/utils/tokenUtils.cjs +39 -0
  300. package/dist/production/src/model/utils/tokenUtils.cjs.map +1 -1
  301. package/dist/production/src/model/utils/tokenUtils.js +40 -1
  302. package/dist/production/src/model/utils/tokenUtils.js.map +1 -1
  303. package/dist/production/src/resolvers/ResolverFactory.cjs +8 -1
  304. package/dist/production/src/resolvers/ResolverFactory.cjs.map +1 -1
  305. package/dist/production/src/resolvers/ResolverFactory.js +8 -1
  306. package/dist/production/src/resolvers/ResolverFactory.js.map +1 -1
  307. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs +41 -0
  308. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs.map +1 -0
  309. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js +41 -0
  310. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js.map +1 -0
  311. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs +83 -0
  312. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs.map +1 -0
  313. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.js +83 -0
  314. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.js.map +1 -0
  315. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs.map +1 -1
  316. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.js.map +1 -1
  317. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs +52 -0
  318. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs.map +1 -0
  319. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js +52 -0
  320. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js.map +1 -0
  321. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.cjs +34 -0
  322. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.cjs.map +1 -0
  323. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.js +34 -0
  324. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.js.map +1 -0
  325. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.cjs +1 -0
  326. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.cjs.map +1 -1
  327. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.js +1 -0
  328. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.js.map +1 -1
  329. package/dist/production/src/schema/tenant.graphql.cjs +161 -10
  330. package/dist/production/src/schema/tenant.graphql.cjs.map +1 -1
  331. package/dist/production/src/schema/tenant.graphql.js +161 -10
  332. package/dist/production/src/schema/tenant.graphql.js.map +1 -1
  333. package/dist/tests/cases/integration/mocked/sql/{createPasswordResetSql.d.ts → createPersonTokenSql.d.ts} +3 -2
  334. package/dist/tests/cases/integration/mocked/sql/createPersonTokenSql.d.ts.map +1 -0
  335. package/dist/tests/cases/integration/mocked/sql/getPersonByEmailSql.d.ts.map +1 -1
  336. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  337. package/dist/types/TenantContainer.d.ts +18 -0
  338. package/dist/types/TenantContainer.d.ts.map +1 -1
  339. package/dist/types/migrations/2024-08-26-120000-passwordless.d.ts +3 -0
  340. package/dist/types/migrations/2024-08-26-120000-passwordless.d.ts.map +1 -0
  341. package/dist/types/migrations/runner.d.ts.map +1 -1
  342. package/dist/types/migrations/snapshot.d.ts.map +1 -1
  343. package/dist/types/model/authorization/PermissionActions.d.ts +25 -0
  344. package/dist/types/model/authorization/PermissionActions.d.ts.map +1 -1
  345. package/dist/types/model/authorization/PermissionsFactory.d.ts.map +1 -1
  346. package/dist/types/model/commands/configuration/UpdateConfigurationCommand.d.ts +8 -0
  347. package/dist/types/model/commands/configuration/UpdateConfigurationCommand.d.ts.map +1 -0
  348. package/dist/types/model/commands/configuration/index.d.ts +2 -0
  349. package/dist/types/model/commands/configuration/index.d.ts.map +1 -0
  350. package/dist/types/model/commands/index.d.ts +2 -2
  351. package/dist/types/model/commands/index.d.ts.map +1 -1
  352. package/dist/types/model/commands/person/CreatePersonCommand.d.ts.map +1 -1
  353. package/dist/types/model/commands/person/TogglePersonPasswordlessCommand.d.ts +8 -0
  354. package/dist/types/model/commands/person/TogglePersonPasswordlessCommand.d.ts.map +1 -0
  355. package/dist/types/model/commands/person/index.d.ts +1 -0
  356. package/dist/types/model/commands/person/index.d.ts.map +1 -1
  357. package/dist/types/model/commands/personToken/ActivateOtpCommand.d.ts +8 -0
  358. package/dist/types/model/commands/personToken/ActivateOtpCommand.d.ts.map +1 -0
  359. package/dist/types/model/commands/personToken/CreatePersonTokenCommand.d.ts +19 -0
  360. package/dist/types/model/commands/personToken/CreatePersonTokenCommand.d.ts.map +1 -0
  361. package/dist/types/model/commands/personToken/IncreaseOtpAttemptCommand.d.ts +7 -0
  362. package/dist/types/model/commands/personToken/IncreaseOtpAttemptCommand.d.ts.map +1 -0
  363. package/dist/types/model/commands/personToken/InvalidateTokenCommand.d.ts +7 -0
  364. package/dist/types/model/commands/personToken/InvalidateTokenCommand.d.ts.map +1 -0
  365. package/dist/types/model/commands/{passwordReset → personToken}/ResetPasswordCommand.d.ts +3 -2
  366. package/dist/types/model/commands/personToken/ResetPasswordCommand.d.ts.map +1 -0
  367. package/dist/types/model/commands/personToken/SavePersonTokenCommand.d.ts +19 -0
  368. package/dist/types/model/commands/personToken/SavePersonTokenCommand.d.ts.map +1 -0
  369. package/dist/types/model/commands/personToken/index.d.ts +7 -0
  370. package/dist/types/model/commands/personToken/index.d.ts.map +1 -0
  371. package/dist/types/model/consts/expirations.d.ts +3 -0
  372. package/dist/types/model/consts/expirations.d.ts.map +1 -0
  373. package/dist/types/model/mailing/UserMailer.d.ts +10 -0
  374. package/dist/types/model/mailing/UserMailer.d.ts.map +1 -1
  375. package/dist/types/model/mailing/templates/PasswordlessSignIn.mustache.d.ts +3 -0
  376. package/dist/types/model/mailing/templates/PasswordlessSignIn.mustache.d.ts.map +1 -0
  377. package/dist/types/model/mailing/type.d.ts +2 -1
  378. package/dist/types/model/mailing/type.d.ts.map +1 -1
  379. package/dist/types/model/queries/configuration/ConfigurationQuery.d.ts +6 -0
  380. package/dist/types/model/queries/configuration/ConfigurationQuery.d.ts.map +1 -0
  381. package/dist/types/model/queries/configuration/index.d.ts +2 -0
  382. package/dist/types/model/queries/configuration/index.d.ts.map +1 -0
  383. package/dist/types/model/queries/index.d.ts +1 -0
  384. package/dist/types/model/queries/index.d.ts.map +1 -1
  385. package/dist/types/model/queries/person/PersonQueryBuilderFactory.d.ts.map +1 -1
  386. package/dist/types/model/queries/person/types.d.ts +1 -0
  387. package/dist/types/model/queries/person/types.d.ts.map +1 -1
  388. package/dist/types/model/queries/personToken/PersonTokenQuery.d.ts +12 -0
  389. package/dist/types/model/queries/personToken/PersonTokenQuery.d.ts.map +1 -0
  390. package/dist/types/model/service/ConfigurationManager.d.ts +9 -0
  391. package/dist/types/model/service/ConfigurationManager.d.ts.map +1 -0
  392. package/dist/types/model/service/InviteManager.d.ts.map +1 -1
  393. package/dist/types/model/service/PasswordResetManager.d.ts +1 -1
  394. package/dist/types/model/service/PasswordResetManager.d.ts.map +1 -1
  395. package/dist/types/model/service/PasswordlessSignInManager.d.ts +54 -0
  396. package/dist/types/model/service/PasswordlessSignInManager.d.ts.map +1 -0
  397. package/dist/types/model/service/PersonManager.d.ts +1 -0
  398. package/dist/types/model/service/PersonManager.d.ts.map +1 -1
  399. package/dist/types/model/service/PersonTokenManager.d.ts +3 -0
  400. package/dist/types/model/service/PersonTokenManager.d.ts.map +1 -0
  401. package/dist/types/model/service/helpers/getPreferredProject.d.ts +3 -0
  402. package/dist/types/model/service/helpers/getPreferredProject.d.ts.map +1 -0
  403. package/dist/types/model/service/idp/providers/AppleProvider.d.ts +2 -0
  404. package/dist/types/model/service/idp/providers/AppleProvider.d.ts.map +1 -1
  405. package/dist/types/model/service/idp/providers/FacebookProvider.d.ts +2 -0
  406. package/dist/types/model/service/idp/providers/FacebookProvider.d.ts.map +1 -1
  407. package/dist/types/model/service/idp/providers/OIDCProvider.d.ts +1 -0
  408. package/dist/types/model/service/idp/providers/OIDCProvider.d.ts.map +1 -1
  409. package/dist/types/model/service/idp/providers/OIDCTypes.d.ts +5 -1
  410. package/dist/types/model/service/idp/providers/OIDCTypes.d.ts.map +1 -1
  411. package/dist/types/model/type/PersonToken.d.ts +16 -0
  412. package/dist/types/model/type/PersonToken.d.ts.map +1 -0
  413. package/dist/types/model/type/index.d.ts +1 -0
  414. package/dist/types/model/type/index.d.ts.map +1 -1
  415. package/dist/types/model/utils/tokenUtils.d.ts +8 -0
  416. package/dist/types/model/utils/tokenUtils.d.ts.map +1 -1
  417. package/dist/types/resolvers/ResolverFactory.d.ts +8 -0
  418. package/dist/types/resolvers/ResolverFactory.d.ts.map +1 -1
  419. package/dist/types/resolvers/mutation/configuration/ConfigurationMutationResolver.d.ts +9 -0
  420. package/dist/types/resolvers/mutation/configuration/ConfigurationMutationResolver.d.ts.map +1 -0
  421. package/dist/types/resolvers/mutation/person/PasswordlessMutationResolver.d.ts +13 -0
  422. package/dist/types/resolvers/mutation/person/PasswordlessMutationResolver.d.ts.map +1 -0
  423. package/dist/types/resolvers/mutation/person/ResetPasswordMutationResolver.d.ts.map +1 -1
  424. package/dist/types/resolvers/mutation/person/TogglePasswordlessMutationResolver.d.ts +13 -0
  425. package/dist/types/resolvers/mutation/person/TogglePasswordlessMutationResolver.d.ts.map +1 -0
  426. package/dist/types/resolvers/query/ConfigurationQueryResolver.d.ts +9 -0
  427. package/dist/types/resolvers/query/ConfigurationQueryResolver.d.ts.map +1 -0
  428. package/dist/types/resolvers/responseHelpers/PersonResponseFactory.d.ts.map +1 -1
  429. package/dist/types/schema/index.d.ts +258 -5
  430. package/dist/types/schema/index.d.ts.map +1 -1
  431. package/dist/types/schema/tenant.graphql.d.ts.map +1 -1
  432. package/dist/types/tsconfig.tsbuildinfo +1 -1
  433. package/package.json +12 -12
  434. package/src/TenantContainer.ts +18 -0
  435. package/src/migrations/2024-08-26-120000-passwordless.ts +31 -0
  436. package/src/migrations/runner.ts +2 -0
  437. package/src/migrations/snapshot-template-end.txt +3 -0
  438. package/src/migrations/snapshot.ts +33 -5
  439. package/src/model/authorization/PermissionActions.ts +7 -0
  440. package/src/model/authorization/PermissionsFactory.ts +5 -0
  441. package/src/model/commands/configuration/UpdateConfigurationCommand.ts +26 -0
  442. package/src/model/commands/configuration/index.ts +1 -0
  443. package/src/model/commands/index.ts +2 -2
  444. package/src/model/commands/person/CreatePersonCommand.ts +1 -0
  445. package/src/model/commands/person/TogglePersonPasswordlessCommand.ts +18 -0
  446. package/src/model/commands/person/index.ts +1 -0
  447. package/src/model/commands/personToken/ActivateOtpCommand.ts +24 -0
  448. package/src/model/commands/personToken/CreatePersonTokenCommand.ts +42 -0
  449. package/src/model/commands/personToken/IncreaseOtpAttemptCommand.ts +23 -0
  450. package/src/model/commands/personToken/InvalidateTokenCommand.ts +22 -0
  451. package/src/model/commands/personToken/ResetPasswordCommand.ts +28 -0
  452. package/src/model/commands/personToken/SavePersonTokenCommand.ts +42 -0
  453. package/src/model/commands/personToken/index.ts +6 -0
  454. package/src/model/consts/expirations.ts +2 -0
  455. package/src/model/mailing/UserMailer.ts +14 -0
  456. package/src/model/mailing/templates/PasswordlessSignIn.mustache.ts +15 -0
  457. package/src/model/mailing/type.ts +3 -0
  458. package/src/model/queries/configuration/ConfigurationQuery.ts +30 -0
  459. package/src/model/queries/configuration/index.ts +1 -0
  460. package/src/model/queries/index.ts +1 -0
  461. package/src/model/queries/person/PersonQueryBuilderFactory.ts +1 -0
  462. package/src/model/queries/person/types.ts +1 -0
  463. package/src/model/queries/personToken/PersonTokenQuery.ts +35 -0
  464. package/src/model/service/ConfigurationManager.ts +22 -0
  465. package/src/model/service/InviteManager.ts +5 -6
  466. package/src/model/service/PasswordResetManager.ts +4 -10
  467. package/src/model/service/PasswordlessSignInManager.ts +190 -0
  468. package/src/model/service/PersonManager.ts +6 -0
  469. package/src/model/service/PersonTokenManager.ts +2 -0
  470. package/src/model/service/helpers/getPreferredProject.ts +11 -0
  471. package/src/model/service/idp/providers/OIDCProvider.ts +1 -0
  472. package/src/model/service/idp/providers/OIDCTypes.ts +1 -0
  473. package/src/model/type/PersonToken.ts +21 -0
  474. package/src/model/type/index.ts +1 -0
  475. package/src/model/utils/tokenUtils.ts +47 -0
  476. package/src/resolvers/ResolverFactory.ts +19 -0
  477. package/src/resolvers/mutation/configuration/ConfigurationMutationResolver.ts +29 -0
  478. package/src/resolvers/mutation/person/PasswordlessMutationResolver.ts +81 -0
  479. package/src/resolvers/mutation/person/ResetPasswordMutationResolver.ts +1 -10
  480. package/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.ts +44 -0
  481. package/src/resolvers/query/ConfigurationQueryResolver.ts +21 -0
  482. package/src/resolvers/responseHelpers/PersonResponseFactory.ts +1 -0
  483. package/src/schema/index.ts +326 -2
  484. package/src/schema/tenant.graphql.ts +161 -10
  485. package/tests/cases/integration/mocked/inviteMutations.test.ts +2 -2
  486. package/tests/cases/integration/mocked/sql/{createPasswordResetSql.ts → createPersonTokenSql.ts} +5 -3
  487. package/tests/cases/integration/mocked/sql/getPersonByEmailSql.ts +2 -1
  488. package/tests/cases/integration/mocked/sql/getPersonByIdSql.ts +1 -1
  489. package/tests/cases/integration/mocked/sql/getPersonByIdentity.ts +1 -1
  490. package/tests/cases/integration/mocked/sql/getPersonByIdpSql.ts +1 -1
  491. package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs +0 -30
  492. package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs.map +0 -1
  493. package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js +0 -30
  494. package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js.map +0 -1
  495. package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.cjs +0 -38
  496. package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.cjs.map +0 -1
  497. package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.js +0 -38
  498. package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.js.map +0 -1
  499. package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs +0 -24
  500. package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs.map +0 -1
  501. package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js +0 -24
  502. package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js.map +0 -1
  503. package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs +0 -30
  504. package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs.map +0 -1
  505. package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js +0 -30
  506. package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js.map +0 -1
  507. package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.cjs +0 -38
  508. package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.cjs.map +0 -1
  509. package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.js +0 -38
  510. package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.js.map +0 -1
  511. package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs +0 -24
  512. package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs.map +0 -1
  513. package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js +0 -24
  514. package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js.map +0 -1
  515. package/dist/tests/cases/integration/mocked/sql/createPasswordResetSql.d.ts.map +0 -1
  516. package/dist/types/model/commands/passwordReset/CreatePasswordResetRequestCommand.d.ts +0 -12
  517. package/dist/types/model/commands/passwordReset/CreatePasswordResetRequestCommand.d.ts.map +0 -1
  518. package/dist/types/model/commands/passwordReset/ResetPasswordCommand.d.ts.map +0 -1
  519. package/dist/types/model/commands/passwordReset/SavePasswordResetRequestCommand.d.ts +0 -10
  520. package/dist/types/model/commands/passwordReset/SavePasswordResetRequestCommand.d.ts.map +0 -1
  521. package/dist/types/model/commands/passwordReset/index.d.ts +0 -4
  522. package/dist/types/model/commands/passwordReset/index.d.ts.map +0 -1
  523. package/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.ts +0 -25
  524. package/src/model/commands/passwordReset/ResetPasswordCommand.ts +0 -57
  525. package/src/model/commands/passwordReset/SavePasswordResetRequestCommand.ts +0 -28
  526. package/src/model/commands/passwordReset/index.ts +0 -3
@@ -0,0 +1,28 @@
1
+ import { ChangePasswordCommand } from "../person/ChangePasswordCommand.js";
2
+ import { ResponseOk } from "../../utils/Response.js";
3
+ import { PersonTokenQuery } from "../../queries/personToken/PersonTokenQuery.js";
4
+ import { InvalidateTokenCommand } from "./InvalidateTokenCommand.js";
5
+ import "@contember/database";
6
+ import "../../type/ApiKey.js";
7
+ import { validateToken } from "../../utils/tokenUtils.js";
8
+ class ResetPasswordCommand {
9
+ constructor(token, password) {
10
+ this.token = token;
11
+ this.password = password;
12
+ }
13
+ async execute({ db, providers, bus }) {
14
+ const now = providers.now();
15
+ const token = await db.createQueryHandler().fetch(PersonTokenQuery.byToken(this.token, "password_reset"));
16
+ const tokenValidationResult = validateToken({ entry: token, token: this.token, now, validationType: "token" });
17
+ if (!tokenValidationResult.ok) {
18
+ return tokenValidationResult;
19
+ }
20
+ await bus.execute(new InvalidateTokenCommand(tokenValidationResult.result.id));
21
+ await bus.execute(new ChangePasswordCommand(tokenValidationResult.result.person_id, this.password));
22
+ return new ResponseOk(null);
23
+ }
24
+ }
25
+ export {
26
+ ResetPasswordCommand
27
+ };
28
+ //# sourceMappingURL=ResetPasswordCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResetPasswordCommand.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/commands/personToken/ResetPasswordCommand.ts"],"sourcesContent":["import { Command } from '../Command'\nimport { ChangePasswordCommand } from '../person/ChangePasswordCommand'\nimport { Response, ResponseOk } from '../../utils/Response'\nimport { PersonTokenQuery } from '../../queries/personToken/PersonTokenQuery'\nimport { InvalidateTokenCommand } from './InvalidateTokenCommand'\nimport { validateToken } from '../../utils'\nimport { PersonToken } from '../../type'\n\nexport class ResetPasswordCommand implements Command<ResetPasswordCommandResponse> {\n\tconstructor(private readonly token: string, private readonly password: string) {}\n\n\tasync execute({ db, providers, bus }: Command.Args): Promise<ResetPasswordCommandResponse> {\n\t\tconst now = providers.now()\n\t\tconst token = await db.createQueryHandler().fetch(PersonTokenQuery.byToken(this.token, 'password_reset'))\n\t\tconst tokenValidationResult = validateToken({ entry: token, token: this.token, now, validationType: 'token' })\n\t\tif (!tokenValidationResult.ok) {\n\t\t\treturn tokenValidationResult\n\t\t}\n\t\tawait bus.execute(new InvalidateTokenCommand(tokenValidationResult.result.id))\n\t\tawait bus.execute(new ChangePasswordCommand(tokenValidationResult.result.person_id, this.password))\n\n\t\treturn new ResponseOk(null)\n\t}\n}\nexport type ResetPasswordCommandErrorCode =\n\t| PersonToken.TokenValidationError\n\nexport type ResetPasswordCommandResponse = Response<null, PersonToken.TokenValidationError>\n"],"names":[],"mappings":";;;;;;;AAQO,MAAM,qBAAsE;AAAA,EAClF,YAA6B,OAAgC,UAAkB;AAAlD,SAAA,QAAA;AAAgC,SAAA,WAAA;AAAA,EAAmB;AAAA,EAEhF,MAAM,QAAQ,EAAE,IAAI,WAAW,OAA4D;AACpF,UAAA,MAAM,UAAU;AAChB,UAAA,QAAQ,MAAM,GAAG,mBAAmB,EAAE,MAAM,iBAAiB,QAAQ,KAAK,OAAO,gBAAgB,CAAC;AAClG,UAAA,wBAAwB,cAAc,EAAE,OAAO,OAAO,OAAO,KAAK,OAAO,KAAK,gBAAgB,QAAS,CAAA;AACzG,QAAA,CAAC,sBAAsB,IAAI;AACvB,aAAA;AAAA,IACR;AACA,UAAM,IAAI,QAAQ,IAAI,uBAAuB,sBAAsB,OAAO,EAAE,CAAC;AACvE,UAAA,IAAI,QAAQ,IAAI,sBAAsB,sBAAsB,OAAO,WAAW,KAAK,QAAQ,CAAC;AAE3F,WAAA,IAAI,WAAW,IAAI;AAAA,EAC3B;AACD;"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const Database = require("@contember/database");
4
+ const time = require("../../utils/time.cjs");
5
+ class SavePersonTokenCommand {
6
+ constructor(personId, tokenHash, type, expirationMinutes) {
7
+ this.personId = personId;
8
+ this.tokenHash = tokenHash;
9
+ this.type = type;
10
+ this.expirationMinutes = expirationMinutes;
11
+ }
12
+ async execute({ db, providers }) {
13
+ const id = providers.uuid();
14
+ const expiresAt = time.plusMinutes(providers.now(), this.expirationMinutes);
15
+ await Database.InsertBuilder.create().into("person_token").values({
16
+ id,
17
+ token_hash: this.tokenHash,
18
+ person_id: this.personId,
19
+ expires_at: expiresAt,
20
+ created_at: providers.now(),
21
+ used_at: null,
22
+ type: this.type
23
+ }).execute(db);
24
+ return { id, expiresAt };
25
+ }
26
+ }
27
+ exports.SavePersonTokenCommand = SavePersonTokenCommand;
28
+ //# sourceMappingURL=SavePersonTokenCommand.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SavePersonTokenCommand.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/commands/personToken/SavePersonTokenCommand.ts"],"sourcesContent":["import { Command } from '../Command'\nimport { InsertBuilder } from '@contember/database'\nimport { plusMinutes } from '../../utils/time'\nimport { TokenHash } from '../../utils'\nimport { PersonToken } from '../../type'\n\nclass SavePersonTokenCommand implements Command<SavePersonTokenCommand.Result> {\n\tconstructor(\n\t\tprivate readonly personId: string,\n\t\tprivate readonly tokenHash: TokenHash,\n\t\tprivate readonly type: PersonToken.Type,\n\t\tprivate readonly expirationMinutes: number,\n\t) {}\n\n\tasync execute({ db, providers }: Command.Args): Promise<SavePersonTokenCommand.Result> {\n\t\tconst id = providers.uuid()\n\t\tconst expiresAt = plusMinutes(providers.now(), this.expirationMinutes)\n\t\tawait InsertBuilder.create()\n\t\t\t.into('person_token')\n\t\t\t.values({\n\t\t\t\tid: id,\n\t\t\t\ttoken_hash: this.tokenHash,\n\t\t\t\tperson_id: this.personId,\n\t\t\t\texpires_at: expiresAt,\n\t\t\t\tcreated_at: providers.now(),\n\t\t\t\tused_at: null,\n\t\t\t\ttype: this.type,\n\t\t\t})\n\t\t\t.execute(db)\n\n\t\treturn { id, expiresAt }\n\t}\n}\n\nnamespace SavePersonTokenCommand {\n\texport interface Result {\n\t\tid: string\n\t\texpiresAt: Date\n\t}\n}\n\nexport { SavePersonTokenCommand }\n"],"names":["plusMinutes","InsertBuilder"],"mappings":";;;;AAMA,MAAM,uBAAyE;AAAA,EAC9E,YACkB,UACA,WACA,MACA,mBAChB;AAJgB,SAAA,WAAA;AACA,SAAA,YAAA;AACA,SAAA,OAAA;AACA,SAAA,oBAAA;AAAA,EACf;AAAA,EAEH,MAAM,QAAQ,EAAE,IAAI,aAAmE;AAChF,UAAA,KAAK,UAAU;AACrB,UAAM,YAAYA,KAAAA,YAAY,UAAU,IAAI,GAAG,KAAK,iBAAiB;AACrE,UAAMC,SAAAA,cAAc,OAAO,EACzB,KAAK,cAAc,EACnB,OAAO;AAAA,MACP;AAAA,MACA,YAAY,KAAK;AAAA,MACjB,WAAW,KAAK;AAAA,MAChB,YAAY;AAAA,MACZ,YAAY,UAAU,IAAI;AAAA,MAC1B,SAAS;AAAA,MACT,MAAM,KAAK;AAAA,IAAA,CACX,EACA,QAAQ,EAAE;AAEL,WAAA,EAAE,IAAI;EACd;AACD;;"}
@@ -0,0 +1,28 @@
1
+ import { InsertBuilder as InsertBuilder$1 } from "@contember/database";
2
+ import { plusMinutes } from "../../utils/time.js";
3
+ class SavePersonTokenCommand {
4
+ constructor(personId, tokenHash, type, expirationMinutes) {
5
+ this.personId = personId;
6
+ this.tokenHash = tokenHash;
7
+ this.type = type;
8
+ this.expirationMinutes = expirationMinutes;
9
+ }
10
+ async execute({ db, providers }) {
11
+ const id = providers.uuid();
12
+ const expiresAt = plusMinutes(providers.now(), this.expirationMinutes);
13
+ await InsertBuilder$1.create().into("person_token").values({
14
+ id,
15
+ token_hash: this.tokenHash,
16
+ person_id: this.personId,
17
+ expires_at: expiresAt,
18
+ created_at: providers.now(),
19
+ used_at: null,
20
+ type: this.type
21
+ }).execute(db);
22
+ return { id, expiresAt };
23
+ }
24
+ }
25
+ export {
26
+ SavePersonTokenCommand
27
+ };
28
+ //# sourceMappingURL=SavePersonTokenCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SavePersonTokenCommand.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/commands/personToken/SavePersonTokenCommand.ts"],"sourcesContent":["import { Command } from '../Command'\nimport { InsertBuilder } from '@contember/database'\nimport { plusMinutes } from '../../utils/time'\nimport { TokenHash } from '../../utils'\nimport { PersonToken } from '../../type'\n\nclass SavePersonTokenCommand implements Command<SavePersonTokenCommand.Result> {\n\tconstructor(\n\t\tprivate readonly personId: string,\n\t\tprivate readonly tokenHash: TokenHash,\n\t\tprivate readonly type: PersonToken.Type,\n\t\tprivate readonly expirationMinutes: number,\n\t) {}\n\n\tasync execute({ db, providers }: Command.Args): Promise<SavePersonTokenCommand.Result> {\n\t\tconst id = providers.uuid()\n\t\tconst expiresAt = plusMinutes(providers.now(), this.expirationMinutes)\n\t\tawait InsertBuilder.create()\n\t\t\t.into('person_token')\n\t\t\t.values({\n\t\t\t\tid: id,\n\t\t\t\ttoken_hash: this.tokenHash,\n\t\t\t\tperson_id: this.personId,\n\t\t\t\texpires_at: expiresAt,\n\t\t\t\tcreated_at: providers.now(),\n\t\t\t\tused_at: null,\n\t\t\t\ttype: this.type,\n\t\t\t})\n\t\t\t.execute(db)\n\n\t\treturn { id, expiresAt }\n\t}\n}\n\nnamespace SavePersonTokenCommand {\n\texport interface Result {\n\t\tid: string\n\t\texpiresAt: Date\n\t}\n}\n\nexport { SavePersonTokenCommand }\n"],"names":["InsertBuilder"],"mappings":";;AAMA,MAAM,uBAAyE;AAAA,EAC9E,YACkB,UACA,WACA,MACA,mBAChB;AAJgB,SAAA,WAAA;AACA,SAAA,YAAA;AACA,SAAA,OAAA;AACA,SAAA,oBAAA;AAAA,EACf;AAAA,EAEH,MAAM,QAAQ,EAAE,IAAI,aAAmE;AAChF,UAAA,KAAK,UAAU;AACrB,UAAM,YAAY,YAAY,UAAU,IAAI,GAAG,KAAK,iBAAiB;AACrE,UAAMA,gBAAc,OAAO,EACzB,KAAK,cAAc,EACnB,OAAO;AAAA,MACP;AAAA,MACA,YAAY,KAAK;AAAA,MACjB,WAAW,KAAK;AAAA,MAChB,YAAY;AAAA,MACZ,YAAY,UAAU,IAAI;AAAA,MAC1B,SAAS;AAAA,MACT,MAAM,KAAK;AAAA,IAAA,CACX,EACA,QAAQ,EAAE;AAEL,WAAA,EAAE,IAAI;EACd;AACD;"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const PASSWORD_RESET_EXPIRATION_MINUTES = 60;
4
+ const INVITATION_RESET_TOKEN_EXPIRATION_MINUTES = 60 * 24;
5
+ exports.INVITATION_RESET_TOKEN_EXPIRATION_MINUTES = INVITATION_RESET_TOKEN_EXPIRATION_MINUTES;
6
+ exports.PASSWORD_RESET_EXPIRATION_MINUTES = PASSWORD_RESET_EXPIRATION_MINUTES;
7
+ //# sourceMappingURL=expirations.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expirations.cjs","sources":["../../../../../../packages/engine-tenant-api/src/model/consts/expirations.ts"],"sourcesContent":["export const PASSWORD_RESET_EXPIRATION_MINUTES = 60\nexport const INVITATION_RESET_TOKEN_EXPIRATION_MINUTES = 60 * 24\n"],"names":[],"mappings":";;AAAO,MAAM,oCAAoC;AAC1C,MAAM,4CAA4C,KAAK;;;"}
@@ -0,0 +1,7 @@
1
+ const PASSWORD_RESET_EXPIRATION_MINUTES = 60;
2
+ const INVITATION_RESET_TOKEN_EXPIRATION_MINUTES = 60 * 24;
3
+ export {
4
+ INVITATION_RESET_TOKEN_EXPIRATION_MINUTES,
5
+ PASSWORD_RESET_EXPIRATION_MINUTES
6
+ };
7
+ //# sourceMappingURL=expirations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expirations.js","sources":["../../../../../../packages/engine-tenant-api/src/model/consts/expirations.ts"],"sourcesContent":["export const PASSWORD_RESET_EXPIRATION_MINUTES = 60\nexport const INVITATION_RESET_TOKEN_EXPIRATION_MINUTES = 60 * 24\n"],"names":[],"mappings":"AAAO,MAAM,oCAAoC;AAC1C,MAAM,4CAA4C,KAAK;"}
@@ -3,10 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const NewUserInvited_mustache = require("./templates/NewUserInvited.mustache.cjs");
4
4
  const ExistingUserInvited_mustache = require("./templates/ExistingUserInvited.mustache.cjs");
5
5
  const PasswordReset_mustache = require("./templates/PasswordReset.mustache.cjs");
6
+ const PasswordlessSignIn_mustache = require("./templates/PasswordlessSignIn.mustache.cjs");
6
7
  const type = require("./type.cjs");
7
8
  require("../queries/apiKey/ApiKeyQuery.cjs");
8
- const MailTemplateQuery = require("../queries/mailTemplate/MailTemplateQuery.cjs");
9
9
  require("@contember/database");
10
+ const MailTemplateQuery = require("../queries/mailTemplate/MailTemplateQuery.cjs");
10
11
  require("../authorization/PermissionActions.cjs");
11
12
  require("@contember/authorization");
12
13
  require("../authorization/PermissionContext.cjs");
@@ -42,6 +43,14 @@ class UserMailer {
42
43
  };
43
44
  await this.sendTemplate(template, mailArguments);
44
45
  }
46
+ async sendPasswordlessEmail(dbContext, mailArguments, customMailOptions) {
47
+ const template = await this.getCustomTemplate(dbContext, { type: type.MailType.passwordlessSignIn, ...customMailOptions }) || {
48
+ subject: "Sign in here",
49
+ content: PasswordlessSignIn_mustache,
50
+ replyTo: null
51
+ };
52
+ await this.sendTemplate(template, mailArguments);
53
+ }
45
54
  async sendTemplate(template, mailArguments) {
46
55
  const html = await this.templateRenderer.render(template.content, mailArguments);
47
56
  await this.mailer.send({
@@ -1 +1 @@
1
- {"version":3,"file":"UserMailer.cjs","sources":["../../../../../../packages/engine-tenant-api/src/model/mailing/UserMailer.ts"],"sourcesContent":["import { Mailer, TemplateRenderer } from '../../utils'\nimport NewUserInvited from './templates/NewUserInvited.mustache'\nimport ExistingUserInvited from './templates/ExistingUserInvited.mustache'\nimport PasswordReset from './templates/PasswordReset.mustache'\nimport { MailTemplateData, MailTemplateIdentifier, MailType } from './type'\nimport { MailTemplateQuery } from '../queries'\nimport Layout from './templates/Layout.mustache'\nimport { DatabaseContext } from '../utils'\n\nexport class UserMailer {\n\tconstructor(\n\t\tprivate readonly mailer: Mailer,\n\t\tprivate readonly templateRenderer: TemplateRenderer,\n\t) { }\n\n\tasync sendNewUserInvitedMail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; password: string | null; token: string | null; project: string; projectSlug: string },\n\t\tcustomMailOptions: { projectId: string; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.newUserInvited, ...customMailOptions })) || {\n\t\t\tsubject: 'You have been invited to {{project}}',\n\t\t\tcontent: NewUserInvited,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tasync sendExistingUserInvitedEmail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; project: string; projectSlug: string },\n\t\tcustomMailOptions: { projectId: string; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.existingUserInvited, ...customMailOptions })) || {\n\t\t\tsubject: 'You have been invited to {{project}}',\n\t\t\tcontent: ExistingUserInvited,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tasync sendPasswordResetEmail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; token: string; project?: string; projectSlug?: string },\n\t\tcustomMailOptions: { projectId: string | null; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.passwordReset, ...customMailOptions })) || {\n\t\t\tsubject: 'Password reset',\n\t\t\tcontent: PasswordReset,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tprivate async sendTemplate(\n\t\ttemplate: Pick<MailTemplateData, 'subject' | 'content' | 'replyTo'>,\n\t\tmailArguments: Record<string, any>,\n\t) {\n\t\tconst html = await this.templateRenderer.render(template.content, mailArguments)\n\t\tawait this.mailer.send({\n\t\t\tto: mailArguments.email,\n\t\t\tsubject: await this.templateRenderer.render(template.subject, mailArguments),\n\t\t\thtml,\n\t\t\t...(template.replyTo ? {\n\t\t\t\treplyTo: template.replyTo,\n\t\t\t} : {}),\n\t\t})\n\t}\n\n\tprivate async getCustomTemplate(\n\t\tdbContext: DatabaseContext,\n\t\tidentifier: MailTemplateIdentifier,\n\t): Promise<Pick<MailTemplateData, 'subject' | 'content' | 'replyTo'> | null> {\n\t\tconst customTemplate =\n\t\t\t(await dbContext.queryHandler.fetch(new MailTemplateQuery(identifier)))\n\t\t\t?? (await dbContext.queryHandler.fetch(new MailTemplateQuery({ ...identifier, projectId: null })))\n\n\t\tif (!customTemplate) {\n\t\t\treturn null\n\t\t}\n\t\tconst content = customTemplate.useLayout ? Layout(customTemplate.content) : customTemplate.content\n\t\treturn { content, subject: customTemplate.subject, replyTo: customTemplate.replyTo }\n\t}\n}\n"],"names":["MailType","NewUserInvited","ExistingUserInvited","PasswordReset","MailTemplateQuery","Layout"],"mappings":";;;;;;;;;;;;;;;AASO,MAAM,WAAW;AAAA,EACvB,YACkB,QACA,kBAChB;AAFgB,SAAA,SAAA;AACA,SAAA,mBAAA;AAAA,EACd;AAAA,EAEJ,MAAM,uBACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAMA,cAAS,gBAAgB,GAAG,kBAAmB,CAAA,KAAM;AAAA,MACtH,SAAS;AAAA,MACT,SAASC;AAAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAM,6BACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAMD,cAAS,qBAAqB,GAAG,kBAAmB,CAAA,KAAM;AAAA,MAC3H,SAAS;AAAA,MACT,SAASE;AAAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAM,uBACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAMF,cAAS,eAAe,GAAG,kBAAmB,CAAA,KAAM;AAAA,MACrH,SAAS;AAAA,MACT,SAASG;AAAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAc,aACb,UACA,eACC;AACD,UAAM,OAAO,MAAM,KAAK,iBAAiB,OAAO,SAAS,SAAS,aAAa;AACzE,UAAA,KAAK,OAAO,KAAK;AAAA,MACtB,IAAI,cAAc;AAAA,MAClB,SAAS,MAAM,KAAK,iBAAiB,OAAO,SAAS,SAAS,aAAa;AAAA,MAC3E;AAAA,MACA,GAAI,SAAS,UAAU;AAAA,QACtB,SAAS,SAAS;AAAA,MAAA,IACf,CAAC;AAAA,IAAA,CACL;AAAA,EACF;AAAA,EAEA,MAAc,kBACb,WACA,YAC4E;AACtE,UAAA,iBACJ,MAAM,UAAU,aAAa,MAAM,IAAIC,kBAAA,kBAAkB,UAAU,CAAC,KACjE,MAAM,UAAU,aAAa,MAAM,IAAIA,oCAAkB,EAAE,GAAG,YAAY,WAAW,KAAM,CAAA,CAAC;AAEjG,QAAI,CAAC,gBAAgB;AACb,aAAA;AAAA,IACR;AACA,UAAM,UAAU,eAAe,YAAYC,gBAAO,eAAe,OAAO,IAAI,eAAe;AAC3F,WAAO,EAAE,SAAS,SAAS,eAAe,SAAS,SAAS,eAAe;EAC5E;AACD;;"}
1
+ {"version":3,"file":"UserMailer.cjs","sources":["../../../../../../packages/engine-tenant-api/src/model/mailing/UserMailer.ts"],"sourcesContent":["import { Mailer, TemplateRenderer } from '../../utils'\nimport NewUserInvited from './templates/NewUserInvited.mustache'\nimport ExistingUserInvited from './templates/ExistingUserInvited.mustache'\nimport PasswordReset from './templates/PasswordReset.mustache'\nimport PasswordlessSignIn from './templates/PasswordlessSignIn.mustache'\nimport { MailTemplateData, MailTemplateIdentifier, MailType } from './type'\nimport { MailTemplateQuery } from '../queries'\nimport Layout from './templates/Layout.mustache'\nimport { DatabaseContext } from '../utils'\n\nexport class UserMailer {\n\tconstructor(\n\t\tprivate readonly mailer: Mailer,\n\t\tprivate readonly templateRenderer: TemplateRenderer,\n\t) { }\n\n\tasync sendNewUserInvitedMail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; password: string | null; token: string | null; project: string; projectSlug: string },\n\t\tcustomMailOptions: { projectId: string; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.newUserInvited, ...customMailOptions })) || {\n\t\t\tsubject: 'You have been invited to {{project}}',\n\t\t\tcontent: NewUserInvited,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tasync sendExistingUserInvitedEmail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; project: string; projectSlug: string },\n\t\tcustomMailOptions: { projectId: string; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.existingUserInvited, ...customMailOptions })) || {\n\t\t\tsubject: 'You have been invited to {{project}}',\n\t\t\tcontent: ExistingUserInvited,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tasync sendPasswordResetEmail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; token: string; project?: string; projectSlug?: string },\n\t\tcustomMailOptions: { projectId: string | null; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.passwordReset, ...customMailOptions })) || {\n\t\t\tsubject: 'Password reset',\n\t\t\tcontent: PasswordReset,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tasync sendPasswordlessEmail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; token: string; project?: string; projectSlug?: string; url?: string },\n\t\tcustomMailOptions: { projectId: string | null; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.passwordlessSignIn, ...customMailOptions })) || {\n\t\t\tsubject: 'Sign in here',\n\t\t\tcontent: PasswordlessSignIn,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tprivate async sendTemplate(\n\t\ttemplate: Pick<MailTemplateData, 'subject' | 'content' | 'replyTo'>,\n\t\tmailArguments: Record<string, any>,\n\t) {\n\t\tconst html = await this.templateRenderer.render(template.content, mailArguments)\n\t\tawait this.mailer.send({\n\t\t\tto: mailArguments.email,\n\t\t\tsubject: await this.templateRenderer.render(template.subject, mailArguments),\n\t\t\thtml,\n\t\t\t...(template.replyTo ? {\n\t\t\t\treplyTo: template.replyTo,\n\t\t\t} : {}),\n\t\t})\n\t}\n\n\tprivate async getCustomTemplate(\n\t\tdbContext: DatabaseContext,\n\t\tidentifier: MailTemplateIdentifier,\n\t): Promise<Pick<MailTemplateData, 'subject' | 'content' | 'replyTo'> | null> {\n\t\tconst customTemplate =\n\t\t\t(await dbContext.queryHandler.fetch(new MailTemplateQuery(identifier)))\n\t\t\t?? (await dbContext.queryHandler.fetch(new MailTemplateQuery({ ...identifier, projectId: null })))\n\n\t\tif (!customTemplate) {\n\t\t\treturn null\n\t\t}\n\t\tconst content = customTemplate.useLayout ? Layout(customTemplate.content) : customTemplate.content\n\t\treturn { content, subject: customTemplate.subject, replyTo: customTemplate.replyTo }\n\t}\n}\n"],"names":["MailType","NewUserInvited","ExistingUserInvited","PasswordReset","PasswordlessSignIn","MailTemplateQuery","Layout"],"mappings":";;;;;;;;;;;;;;;;AAUO,MAAM,WAAW;AAAA,EACvB,YACkB,QACA,kBAChB;AAFgB,SAAA,SAAA;AACA,SAAA,mBAAA;AAAA,EACd;AAAA,EAEJ,MAAM,uBACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAMA,cAAS,gBAAgB,GAAG,kBAAmB,CAAA,KAAM;AAAA,MACtH,SAAS;AAAA,MACT,SAASC;AAAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAM,6BACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAMD,cAAS,qBAAqB,GAAG,kBAAmB,CAAA,KAAM;AAAA,MAC3H,SAAS;AAAA,MACT,SAASE;AAAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAM,uBACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAMF,cAAS,eAAe,GAAG,kBAAmB,CAAA,KAAM;AAAA,MACrH,SAAS;AAAA,MACT,SAASG;AAAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAM,sBACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAMH,cAAS,oBAAoB,GAAG,kBAAmB,CAAA,KAAM;AAAA,MAC1H,SAAS;AAAA,MACT,SAASI;AAAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAc,aACb,UACA,eACC;AACD,UAAM,OAAO,MAAM,KAAK,iBAAiB,OAAO,SAAS,SAAS,aAAa;AACzE,UAAA,KAAK,OAAO,KAAK;AAAA,MACtB,IAAI,cAAc;AAAA,MAClB,SAAS,MAAM,KAAK,iBAAiB,OAAO,SAAS,SAAS,aAAa;AAAA,MAC3E;AAAA,MACA,GAAI,SAAS,UAAU;AAAA,QACtB,SAAS,SAAS;AAAA,MAAA,IACf,CAAC;AAAA,IAAA,CACL;AAAA,EACF;AAAA,EAEA,MAAc,kBACb,WACA,YAC4E;AACtE,UAAA,iBACJ,MAAM,UAAU,aAAa,MAAM,IAAIC,kBAAA,kBAAkB,UAAU,CAAC,KACjE,MAAM,UAAU,aAAa,MAAM,IAAIA,oCAAkB,EAAE,GAAG,YAAY,WAAW,KAAM,CAAA,CAAC;AAEjG,QAAI,CAAC,gBAAgB;AACb,aAAA;AAAA,IACR;AACA,UAAM,UAAU,eAAe,YAAYC,gBAAO,eAAe,OAAO,IAAI,eAAe;AAC3F,WAAO,EAAE,SAAS,SAAS,eAAe,SAAS,SAAS,eAAe;EAC5E;AACD;;"}
@@ -1,10 +1,11 @@
1
1
  import NewUserInvited from "./templates/NewUserInvited.mustache.js";
2
2
  import ExistingUserInvited from "./templates/ExistingUserInvited.mustache.js";
3
3
  import PasswordReset from "./templates/PasswordReset.mustache.js";
4
+ import PasswordlessSignIn from "./templates/PasswordlessSignIn.mustache.js";
4
5
  import { MailType } from "./type.js";
5
6
  import "../queries/apiKey/ApiKeyQuery.js";
6
- import { MailTemplateQuery } from "../queries/mailTemplate/MailTemplateQuery.js";
7
7
  import "@contember/database";
8
+ import { MailTemplateQuery } from "../queries/mailTemplate/MailTemplateQuery.js";
8
9
  import "../authorization/PermissionActions.js";
9
10
  import "@contember/authorization";
10
11
  import "../authorization/PermissionContext.js";
@@ -40,6 +41,14 @@ class UserMailer {
40
41
  };
41
42
  await this.sendTemplate(template, mailArguments);
42
43
  }
44
+ async sendPasswordlessEmail(dbContext, mailArguments, customMailOptions) {
45
+ const template = await this.getCustomTemplate(dbContext, { type: MailType.passwordlessSignIn, ...customMailOptions }) || {
46
+ subject: "Sign in here",
47
+ content: PasswordlessSignIn,
48
+ replyTo: null
49
+ };
50
+ await this.sendTemplate(template, mailArguments);
51
+ }
43
52
  async sendTemplate(template, mailArguments) {
44
53
  const html = await this.templateRenderer.render(template.content, mailArguments);
45
54
  await this.mailer.send({
@@ -1 +1 @@
1
- {"version":3,"file":"UserMailer.js","sources":["../../../../../../packages/engine-tenant-api/src/model/mailing/UserMailer.ts"],"sourcesContent":["import { Mailer, TemplateRenderer } from '../../utils'\nimport NewUserInvited from './templates/NewUserInvited.mustache'\nimport ExistingUserInvited from './templates/ExistingUserInvited.mustache'\nimport PasswordReset from './templates/PasswordReset.mustache'\nimport { MailTemplateData, MailTemplateIdentifier, MailType } from './type'\nimport { MailTemplateQuery } from '../queries'\nimport Layout from './templates/Layout.mustache'\nimport { DatabaseContext } from '../utils'\n\nexport class UserMailer {\n\tconstructor(\n\t\tprivate readonly mailer: Mailer,\n\t\tprivate readonly templateRenderer: TemplateRenderer,\n\t) { }\n\n\tasync sendNewUserInvitedMail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; password: string | null; token: string | null; project: string; projectSlug: string },\n\t\tcustomMailOptions: { projectId: string; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.newUserInvited, ...customMailOptions })) || {\n\t\t\tsubject: 'You have been invited to {{project}}',\n\t\t\tcontent: NewUserInvited,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tasync sendExistingUserInvitedEmail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; project: string; projectSlug: string },\n\t\tcustomMailOptions: { projectId: string; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.existingUserInvited, ...customMailOptions })) || {\n\t\t\tsubject: 'You have been invited to {{project}}',\n\t\t\tcontent: ExistingUserInvited,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tasync sendPasswordResetEmail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; token: string; project?: string; projectSlug?: string },\n\t\tcustomMailOptions: { projectId: string | null; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.passwordReset, ...customMailOptions })) || {\n\t\t\tsubject: 'Password reset',\n\t\t\tcontent: PasswordReset,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tprivate async sendTemplate(\n\t\ttemplate: Pick<MailTemplateData, 'subject' | 'content' | 'replyTo'>,\n\t\tmailArguments: Record<string, any>,\n\t) {\n\t\tconst html = await this.templateRenderer.render(template.content, mailArguments)\n\t\tawait this.mailer.send({\n\t\t\tto: mailArguments.email,\n\t\t\tsubject: await this.templateRenderer.render(template.subject, mailArguments),\n\t\t\thtml,\n\t\t\t...(template.replyTo ? {\n\t\t\t\treplyTo: template.replyTo,\n\t\t\t} : {}),\n\t\t})\n\t}\n\n\tprivate async getCustomTemplate(\n\t\tdbContext: DatabaseContext,\n\t\tidentifier: MailTemplateIdentifier,\n\t): Promise<Pick<MailTemplateData, 'subject' | 'content' | 'replyTo'> | null> {\n\t\tconst customTemplate =\n\t\t\t(await dbContext.queryHandler.fetch(new MailTemplateQuery(identifier)))\n\t\t\t?? (await dbContext.queryHandler.fetch(new MailTemplateQuery({ ...identifier, projectId: null })))\n\n\t\tif (!customTemplate) {\n\t\t\treturn null\n\t\t}\n\t\tconst content = customTemplate.useLayout ? Layout(customTemplate.content) : customTemplate.content\n\t\treturn { content, subject: customTemplate.subject, replyTo: customTemplate.replyTo }\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AASO,MAAM,WAAW;AAAA,EACvB,YACkB,QACA,kBAChB;AAFgB,SAAA,SAAA;AACA,SAAA,mBAAA;AAAA,EACd;AAAA,EAEJ,MAAM,uBACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAM,SAAS,gBAAgB,GAAG,kBAAmB,CAAA,KAAM;AAAA,MACtH,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAM,6BACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAM,SAAS,qBAAqB,GAAG,kBAAmB,CAAA,KAAM;AAAA,MAC3H,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAM,uBACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAM,SAAS,eAAe,GAAG,kBAAmB,CAAA,KAAM;AAAA,MACrH,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAc,aACb,UACA,eACC;AACD,UAAM,OAAO,MAAM,KAAK,iBAAiB,OAAO,SAAS,SAAS,aAAa;AACzE,UAAA,KAAK,OAAO,KAAK;AAAA,MACtB,IAAI,cAAc;AAAA,MAClB,SAAS,MAAM,KAAK,iBAAiB,OAAO,SAAS,SAAS,aAAa;AAAA,MAC3E;AAAA,MACA,GAAI,SAAS,UAAU;AAAA,QACtB,SAAS,SAAS;AAAA,MAAA,IACf,CAAC;AAAA,IAAA,CACL;AAAA,EACF;AAAA,EAEA,MAAc,kBACb,WACA,YAC4E;AACtE,UAAA,iBACJ,MAAM,UAAU,aAAa,MAAM,IAAI,kBAAkB,UAAU,CAAC,KACjE,MAAM,UAAU,aAAa,MAAM,IAAI,kBAAkB,EAAE,GAAG,YAAY,WAAW,KAAM,CAAA,CAAC;AAEjG,QAAI,CAAC,gBAAgB;AACb,aAAA;AAAA,IACR;AACA,UAAM,UAAU,eAAe,YAAY,OAAO,eAAe,OAAO,IAAI,eAAe;AAC3F,WAAO,EAAE,SAAS,SAAS,eAAe,SAAS,SAAS,eAAe;EAC5E;AACD;"}
1
+ {"version":3,"file":"UserMailer.js","sources":["../../../../../../packages/engine-tenant-api/src/model/mailing/UserMailer.ts"],"sourcesContent":["import { Mailer, TemplateRenderer } from '../../utils'\nimport NewUserInvited from './templates/NewUserInvited.mustache'\nimport ExistingUserInvited from './templates/ExistingUserInvited.mustache'\nimport PasswordReset from './templates/PasswordReset.mustache'\nimport PasswordlessSignIn from './templates/PasswordlessSignIn.mustache'\nimport { MailTemplateData, MailTemplateIdentifier, MailType } from './type'\nimport { MailTemplateQuery } from '../queries'\nimport Layout from './templates/Layout.mustache'\nimport { DatabaseContext } from '../utils'\n\nexport class UserMailer {\n\tconstructor(\n\t\tprivate readonly mailer: Mailer,\n\t\tprivate readonly templateRenderer: TemplateRenderer,\n\t) { }\n\n\tasync sendNewUserInvitedMail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; password: string | null; token: string | null; project: string; projectSlug: string },\n\t\tcustomMailOptions: { projectId: string; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.newUserInvited, ...customMailOptions })) || {\n\t\t\tsubject: 'You have been invited to {{project}}',\n\t\t\tcontent: NewUserInvited,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tasync sendExistingUserInvitedEmail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; project: string; projectSlug: string },\n\t\tcustomMailOptions: { projectId: string; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.existingUserInvited, ...customMailOptions })) || {\n\t\t\tsubject: 'You have been invited to {{project}}',\n\t\t\tcontent: ExistingUserInvited,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tasync sendPasswordResetEmail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; token: string; project?: string; projectSlug?: string },\n\t\tcustomMailOptions: { projectId: string | null; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.passwordReset, ...customMailOptions })) || {\n\t\t\tsubject: 'Password reset',\n\t\t\tcontent: PasswordReset,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tasync sendPasswordlessEmail(\n\t\tdbContext: DatabaseContext,\n\t\tmailArguments: { email: string; token: string; project?: string; projectSlug?: string; url?: string },\n\t\tcustomMailOptions: { projectId: string | null; variant: string },\n\t): Promise<void> {\n\t\tconst template = (await this.getCustomTemplate(dbContext, { type: MailType.passwordlessSignIn, ...customMailOptions })) || {\n\t\t\tsubject: 'Sign in here',\n\t\t\tcontent: PasswordlessSignIn,\n\t\t\treplyTo: null,\n\t\t}\n\t\tawait this.sendTemplate(template, mailArguments)\n\t}\n\n\tprivate async sendTemplate(\n\t\ttemplate: Pick<MailTemplateData, 'subject' | 'content' | 'replyTo'>,\n\t\tmailArguments: Record<string, any>,\n\t) {\n\t\tconst html = await this.templateRenderer.render(template.content, mailArguments)\n\t\tawait this.mailer.send({\n\t\t\tto: mailArguments.email,\n\t\t\tsubject: await this.templateRenderer.render(template.subject, mailArguments),\n\t\t\thtml,\n\t\t\t...(template.replyTo ? {\n\t\t\t\treplyTo: template.replyTo,\n\t\t\t} : {}),\n\t\t})\n\t}\n\n\tprivate async getCustomTemplate(\n\t\tdbContext: DatabaseContext,\n\t\tidentifier: MailTemplateIdentifier,\n\t): Promise<Pick<MailTemplateData, 'subject' | 'content' | 'replyTo'> | null> {\n\t\tconst customTemplate =\n\t\t\t(await dbContext.queryHandler.fetch(new MailTemplateQuery(identifier)))\n\t\t\t?? (await dbContext.queryHandler.fetch(new MailTemplateQuery({ ...identifier, projectId: null })))\n\n\t\tif (!customTemplate) {\n\t\t\treturn null\n\t\t}\n\t\tconst content = customTemplate.useLayout ? Layout(customTemplate.content) : customTemplate.content\n\t\treturn { content, subject: customTemplate.subject, replyTo: customTemplate.replyTo }\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAUO,MAAM,WAAW;AAAA,EACvB,YACkB,QACA,kBAChB;AAFgB,SAAA,SAAA;AACA,SAAA,mBAAA;AAAA,EACd;AAAA,EAEJ,MAAM,uBACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAM,SAAS,gBAAgB,GAAG,kBAAmB,CAAA,KAAM;AAAA,MACtH,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAM,6BACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAM,SAAS,qBAAqB,GAAG,kBAAmB,CAAA,KAAM;AAAA,MAC3H,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAM,uBACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAM,SAAS,eAAe,GAAG,kBAAmB,CAAA,KAAM;AAAA,MACrH,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAM,sBACL,WACA,eACA,mBACgB;AAChB,UAAM,WAAY,MAAM,KAAK,kBAAkB,WAAW,EAAE,MAAM,SAAS,oBAAoB,GAAG,kBAAmB,CAAA,KAAM;AAAA,MAC1H,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IAAA;AAEJ,UAAA,KAAK,aAAa,UAAU,aAAa;AAAA,EAChD;AAAA,EAEA,MAAc,aACb,UACA,eACC;AACD,UAAM,OAAO,MAAM,KAAK,iBAAiB,OAAO,SAAS,SAAS,aAAa;AACzE,UAAA,KAAK,OAAO,KAAK;AAAA,MACtB,IAAI,cAAc;AAAA,MAClB,SAAS,MAAM,KAAK,iBAAiB,OAAO,SAAS,SAAS,aAAa;AAAA,MAC3E;AAAA,MACA,GAAI,SAAS,UAAU;AAAA,QACtB,SAAS,SAAS;AAAA,MAAA,IACf,CAAC;AAAA,IAAA,CACL;AAAA,EACF;AAAA,EAEA,MAAc,kBACb,WACA,YAC4E;AACtE,UAAA,iBACJ,MAAM,UAAU,aAAa,MAAM,IAAI,kBAAkB,UAAU,CAAC,KACjE,MAAM,UAAU,aAAa,MAAM,IAAI,kBAAkB,EAAE,GAAG,YAAY,WAAW,KAAM,CAAA,CAAC;AAEjG,QAAI,CAAC,gBAAgB;AACb,aAAA;AAAA,IACR;AACA,UAAM,UAAU,eAAe,YAAY,OAAO,eAAe,OAAO,IAAI,eAAe;AAC3F,WAAO,EAAE,SAAS,SAAS,eAAe,SAAS,SAAS,eAAe;EAC5E;AACD;"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ const Layout_mustache = require("./Layout.mustache.cjs");
3
+ const PasswordlessSignIn = Layout_mustache(`
4
+ <p>Hello,</p>
5
+ <p>
6
+ sign in was requested for your account ({{email}}):<br>
7
+ {{#url}}
8
+ <p>Click the following link to sign in:</p>
9
+ <a href="{{url}}">{{url}}</a>
10
+ {{/url}}
11
+ {{^url}}
12
+ <p>Passwordless sign-in is misconfigured. Please contact your administrator.</p>
13
+ {{/url}}
14
+ </p>
15
+ `);
16
+ module.exports = PasswordlessSignIn;
17
+ //# sourceMappingURL=PasswordlessSignIn.mustache.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PasswordlessSignIn.mustache.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/mailing/templates/PasswordlessSignIn.mustache.ts"],"sourcesContent":["import Layout from './Layout.mustache'\n// language=Mustache\nexport default Layout(`\n\t<p>Hello,</p>\n\t<p>\n\t\tsign in was requested for your account ({{email}}):<br>\n\t\t{{#url}}\n\t\t\t<p>Click the following link to sign in:</p>\n\t\t\t<a href=\"{{url}}\">{{url}}</a>\n\t\t{{/url}}\n\t\t{{^url}}\n\t\t\t<p>Passwordless sign-in is misconfigured. Please contact your administrator.</p>\n\t\t{{/url}}\n\t</p>\n`)\n"],"names":["Layout"],"mappings":";;AAEA,MAAeA,qBAAAA,gBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAYrB;;"}
@@ -0,0 +1,18 @@
1
+ import Layout from "./Layout.mustache.js";
2
+ const PasswordlessSignIn = Layout(`
3
+ <p>Hello,</p>
4
+ <p>
5
+ sign in was requested for your account ({{email}}):<br>
6
+ {{#url}}
7
+ <p>Click the following link to sign in:</p>
8
+ <a href="{{url}}">{{url}}</a>
9
+ {{/url}}
10
+ {{^url}}
11
+ <p>Passwordless sign-in is misconfigured. Please contact your administrator.</p>
12
+ {{/url}}
13
+ </p>
14
+ `);
15
+ export {
16
+ PasswordlessSignIn as default
17
+ };
18
+ //# sourceMappingURL=PasswordlessSignIn.mustache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PasswordlessSignIn.mustache.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/mailing/templates/PasswordlessSignIn.mustache.ts"],"sourcesContent":["import Layout from './Layout.mustache'\n// language=Mustache\nexport default Layout(`\n\t<p>Hello,</p>\n\t<p>\n\t\tsign in was requested for your account ({{email}}):<br>\n\t\t{{#url}}\n\t\t\t<p>Click the following link to sign in:</p>\n\t\t\t<a href=\"{{url}}\">{{url}}</a>\n\t\t{{/url}}\n\t\t{{^url}}\n\t\t\t<p>Passwordless sign-in is misconfigured. Please contact your administrator.</p>\n\t\t{{/url}}\n\t</p>\n`)\n"],"names":[],"mappings":";AAEA,MAAe,qBAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAYrB;"}
@@ -4,14 +4,16 @@ var MailType = /* @__PURE__ */ ((MailType2) => {
4
4
  MailType2["existingUserInvited"] = "existingUserInvited";
5
5
  MailType2["newUserInvited"] = "newUserInvited";
6
6
  MailType2["passwordReset"] = "passwordReset";
7
+ MailType2["passwordlessSignIn"] = "passwordlessSignIn";
7
8
  return MailType2;
8
9
  })(MailType || {});
9
10
  const mailTypeFromSchemaToDb = (type) => {
10
11
  return {
11
12
  EXISTING_USER_INVITED: "existingUserInvited",
12
13
  NEW_USER_INVITED: "newUserInvited",
13
- RESET_PASSWORD_REQUEST: "passwordReset"
14
- /* passwordReset */
14
+ RESET_PASSWORD_REQUEST: "passwordReset",
15
+ PASSWORDLESS_SIGN_IN: "passwordlessSignIn"
16
+ /* passwordlessSignIn */
15
17
  }[type];
16
18
  };
17
19
  const mailTypeFromDbToSchema = (type) => {
@@ -27,7 +29,11 @@ const mailTypeFromDbToSchema = (type) => {
27
29
  [
28
30
  "passwordReset"
29
31
  /* passwordReset */
30
- ]: "RESET_PASSWORD_REQUEST"
32
+ ]: "RESET_PASSWORD_REQUEST",
33
+ [
34
+ "passwordlessSignIn"
35
+ /* passwordlessSignIn */
36
+ ]: "PASSWORDLESS_SIGN_IN"
31
37
  }[type];
32
38
  };
33
39
  exports.MailType = MailType;
@@ -1 +1 @@
1
- {"version":3,"file":"type.cjs","sources":["../../../../../../packages/engine-tenant-api/src/model/mailing/type.ts"],"sourcesContent":["import { MailType as SchemaMailType } from '../../schema'\n\nexport enum MailType {\n\texistingUserInvited = 'existingUserInvited',\n\tnewUserInvited = 'newUserInvited',\n\tpasswordReset = 'passwordReset',\n}\n\nexport const mailTypeFromSchemaToDb = (type: SchemaMailType): MailType => {\n\treturn {\n\t\tEXISTING_USER_INVITED: MailType.existingUserInvited,\n\t\tNEW_USER_INVITED: MailType.newUserInvited,\n\t\tRESET_PASSWORD_REQUEST: MailType.passwordReset,\n\t}[type]\n}\n\nexport const mailTypeFromDbToSchema = (type: MailType): SchemaMailType => {\n\treturn {\n\t\t[MailType.existingUserInvited]: 'EXISTING_USER_INVITED' as const,\n\t\t[MailType.newUserInvited]: 'NEW_USER_INVITED' as const,\n\t\t[MailType.passwordReset]: 'RESET_PASSWORD_REQUEST' as const,\n\t}[type]\n}\n\nexport interface MailTemplateIdentifier {\n\tprojectId: string | null\n\ttype: MailType\n\tvariant: string\n}\n\nexport interface MailTemplateData {\n\tsubject: string\n\tcontent: string\n\tuseLayout: boolean\n\treplyTo: string | null\n}\n\nexport interface MailTemplate extends MailTemplateIdentifier, MailTemplateData {}\n"],"names":["MailType"],"mappings":";;AAEY,IAAA,6BAAAA,cAAL;AACNA,YAAA,qBAAsB,IAAA;AACtBA,YAAA,gBAAiB,IAAA;AACjBA,YAAA,eAAgB,IAAA;AAHLA,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAMC,MAAA,yBAAyB,CAAC,SAAmC;AAClE,SAAA;AAAA,IACN,uBAAuB;AAAA,IACvB,kBAAkB;AAAA,IAClB,wBAAwB;AAAA;AAAA,IACvB,IAAI;AACP;AAEa,MAAA,yBAAyB,CAAC,SAAmC;AAClE,SAAA;AAAA,IACN;AAAA,MAAC;AAAA;AAAA,OAA+B;AAAA,IAChC;AAAA,MAAC;AAAA;AAAA,OAA0B;AAAA,IAC3B;AAAA,MAAC;AAAA;AAAA,OAAyB;AAAA,IACzB,IAAI;AACP;;;;"}
1
+ {"version":3,"file":"type.cjs","sources":["../../../../../../packages/engine-tenant-api/src/model/mailing/type.ts"],"sourcesContent":["import { MailType as SchemaMailType } from '../../schema'\n\nexport enum MailType {\n\texistingUserInvited = 'existingUserInvited',\n\tnewUserInvited = 'newUserInvited',\n\tpasswordReset = 'passwordReset',\n\tpasswordlessSignIn = 'passwordlessSignIn',\n}\n\nexport const mailTypeFromSchemaToDb = (type: SchemaMailType): MailType => {\n\treturn {\n\t\tEXISTING_USER_INVITED: MailType.existingUserInvited,\n\t\tNEW_USER_INVITED: MailType.newUserInvited,\n\t\tRESET_PASSWORD_REQUEST: MailType.passwordReset,\n\t\tPASSWORDLESS_SIGN_IN: MailType.passwordlessSignIn,\n\t}[type]\n}\n\nexport const mailTypeFromDbToSchema = (type: MailType): SchemaMailType => {\n\treturn {\n\t\t[MailType.existingUserInvited]: 'EXISTING_USER_INVITED' as const,\n\t\t[MailType.newUserInvited]: 'NEW_USER_INVITED' as const,\n\t\t[MailType.passwordReset]: 'RESET_PASSWORD_REQUEST' as const,\n\t\t[MailType.passwordlessSignIn]: 'PASSWORDLESS_SIGN_IN' as const,\n\t}[type]\n}\n\nexport interface MailTemplateIdentifier {\n\tprojectId: string | null\n\ttype: MailType\n\tvariant: string\n}\n\nexport interface MailTemplateData {\n\tsubject: string\n\tcontent: string\n\tuseLayout: boolean\n\treplyTo: string | null\n}\n\nexport interface MailTemplate extends MailTemplateIdentifier, MailTemplateData {}\n"],"names":["MailType"],"mappings":";;AAEY,IAAA,6BAAAA,cAAL;AACNA,YAAA,qBAAsB,IAAA;AACtBA,YAAA,gBAAiB,IAAA;AACjBA,YAAA,eAAgB,IAAA;AAChBA,YAAA,oBAAqB,IAAA;AAJVA,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAOC,MAAA,yBAAyB,CAAC,SAAmC;AAClE,SAAA;AAAA,IACN,uBAAuB;AAAA,IACvB,kBAAkB;AAAA,IAClB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA;AAAA,IACrB,IAAI;AACP;AAEa,MAAA,yBAAyB,CAAC,SAAmC;AAClE,SAAA;AAAA,IACN;AAAA,MAAC;AAAA;AAAA,OAA+B;AAAA,IAChC;AAAA,MAAC;AAAA;AAAA,OAA0B;AAAA,IAC3B;AAAA,MAAC;AAAA;AAAA,OAAyB;AAAA,IAC1B;AAAA,MAAC;AAAA;AAAA,OAA8B;AAAA,IAC9B,IAAI;AACP;;;;"}
@@ -2,14 +2,16 @@ var MailType = /* @__PURE__ */ ((MailType2) => {
2
2
  MailType2["existingUserInvited"] = "existingUserInvited";
3
3
  MailType2["newUserInvited"] = "newUserInvited";
4
4
  MailType2["passwordReset"] = "passwordReset";
5
+ MailType2["passwordlessSignIn"] = "passwordlessSignIn";
5
6
  return MailType2;
6
7
  })(MailType || {});
7
8
  const mailTypeFromSchemaToDb = (type) => {
8
9
  return {
9
10
  EXISTING_USER_INVITED: "existingUserInvited",
10
11
  NEW_USER_INVITED: "newUserInvited",
11
- RESET_PASSWORD_REQUEST: "passwordReset"
12
- /* passwordReset */
12
+ RESET_PASSWORD_REQUEST: "passwordReset",
13
+ PASSWORDLESS_SIGN_IN: "passwordlessSignIn"
14
+ /* passwordlessSignIn */
13
15
  }[type];
14
16
  };
15
17
  const mailTypeFromDbToSchema = (type) => {
@@ -25,7 +27,11 @@ const mailTypeFromDbToSchema = (type) => {
25
27
  [
26
28
  "passwordReset"
27
29
  /* passwordReset */
28
- ]: "RESET_PASSWORD_REQUEST"
30
+ ]: "RESET_PASSWORD_REQUEST",
31
+ [
32
+ "passwordlessSignIn"
33
+ /* passwordlessSignIn */
34
+ ]: "PASSWORDLESS_SIGN_IN"
29
35
  }[type];
30
36
  };
31
37
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sources":["../../../../../../packages/engine-tenant-api/src/model/mailing/type.ts"],"sourcesContent":["import { MailType as SchemaMailType } from '../../schema'\n\nexport enum MailType {\n\texistingUserInvited = 'existingUserInvited',\n\tnewUserInvited = 'newUserInvited',\n\tpasswordReset = 'passwordReset',\n}\n\nexport const mailTypeFromSchemaToDb = (type: SchemaMailType): MailType => {\n\treturn {\n\t\tEXISTING_USER_INVITED: MailType.existingUserInvited,\n\t\tNEW_USER_INVITED: MailType.newUserInvited,\n\t\tRESET_PASSWORD_REQUEST: MailType.passwordReset,\n\t}[type]\n}\n\nexport const mailTypeFromDbToSchema = (type: MailType): SchemaMailType => {\n\treturn {\n\t\t[MailType.existingUserInvited]: 'EXISTING_USER_INVITED' as const,\n\t\t[MailType.newUserInvited]: 'NEW_USER_INVITED' as const,\n\t\t[MailType.passwordReset]: 'RESET_PASSWORD_REQUEST' as const,\n\t}[type]\n}\n\nexport interface MailTemplateIdentifier {\n\tprojectId: string | null\n\ttype: MailType\n\tvariant: string\n}\n\nexport interface MailTemplateData {\n\tsubject: string\n\tcontent: string\n\tuseLayout: boolean\n\treplyTo: string | null\n}\n\nexport interface MailTemplate extends MailTemplateIdentifier, MailTemplateData {}\n"],"names":["MailType"],"mappings":"AAEY,IAAA,6BAAAA,cAAL;AACNA,YAAA,qBAAsB,IAAA;AACtBA,YAAA,gBAAiB,IAAA;AACjBA,YAAA,eAAgB,IAAA;AAHLA,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAMC,MAAA,yBAAyB,CAAC,SAAmC;AAClE,SAAA;AAAA,IACN,uBAAuB;AAAA,IACvB,kBAAkB;AAAA,IAClB,wBAAwB;AAAA;AAAA,IACvB,IAAI;AACP;AAEa,MAAA,yBAAyB,CAAC,SAAmC;AAClE,SAAA;AAAA,IACN;AAAA,MAAC;AAAA;AAAA,OAA+B;AAAA,IAChC;AAAA,MAAC;AAAA;AAAA,OAA0B;AAAA,IAC3B;AAAA,MAAC;AAAA;AAAA,OAAyB;AAAA,IACzB,IAAI;AACP;"}
1
+ {"version":3,"file":"type.js","sources":["../../../../../../packages/engine-tenant-api/src/model/mailing/type.ts"],"sourcesContent":["import { MailType as SchemaMailType } from '../../schema'\n\nexport enum MailType {\n\texistingUserInvited = 'existingUserInvited',\n\tnewUserInvited = 'newUserInvited',\n\tpasswordReset = 'passwordReset',\n\tpasswordlessSignIn = 'passwordlessSignIn',\n}\n\nexport const mailTypeFromSchemaToDb = (type: SchemaMailType): MailType => {\n\treturn {\n\t\tEXISTING_USER_INVITED: MailType.existingUserInvited,\n\t\tNEW_USER_INVITED: MailType.newUserInvited,\n\t\tRESET_PASSWORD_REQUEST: MailType.passwordReset,\n\t\tPASSWORDLESS_SIGN_IN: MailType.passwordlessSignIn,\n\t}[type]\n}\n\nexport const mailTypeFromDbToSchema = (type: MailType): SchemaMailType => {\n\treturn {\n\t\t[MailType.existingUserInvited]: 'EXISTING_USER_INVITED' as const,\n\t\t[MailType.newUserInvited]: 'NEW_USER_INVITED' as const,\n\t\t[MailType.passwordReset]: 'RESET_PASSWORD_REQUEST' as const,\n\t\t[MailType.passwordlessSignIn]: 'PASSWORDLESS_SIGN_IN' as const,\n\t}[type]\n}\n\nexport interface MailTemplateIdentifier {\n\tprojectId: string | null\n\ttype: MailType\n\tvariant: string\n}\n\nexport interface MailTemplateData {\n\tsubject: string\n\tcontent: string\n\tuseLayout: boolean\n\treplyTo: string | null\n}\n\nexport interface MailTemplate extends MailTemplateIdentifier, MailTemplateData {}\n"],"names":["MailType"],"mappings":"AAEY,IAAA,6BAAAA,cAAL;AACNA,YAAA,qBAAsB,IAAA;AACtBA,YAAA,gBAAiB,IAAA;AACjBA,YAAA,eAAgB,IAAA;AAChBA,YAAA,oBAAqB,IAAA;AAJVA,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAOC,MAAA,yBAAyB,CAAC,SAAmC;AAClE,SAAA;AAAA,IACN,uBAAuB;AAAA,IACvB,kBAAkB;AAAA,IAClB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA;AAAA,IACrB,IAAI;AACP;AAEa,MAAA,yBAAyB,CAAC,SAAmC;AAClE,SAAA;AAAA,IACN;AAAA,MAAC;AAAA;AAAA,OAA+B;AAAA,IAChC;AAAA,MAAC;AAAA;AAAA,OAA0B;AAAA,IAC3B;AAAA,MAAC;AAAA;AAAA,OAAyB;AAAA,IAC1B;AAAA,MAAC;AAAA;AAAA,OAA8B;AAAA,IAC9B,IAAI;AACP;"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const Database = require("@contember/database");
4
+ class ConfigurationQuery extends Database.DatabaseQuery {
5
+ async fetch({ db }) {
6
+ const rows = await Database.SelectBuilder.create().from("config").select(new Database.Literal("*")).getResult(db);
7
+ const result = this.fetchOneOrNull(rows);
8
+ if (!result) {
9
+ throw new Error("Configuration not found");
10
+ }
11
+ return {
12
+ passwordless: {
13
+ enabled: result.passwordless_enabled,
14
+ url: result.passwordless_url,
15
+ expirationMinutes: result.passwordless_expiration_minutes
16
+ }
17
+ };
18
+ }
19
+ }
20
+ exports.ConfigurationQuery = ConfigurationQuery;
21
+ //# sourceMappingURL=ConfigurationQuery.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigurationQuery.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/queries/configuration/ConfigurationQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { Config, ConfigPolicy } from '../../../schema'\n\nexport class ConfigurationQuery extends DatabaseQuery<Config> {\n\n\tasync fetch({ db }: DatabaseQueryable): Promise<Config> {\n\t\tconst rows = await SelectBuilder.create<ConfigurationRow>()\n\t\t\t.from('config')\n\t\t\t.select(new Literal('*'))\n\t\t\t.getResult(db)\n\t\tconst result = this.fetchOneOrNull(rows)\n\t\tif (!result) {\n\t\t\tthrow new Error('Configuration not found')\n\t\t}\n\n\t\treturn {\n\t\t\tpasswordless: {\n\t\t\t\tenabled: result.passwordless_enabled,\n\t\t\t\turl: result.passwordless_url,\n\t\t\t\texpirationMinutes: result.passwordless_expiration_minutes,\n\t\t\t},\n\t\t}\n\t}\n}\n\ninterface ConfigurationRow {\n\tpasswordless_enabled: ConfigPolicy\n\tpasswordless_url: string | null\n\tpasswordless_expiration_minutes: number\n}\n"],"names":["DatabaseQuery","SelectBuilder","Literal"],"mappings":";;;AAGO,MAAM,2BAA2BA,SAAAA,cAAsB;AAAA,EAE7D,MAAM,MAAM,EAAE,MAA0C;AACvD,UAAM,OAAO,MAAMC,SAAAA,cAAc,SAC/B,KAAK,QAAQ,EACb,OAAO,IAAIC,SAAQ,QAAA,GAAG,CAAC,EACvB,UAAU,EAAE;AACR,UAAA,SAAS,KAAK,eAAe,IAAI;AACvC,QAAI,CAAC,QAAQ;AACN,YAAA,IAAI,MAAM,yBAAyB;AAAA,IAC1C;AAEO,WAAA;AAAA,MACN,cAAc;AAAA,QACb,SAAS,OAAO;AAAA,QAChB,KAAK,OAAO;AAAA,QACZ,mBAAmB,OAAO;AAAA,MAC3B;AAAA,IAAA;AAAA,EAEF;AACD;;"}
@@ -0,0 +1,21 @@
1
+ import { DatabaseQuery, SelectBuilder, Literal } from "@contember/database";
2
+ class ConfigurationQuery extends DatabaseQuery {
3
+ async fetch({ db }) {
4
+ const rows = await SelectBuilder.create().from("config").select(new Literal("*")).getResult(db);
5
+ const result = this.fetchOneOrNull(rows);
6
+ if (!result) {
7
+ throw new Error("Configuration not found");
8
+ }
9
+ return {
10
+ passwordless: {
11
+ enabled: result.passwordless_enabled,
12
+ url: result.passwordless_url,
13
+ expirationMinutes: result.passwordless_expiration_minutes
14
+ }
15
+ };
16
+ }
17
+ }
18
+ export {
19
+ ConfigurationQuery
20
+ };
21
+ //# sourceMappingURL=ConfigurationQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigurationQuery.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/queries/configuration/ConfigurationQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { Config, ConfigPolicy } from '../../../schema'\n\nexport class ConfigurationQuery extends DatabaseQuery<Config> {\n\n\tasync fetch({ db }: DatabaseQueryable): Promise<Config> {\n\t\tconst rows = await SelectBuilder.create<ConfigurationRow>()\n\t\t\t.from('config')\n\t\t\t.select(new Literal('*'))\n\t\t\t.getResult(db)\n\t\tconst result = this.fetchOneOrNull(rows)\n\t\tif (!result) {\n\t\t\tthrow new Error('Configuration not found')\n\t\t}\n\n\t\treturn {\n\t\t\tpasswordless: {\n\t\t\t\tenabled: result.passwordless_enabled,\n\t\t\t\turl: result.passwordless_url,\n\t\t\t\texpirationMinutes: result.passwordless_expiration_minutes,\n\t\t\t},\n\t\t}\n\t}\n}\n\ninterface ConfigurationRow {\n\tpasswordless_enabled: ConfigPolicy\n\tpasswordless_url: string | null\n\tpasswordless_expiration_minutes: number\n}\n"],"names":[],"mappings":";AAGO,MAAM,2BAA2B,cAAsB;AAAA,EAE7D,MAAM,MAAM,EAAE,MAA0C;AACvD,UAAM,OAAO,MAAM,cAAc,SAC/B,KAAK,QAAQ,EACb,OAAO,IAAI,QAAQ,GAAG,CAAC,EACvB,UAAU,EAAE;AACR,UAAA,SAAS,KAAK,eAAe,IAAI;AACvC,QAAI,CAAC,QAAQ;AACN,YAAA,IAAI,MAAM,yBAAyB;AAAA,IAC1C;AAEO,WAAA;AAAA,MACN,cAAc;AAAA,QACb,SAAS,OAAO;AAAA,QAChB,KAAK,OAAO;AAAA,QACZ,mBAAmB,OAAO;AAAA,MAC3B;AAAA,IAAA;AAAA,EAEF;AACD;"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const Database = require("@contember/database");
4
4
  class PersonQueryBuilderFactory {
5
5
  static createPersonQueryBuilder() {
6
- return Database.SelectBuilder.create().select(["person", "id"]).select(["person", "password_hash"]).select(["person", "otp_uri"]).select(["person", "otp_activated_at"]).select(["person", "identity_id"]).select(["person", "email"]).select(["person", "name"]).select(["person", "disabled_at"]).select(["identity", "roles"]).from("person").join("identity", "identity", (expr) => expr.columnsEq(["identity", "id"], ["person", "identity_id"]));
6
+ return Database.SelectBuilder.create().select(["person", "id"]).select(["person", "password_hash"]).select(["person", "otp_uri"]).select(["person", "otp_activated_at"]).select(["person", "identity_id"]).select(["person", "email"]).select(["person", "name"]).select(["person", "disabled_at"]).select(["person", "passwordless_enabled"]).select(["identity", "roles"]).from("person").join("identity", "identity", (expr) => expr.columnsEq(["identity", "id"], ["person", "identity_id"]));
7
7
  }
8
8
  }
9
9
  exports.PersonQueryBuilderFactory = PersonQueryBuilderFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"PersonQueryBuilderFactory.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/queries/person/PersonQueryBuilderFactory.ts"],"sourcesContent":["import { PersonRow } from './types'\nimport { SelectBuilder } from '@contember/database'\n\nexport class PersonQueryBuilderFactory {\n\tpublic static createPersonQueryBuilder() {\n\t\treturn SelectBuilder.create<PersonRow>()\n\t\t\t.select(['person', 'id'])\n\t\t\t.select(['person', 'password_hash'])\n\t\t\t.select(['person', 'otp_uri'])\n\t\t\t.select(['person', 'otp_activated_at'])\n\t\t\t.select(['person', 'identity_id'])\n\t\t\t.select(['person', 'email'])\n\t\t\t.select(['person', 'name'])\n\t\t\t.select(['person', 'disabled_at'])\n\t\t\t.select(['identity', 'roles'])\n\t\t\t.from('person')\n\t\t\t.join('identity', 'identity', expr => expr.columnsEq(['identity', 'id'], ['person', 'identity_id']))\n\t}\n}\n"],"names":["SelectBuilder"],"mappings":";;;AAGO,MAAM,0BAA0B;AAAA,EACtC,OAAc,2BAA2B;AACxC,WAAOA,SAAc,cAAA,OAAA,EACnB,OAAO,CAAC,UAAU,IAAI,CAAC,EACvB,OAAO,CAAC,UAAU,eAAe,CAAC,EAClC,OAAO,CAAC,UAAU,SAAS,CAAC,EAC5B,OAAO,CAAC,UAAU,kBAAkB,CAAC,EACrC,OAAO,CAAC,UAAU,aAAa,CAAC,EAChC,OAAO,CAAC,UAAU,OAAO,CAAC,EAC1B,OAAO,CAAC,UAAU,MAAM,CAAC,EACzB,OAAO,CAAC,UAAU,aAAa,CAAC,EAChC,OAAO,CAAC,YAAY,OAAO,CAAC,EAC5B,KAAK,QAAQ,EACb,KAAK,YAAY,YAAY,UAAQ,KAAK,UAAU,CAAC,YAAY,IAAI,GAAG,CAAC,UAAU,aAAa,CAAC,CAAC;AAAA,EACrG;AACD;;"}
1
+ {"version":3,"file":"PersonQueryBuilderFactory.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/queries/person/PersonQueryBuilderFactory.ts"],"sourcesContent":["import { PersonRow } from './types'\nimport { SelectBuilder } from '@contember/database'\n\nexport class PersonQueryBuilderFactory {\n\tpublic static createPersonQueryBuilder() {\n\t\treturn SelectBuilder.create<PersonRow>()\n\t\t\t.select(['person', 'id'])\n\t\t\t.select(['person', 'password_hash'])\n\t\t\t.select(['person', 'otp_uri'])\n\t\t\t.select(['person', 'otp_activated_at'])\n\t\t\t.select(['person', 'identity_id'])\n\t\t\t.select(['person', 'email'])\n\t\t\t.select(['person', 'name'])\n\t\t\t.select(['person', 'disabled_at'])\n\t\t\t.select(['person', 'passwordless_enabled'])\n\t\t\t.select(['identity', 'roles'])\n\t\t\t.from('person')\n\t\t\t.join('identity', 'identity', expr => expr.columnsEq(['identity', 'id'], ['person', 'identity_id']))\n\t}\n}\n"],"names":["SelectBuilder"],"mappings":";;;AAGO,MAAM,0BAA0B;AAAA,EACtC,OAAc,2BAA2B;AACxC,WAAOA,SAAAA,cAAc,OAAkB,EACrC,OAAO,CAAC,UAAU,IAAI,CAAC,EACvB,OAAO,CAAC,UAAU,eAAe,CAAC,EAClC,OAAO,CAAC,UAAU,SAAS,CAAC,EAC5B,OAAO,CAAC,UAAU,kBAAkB,CAAC,EACrC,OAAO,CAAC,UAAU,aAAa,CAAC,EAChC,OAAO,CAAC,UAAU,OAAO,CAAC,EAC1B,OAAO,CAAC,UAAU,MAAM,CAAC,EACzB,OAAO,CAAC,UAAU,aAAa,CAAC,EAChC,OAAO,CAAC,UAAU,sBAAsB,CAAC,EACzC,OAAO,CAAC,YAAY,OAAO,CAAC,EAC5B,KAAK,QAAQ,EACb,KAAK,YAAY,YAAY,CAAQ,SAAA,KAAK,UAAU,CAAC,YAAY,IAAI,GAAG,CAAC,UAAU,aAAa,CAAC,CAAC;AAAA,EACrG;AACD;;"}
@@ -1,7 +1,7 @@
1
1
  import { SelectBuilder } from "@contember/database";
2
2
  class PersonQueryBuilderFactory {
3
3
  static createPersonQueryBuilder() {
4
- return SelectBuilder.create().select(["person", "id"]).select(["person", "password_hash"]).select(["person", "otp_uri"]).select(["person", "otp_activated_at"]).select(["person", "identity_id"]).select(["person", "email"]).select(["person", "name"]).select(["person", "disabled_at"]).select(["identity", "roles"]).from("person").join("identity", "identity", (expr) => expr.columnsEq(["identity", "id"], ["person", "identity_id"]));
4
+ return SelectBuilder.create().select(["person", "id"]).select(["person", "password_hash"]).select(["person", "otp_uri"]).select(["person", "otp_activated_at"]).select(["person", "identity_id"]).select(["person", "email"]).select(["person", "name"]).select(["person", "disabled_at"]).select(["person", "passwordless_enabled"]).select(["identity", "roles"]).from("person").join("identity", "identity", (expr) => expr.columnsEq(["identity", "id"], ["person", "identity_id"]));
5
5
  }
6
6
  }
7
7
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"PersonQueryBuilderFactory.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/queries/person/PersonQueryBuilderFactory.ts"],"sourcesContent":["import { PersonRow } from './types'\nimport { SelectBuilder } from '@contember/database'\n\nexport class PersonQueryBuilderFactory {\n\tpublic static createPersonQueryBuilder() {\n\t\treturn SelectBuilder.create<PersonRow>()\n\t\t\t.select(['person', 'id'])\n\t\t\t.select(['person', 'password_hash'])\n\t\t\t.select(['person', 'otp_uri'])\n\t\t\t.select(['person', 'otp_activated_at'])\n\t\t\t.select(['person', 'identity_id'])\n\t\t\t.select(['person', 'email'])\n\t\t\t.select(['person', 'name'])\n\t\t\t.select(['person', 'disabled_at'])\n\t\t\t.select(['identity', 'roles'])\n\t\t\t.from('person')\n\t\t\t.join('identity', 'identity', expr => expr.columnsEq(['identity', 'id'], ['person', 'identity_id']))\n\t}\n}\n"],"names":[],"mappings":";AAGO,MAAM,0BAA0B;AAAA,EACtC,OAAc,2BAA2B;AACxC,WAAO,cAAc,OAAA,EACnB,OAAO,CAAC,UAAU,IAAI,CAAC,EACvB,OAAO,CAAC,UAAU,eAAe,CAAC,EAClC,OAAO,CAAC,UAAU,SAAS,CAAC,EAC5B,OAAO,CAAC,UAAU,kBAAkB,CAAC,EACrC,OAAO,CAAC,UAAU,aAAa,CAAC,EAChC,OAAO,CAAC,UAAU,OAAO,CAAC,EAC1B,OAAO,CAAC,UAAU,MAAM,CAAC,EACzB,OAAO,CAAC,UAAU,aAAa,CAAC,EAChC,OAAO,CAAC,YAAY,OAAO,CAAC,EAC5B,KAAK,QAAQ,EACb,KAAK,YAAY,YAAY,UAAQ,KAAK,UAAU,CAAC,YAAY,IAAI,GAAG,CAAC,UAAU,aAAa,CAAC,CAAC;AAAA,EACrG;AACD;"}
1
+ {"version":3,"file":"PersonQueryBuilderFactory.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/queries/person/PersonQueryBuilderFactory.ts"],"sourcesContent":["import { PersonRow } from './types'\nimport { SelectBuilder } from '@contember/database'\n\nexport class PersonQueryBuilderFactory {\n\tpublic static createPersonQueryBuilder() {\n\t\treturn SelectBuilder.create<PersonRow>()\n\t\t\t.select(['person', 'id'])\n\t\t\t.select(['person', 'password_hash'])\n\t\t\t.select(['person', 'otp_uri'])\n\t\t\t.select(['person', 'otp_activated_at'])\n\t\t\t.select(['person', 'identity_id'])\n\t\t\t.select(['person', 'email'])\n\t\t\t.select(['person', 'name'])\n\t\t\t.select(['person', 'disabled_at'])\n\t\t\t.select(['person', 'passwordless_enabled'])\n\t\t\t.select(['identity', 'roles'])\n\t\t\t.from('person')\n\t\t\t.join('identity', 'identity', expr => expr.columnsEq(['identity', 'id'], ['person', 'identity_id']))\n\t}\n}\n"],"names":[],"mappings":";AAGO,MAAM,0BAA0B;AAAA,EACtC,OAAc,2BAA2B;AACxC,WAAO,cAAc,OAAkB,EACrC,OAAO,CAAC,UAAU,IAAI,CAAC,EACvB,OAAO,CAAC,UAAU,eAAe,CAAC,EAClC,OAAO,CAAC,UAAU,SAAS,CAAC,EAC5B,OAAO,CAAC,UAAU,kBAAkB,CAAC,EACrC,OAAO,CAAC,UAAU,aAAa,CAAC,EAChC,OAAO,CAAC,UAAU,OAAO,CAAC,EAC1B,OAAO,CAAC,UAAU,MAAM,CAAC,EACzB,OAAO,CAAC,UAAU,aAAa,CAAC,EAChC,OAAO,CAAC,UAAU,sBAAsB,CAAC,EACzC,OAAO,CAAC,YAAY,OAAO,CAAC,EAC5B,KAAK,QAAQ,EACb,KAAK,YAAY,YAAY,CAAQ,SAAA,KAAK,UAAU,CAAC,YAAY,IAAI,GAAG,CAAC,UAAU,aAAa,CAAC,CAAC;AAAA,EACrG;AACD;"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const Database = require("@contember/database");
4
+ require("../../type/ApiKey.cjs");
5
+ const tokenUtils = require("../../utils/tokenUtils.cjs");
6
+ class PersonTokenQuery extends Database.DatabaseQuery {
7
+ constructor(identifierType, identifier, type) {
8
+ super();
9
+ this.identifierType = identifierType;
10
+ this.identifier = identifier;
11
+ this.type = type;
12
+ }
13
+ static byId(id, type) {
14
+ return new PersonTokenQuery("id", id, type);
15
+ }
16
+ static byToken(token, type) {
17
+ const tokenHash = tokenUtils.computeTokenHash(token);
18
+ return new PersonTokenQuery("token_hash", tokenHash, type);
19
+ }
20
+ async fetch({ db }) {
21
+ const result = await Database.SelectBuilder.create().from("person_token").select(new Database.Literal("*")).where({
22
+ [this.identifierType]: this.identifier,
23
+ type: this.type
24
+ }).getResult(db);
25
+ return this.fetchOneOrNull(result);
26
+ }
27
+ }
28
+ exports.PersonTokenQuery = PersonTokenQuery;
29
+ //# sourceMappingURL=PersonTokenQuery.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersonTokenQuery.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/queries/personToken/PersonTokenQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { PersonToken } from '../../type'\nimport { computeTokenHash } from '../../utils'\n\nexport class PersonTokenQuery extends DatabaseQuery<PersonToken.Row | null> {\n\n\tprivate constructor(\n\t\tprivate readonly identifierType: 'id' | 'token_hash',\n\t\tprivate readonly identifier: string,\n\t\tprivate readonly type: PersonToken.Type,\n\t) {\n\t\tsuper()\n\t}\n\n\tpublic static byId(id: string, type: PersonToken.Type): PersonTokenQuery {\n\t\treturn new PersonTokenQuery('id', id, type)\n\t}\n\n\tpublic static byToken(token: string, type: PersonToken.Type): PersonTokenQuery {\n\t\tconst tokenHash = computeTokenHash(token)\n\t\treturn new PersonTokenQuery('token_hash', tokenHash, type)\n\t}\n\n\tasync fetch({ db }: DatabaseQueryable): Promise<PersonToken.Row | null> {\n\t\tconst result = await SelectBuilder.create<PersonToken.Row>()\n\t\t\t.from('person_token')\n\t\t\t.select(new Literal('*'))\n\t\t\t.where({\n\t\t\t\t[this.identifierType]: this.identifier,\n\t\t\t\ttype: this.type,\n\t\t\t})\n\t\t\t.getResult(db)\n\t\treturn this.fetchOneOrNull(result)\n\t}\n}\n"],"names":["DatabaseQuery","computeTokenHash","SelectBuilder","Literal"],"mappings":";;;;;AAIO,MAAM,yBAAyBA,SAAAA,cAAsC;AAAA,EAEnE,YACU,gBACA,YACA,MAChB;AACK;AAJW,SAAA,iBAAA;AACA,SAAA,aAAA;AACA,SAAA,OAAA;AAAA,EAGlB;AAAA,EAEA,OAAc,KAAK,IAAY,MAA0C;AACxE,WAAO,IAAI,iBAAiB,MAAM,IAAI,IAAI;AAAA,EAC3C;AAAA,EAEA,OAAc,QAAQ,OAAe,MAA0C;AACxE,UAAA,YAAYC,4BAAiB,KAAK;AACxC,WAAO,IAAI,iBAAiB,cAAc,WAAW,IAAI;AAAA,EAC1D;AAAA,EAEA,MAAM,MAAM,EAAE,MAA0D;AACvE,UAAM,SAAS,MAAMC,SAAAA,cAAc,OAAA,EACjC,KAAK,cAAc,EACnB,OAAO,IAAIC,SAAA,QAAQ,GAAG,CAAC,EACvB,MAAM;AAAA,MACN,CAAC,KAAK,cAAc,GAAG,KAAK;AAAA,MAC5B,MAAM,KAAK;AAAA,IAAA,CACX,EACA,UAAU,EAAE;AACP,WAAA,KAAK,eAAe,MAAM;AAAA,EAClC;AACD;;"}
@@ -0,0 +1,29 @@
1
+ import { DatabaseQuery, SelectBuilder, Literal } from "@contember/database";
2
+ import "../../type/ApiKey.js";
3
+ import { computeTokenHash } from "../../utils/tokenUtils.js";
4
+ class PersonTokenQuery extends DatabaseQuery {
5
+ constructor(identifierType, identifier, type) {
6
+ super();
7
+ this.identifierType = identifierType;
8
+ this.identifier = identifier;
9
+ this.type = type;
10
+ }
11
+ static byId(id, type) {
12
+ return new PersonTokenQuery("id", id, type);
13
+ }
14
+ static byToken(token, type) {
15
+ const tokenHash = computeTokenHash(token);
16
+ return new PersonTokenQuery("token_hash", tokenHash, type);
17
+ }
18
+ async fetch({ db }) {
19
+ const result = await SelectBuilder.create().from("person_token").select(new Literal("*")).where({
20
+ [this.identifierType]: this.identifier,
21
+ type: this.type
22
+ }).getResult(db);
23
+ return this.fetchOneOrNull(result);
24
+ }
25
+ }
26
+ export {
27
+ PersonTokenQuery
28
+ };
29
+ //# sourceMappingURL=PersonTokenQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersonTokenQuery.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/queries/personToken/PersonTokenQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { PersonToken } from '../../type'\nimport { computeTokenHash } from '../../utils'\n\nexport class PersonTokenQuery extends DatabaseQuery<PersonToken.Row | null> {\n\n\tprivate constructor(\n\t\tprivate readonly identifierType: 'id' | 'token_hash',\n\t\tprivate readonly identifier: string,\n\t\tprivate readonly type: PersonToken.Type,\n\t) {\n\t\tsuper()\n\t}\n\n\tpublic static byId(id: string, type: PersonToken.Type): PersonTokenQuery {\n\t\treturn new PersonTokenQuery('id', id, type)\n\t}\n\n\tpublic static byToken(token: string, type: PersonToken.Type): PersonTokenQuery {\n\t\tconst tokenHash = computeTokenHash(token)\n\t\treturn new PersonTokenQuery('token_hash', tokenHash, type)\n\t}\n\n\tasync fetch({ db }: DatabaseQueryable): Promise<PersonToken.Row | null> {\n\t\tconst result = await SelectBuilder.create<PersonToken.Row>()\n\t\t\t.from('person_token')\n\t\t\t.select(new Literal('*'))\n\t\t\t.where({\n\t\t\t\t[this.identifierType]: this.identifier,\n\t\t\t\ttype: this.type,\n\t\t\t})\n\t\t\t.getResult(db)\n\t\treturn this.fetchOneOrNull(result)\n\t}\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,yBAAyB,cAAsC;AAAA,EAEnE,YACU,gBACA,YACA,MAChB;AACK;AAJW,SAAA,iBAAA;AACA,SAAA,aAAA;AACA,SAAA,OAAA;AAAA,EAGlB;AAAA,EAEA,OAAc,KAAK,IAAY,MAA0C;AACxE,WAAO,IAAI,iBAAiB,MAAM,IAAI,IAAI;AAAA,EAC3C;AAAA,EAEA,OAAc,QAAQ,OAAe,MAA0C;AACxE,UAAA,YAAY,iBAAiB,KAAK;AACxC,WAAO,IAAI,iBAAiB,cAAc,WAAW,IAAI;AAAA,EAC1D;AAAA,EAEA,MAAM,MAAM,EAAE,MAA0D;AACvE,UAAM,SAAS,MAAM,cAAc,OAAA,EACjC,KAAK,cAAc,EACnB,OAAO,IAAI,QAAQ,GAAG,CAAC,EACvB,MAAM;AAAA,MACN,CAAC,KAAK,cAAc,GAAG,KAAK;AAAA,MAC5B,MAAM,KAAK;AAAA,IAAA,CACX,EACA,UAAU,EAAE;AACP,WAAA,KAAK,eAAe,MAAM;AAAA,EAClC;AACD;"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const Response = require("../utils/Response.cjs");
4
+ require("../type/ApiKey.cjs");
5
+ require("@contember/database");
6
+ require("node:crypto");
7
+ const UpdateConfigurationCommand = require("../commands/configuration/UpdateConfigurationCommand.cjs");
8
+ require("../queries/apiKey/ApiKeyQuery.cjs");
9
+ const ConfigurationQuery = require("../queries/configuration/ConfigurationQuery.cjs");
10
+ require("../authorization/PermissionActions.cjs");
11
+ require("@contember/authorization");
12
+ require("../authorization/PermissionContext.cjs");
13
+ require("../authorization/PermissionsFactory.cjs");
14
+ require("@contember/schema");
15
+ class ConfigurationManager {
16
+ constructor() {
17
+ }
18
+ async updateConfiguration(db, configuration) {
19
+ await db.commandBus.execute(new UpdateConfigurationCommand.UpdateConfigurationCommand(configuration));
20
+ return new Response.ResponseOk(null);
21
+ }
22
+ async fetchConfiguration(db) {
23
+ return await db.queryHandler.fetch(new ConfigurationQuery.ConfigurationQuery());
24
+ }
25
+ }
26
+ exports.ConfigurationManager = ConfigurationManager;
27
+ //# sourceMappingURL=ConfigurationManager.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigurationManager.cjs","sources":["../../../../../../packages/engine-tenant-api/src/model/service/ConfigurationManager.ts"],"sourcesContent":["import { Config, ConfigInput, ConfigureErrorCode } from '../../schema'\nimport { Response, ResponseOk } from '../utils/Response'\nimport { DatabaseContext } from '../utils'\nimport { UpdateConfigurationCommand } from '../commands'\nimport { ConfigurationQuery } from '../queries'\n\nexport class ConfigurationManager {\n\tconstructor() {\n\t}\n\n\tpublic async updateConfiguration(db: DatabaseContext, configuration: ConfigInput): Promise<Response<null, ConfigureErrorCode>> {\n\t\t// todo: validate configuration\n\n\t\tawait db.commandBus.execute(new UpdateConfigurationCommand(configuration))\n\n\t\treturn new ResponseOk(null)\n\t}\n\n\tpublic async fetchConfiguration(db: DatabaseContext): Promise<Config> {\n\t\treturn await db.queryHandler.fetch(new ConfigurationQuery())\n\t}\n}\n"],"names":["UpdateConfigurationCommand","ResponseOk","ConfigurationQuery"],"mappings":";;;;;;;;;;;;;;AAMO,MAAM,qBAAqB;AAAA,EACjC,cAAc;AAAA,EACd;AAAA,EAEA,MAAa,oBAAoB,IAAqB,eAAyE;AAG9H,UAAM,GAAG,WAAW,QAAQ,IAAIA,2BAAA,2BAA2B,aAAa,CAAC;AAElE,WAAA,IAAIC,SAAAA,WAAW,IAAI;AAAA,EAC3B;AAAA,EAEA,MAAa,mBAAmB,IAAsC;AACrE,WAAO,MAAM,GAAG,aAAa,MAAM,IAAIC,mBAAAA,mBAAoB,CAAA;AAAA,EAC5D;AACD;;"}