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

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 (534) 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/resolvers/types/ProjectTypeResolver.cjs.map +1 -1
  164. package/dist/development/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
  165. package/dist/development/src/schema/tenant.graphql.cjs +161 -10
  166. package/dist/development/src/schema/tenant.graphql.cjs.map +1 -1
  167. package/dist/development/src/schema/tenant.graphql.js +161 -10
  168. package/dist/development/src/schema/tenant.graphql.js.map +1 -1
  169. package/dist/production/index.cjs +18 -6
  170. package/dist/production/index.cjs.map +1 -1
  171. package/dist/production/index.js +20 -8
  172. package/dist/production/index.js.map +1 -1
  173. package/dist/production/src/TenantContainer.cjs +7 -1
  174. package/dist/production/src/TenantContainer.cjs.map +1 -1
  175. package/dist/production/src/TenantContainer.js +7 -1
  176. package/dist/production/src/TenantContainer.js.map +1 -1
  177. package/dist/production/src/migrations/2024-08-26-120000-passwordless.cjs +31 -0
  178. package/dist/production/src/migrations/2024-08-26-120000-passwordless.cjs.map +1 -0
  179. package/dist/production/src/migrations/2024-08-26-120000-passwordless.js +32 -0
  180. package/dist/production/src/migrations/2024-08-26-120000-passwordless.js.map +1 -0
  181. package/dist/production/src/migrations/runner.cjs +3 -1
  182. package/dist/production/src/migrations/runner.cjs.map +1 -1
  183. package/dist/production/src/migrations/runner.js +3 -1
  184. package/dist/production/src/migrations/runner.js.map +1 -1
  185. package/dist/production/src/migrations/snapshot.cjs +33 -5
  186. package/dist/production/src/migrations/snapshot.cjs.map +1 -1
  187. package/dist/production/src/migrations/snapshot.js +33 -5
  188. package/dist/production/src/migrations/snapshot.js.map +1 -1
  189. package/dist/production/src/model/authorization/PermissionActions.cjs +5 -0
  190. package/dist/production/src/model/authorization/PermissionActions.cjs.map +1 -1
  191. package/dist/production/src/model/authorization/PermissionActions.js +5 -0
  192. package/dist/production/src/model/authorization/PermissionActions.js.map +1 -1
  193. package/dist/production/src/model/authorization/PermissionsFactory.cjs +5 -0
  194. package/dist/production/src/model/authorization/PermissionsFactory.cjs.map +1 -1
  195. package/dist/production/src/model/authorization/PermissionsFactory.js +5 -0
  196. package/dist/production/src/model/authorization/PermissionsFactory.js.map +1 -1
  197. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.cjs +20 -0
  198. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.cjs.map +1 -0
  199. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.js +20 -0
  200. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.js.map +1 -0
  201. package/dist/production/src/model/commands/person/CreatePersonCommand.cjs +2 -1
  202. package/dist/production/src/model/commands/person/CreatePersonCommand.cjs.map +1 -1
  203. package/dist/production/src/model/commands/person/CreatePersonCommand.js +2 -1
  204. package/dist/production/src/model/commands/person/CreatePersonCommand.js.map +1 -1
  205. package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.cjs +18 -0
  206. package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.cjs.map +1 -0
  207. package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.js +18 -0
  208. package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.js.map +1 -0
  209. package/dist/production/src/model/commands/personToken/ActivateOtpCommand.cjs +20 -0
  210. package/dist/production/src/model/commands/personToken/ActivateOtpCommand.cjs.map +1 -0
  211. package/dist/production/src/model/commands/personToken/ActivateOtpCommand.js +20 -0
  212. package/dist/production/src/model/commands/personToken/ActivateOtpCommand.js.map +1 -0
  213. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.cjs +33 -0
  214. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.cjs.map +1 -0
  215. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.js +33 -0
  216. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.js.map +1 -0
  217. package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.cjs +19 -0
  218. package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.cjs.map +1 -0
  219. package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.js +19 -0
  220. package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.js.map +1 -0
  221. package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.cjs +19 -0
  222. package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.cjs.map +1 -0
  223. package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.js +19 -0
  224. package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.js.map +1 -0
  225. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.cjs +28 -0
  226. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.cjs.map +1 -0
  227. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.js +28 -0
  228. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.js.map +1 -0
  229. package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.cjs +28 -0
  230. package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.cjs.map +1 -0
  231. package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.js +28 -0
  232. package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.js.map +1 -0
  233. package/dist/production/src/model/consts/expirations.cjs +7 -0
  234. package/dist/production/src/model/consts/expirations.cjs.map +1 -0
  235. package/dist/production/src/model/consts/expirations.js +7 -0
  236. package/dist/production/src/model/consts/expirations.js.map +1 -0
  237. package/dist/production/src/model/mailing/UserMailer.cjs +10 -1
  238. package/dist/production/src/model/mailing/UserMailer.cjs.map +1 -1
  239. package/dist/production/src/model/mailing/UserMailer.js +10 -1
  240. package/dist/production/src/model/mailing/UserMailer.js.map +1 -1
  241. package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.cjs +17 -0
  242. package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.cjs.map +1 -0
  243. package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.js +18 -0
  244. package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.js.map +1 -0
  245. package/dist/production/src/model/mailing/type.cjs +9 -3
  246. package/dist/production/src/model/mailing/type.cjs.map +1 -1
  247. package/dist/production/src/model/mailing/type.js +9 -3
  248. package/dist/production/src/model/mailing/type.js.map +1 -1
  249. package/dist/production/src/model/queries/configuration/ConfigurationQuery.cjs +21 -0
  250. package/dist/production/src/model/queries/configuration/ConfigurationQuery.cjs.map +1 -0
  251. package/dist/production/src/model/queries/configuration/ConfigurationQuery.js +21 -0
  252. package/dist/production/src/model/queries/configuration/ConfigurationQuery.js.map +1 -0
  253. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.cjs +1 -1
  254. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.cjs.map +1 -1
  255. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.js +1 -1
  256. package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.js.map +1 -1
  257. package/dist/production/src/model/queries/personToken/PersonTokenQuery.cjs +29 -0
  258. package/dist/production/src/model/queries/personToken/PersonTokenQuery.cjs.map +1 -0
  259. package/dist/production/src/model/queries/personToken/PersonTokenQuery.js +29 -0
  260. package/dist/production/src/model/queries/personToken/PersonTokenQuery.js.map +1 -0
  261. package/dist/production/src/model/service/ConfigurationManager.cjs +27 -0
  262. package/dist/production/src/model/service/ConfigurationManager.cjs.map +1 -0
  263. package/dist/production/src/model/service/ConfigurationManager.js +27 -0
  264. package/dist/production/src/model/service/ConfigurationManager.js.map +1 -0
  265. package/dist/production/src/model/service/InviteManager.cjs +7 -7
  266. package/dist/production/src/model/service/InviteManager.cjs.map +1 -1
  267. package/dist/production/src/model/service/InviteManager.js +6 -6
  268. package/dist/production/src/model/service/InviteManager.js.map +1 -1
  269. package/dist/production/src/model/service/PasswordChangeManager.cjs +1 -1
  270. package/dist/production/src/model/service/PasswordChangeManager.js +1 -1
  271. package/dist/production/src/model/service/PasswordResetManager.cjs +7 -15
  272. package/dist/production/src/model/service/PasswordResetManager.cjs.map +1 -1
  273. package/dist/production/src/model/service/PasswordResetManager.js +7 -15
  274. package/dist/production/src/model/service/PasswordResetManager.js.map +1 -1
  275. package/dist/production/src/model/service/PasswordlessSignInManager.cjs +135 -0
  276. package/dist/production/src/model/service/PasswordlessSignInManager.cjs.map +1 -0
  277. package/dist/production/src/model/service/PasswordlessSignInManager.js +135 -0
  278. package/dist/production/src/model/service/PasswordlessSignInManager.js.map +1 -0
  279. package/dist/production/src/model/service/PersonManager.cjs +7 -0
  280. package/dist/production/src/model/service/PersonManager.cjs.map +1 -1
  281. package/dist/production/src/model/service/PersonManager.js +7 -0
  282. package/dist/production/src/model/service/PersonManager.js.map +1 -1
  283. package/dist/production/src/model/service/ProjectManager.cjs +2 -2
  284. package/dist/production/src/model/service/ProjectManager.js +2 -2
  285. package/dist/production/src/model/service/RolesManager.cjs +1 -1
  286. package/dist/production/src/model/service/RolesManager.js +1 -1
  287. package/dist/production/src/model/service/SignUpManager.cjs +1 -1
  288. package/dist/production/src/model/service/SignUpManager.js +1 -1
  289. package/dist/production/src/model/service/helpers/getPreferredProject.cjs +13 -0
  290. package/dist/production/src/model/service/helpers/getPreferredProject.cjs.map +1 -0
  291. package/dist/production/src/model/service/helpers/getPreferredProject.js +13 -0
  292. package/dist/production/src/model/service/helpers/getPreferredProject.js.map +1 -0
  293. package/dist/production/src/model/service/idp/providers/OIDCProvider.cjs +2 -1
  294. package/dist/production/src/model/service/idp/providers/OIDCProvider.cjs.map +1 -1
  295. package/dist/production/src/model/service/idp/providers/OIDCProvider.js +2 -1
  296. package/dist/production/src/model/service/idp/providers/OIDCProvider.js.map +1 -1
  297. package/dist/production/src/model/service/idp/providers/OIDCTypes.cjs +2 -1
  298. package/dist/production/src/model/service/idp/providers/OIDCTypes.cjs.map +1 -1
  299. package/dist/production/src/model/service/idp/providers/OIDCTypes.js +2 -1
  300. package/dist/production/src/model/service/idp/providers/OIDCTypes.js.map +1 -1
  301. package/dist/production/src/model/utils/tokenUtils.cjs +39 -0
  302. package/dist/production/src/model/utils/tokenUtils.cjs.map +1 -1
  303. package/dist/production/src/model/utils/tokenUtils.js +40 -1
  304. package/dist/production/src/model/utils/tokenUtils.js.map +1 -1
  305. package/dist/production/src/resolvers/ResolverFactory.cjs +8 -1
  306. package/dist/production/src/resolvers/ResolverFactory.cjs.map +1 -1
  307. package/dist/production/src/resolvers/ResolverFactory.js +8 -1
  308. package/dist/production/src/resolvers/ResolverFactory.js.map +1 -1
  309. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs +41 -0
  310. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs.map +1 -0
  311. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js +41 -0
  312. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js.map +1 -0
  313. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs +83 -0
  314. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs.map +1 -0
  315. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.js +83 -0
  316. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.js.map +1 -0
  317. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs.map +1 -1
  318. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.js.map +1 -1
  319. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs +52 -0
  320. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs.map +1 -0
  321. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js +52 -0
  322. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js.map +1 -0
  323. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.cjs +34 -0
  324. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.cjs.map +1 -0
  325. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.js +34 -0
  326. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.js.map +1 -0
  327. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.cjs +1 -0
  328. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.cjs.map +1 -1
  329. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.js +1 -0
  330. package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.js.map +1 -1
  331. package/dist/production/src/resolvers/types/ProjectTypeResolver.cjs.map +1 -1
  332. package/dist/production/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
  333. package/dist/production/src/schema/tenant.graphql.cjs +161 -10
  334. package/dist/production/src/schema/tenant.graphql.cjs.map +1 -1
  335. package/dist/production/src/schema/tenant.graphql.js +161 -10
  336. package/dist/production/src/schema/tenant.graphql.js.map +1 -1
  337. package/dist/tests/cases/integration/mocked/sql/{createPasswordResetSql.d.ts → createPersonTokenSql.d.ts} +3 -2
  338. package/dist/tests/cases/integration/mocked/sql/createPersonTokenSql.d.ts.map +1 -0
  339. package/dist/tests/cases/integration/mocked/sql/getPersonByEmailSql.d.ts.map +1 -1
  340. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  341. package/dist/types/TenantContainer.d.ts +18 -0
  342. package/dist/types/TenantContainer.d.ts.map +1 -1
  343. package/dist/types/migrations/2024-08-26-120000-passwordless.d.ts +3 -0
  344. package/dist/types/migrations/2024-08-26-120000-passwordless.d.ts.map +1 -0
  345. package/dist/types/migrations/runner.d.ts.map +1 -1
  346. package/dist/types/migrations/snapshot.d.ts.map +1 -1
  347. package/dist/types/model/authorization/PermissionActions.d.ts +25 -0
  348. package/dist/types/model/authorization/PermissionActions.d.ts.map +1 -1
  349. package/dist/types/model/authorization/PermissionsFactory.d.ts.map +1 -1
  350. package/dist/types/model/commands/configuration/UpdateConfigurationCommand.d.ts +8 -0
  351. package/dist/types/model/commands/configuration/UpdateConfigurationCommand.d.ts.map +1 -0
  352. package/dist/types/model/commands/configuration/index.d.ts +2 -0
  353. package/dist/types/model/commands/configuration/index.d.ts.map +1 -0
  354. package/dist/types/model/commands/index.d.ts +2 -2
  355. package/dist/types/model/commands/index.d.ts.map +1 -1
  356. package/dist/types/model/commands/person/CreatePersonCommand.d.ts.map +1 -1
  357. package/dist/types/model/commands/person/TogglePersonPasswordlessCommand.d.ts +8 -0
  358. package/dist/types/model/commands/person/TogglePersonPasswordlessCommand.d.ts.map +1 -0
  359. package/dist/types/model/commands/person/index.d.ts +1 -0
  360. package/dist/types/model/commands/person/index.d.ts.map +1 -1
  361. package/dist/types/model/commands/personToken/ActivateOtpCommand.d.ts +8 -0
  362. package/dist/types/model/commands/personToken/ActivateOtpCommand.d.ts.map +1 -0
  363. package/dist/types/model/commands/personToken/CreatePersonTokenCommand.d.ts +19 -0
  364. package/dist/types/model/commands/personToken/CreatePersonTokenCommand.d.ts.map +1 -0
  365. package/dist/types/model/commands/personToken/IncreaseOtpAttemptCommand.d.ts +7 -0
  366. package/dist/types/model/commands/personToken/IncreaseOtpAttemptCommand.d.ts.map +1 -0
  367. package/dist/types/model/commands/personToken/InvalidateTokenCommand.d.ts +7 -0
  368. package/dist/types/model/commands/personToken/InvalidateTokenCommand.d.ts.map +1 -0
  369. package/dist/types/model/commands/{passwordReset → personToken}/ResetPasswordCommand.d.ts +3 -2
  370. package/dist/types/model/commands/personToken/ResetPasswordCommand.d.ts.map +1 -0
  371. package/dist/types/model/commands/personToken/SavePersonTokenCommand.d.ts +19 -0
  372. package/dist/types/model/commands/personToken/SavePersonTokenCommand.d.ts.map +1 -0
  373. package/dist/types/model/commands/personToken/index.d.ts +7 -0
  374. package/dist/types/model/commands/personToken/index.d.ts.map +1 -0
  375. package/dist/types/model/consts/expirations.d.ts +3 -0
  376. package/dist/types/model/consts/expirations.d.ts.map +1 -0
  377. package/dist/types/model/mailing/UserMailer.d.ts +10 -0
  378. package/dist/types/model/mailing/UserMailer.d.ts.map +1 -1
  379. package/dist/types/model/mailing/templates/PasswordlessSignIn.mustache.d.ts +3 -0
  380. package/dist/types/model/mailing/templates/PasswordlessSignIn.mustache.d.ts.map +1 -0
  381. package/dist/types/model/mailing/type.d.ts +2 -1
  382. package/dist/types/model/mailing/type.d.ts.map +1 -1
  383. package/dist/types/model/queries/configuration/ConfigurationQuery.d.ts +6 -0
  384. package/dist/types/model/queries/configuration/ConfigurationQuery.d.ts.map +1 -0
  385. package/dist/types/model/queries/configuration/index.d.ts +2 -0
  386. package/dist/types/model/queries/configuration/index.d.ts.map +1 -0
  387. package/dist/types/model/queries/index.d.ts +1 -0
  388. package/dist/types/model/queries/index.d.ts.map +1 -1
  389. package/dist/types/model/queries/person/PersonQueryBuilderFactory.d.ts.map +1 -1
  390. package/dist/types/model/queries/person/types.d.ts +1 -0
  391. package/dist/types/model/queries/person/types.d.ts.map +1 -1
  392. package/dist/types/model/queries/personToken/PersonTokenQuery.d.ts +12 -0
  393. package/dist/types/model/queries/personToken/PersonTokenQuery.d.ts.map +1 -0
  394. package/dist/types/model/service/ConfigurationManager.d.ts +9 -0
  395. package/dist/types/model/service/ConfigurationManager.d.ts.map +1 -0
  396. package/dist/types/model/service/InviteManager.d.ts.map +1 -1
  397. package/dist/types/model/service/PasswordResetManager.d.ts +1 -1
  398. package/dist/types/model/service/PasswordResetManager.d.ts.map +1 -1
  399. package/dist/types/model/service/PasswordlessSignInManager.d.ts +54 -0
  400. package/dist/types/model/service/PasswordlessSignInManager.d.ts.map +1 -0
  401. package/dist/types/model/service/PersonManager.d.ts +1 -0
  402. package/dist/types/model/service/PersonManager.d.ts.map +1 -1
  403. package/dist/types/model/service/PersonTokenManager.d.ts +3 -0
  404. package/dist/types/model/service/PersonTokenManager.d.ts.map +1 -0
  405. package/dist/types/model/service/helpers/getPreferredProject.d.ts +3 -0
  406. package/dist/types/model/service/helpers/getPreferredProject.d.ts.map +1 -0
  407. package/dist/types/model/service/idp/providers/AppleProvider.d.ts +2 -0
  408. package/dist/types/model/service/idp/providers/AppleProvider.d.ts.map +1 -1
  409. package/dist/types/model/service/idp/providers/FacebookProvider.d.ts +2 -0
  410. package/dist/types/model/service/idp/providers/FacebookProvider.d.ts.map +1 -1
  411. package/dist/types/model/service/idp/providers/OIDCProvider.d.ts +1 -0
  412. package/dist/types/model/service/idp/providers/OIDCProvider.d.ts.map +1 -1
  413. package/dist/types/model/service/idp/providers/OIDCTypes.d.ts +9 -5
  414. package/dist/types/model/service/idp/providers/OIDCTypes.d.ts.map +1 -1
  415. package/dist/types/model/type/PersonToken.d.ts +16 -0
  416. package/dist/types/model/type/PersonToken.d.ts.map +1 -0
  417. package/dist/types/model/type/index.d.ts +1 -0
  418. package/dist/types/model/type/index.d.ts.map +1 -1
  419. package/dist/types/model/utils/tokenUtils.d.ts +8 -0
  420. package/dist/types/model/utils/tokenUtils.d.ts.map +1 -1
  421. package/dist/types/resolvers/ResolverFactory.d.ts +8 -0
  422. package/dist/types/resolvers/ResolverFactory.d.ts.map +1 -1
  423. package/dist/types/resolvers/mutation/configuration/ConfigurationMutationResolver.d.ts +9 -0
  424. package/dist/types/resolvers/mutation/configuration/ConfigurationMutationResolver.d.ts.map +1 -0
  425. package/dist/types/resolvers/mutation/person/PasswordlessMutationResolver.d.ts +13 -0
  426. package/dist/types/resolvers/mutation/person/PasswordlessMutationResolver.d.ts.map +1 -0
  427. package/dist/types/resolvers/mutation/person/ResetPasswordMutationResolver.d.ts.map +1 -1
  428. package/dist/types/resolvers/mutation/person/TogglePasswordlessMutationResolver.d.ts +13 -0
  429. package/dist/types/resolvers/mutation/person/TogglePasswordlessMutationResolver.d.ts.map +1 -0
  430. package/dist/types/resolvers/query/ConfigurationQueryResolver.d.ts +9 -0
  431. package/dist/types/resolvers/query/ConfigurationQueryResolver.d.ts.map +1 -0
  432. package/dist/types/resolvers/responseHelpers/PersonResponseFactory.d.ts.map +1 -1
  433. package/dist/types/resolvers/types/ProjectTypeResolver.d.ts +3 -3
  434. package/dist/types/schema/index.d.ts +360 -38
  435. package/dist/types/schema/index.d.ts.map +1 -1
  436. package/dist/types/schema/tenant.graphql.d.ts.map +1 -1
  437. package/dist/types/tsconfig.tsbuildinfo +1 -1
  438. package/dist/types/utils/batchQuery.d.ts.map +1 -1
  439. package/{graphql-tenant.codegen.yml → graphql.codegen.yml} +1 -1
  440. package/package.json +22 -26
  441. package/src/TenantContainer.ts +18 -0
  442. package/src/migrations/2024-08-26-120000-passwordless.ts +31 -0
  443. package/src/migrations/runner.ts +2 -0
  444. package/src/migrations/snapshot-template-end.txt +3 -0
  445. package/src/migrations/snapshot.ts +33 -5
  446. package/src/model/authorization/PermissionActions.ts +7 -0
  447. package/src/model/authorization/PermissionsFactory.ts +5 -0
  448. package/src/model/commands/configuration/UpdateConfigurationCommand.ts +26 -0
  449. package/src/model/commands/configuration/index.ts +1 -0
  450. package/src/model/commands/index.ts +2 -2
  451. package/src/model/commands/person/CreatePersonCommand.ts +1 -0
  452. package/src/model/commands/person/TogglePersonPasswordlessCommand.ts +18 -0
  453. package/src/model/commands/person/index.ts +1 -0
  454. package/src/model/commands/personToken/ActivateOtpCommand.ts +24 -0
  455. package/src/model/commands/personToken/CreatePersonTokenCommand.ts +42 -0
  456. package/src/model/commands/personToken/IncreaseOtpAttemptCommand.ts +23 -0
  457. package/src/model/commands/personToken/InvalidateTokenCommand.ts +22 -0
  458. package/src/model/commands/personToken/ResetPasswordCommand.ts +28 -0
  459. package/src/model/commands/personToken/SavePersonTokenCommand.ts +42 -0
  460. package/src/model/commands/personToken/index.ts +6 -0
  461. package/src/model/consts/expirations.ts +2 -0
  462. package/src/model/mailing/UserMailer.ts +14 -0
  463. package/src/model/mailing/templates/PasswordlessSignIn.mustache.ts +15 -0
  464. package/src/model/mailing/type.ts +3 -0
  465. package/src/model/queries/configuration/ConfigurationQuery.ts +30 -0
  466. package/src/model/queries/configuration/index.ts +1 -0
  467. package/src/model/queries/index.ts +1 -0
  468. package/src/model/queries/person/PersonQueryBuilderFactory.ts +1 -0
  469. package/src/model/queries/person/types.ts +1 -0
  470. package/src/model/queries/personToken/PersonTokenQuery.ts +35 -0
  471. package/src/model/service/ConfigurationManager.ts +22 -0
  472. package/src/model/service/InviteManager.ts +5 -6
  473. package/src/model/service/PasswordResetManager.ts +4 -10
  474. package/src/model/service/PasswordlessSignInManager.ts +190 -0
  475. package/src/model/service/PersonManager.ts +6 -0
  476. package/src/model/service/PersonTokenManager.ts +2 -0
  477. package/src/model/service/helpers/getPreferredProject.ts +11 -0
  478. package/src/model/service/idp/providers/OIDCProvider.ts +1 -0
  479. package/src/model/service/idp/providers/OIDCTypes.ts +1 -0
  480. package/src/model/type/PersonToken.ts +21 -0
  481. package/src/model/type/index.ts +1 -0
  482. package/src/model/utils/tokenUtils.ts +47 -0
  483. package/src/resolvers/ResolverFactory.ts +19 -0
  484. package/src/resolvers/mutation/configuration/ConfigurationMutationResolver.ts +29 -0
  485. package/src/resolvers/mutation/person/PasswordlessMutationResolver.ts +81 -0
  486. package/src/resolvers/mutation/person/ResetPasswordMutationResolver.ts +1 -10
  487. package/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.ts +44 -0
  488. package/src/resolvers/query/ConfigurationQueryResolver.ts +21 -0
  489. package/src/resolvers/responseHelpers/PersonResponseFactory.ts +1 -0
  490. package/src/resolvers/types/ProjectTypeResolver.ts +3 -3
  491. package/src/schema/index.ts +360 -35
  492. package/src/schema/tenant.graphql.ts +161 -10
  493. package/tests/cases/integration/mocked/inviteMutations.test.ts +2 -2
  494. package/tests/cases/integration/mocked/sql/{createPasswordResetSql.ts → createPersonTokenSql.ts} +5 -3
  495. package/tests/cases/integration/mocked/sql/getPersonByEmailSql.ts +2 -1
  496. package/tests/cases/integration/mocked/sql/getPersonByIdSql.ts +1 -1
  497. package/tests/cases/integration/mocked/sql/getPersonByIdentity.ts +1 -1
  498. package/tests/cases/integration/mocked/sql/getPersonByIdpSql.ts +1 -1
  499. package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs +0 -30
  500. package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs.map +0 -1
  501. package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js +0 -30
  502. package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js.map +0 -1
  503. package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.cjs +0 -38
  504. package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.cjs.map +0 -1
  505. package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.js +0 -38
  506. package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.js.map +0 -1
  507. package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs +0 -24
  508. package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs.map +0 -1
  509. package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js +0 -24
  510. package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js.map +0 -1
  511. package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs +0 -30
  512. package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs.map +0 -1
  513. package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js +0 -30
  514. package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js.map +0 -1
  515. package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.cjs +0 -38
  516. package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.cjs.map +0 -1
  517. package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.js +0 -38
  518. package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.js.map +0 -1
  519. package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs +0 -24
  520. package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs.map +0 -1
  521. package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js +0 -24
  522. package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js.map +0 -1
  523. package/dist/tests/cases/integration/mocked/sql/createPasswordResetSql.d.ts.map +0 -1
  524. package/dist/types/model/commands/passwordReset/CreatePasswordResetRequestCommand.d.ts +0 -12
  525. package/dist/types/model/commands/passwordReset/CreatePasswordResetRequestCommand.d.ts.map +0 -1
  526. package/dist/types/model/commands/passwordReset/ResetPasswordCommand.d.ts.map +0 -1
  527. package/dist/types/model/commands/passwordReset/SavePasswordResetRequestCommand.d.ts +0 -10
  528. package/dist/types/model/commands/passwordReset/SavePasswordResetRequestCommand.d.ts.map +0 -1
  529. package/dist/types/model/commands/passwordReset/index.d.ts +0 -4
  530. package/dist/types/model/commands/passwordReset/index.d.ts.map +0 -1
  531. package/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.ts +0 -25
  532. package/src/model/commands/passwordReset/ResetPasswordCommand.ts +0 -57
  533. package/src/model/commands/passwordReset/SavePasswordResetRequestCommand.ts +0 -28
  534. package/src/model/commands/passwordReset/index.ts +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"batchQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/batchQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,MAAM,MAAM,UAAU,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAEhE,MAAM,MAAM,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,eAAe,KAAK,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,CAAA;AACnK,eAAO,MAAM,WAAW,GAAI,GAAG,EAAE,MAAM,EAAE,IAAI,kCADqC,eAAe,KAAK,OAAO,QAAQ,oFAClB,CAAA;AAEnG,eAAO,MAAM,eAAe,GAAI,GAAG,EAAE,MAAM,EAAE,IAAI,2BACvB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MACvD,eAAe,KACjB,UAAU,CAAC,GAAG,EAAE,IAAI,CAiBtB,CAAA"}
1
+ {"version":3,"file":"batchQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/batchQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,MAAM,MAAM,UAAU,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAEhE,MAAM,MAAM,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,eAAe,KAAK,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,CAAA;AACnK,eAAO,MAAM,WAAW,GAAI,GAAG,EAAE,MAAM,EAAE,IAAI,kCADqC,eAAe,wGACE,CAAA;AAEnG,eAAO,MAAM,eAAe,GAAI,GAAG,EAAE,MAAM,EAAE,IAAI,2BACvB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MACvD,eAAe,KACjB,UAAU,CAAC,GAAG,EAAE,IAAI,CAiBtB,CAAA"}
@@ -14,4 +14,4 @@ generates:
14
14
  - "typescript-resolvers"
15
15
  hooks:
16
16
  afterAllFileWrite:
17
- - eslint --fix
17
+ - yarn run -T eslint --fix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/engine-tenant-api",
3
- "version": "2.0.0-alpha.14",
3
+ "version": "2.0.0-alpha.16",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/production/index.js",
6
6
  "typings": "./dist/types/index.d.ts",
@@ -23,38 +23,34 @@
23
23
  }
24
24
  },
25
25
  "scripts": {
26
- "generate": "gql-gen --config graphql-tenant.codegen.yml"
26
+ "generate": "gql-gen --config graphql.codegen.yml"
27
27
  },
28
28
  "dependencies": {
29
- "@contember/authorization": "2.0.0-alpha.14",
30
- "@contember/config-loader": "2.0.0-alpha.14",
31
- "@contember/database": "2.0.0-alpha.14",
32
- "@contember/database-migrations": "2.0.0-alpha.14",
33
- "@contember/dic": "2.0.0-alpha.14",
34
- "@contember/graphql-utils": "2.0.0-alpha.14",
35
- "@contember/logger": "2.0.0-alpha.14",
36
- "@contember/schema": "2.0.0-alpha.14",
37
- "@contember/schema-utils": "2.0.0-alpha.14",
38
- "@contember/typesafe": "2.0.0-alpha.14",
39
- "@graphql-tools/utils": "^10.0.8",
29
+ "@contember/authorization": "2.0.0-alpha.16",
30
+ "@contember/config-loader": "2.0.0-alpha.16",
31
+ "@contember/database": "2.0.0-alpha.16",
32
+ "@contember/database-migrations": "2.0.0-alpha.16",
33
+ "@contember/dic": "2.0.0-alpha.16",
34
+ "@contember/graphql-utils": "2.0.0-alpha.16",
35
+ "@contember/logger": "2.0.0-alpha.16",
36
+ "@contember/schema": "2.0.0-alpha.16",
37
+ "@contember/schema-utils": "2.0.0-alpha.16",
38
+ "@contember/typesafe": "2.0.0-alpha.16",
39
+ "@graphql-tools/utils": "^10.5.4",
40
40
  "graphql-tag": "^2.12.6",
41
- "jose": "^5.1.1",
41
+ "jose": "^5.8.0",
42
42
  "mustache": "^4.2.0",
43
- "nodemailer": "^6.9.7",
44
- "openid-client": "^5.6.1",
45
- "otpauth": "^9.1.5"
43
+ "nodemailer": "^6.9.15",
44
+ "openid-client": "^5.7.0",
45
+ "otpauth": "^9.3.2"
46
46
  },
47
47
  "devDependencies": {
48
- "@contember/database-tester": "2.0.0-alpha.14",
49
- "@graphql-codegen/cli": "^5.0.0",
50
- "@graphql-codegen/typescript": "^4.0.1",
51
- "@graphql-codegen/typescript-operations": "^4.0.1",
52
- "@graphql-codegen/typescript-resolvers": "^4.0.1",
53
- "@graphql-tools/schema": "^10.0.0",
48
+ "@contember/database-tester": "2.0.0-alpha.16",
49
+ "@graphql-tools/schema": "^10.0.6",
54
50
  "@types/mustache": "^4.2.5",
55
- "@types/node": "^20.9.0",
56
- "@types/nodemailer": "^6.4.14",
57
- "graphql": "^16.8.1"
51
+ "@types/node": "^20.16.5",
52
+ "@types/nodemailer": "^6.4.15",
53
+ "graphql": "^16.9.0"
58
54
  },
59
55
  "peerDependencies": {
60
56
  "graphql": ">= 14.6.0",
@@ -79,6 +79,12 @@ import { UpdateIDPMutationResolver } from './resolvers/mutation/idp/UpdateIDPMut
79
79
  import { TenantCredentials, TenantMigrationsRunner } from './migrations'
80
80
  import { DisablePersonMutationResolver } from './resolvers/mutation/person/DisablePersonMutationResolver'
81
81
  import { MailTemplateQueryResolver } from './resolvers/query/MailTemplateQueryResolver'
82
+ import { ConfigurationManager } from './model/service/ConfigurationManager'
83
+ import { ConfigurationMutationResolver } from './resolvers/mutation/configuration/ConfigurationMutationResolver'
84
+ import { ConfigurationQueryResolver } from './resolvers/query/ConfigurationQueryResolver'
85
+ import { PasswordlessMutationResolver } from './resolvers/mutation/person/PasswordlessMutationResolver'
86
+ import { PasswordlessSignInManager } from './model/service/PasswordlessSignInManager'
87
+ import { TogglePasswordlessMutationResolver } from './resolvers/mutation/person/TogglePasswordlessMutationResolver'
82
88
 
83
89
  export interface TenantContainer {
84
90
  projectMemberManager: ProjectMemberManager
@@ -201,6 +207,10 @@ export class TenantContainerFactory {
201
207
  new MailTemplateManager())
202
208
  .addService('rolesManager', () =>
203
209
  new RolesManager())
210
+ .addService('configurationManager', () =>
211
+ new ConfigurationManager())
212
+ .addService('passwordlessSignInManager', ({ apiKeyManager, configurationManager, userMailer, projectManager, otpAuthenticator }) =>
213
+ new PasswordlessSignInManager(apiKeyManager, configurationManager, userMailer, projectManager, otpAuthenticator))
204
214
 
205
215
  .addService('identityTypeResolver', ({ projectMemberManager, projectManager, permissionContextFactory }) =>
206
216
  new IdentityTypeResolver(projectMemberManager, projectManager, permissionContextFactory))
@@ -268,6 +278,14 @@ export class TenantContainerFactory {
268
278
  new SetProjectSecretMutationResolver(projectManager, secretManager))
269
279
  .addService('identityGlobalRolesMutationResolver', ({ rolesManager }) =>
270
280
  new IdentityGlobalRolesMutationResolver(rolesManager))
281
+ .addService('configurationMutationResolver', ({ configurationManager }) =>
282
+ new ConfigurationMutationResolver(configurationManager))
283
+ .addService('configurationQueryResolver', ({ configurationManager }) =>
284
+ new ConfigurationQueryResolver(configurationManager))
285
+ .addService('passwordlessMutationResolver', ({ passwordlessSignInManager, signInResponseFactory }) =>
286
+ new PasswordlessMutationResolver(passwordlessSignInManager, signInResponseFactory))
287
+ .addService('togglePasswordlessMutationResolver', ({ configurationManager, personManager }) =>
288
+ new TogglePasswordlessMutationResolver(configurationManager, personManager))
271
289
  .addService('resolverContextFactory', ({ permissionContextFactory }) =>
272
290
  new TenantResolverContextFactory(permissionContextFactory))
273
291
  .addService('resolvers', container =>
@@ -0,0 +1,31 @@
1
+ import { MigrationBuilder } from '@contember/database-migrations'
2
+
3
+ const sql = `
4
+ CREATE TYPE CONFIG_SINGLETON AS ENUM ('singleton');
5
+ CREATE TYPE CONFIG_POLICY AS ENUM ('always', 'never', 'optIn', 'optOut');
6
+ CREATE TABLE "config"
7
+ (
8
+ id CONFIG_SINGLETON PRIMARY KEY DEFAULT 'singleton',
9
+ passwordless_enabled CONFIG_POLICY NOT NULL DEFAULT 'never',
10
+ passwordless_url TEXT,
11
+ passwordless_expiration_minutes INTEGER NOT NULL DEFAULT 5
12
+ );
13
+ INSERT INTO "config" (id)
14
+ VALUES (DEFAULT);
15
+
16
+ ALTER TABLE person_password_reset
17
+ RENAME TO person_token;
18
+ CREATE TYPE PERSON_TOKEN_TYPE AS ENUM ('password_reset', 'passwordless');
19
+ ALTER TABLE person_token
20
+ ADD COLUMN type PERSON_TOKEN_TYPE NOT NULL DEFAULT 'password_reset',
21
+ ADD COLUMN otp_hash TEXT DEFAULT NULL,
22
+ ADD COLUMN otp_attempts INTEGER NOT NULL DEFAULT 0;
23
+
24
+ ALTER TABLE person
25
+ ADD COLUMN passwordless_enabled BOOLEAN DEFAULT NULL;
26
+
27
+ `
28
+
29
+ export default async function (builder: MigrationBuilder) {
30
+ builder.sql(sql)
31
+ }
@@ -37,6 +37,7 @@ import _20230120135500personemailnormalize from './2023-01-20-135500-person-emai
37
37
  import _20230603104000persondisabled from './2023-06-03-104000-person-disabled'
38
38
  import _20230901165000idpreturnconfig from './2023-09-01-165000-idp-return-config'
39
39
  import _20240620140000mailreply from './2024-06-20-140000-mail-reply'
40
+ import _20240826120000passwordless from './2024-08-26-120000-passwordless'
40
41
 
41
42
  import snapshot from './snapshot'
42
43
  import { computeTokenHash, Providers } from '../model'
@@ -87,6 +88,7 @@ const migrations = {
87
88
  '2023-06-03-104000-person-disabled': _20230603104000persondisabled,
88
89
  '2023-09-01-165000-idp-return-config': _20230901165000idpreturnconfig,
89
90
  '2024-06-20-140000-mail-reply': _20240620140000mailreply,
91
+ '2024-08-26-120000-passwordless': _20240826120000passwordless,
90
92
  }
91
93
 
92
94
  export class TenantMigrationsRunner {
@@ -1,3 +1,6 @@
1
+ INSERT INTO "config" (id)
2
+ VALUES (DEFAULT);
3
+
1
4
  DO LANGUAGE plpgsql
2
5
  $$
3
6
  BEGIN
@@ -4,6 +4,19 @@ import { createCredentials } from './tenantCredentials'
4
4
 
5
5
  export default async function (builder: MigrationBuilder, args: TenantMigrationArgs) {
6
6
  builder.sql(`
7
+ CREATE TYPE "config_policy" AS ENUM (
8
+ 'always',
9
+ 'never',
10
+ 'optIn',
11
+ 'optOut'
12
+ );
13
+ CREATE TYPE "config_singleton" AS ENUM (
14
+ 'singleton'
15
+ );
16
+ CREATE TYPE "person_token_type" AS ENUM (
17
+ 'password_reset',
18
+ 'passwordless'
19
+ );
7
20
  CREATE FUNCTION "project_deleted"() RETURNS "trigger"
8
21
  LANGUAGE "plpgsql"
9
22
  AS $$
@@ -40,6 +53,12 @@ CREATE TABLE "api_key" (
40
53
  "expiration" integer,
41
54
  "disabled_at" timestamp with time zone
42
55
  );
56
+ CREATE TABLE "config" (
57
+ "id" "config_singleton" DEFAULT 'singleton'::"config_singleton" NOT NULL,
58
+ "passwordless_enabled" "config_policy" DEFAULT 'never'::"config_policy" NOT NULL,
59
+ "passwordless_url" "text",
60
+ "passwordless_expiration_minutes" integer DEFAULT 5 NOT NULL
61
+ );
43
62
  CREATE TABLE "identity" (
44
63
  "id" "uuid" NOT NULL,
45
64
  "parent_id" "uuid",
@@ -77,6 +96,7 @@ CREATE TABLE "person" (
77
96
  "name" "text",
78
97
  "idp_only" boolean DEFAULT false NOT NULL,
79
98
  "disabled_at" timestamp with time zone,
99
+ "passwordless_enabled" boolean,
80
100
  CONSTRAINT "idp_only_no_email" CHECK ((("idp_only" = false) OR (("idp_only" = true) AND ("email" IS NULL))))
81
101
  );
82
102
  CREATE TABLE "person_identity_provider" (
@@ -86,13 +106,16 @@ CREATE TABLE "person_identity_provider" (
86
106
  "created_at" timestamp with time zone DEFAULT "now"() NOT NULL,
87
107
  "external_identifier" "text" NOT NULL
88
108
  );
89
- CREATE TABLE "person_password_reset" (
109
+ CREATE TABLE "person_token" (
90
110
  "id" "uuid" NOT NULL,
91
111
  "token_hash" "text" NOT NULL,
92
112
  "person_id" "uuid" NOT NULL,
93
113
  "expires_at" timestamp with time zone NOT NULL,
94
114
  "created_at" timestamp with time zone NOT NULL,
95
- "used_at" timestamp with time zone
115
+ "used_at" timestamp with time zone,
116
+ "type" "person_token_type" DEFAULT 'password_reset'::"person_token_type" NOT NULL,
117
+ "otp_hash" "text",
118
+ "otp_attempts" integer DEFAULT 0 NOT NULL
96
119
  );
97
120
  CREATE TABLE "project" (
98
121
  "id" "uuid" NOT NULL,
@@ -124,6 +147,8 @@ CREATE TABLE "project_secret" (
124
147
  );
125
148
  ALTER TABLE ONLY "api_key"
126
149
  ADD CONSTRAINT "api_key_id" PRIMARY KEY ("id");
150
+ ALTER TABLE ONLY "config"
151
+ ADD CONSTRAINT "config_pkey" PRIMARY KEY ("id");
127
152
  ALTER TABLE ONLY "person"
128
153
  ADD CONSTRAINT "email_unique" UNIQUE ("email");
129
154
  ALTER TABLE ONLY "identity"
@@ -140,7 +165,7 @@ ALTER TABLE ONLY "person"
140
165
  ADD CONSTRAINT "person_identity_id_key" UNIQUE ("identity_id");
141
166
  ALTER TABLE ONLY "person_identity_provider"
142
167
  ADD CONSTRAINT "person_identity_provider_pkey" PRIMARY KEY ("id");
143
- ALTER TABLE ONLY "person_password_reset"
168
+ ALTER TABLE ONLY "person_token"
144
169
  ADD CONSTRAINT "person_password_reset_id" PRIMARY KEY ("id");
145
170
  ALTER TABLE ONLY "project"
146
171
  ADD CONSTRAINT "project_id" PRIMARY KEY ("id");
@@ -161,7 +186,7 @@ CREATE INDEX "mail_template_project_index" ON "mail_template" USING "btree" ("pr
161
186
  CREATE INDEX "person_identity_id" ON "person" USING "btree" ("identity_id");
162
187
  CREATE UNIQUE INDEX "person_identity_provider_identifier" ON "person_identity_provider" USING "btree" ("identity_provider_id", "external_identifier");
163
188
  CREATE INDEX "person_identity_provider_person_id" ON "person_identity_provider" USING "btree" ("person_id");
164
- CREATE UNIQUE INDEX "person_password_reset_token" ON "person_password_reset" USING "btree" ("token_hash");
189
+ CREATE UNIQUE INDEX "person_password_reset_token" ON "person_token" USING "btree" ("token_hash");
165
190
  CREATE INDEX "project_alias" ON "project" USING "gin" ((("config" -> 'alias'::"text")));
166
191
  CREATE INDEX "project_membership_identity_index" ON "project_membership" USING "btree" ("identity_id");
167
192
  CREATE UNIQUE INDEX "project_membership_unique" ON "project_membership" USING "btree" ("project_id", "identity_id", "role");
@@ -183,7 +208,7 @@ ALTER TABLE ONLY "person_identity_provider"
183
208
  ADD CONSTRAINT "person_identity_provider_idp" FOREIGN KEY ("identity_provider_id") REFERENCES "identity_provider"("id") ON DELETE CASCADE;
184
209
  ALTER TABLE ONLY "person_identity_provider"
185
210
  ADD CONSTRAINT "person_identity_provider_person" FOREIGN KEY ("person_id") REFERENCES "person"("id") ON DELETE CASCADE;
186
- ALTER TABLE ONLY "person_password_reset"
211
+ ALTER TABLE ONLY "person_token"
187
212
  ADD CONSTRAINT "person_password_reset_person" FOREIGN KEY ("person_id") REFERENCES "person"("id") ON DELETE CASCADE;
188
213
  ALTER TABLE ONLY "project_membership"
189
214
  ADD CONSTRAINT "project_membership_identity" FOREIGN KEY ("identity_id") REFERENCES "identity"("id") ON DELETE CASCADE;
@@ -193,6 +218,9 @@ ALTER TABLE ONLY "project_membership_variable"
193
218
  ADD CONSTRAINT "project_membership_variable_membership" FOREIGN KEY ("membership_id") REFERENCES "project_membership"("id") ON DELETE CASCADE;
194
219
  ALTER TABLE ONLY "project_secret"
195
220
  ADD CONSTRAINT "project_secret_project" FOREIGN KEY ("project_id") REFERENCES "project"("id") ON DELETE CASCADE;
221
+ INSERT INTO "config" (id)
222
+ VALUES (DEFAULT);
223
+
196
224
  DO LANGUAGE plpgsql
197
225
  $$
198
226
  BEGIN
@@ -13,6 +13,10 @@ namespace PermissionActions {
13
13
  idp = 'idp',
14
14
  }
15
15
 
16
+
17
+ export const CONFIGURE = Authorizator.createAction(Resources.system, 'configure')
18
+ export const CONFIG_VIEW = Authorizator.createAction(Resources.system, 'viewConfig')
19
+
16
20
  export const IDENTITY_VIEW_PERMISSIONS = Authorizator.createAction(Resources.identity, 'viewPermissions')
17
21
  export const IDENTITY_ADD_GLOBAL_ROLES = (roles?: readonly string[]) => Authorizator.createAction(Resources.identity, 'addGlobalRoles', { roles })
18
22
  export const IDENTITY_REMOVE_GLOBAL_ROLES = (roles?: readonly string[]) => Authorizator.createAction(Resources.identity, 'removeGlobalRoles', { roles })
@@ -26,11 +30,14 @@ namespace PermissionActions {
26
30
  export const PERSON_SETUP_OTP = Authorizator.createAction(Resources.person, 'setupOtp')
27
31
  export const PERSON_CHANGE_PROFILE = (roles?: readonly string[]) => Authorizator.createAction(Resources.person, 'changeProfile', { roles })
28
32
  export const PERSON_CHANGE_MY_PROFILE = Authorizator.createAction(Resources.person, 'changeMyProfile')
33
+ export const PERSON_TOGGLE_PASSWORDLESS = Authorizator.createAction(Resources.person, 'togglePasswordless')
29
34
  export const PERSON_CHANGE_PASSWORD = (roles?: readonly string[]) => Authorizator.createAction(Resources.person, 'changePassword', { roles })
30
35
  export const PERSON_CHANGE_MY_PASSWORD = Authorizator.createAction(Resources.person, 'changeMyPassword')
31
36
  export const PERSON_RESET_PASSWORD = Authorizator.createAction(Resources.person, 'resetPassword')
32
37
  export const PERSON_CREATE_IDP_URL = Authorizator.createAction(Resources.person, 'createIdPUrl')
33
38
  export const PERSON_SIGN_IN_IDP = Authorizator.createAction(Resources.person, 'signInIdp')
39
+ export const PERSON_REQUEST_PASSWORDLESS_SIGN_IN = Authorizator.createAction(Resources.person, 'requestPasswordlessSignIn')
40
+ export const PERSON_PASSWORDLESS_SIGN_IN = Authorizator.createAction(Resources.person, 'passwordlessSignIn')
34
41
  export const PERSON_CREATE_SESSION_KEY = (roles?: readonly string[]) => Authorizator.createAction(Resources.person, 'createSessionToken', { roles })
35
42
 
36
43
  export const PERSON_INVITE = (memberships: readonly Acl.Membership[]) => Authorizator.createAction(Resources.person, 'invite', { memberships })
@@ -24,10 +24,13 @@ class PermissionsFactory {
24
24
  permissions.allow(TenantRole.LOGIN, PermissionActions.PERSON_RESET_PASSWORD)
25
25
  permissions.allow(TenantRole.LOGIN, PermissionActions.PERSON_CREATE_IDP_URL)
26
26
  permissions.allow(TenantRole.LOGIN, PermissionActions.PERSON_SIGN_IN_IDP)
27
+ permissions.allow(TenantRole.LOGIN, PermissionActions.PERSON_PASSWORDLESS_SIGN_IN)
28
+ permissions.allow(TenantRole.LOGIN, PermissionActions.PERSON_REQUEST_PASSWORDLESS_SIGN_IN)
27
29
 
28
30
  permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_VIEW)
29
31
  permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_CHANGE_MY_PASSWORD)
30
32
  permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_CHANGE_MY_PROFILE)
33
+ permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_TOGGLE_PASSWORDLESS)
31
34
  permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_SIGN_OUT)
32
35
  permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_SETUP_OTP)
33
36
 
@@ -65,6 +68,8 @@ class PermissionsFactory {
65
68
  permissions.allow(TenantRole.PROJECT_ADMIN, PermissionActions.IDP_LIST)
66
69
 
67
70
  permissions.allow(TenantRole.PROJECT_ADMIN, PermissionActions.ENTRYPOINT_DEPLOY)
71
+ permissions.allow(TenantRole.PROJECT_ADMIN, PermissionActions.CONFIGURE)
72
+ permissions.allow(TenantRole.PROJECT_ADMIN, PermissionActions.CONFIG_VIEW)
68
73
 
69
74
  permissions.allow(TenantRole.PROJECT_CREATOR, PermissionActions.PROJECT_CREATE)
70
75
  permissions.allow(TenantRole.ENTRYPOINT_DEPLOYER, PermissionActions.ENTRYPOINT_DEPLOY)
@@ -0,0 +1,26 @@
1
+ import { Command } from '../Command'
2
+ import { ConfigInput } from '../../../schema'
3
+ import { UpdateBuilder } from '@contember/database'
4
+
5
+ export class UpdateConfigurationCommand implements Command<void> {
6
+ constructor(
7
+ private readonly configuration: ConfigInput,
8
+ ) {
9
+ }
10
+
11
+ async execute({ db }: Command.Args): Promise<void> {
12
+ const result = await UpdateBuilder.create()
13
+ .table('config')
14
+ .where({ id: 'singleton' })
15
+ .values({
16
+ passwordless_enabled: this.configuration.passwordless?.enabled,
17
+ passwordless_url: this.configuration.passwordless?.url,
18
+ passwordless_expiration_minutes: this.configuration.passwordless?.expirationMinutes,
19
+ })
20
+ .execute(db)
21
+ if (!result) {
22
+ throw new Error('Configuration not found')
23
+ }
24
+ }
25
+
26
+ }
@@ -0,0 +1 @@
1
+ export * from './UpdateConfigurationCommand'
@@ -1,5 +1,5 @@
1
1
  export * from './apiKey'
2
- export * from './apiKey'
2
+ export * from './configuration'
3
3
  export * from './person'
4
4
  export * from './Command'
5
5
  export * from './CommandBus'
@@ -8,4 +8,4 @@ export * from './project'
8
8
  export * from './mailTemplate'
9
9
  export * from './membership'
10
10
  export * from './otp'
11
- export * from './passwordReset'
11
+ export * from './personToken'
@@ -40,6 +40,7 @@ export class CreatePersonCommand implements Command<Omit<PersonRow, 'roles'>> {
40
40
  otp_uri: null,
41
41
  otp_activated_at: null,
42
42
  disabled_at: null,
43
+ passwordless_enabled: null,
43
44
  }
44
45
  }
45
46
  }
@@ -0,0 +1,18 @@
1
+ import { Command } from '../Command'
2
+ import { UpdateBuilder } from '@contember/database'
3
+
4
+ export class TogglePersonPasswordlessCommand implements Command<void> {
5
+ constructor(private readonly personId: string, private readonly value: boolean | null) { }
6
+
7
+ async execute({ db }: Command.Args): Promise<void> {
8
+ await UpdateBuilder.create()
9
+ .table('person')
10
+ .values({
11
+ passwordless_enabled: this.value,
12
+ })
13
+ .where({
14
+ id: this.personId,
15
+ })
16
+ .execute(db)
17
+ }
18
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './ChangePasswordCommand'
2
2
  export * from './CreatePersonCommand'
3
3
  export * from './CreatePersonIdentityProviderIdentifierCommand'
4
+ export * from './TogglePersonPasswordlessCommand'
@@ -0,0 +1,24 @@
1
+ import { Command } from '../Command'
2
+ import { UpdateBuilder } from '@contember/database'
3
+ import { ImplementationException } from '../../../exceptions'
4
+
5
+ export class ActivateOtpCommand implements Command<void> {
6
+ constructor(
7
+ private readonly id: string,
8
+ private readonly otpHash: string,
9
+ ) {}
10
+
11
+ async execute({ db, providers }: Command.Args): Promise<void> {
12
+ const count = await UpdateBuilder.create()
13
+ .table('person_token')
14
+ .where({ id: this.id })
15
+ .values({
16
+ otp_hash: this.otpHash,
17
+ })
18
+ .execute(db)
19
+
20
+ if (count === 0) {
21
+ throw new ImplementationException()
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,42 @@
1
+ import { Command } from '../Command'
2
+ import { computeTokenHash, generateToken } from '../../utils'
3
+ import { SavePersonTokenCommand } from './SavePersonTokenCommand'
4
+ import { PersonToken } from '../../type'
5
+ import { PASSWORD_RESET_EXPIRATION_MINUTES } from '../../consts/expirations'
6
+
7
+ export class CreatePersonTokenCommand implements Command<CreatePersonTokenCommand.Result> {
8
+ private constructor(
9
+ private readonly personId: string,
10
+ private readonly type: PersonToken.Type,
11
+ private readonly expirationMinutes: number,
12
+ ) {}
13
+
14
+ static createPasswordResetRequest(personId: string, expirationMinutes: number = PASSWORD_RESET_EXPIRATION_MINUTES): CreatePersonTokenCommand {
15
+ return new CreatePersonTokenCommand(personId, 'password_reset', expirationMinutes)
16
+ }
17
+
18
+ static createPasswordlessRequest(personId: string, expirationMinutes: number): CreatePersonTokenCommand {
19
+ return new CreatePersonTokenCommand(personId, 'passwordless', expirationMinutes)
20
+ }
21
+
22
+ async execute({ db, providers, bus }: Command.Args): Promise<CreatePersonTokenCommand.Result> {
23
+ const token = await generateToken(providers)
24
+ const tokenHash = computeTokenHash(token)
25
+ const result = await bus.execute(new SavePersonTokenCommand(
26
+ this.personId,
27
+ tokenHash,
28
+ this.type,
29
+ this.expirationMinutes,
30
+ ))
31
+
32
+ return { ...result, token }
33
+ }
34
+ }
35
+
36
+ namespace CreatePersonTokenCommand {
37
+ export interface Result {
38
+ readonly id: string
39
+ readonly token: string
40
+ readonly expiresAt: Date
41
+ }
42
+ }
@@ -0,0 +1,23 @@
1
+ import { Command } from '../Command'
2
+ import { Literal, UpdateBuilder } from '@contember/database'
3
+ import { ImplementationException } from '../../../exceptions'
4
+
5
+ export class IncreaseOtpAttemptCommand implements Command<void> {
6
+ constructor(
7
+ private readonly id: string,
8
+ ) {}
9
+
10
+ async execute({ db, providers }: Command.Args): Promise<void> {
11
+ const count = await UpdateBuilder.create()
12
+ .table('person_token')
13
+ .where({ id: this.id })
14
+ .values({
15
+ otp_attempts: new Literal('otp_attempts + 1'),
16
+ })
17
+ .execute(db)
18
+
19
+ if (count === 0) {
20
+ throw new ImplementationException()
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,22 @@
1
+ import { Command } from '../Command'
2
+ import { UpdateBuilder } from '@contember/database'
3
+ import { ImplementationException } from '../../../exceptions'
4
+
5
+ export class InvalidateTokenCommand implements Command<void> {
6
+ constructor(private readonly id: string) {}
7
+
8
+ async execute({ db, providers }: Command.Args): Promise<void> {
9
+ const count = await UpdateBuilder.create()
10
+ .table('person_token')
11
+ .where({ id: this.id })
12
+ .where(expr => expr.isNull('used_at'))
13
+ .values({
14
+ used_at: providers.now(),
15
+ })
16
+ .execute(db)
17
+
18
+ if (count === 0) {
19
+ throw new ImplementationException()
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,28 @@
1
+ import { Command } from '../Command'
2
+ import { ChangePasswordCommand } from '../person/ChangePasswordCommand'
3
+ import { Response, ResponseOk } from '../../utils/Response'
4
+ import { PersonTokenQuery } from '../../queries/personToken/PersonTokenQuery'
5
+ import { InvalidateTokenCommand } from './InvalidateTokenCommand'
6
+ import { validateToken } from '../../utils'
7
+ import { PersonToken } from '../../type'
8
+
9
+ export class ResetPasswordCommand implements Command<ResetPasswordCommandResponse> {
10
+ constructor(private readonly token: string, private readonly password: string) {}
11
+
12
+ async execute({ db, providers, bus }: Command.Args): Promise<ResetPasswordCommandResponse> {
13
+ const now = providers.now()
14
+ const token = await db.createQueryHandler().fetch(PersonTokenQuery.byToken(this.token, 'password_reset'))
15
+ const tokenValidationResult = validateToken({ entry: token, token: this.token, now, validationType: 'token' })
16
+ if (!tokenValidationResult.ok) {
17
+ return tokenValidationResult
18
+ }
19
+ await bus.execute(new InvalidateTokenCommand(tokenValidationResult.result.id))
20
+ await bus.execute(new ChangePasswordCommand(tokenValidationResult.result.person_id, this.password))
21
+
22
+ return new ResponseOk(null)
23
+ }
24
+ }
25
+ export type ResetPasswordCommandErrorCode =
26
+ | PersonToken.TokenValidationError
27
+
28
+ export type ResetPasswordCommandResponse = Response<null, PersonToken.TokenValidationError>
@@ -0,0 +1,42 @@
1
+ import { Command } from '../Command'
2
+ import { InsertBuilder } from '@contember/database'
3
+ import { plusMinutes } from '../../utils/time'
4
+ import { TokenHash } from '../../utils'
5
+ import { PersonToken } from '../../type'
6
+
7
+ class SavePersonTokenCommand implements Command<SavePersonTokenCommand.Result> {
8
+ constructor(
9
+ private readonly personId: string,
10
+ private readonly tokenHash: TokenHash,
11
+ private readonly type: PersonToken.Type,
12
+ private readonly expirationMinutes: number,
13
+ ) {}
14
+
15
+ async execute({ db, providers }: Command.Args): Promise<SavePersonTokenCommand.Result> {
16
+ const id = providers.uuid()
17
+ const expiresAt = plusMinutes(providers.now(), this.expirationMinutes)
18
+ await InsertBuilder.create()
19
+ .into('person_token')
20
+ .values({
21
+ id: id,
22
+ token_hash: this.tokenHash,
23
+ person_id: this.personId,
24
+ expires_at: expiresAt,
25
+ created_at: providers.now(),
26
+ used_at: null,
27
+ type: this.type,
28
+ })
29
+ .execute(db)
30
+
31
+ return { id, expiresAt }
32
+ }
33
+ }
34
+
35
+ namespace SavePersonTokenCommand {
36
+ export interface Result {
37
+ id: string
38
+ expiresAt: Date
39
+ }
40
+ }
41
+
42
+ export { SavePersonTokenCommand }
@@ -0,0 +1,6 @@
1
+ export * from './ActivateOtpCommand'
2
+ export * from './CreatePersonTokenCommand'
3
+ export * from './InvalidateTokenCommand'
4
+ export * from './IncreaseOtpAttemptCommand'
5
+ export * from './ResetPasswordCommand'
6
+ export * from './SavePersonTokenCommand'
@@ -0,0 +1,2 @@
1
+ export const PASSWORD_RESET_EXPIRATION_MINUTES = 60
2
+ export const INVITATION_RESET_TOKEN_EXPIRATION_MINUTES = 60 * 24
@@ -2,6 +2,7 @@ import { Mailer, TemplateRenderer } from '../../utils'
2
2
  import NewUserInvited from './templates/NewUserInvited.mustache'
3
3
  import ExistingUserInvited from './templates/ExistingUserInvited.mustache'
4
4
  import PasswordReset from './templates/PasswordReset.mustache'
5
+ import PasswordlessSignIn from './templates/PasswordlessSignIn.mustache'
5
6
  import { MailTemplateData, MailTemplateIdentifier, MailType } from './type'
6
7
  import { MailTemplateQuery } from '../queries'
7
8
  import Layout from './templates/Layout.mustache'
@@ -52,6 +53,19 @@ export class UserMailer {
52
53
  await this.sendTemplate(template, mailArguments)
53
54
  }
54
55
 
56
+ async sendPasswordlessEmail(
57
+ dbContext: DatabaseContext,
58
+ mailArguments: { email: string; token: string; project?: string; projectSlug?: string; url?: string },
59
+ customMailOptions: { projectId: string | null; variant: string },
60
+ ): Promise<void> {
61
+ const template = (await this.getCustomTemplate(dbContext, { type: MailType.passwordlessSignIn, ...customMailOptions })) || {
62
+ subject: 'Sign in here',
63
+ content: PasswordlessSignIn,
64
+ replyTo: null,
65
+ }
66
+ await this.sendTemplate(template, mailArguments)
67
+ }
68
+
55
69
  private async sendTemplate(
56
70
  template: Pick<MailTemplateData, 'subject' | 'content' | 'replyTo'>,
57
71
  mailArguments: Record<string, any>,