@contember/engine-tenant-api 2.1.0-alpha.2 → 2.1.0-alpha.20

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 (759) hide show
  1. package/dist/development/index.cjs +5 -6
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +2 -3
  4. package/dist/development/src/TenantContainer.cjs +4 -2
  5. package/dist/development/src/TenantContainer.cjs.map +1 -1
  6. package/dist/development/src/TenantContainer.js +4 -2
  7. package/dist/development/src/TenantContainer.js.map +1 -1
  8. package/dist/development/src/bridges/system/IdentityFetcher.cjs +1 -0
  9. package/dist/development/src/bridges/system/IdentityFetcher.cjs.map +1 -1
  10. package/dist/development/src/bridges/system/IdentityFetcher.js +1 -0
  11. package/dist/development/src/bridges/system/IdentityFetcher.js.map +1 -1
  12. package/dist/development/src/migrations/2025-04-16-180000-config-up.cjs +39 -0
  13. package/dist/development/src/migrations/2025-04-16-180000-config-up.cjs.map +1 -0
  14. package/dist/development/src/migrations/2025-04-16-180000-config-up.js +40 -0
  15. package/dist/development/src/migrations/2025-04-16-180000-config-up.js.map +1 -0
  16. package/dist/development/src/migrations/2025-04-17-160000-auth-log.cjs +45 -0
  17. package/dist/development/src/migrations/2025-04-17-160000-auth-log.cjs.map +1 -0
  18. package/dist/development/src/migrations/2025-04-17-160000-auth-log.js +46 -0
  19. package/dist/development/src/migrations/2025-04-17-160000-auth-log.js.map +1 -0
  20. package/dist/development/src/migrations/runner.cjs +9 -4
  21. package/dist/development/src/migrations/runner.cjs.map +1 -1
  22. package/dist/development/src/migrations/runner.js +7 -2
  23. package/dist/development/src/migrations/runner.js.map +1 -1
  24. package/dist/development/src/migrations/snapshot.cjs +56 -1
  25. package/dist/development/src/migrations/snapshot.cjs.map +1 -1
  26. package/dist/development/src/migrations/snapshot.js +56 -1
  27. package/dist/development/src/migrations/snapshot.js.map +1 -1
  28. package/dist/development/src/model/authorization/MembershipMatcher.cjs +6 -0
  29. package/dist/development/src/model/authorization/MembershipMatcher.cjs.map +1 -1
  30. package/dist/development/src/model/authorization/MembershipMatcher.js +6 -0
  31. package/dist/development/src/model/authorization/MembershipMatcher.js.map +1 -1
  32. package/dist/development/src/model/commands/apiKey/CreateApiKeyCommand.cjs +7 -7
  33. package/dist/development/src/model/commands/apiKey/CreateApiKeyCommand.cjs.map +1 -1
  34. package/dist/development/src/model/commands/apiKey/CreateApiKeyCommand.js +1 -1
  35. package/dist/development/src/model/commands/authLog/CreateAuthLogEntryCommand.cjs +27 -0
  36. package/dist/development/src/model/commands/authLog/CreateAuthLogEntryCommand.cjs.map +1 -0
  37. package/dist/development/src/model/commands/authLog/CreateAuthLogEntryCommand.js +27 -0
  38. package/dist/development/src/model/commands/authLog/CreateAuthLogEntryCommand.js.map +1 -0
  39. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.cjs +15 -2
  40. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.cjs.map +1 -1
  41. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.js +15 -2
  42. package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.js.map +1 -1
  43. package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.cjs +4 -4
  44. package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.cjs.map +1 -1
  45. package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.js +1 -1
  46. package/dist/development/src/model/commands/personToken/ResetPasswordCommand.cjs +5 -5
  47. package/dist/development/src/model/commands/personToken/ResetPasswordCommand.cjs.map +1 -1
  48. package/dist/development/src/model/commands/personToken/ResetPasswordCommand.js +1 -1
  49. package/dist/development/src/model/queries/apiKey/ApiKeyQuery.cjs +4 -4
  50. package/dist/development/src/model/queries/apiKey/ApiKeyQuery.cjs.map +1 -1
  51. package/dist/development/src/model/queries/apiKey/ApiKeyQuery.js +1 -1
  52. package/dist/development/src/model/queries/authLog/NextLoginAttemptQuery.cjs +46 -0
  53. package/dist/development/src/model/queries/authLog/NextLoginAttemptQuery.cjs.map +1 -0
  54. package/dist/development/src/model/queries/authLog/NextLoginAttemptQuery.js +46 -0
  55. package/dist/development/src/model/queries/authLog/NextLoginAttemptQuery.js.map +1 -0
  56. package/dist/development/src/model/queries/configuration/ConfigurationQuery.cjs +18 -1
  57. package/dist/development/src/model/queries/configuration/ConfigurationQuery.cjs.map +1 -1
  58. package/dist/development/src/model/queries/configuration/ConfigurationQuery.js +18 -1
  59. package/dist/development/src/model/queries/configuration/ConfigurationQuery.js.map +1 -1
  60. package/dist/development/src/model/queries/personToken/PersonTokenQuery.cjs +3 -3
  61. package/dist/development/src/model/queries/personToken/PersonTokenQuery.cjs.map +1 -1
  62. package/dist/development/src/model/queries/personToken/PersonTokenQuery.js +1 -1
  63. package/dist/development/src/model/service/AuthLogService.cjs +34 -0
  64. package/dist/development/src/model/service/AuthLogService.cjs.map +1 -0
  65. package/dist/development/src/model/service/AuthLogService.js +34 -0
  66. package/dist/development/src/model/service/AuthLogService.js.map +1 -0
  67. package/dist/development/src/model/service/ConfigurationManager.cjs +0 -10
  68. package/dist/development/src/model/service/ConfigurationManager.cjs.map +1 -1
  69. package/dist/development/src/model/service/ConfigurationManager.js +0 -10
  70. package/dist/development/src/model/service/ConfigurationManager.js.map +1 -1
  71. package/dist/development/src/model/service/IDPSignInManager.cjs +37 -5
  72. package/dist/development/src/model/service/IDPSignInManager.cjs.map +1 -1
  73. package/dist/development/src/model/service/IDPSignInManager.js +37 -5
  74. package/dist/development/src/model/service/IDPSignInManager.js.map +1 -1
  75. package/dist/development/src/model/service/MembershipValidator.cjs +1 -1
  76. package/dist/development/src/model/service/MembershipValidator.cjs.map +1 -1
  77. package/dist/development/src/model/service/MembershipValidator.js +1 -1
  78. package/dist/development/src/model/service/MembershipValidator.js.map +1 -1
  79. package/dist/development/src/model/service/PasswordChangeManager.cjs +21 -12
  80. package/dist/development/src/model/service/PasswordChangeManager.cjs.map +1 -1
  81. package/dist/development/src/model/service/PasswordChangeManager.js +20 -11
  82. package/dist/development/src/model/service/PasswordChangeManager.js.map +1 -1
  83. package/dist/development/src/model/service/PasswordResetManager.cjs +40 -8
  84. package/dist/development/src/model/service/PasswordResetManager.cjs.map +1 -1
  85. package/dist/development/src/model/service/PasswordResetManager.js +40 -8
  86. package/dist/development/src/model/service/PasswordResetManager.js.map +1 -1
  87. package/dist/development/src/model/service/PasswordStrengthValidator.cjs +63 -0
  88. package/dist/development/src/model/service/PasswordStrengthValidator.cjs.map +1 -0
  89. package/dist/development/src/model/service/PasswordStrengthValidator.js +63 -0
  90. package/dist/development/src/model/service/PasswordStrengthValidator.js.map +1 -0
  91. package/dist/development/src/model/service/PasswordlessSignInManager.cjs +89 -24
  92. package/dist/development/src/model/service/PasswordlessSignInManager.cjs.map +1 -1
  93. package/dist/development/src/model/service/PasswordlessSignInManager.js +81 -16
  94. package/dist/development/src/model/service/PasswordlessSignInManager.js.map +1 -1
  95. package/dist/development/src/model/service/PersonAccessManager.cjs +7 -29
  96. package/dist/development/src/model/service/PersonAccessManager.cjs.map +1 -1
  97. package/dist/development/src/model/service/PersonAccessManager.js +7 -29
  98. package/dist/development/src/model/service/PersonAccessManager.js.map +1 -1
  99. package/dist/development/src/model/service/SignInManager.cjs +56 -31
  100. package/dist/development/src/model/service/SignInManager.cjs.map +1 -1
  101. package/dist/development/src/model/service/SignInManager.js +57 -32
  102. package/dist/development/src/model/service/SignInManager.js.map +1 -1
  103. package/dist/development/src/model/service/SignUpManager.cjs +13 -8
  104. package/dist/development/src/model/service/SignUpManager.cjs.map +1 -1
  105. package/dist/development/src/model/service/SignUpManager.js +11 -6
  106. package/dist/development/src/model/service/SignUpManager.js.map +1 -1
  107. package/dist/development/src/model/service/apiKey/ApiKeyManager.cjs +6 -1
  108. package/dist/development/src/model/service/apiKey/ApiKeyManager.cjs.map +1 -1
  109. package/dist/development/src/model/service/apiKey/ApiKeyManager.js +6 -1
  110. package/dist/development/src/model/service/apiKey/ApiKeyManager.js.map +1 -1
  111. package/dist/development/src/model/utils/Response.cjs +2 -1
  112. package/dist/development/src/model/utils/Response.cjs.map +1 -1
  113. package/dist/development/src/model/utils/Response.js +2 -1
  114. package/dist/development/src/model/utils/Response.js.map +1 -1
  115. package/dist/development/src/model/utils/blacklist.cjs +10006 -0
  116. package/dist/development/src/model/utils/blacklist.cjs.map +1 -0
  117. package/dist/development/src/model/utils/blacklist.js +10006 -0
  118. package/dist/development/src/model/utils/blacklist.js.map +1 -0
  119. package/dist/{production/src/model/utils/typeUtils.cjs → development/src/model/utils/hex.cjs} +1 -1
  120. package/dist/development/src/model/utils/hex.cjs.map +1 -0
  121. package/dist/development/src/model/utils/{typeUtils.js → hex.js} +1 -1
  122. package/dist/development/src/model/utils/hex.js.map +1 -0
  123. package/dist/development/src/model/utils/interval.cjs +8 -0
  124. package/dist/development/src/model/utils/interval.cjs.map +1 -0
  125. package/dist/development/src/model/utils/interval.js +8 -0
  126. package/dist/development/src/model/utils/interval.js.map +1 -0
  127. package/dist/development/src/model/utils/{tokenUtils.cjs → token.cjs} +3 -3
  128. package/dist/development/src/model/utils/token.cjs.map +1 -0
  129. package/dist/development/src/model/utils/{tokenUtils.js → token.js} +2 -2
  130. package/dist/development/src/model/utils/token.js.map +1 -0
  131. package/dist/development/src/resolvers/ResolverFactory.cjs +1 -0
  132. package/dist/development/src/resolvers/ResolverFactory.cjs.map +1 -1
  133. package/dist/development/src/resolvers/ResolverFactory.js +2 -1
  134. package/dist/development/src/resolvers/ResolverFactory.js.map +1 -1
  135. package/dist/development/src/resolvers/TenantResolverContextFactory.cjs +10 -2
  136. package/dist/development/src/resolvers/TenantResolverContextFactory.cjs.map +1 -1
  137. package/dist/development/src/resolvers/TenantResolverContextFactory.js +10 -2
  138. package/dist/development/src/resolvers/TenantResolverContextFactory.js.map +1 -1
  139. package/dist/development/src/resolvers/errorUtils.cjs +15 -4
  140. package/dist/development/src/resolvers/errorUtils.cjs.map +1 -1
  141. package/dist/development/src/resolvers/errorUtils.js +15 -4
  142. package/dist/development/src/resolvers/errorUtils.js.map +1 -1
  143. package/dist/development/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.cjs +4 -3
  144. package/dist/development/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.cjs.map +1 -1
  145. package/dist/development/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.js +2 -1
  146. package/dist/development/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.js.map +1 -1
  147. package/dist/development/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.cjs +1 -0
  148. package/dist/development/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.cjs.map +1 -1
  149. package/dist/development/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.js +1 -0
  150. package/dist/development/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.js.map +1 -1
  151. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs +1 -0
  152. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs.map +1 -1
  153. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js +1 -0
  154. package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js.map +1 -1
  155. package/dist/development/src/resolvers/mutation/identity/GlobalRolesMutationResolver.cjs +1 -0
  156. package/dist/development/src/resolvers/mutation/identity/GlobalRolesMutationResolver.cjs.map +1 -1
  157. package/dist/development/src/resolvers/mutation/identity/GlobalRolesMutationResolver.js +1 -0
  158. package/dist/development/src/resolvers/mutation/identity/GlobalRolesMutationResolver.js.map +1 -1
  159. package/dist/development/src/resolvers/mutation/idp/AddIDPMutationResolver.cjs +1 -0
  160. package/dist/development/src/resolvers/mutation/idp/AddIDPMutationResolver.cjs.map +1 -1
  161. package/dist/development/src/resolvers/mutation/idp/AddIDPMutationResolver.js +1 -0
  162. package/dist/development/src/resolvers/mutation/idp/AddIDPMutationResolver.js.map +1 -1
  163. package/dist/development/src/resolvers/mutation/idp/DisableIDPMutationResolver.cjs +1 -0
  164. package/dist/development/src/resolvers/mutation/idp/DisableIDPMutationResolver.cjs.map +1 -1
  165. package/dist/development/src/resolvers/mutation/idp/DisableIDPMutationResolver.js +1 -0
  166. package/dist/development/src/resolvers/mutation/idp/DisableIDPMutationResolver.js.map +1 -1
  167. package/dist/development/src/resolvers/mutation/idp/EnableIDPMutationResolver.cjs +1 -0
  168. package/dist/development/src/resolvers/mutation/idp/EnableIDPMutationResolver.cjs.map +1 -1
  169. package/dist/development/src/resolvers/mutation/idp/EnableIDPMutationResolver.js +1 -0
  170. package/dist/development/src/resolvers/mutation/idp/EnableIDPMutationResolver.js.map +1 -1
  171. package/dist/development/src/resolvers/mutation/idp/UpdateIDPMutationResolver.cjs +1 -0
  172. package/dist/development/src/resolvers/mutation/idp/UpdateIDPMutationResolver.cjs.map +1 -1
  173. package/dist/development/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js +1 -0
  174. package/dist/development/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js.map +1 -1
  175. package/dist/development/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.cjs +1 -0
  176. package/dist/development/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.cjs.map +1 -1
  177. package/dist/development/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.js +1 -0
  178. package/dist/development/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.js.map +1 -1
  179. package/dist/development/src/resolvers/mutation/person/ChangePasswordMutationResolver.cjs +17 -6
  180. package/dist/development/src/resolvers/mutation/person/ChangePasswordMutationResolver.cjs.map +1 -1
  181. package/dist/development/src/resolvers/mutation/person/ChangePasswordMutationResolver.js +17 -6
  182. package/dist/development/src/resolvers/mutation/person/ChangePasswordMutationResolver.js.map +1 -1
  183. package/dist/development/src/resolvers/mutation/person/ChangeProfileMutationResolver.cjs +14 -0
  184. package/dist/development/src/resolvers/mutation/person/ChangeProfileMutationResolver.cjs.map +1 -1
  185. package/dist/development/src/resolvers/mutation/person/ChangeProfileMutationResolver.js +14 -0
  186. package/dist/development/src/resolvers/mutation/person/ChangeProfileMutationResolver.js.map +1 -1
  187. package/dist/development/src/resolvers/mutation/person/DisablePersonMutationResolver.cjs +7 -1
  188. package/dist/development/src/resolvers/mutation/person/DisablePersonMutationResolver.cjs.map +1 -1
  189. package/dist/development/src/resolvers/mutation/person/DisablePersonMutationResolver.js +7 -1
  190. package/dist/development/src/resolvers/mutation/person/DisablePersonMutationResolver.js.map +1 -1
  191. package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.cjs +5 -0
  192. package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.cjs.map +1 -1
  193. package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.js +5 -0
  194. package/dist/development/src/resolvers/mutation/person/IDPMutationResolver.js.map +1 -1
  195. package/dist/development/src/resolvers/mutation/person/InviteMutationResolver.cjs +3 -2
  196. package/dist/development/src/resolvers/mutation/person/InviteMutationResolver.cjs.map +1 -1
  197. package/dist/development/src/resolvers/mutation/person/InviteMutationResolver.js +2 -1
  198. package/dist/development/src/resolvers/mutation/person/InviteMutationResolver.js.map +1 -1
  199. package/dist/development/src/resolvers/mutation/person/OtpMutationResolver.cjs +26 -1
  200. package/dist/development/src/resolvers/mutation/person/OtpMutationResolver.cjs.map +1 -1
  201. package/dist/development/src/resolvers/mutation/person/OtpMutationResolver.js +26 -1
  202. package/dist/development/src/resolvers/mutation/person/OtpMutationResolver.js.map +1 -1
  203. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs +20 -0
  204. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs.map +1 -1
  205. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.js +20 -0
  206. package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.js.map +1 -1
  207. package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs +25 -2
  208. package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs.map +1 -1
  209. package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.js +25 -2
  210. package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.js.map +1 -1
  211. package/dist/development/src/resolvers/mutation/person/SignInMutationResolver.cjs +22 -0
  212. package/dist/development/src/resolvers/mutation/person/SignInMutationResolver.cjs.map +1 -1
  213. package/dist/development/src/resolvers/mutation/person/SignInMutationResolver.js +22 -0
  214. package/dist/development/src/resolvers/mutation/person/SignInMutationResolver.js.map +1 -1
  215. package/dist/development/src/resolvers/mutation/person/SignOutMutationResolver.cjs +1 -0
  216. package/dist/development/src/resolvers/mutation/person/SignOutMutationResolver.cjs.map +1 -1
  217. package/dist/development/src/resolvers/mutation/person/SignOutMutationResolver.js +1 -0
  218. package/dist/development/src/resolvers/mutation/person/SignOutMutationResolver.js.map +1 -1
  219. package/dist/development/src/resolvers/mutation/person/SignUpMutationResolver.cjs +2 -1
  220. package/dist/development/src/resolvers/mutation/person/SignUpMutationResolver.cjs.map +1 -1
  221. package/dist/development/src/resolvers/mutation/person/SignUpMutationResolver.js +2 -1
  222. package/dist/development/src/resolvers/mutation/person/SignUpMutationResolver.js.map +1 -1
  223. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs +3 -1
  224. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs.map +1 -1
  225. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js +3 -1
  226. package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js.map +1 -1
  227. package/dist/development/src/resolvers/mutation/project/CreateProjectMutationResolver.cjs +3 -2
  228. package/dist/development/src/resolvers/mutation/project/CreateProjectMutationResolver.cjs.map +1 -1
  229. package/dist/development/src/resolvers/mutation/project/CreateProjectMutationResolver.js +2 -1
  230. package/dist/development/src/resolvers/mutation/project/CreateProjectMutationResolver.js.map +1 -1
  231. package/dist/development/src/resolvers/mutation/project/SetProjectSecretMutationResolver.cjs +1 -0
  232. package/dist/development/src/resolvers/mutation/project/SetProjectSecretMutationResolver.cjs.map +1 -1
  233. package/dist/development/src/resolvers/mutation/project/SetProjectSecretMutationResolver.js +1 -0
  234. package/dist/development/src/resolvers/mutation/project/SetProjectSecretMutationResolver.js.map +1 -1
  235. package/dist/development/src/resolvers/mutation/project/UpdateProjectMutationResolver.cjs +1 -0
  236. package/dist/development/src/resolvers/mutation/project/UpdateProjectMutationResolver.cjs.map +1 -1
  237. package/dist/development/src/resolvers/mutation/project/UpdateProjectMutationResolver.js +1 -0
  238. package/dist/development/src/resolvers/mutation/project/UpdateProjectMutationResolver.js.map +1 -1
  239. package/dist/development/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.cjs +1 -0
  240. package/dist/development/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.cjs.map +1 -1
  241. package/dist/development/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.js +1 -0
  242. package/dist/development/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.js.map +1 -1
  243. package/dist/development/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.cjs +1 -0
  244. package/dist/development/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.cjs.map +1 -1
  245. package/dist/development/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.js +1 -0
  246. package/dist/development/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.js.map +1 -1
  247. package/dist/development/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.cjs +1 -0
  248. package/dist/development/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.cjs.map +1 -1
  249. package/dist/development/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.js +1 -0
  250. package/dist/development/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.js.map +1 -1
  251. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.cjs +3 -1
  252. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.cjs.map +1 -1
  253. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.js +3 -1
  254. package/dist/development/src/resolvers/query/ConfigurationQueryResolver.js.map +1 -1
  255. package/dist/development/src/resolvers/query/IDPQueryResolver.cjs +1 -0
  256. package/dist/development/src/resolvers/query/IDPQueryResolver.cjs.map +1 -1
  257. package/dist/development/src/resolvers/query/IDPQueryResolver.js +1 -0
  258. package/dist/development/src/resolvers/query/IDPQueryResolver.js.map +1 -1
  259. package/dist/development/src/resolvers/query/MailTemplateQueryResolver.cjs +1 -0
  260. package/dist/development/src/resolvers/query/MailTemplateQueryResolver.cjs.map +1 -1
  261. package/dist/development/src/resolvers/query/MailTemplateQueryResolver.js +1 -0
  262. package/dist/development/src/resolvers/query/MailTemplateQueryResolver.js.map +1 -1
  263. package/dist/development/src/resolvers/query/PersonQueryResolver.cjs +1 -0
  264. package/dist/development/src/resolvers/query/PersonQueryResolver.cjs.map +1 -1
  265. package/dist/development/src/resolvers/query/PersonQueryResolver.js +1 -0
  266. package/dist/development/src/resolvers/query/PersonQueryResolver.js.map +1 -1
  267. package/dist/development/src/resolvers/query/ProjectMembersQueryResolver.cjs +1 -0
  268. package/dist/development/src/resolvers/query/ProjectMembersQueryResolver.cjs.map +1 -1
  269. package/dist/development/src/resolvers/query/ProjectMembersQueryResolver.js +1 -0
  270. package/dist/development/src/resolvers/query/ProjectMembersQueryResolver.js.map +1 -1
  271. package/dist/development/src/resolvers/query/ProjectQueryResolver.cjs +1 -0
  272. package/dist/development/src/resolvers/query/ProjectQueryResolver.cjs.map +1 -1
  273. package/dist/development/src/resolvers/query/ProjectQueryResolver.js +1 -0
  274. package/dist/development/src/resolvers/query/ProjectQueryResolver.js.map +1 -1
  275. package/dist/development/src/resolvers/responseHelpers/SignInResponseFactory.cjs +1 -0
  276. package/dist/development/src/resolvers/responseHelpers/SignInResponseFactory.cjs.map +1 -1
  277. package/dist/development/src/resolvers/responseHelpers/SignInResponseFactory.js +1 -0
  278. package/dist/development/src/resolvers/responseHelpers/SignInResponseFactory.js.map +1 -1
  279. package/dist/development/src/resolvers/types/IdentityTypeResolver.cjs +1 -0
  280. package/dist/development/src/resolvers/types/IdentityTypeResolver.cjs.map +1 -1
  281. package/dist/development/src/resolvers/types/IdentityTypeResolver.js +1 -0
  282. package/dist/development/src/resolvers/types/IdentityTypeResolver.js.map +1 -1
  283. package/dist/development/src/resolvers/types/ProjectTypeResolver.cjs +1 -0
  284. package/dist/development/src/resolvers/types/ProjectTypeResolver.cjs.map +1 -1
  285. package/dist/development/src/resolvers/types/ProjectTypeResolver.js +1 -0
  286. package/dist/development/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
  287. package/dist/development/src/schema/tenant.graphql.cjs +64 -2
  288. package/dist/development/src/schema/tenant.graphql.cjs.map +1 -1
  289. package/dist/development/src/schema/tenant.graphql.js +64 -2
  290. package/dist/development/src/schema/tenant.graphql.js.map +1 -1
  291. package/dist/production/index.cjs +5 -6
  292. package/dist/production/index.cjs.map +1 -1
  293. package/dist/production/index.js +2 -3
  294. package/dist/production/src/TenantContainer.cjs +4 -2
  295. package/dist/production/src/TenantContainer.cjs.map +1 -1
  296. package/dist/production/src/TenantContainer.js +4 -2
  297. package/dist/production/src/TenantContainer.js.map +1 -1
  298. package/dist/production/src/bridges/system/IdentityFetcher.cjs +1 -0
  299. package/dist/production/src/bridges/system/IdentityFetcher.cjs.map +1 -1
  300. package/dist/production/src/bridges/system/IdentityFetcher.js +1 -0
  301. package/dist/production/src/bridges/system/IdentityFetcher.js.map +1 -1
  302. package/dist/production/src/migrations/2025-04-16-180000-config-up.cjs +39 -0
  303. package/dist/production/src/migrations/2025-04-16-180000-config-up.cjs.map +1 -0
  304. package/dist/production/src/migrations/2025-04-16-180000-config-up.js +40 -0
  305. package/dist/production/src/migrations/2025-04-16-180000-config-up.js.map +1 -0
  306. package/dist/production/src/migrations/2025-04-17-160000-auth-log.cjs +45 -0
  307. package/dist/production/src/migrations/2025-04-17-160000-auth-log.cjs.map +1 -0
  308. package/dist/production/src/migrations/2025-04-17-160000-auth-log.js +46 -0
  309. package/dist/production/src/migrations/2025-04-17-160000-auth-log.js.map +1 -0
  310. package/dist/production/src/migrations/runner.cjs +9 -4
  311. package/dist/production/src/migrations/runner.cjs.map +1 -1
  312. package/dist/production/src/migrations/runner.js +7 -2
  313. package/dist/production/src/migrations/runner.js.map +1 -1
  314. package/dist/production/src/migrations/snapshot.cjs +56 -1
  315. package/dist/production/src/migrations/snapshot.cjs.map +1 -1
  316. package/dist/production/src/migrations/snapshot.js +56 -1
  317. package/dist/production/src/migrations/snapshot.js.map +1 -1
  318. package/dist/production/src/model/authorization/MembershipMatcher.cjs +6 -0
  319. package/dist/production/src/model/authorization/MembershipMatcher.cjs.map +1 -1
  320. package/dist/production/src/model/authorization/MembershipMatcher.js +6 -0
  321. package/dist/production/src/model/authorization/MembershipMatcher.js.map +1 -1
  322. package/dist/production/src/model/commands/apiKey/CreateApiKeyCommand.cjs +7 -7
  323. package/dist/production/src/model/commands/apiKey/CreateApiKeyCommand.cjs.map +1 -1
  324. package/dist/production/src/model/commands/apiKey/CreateApiKeyCommand.js +1 -1
  325. package/dist/production/src/model/commands/authLog/CreateAuthLogEntryCommand.cjs +27 -0
  326. package/dist/production/src/model/commands/authLog/CreateAuthLogEntryCommand.cjs.map +1 -0
  327. package/dist/production/src/model/commands/authLog/CreateAuthLogEntryCommand.js +27 -0
  328. package/dist/production/src/model/commands/authLog/CreateAuthLogEntryCommand.js.map +1 -0
  329. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.cjs +15 -2
  330. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.cjs.map +1 -1
  331. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.js +15 -2
  332. package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.js.map +1 -1
  333. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.cjs +4 -4
  334. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.cjs.map +1 -1
  335. package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.js +1 -1
  336. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.cjs +5 -5
  337. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.cjs.map +1 -1
  338. package/dist/production/src/model/commands/personToken/ResetPasswordCommand.js +1 -1
  339. package/dist/production/src/model/queries/apiKey/ApiKeyQuery.cjs +4 -4
  340. package/dist/production/src/model/queries/apiKey/ApiKeyQuery.cjs.map +1 -1
  341. package/dist/production/src/model/queries/apiKey/ApiKeyQuery.js +1 -1
  342. package/dist/production/src/model/queries/authLog/NextLoginAttemptQuery.cjs +46 -0
  343. package/dist/production/src/model/queries/authLog/NextLoginAttemptQuery.cjs.map +1 -0
  344. package/dist/production/src/model/queries/authLog/NextLoginAttemptQuery.js +46 -0
  345. package/dist/production/src/model/queries/authLog/NextLoginAttemptQuery.js.map +1 -0
  346. package/dist/production/src/model/queries/configuration/ConfigurationQuery.cjs +18 -1
  347. package/dist/production/src/model/queries/configuration/ConfigurationQuery.cjs.map +1 -1
  348. package/dist/production/src/model/queries/configuration/ConfigurationQuery.js +18 -1
  349. package/dist/production/src/model/queries/configuration/ConfigurationQuery.js.map +1 -1
  350. package/dist/production/src/model/queries/personToken/PersonTokenQuery.cjs +3 -3
  351. package/dist/production/src/model/queries/personToken/PersonTokenQuery.cjs.map +1 -1
  352. package/dist/production/src/model/queries/personToken/PersonTokenQuery.js +1 -1
  353. package/dist/production/src/model/service/AuthLogService.cjs +34 -0
  354. package/dist/production/src/model/service/AuthLogService.cjs.map +1 -0
  355. package/dist/production/src/model/service/AuthLogService.js +34 -0
  356. package/dist/production/src/model/service/AuthLogService.js.map +1 -0
  357. package/dist/production/src/model/service/ConfigurationManager.cjs +0 -10
  358. package/dist/production/src/model/service/ConfigurationManager.cjs.map +1 -1
  359. package/dist/production/src/model/service/ConfigurationManager.js +0 -10
  360. package/dist/production/src/model/service/ConfigurationManager.js.map +1 -1
  361. package/dist/production/src/model/service/IDPSignInManager.cjs +37 -5
  362. package/dist/production/src/model/service/IDPSignInManager.cjs.map +1 -1
  363. package/dist/production/src/model/service/IDPSignInManager.js +37 -5
  364. package/dist/production/src/model/service/IDPSignInManager.js.map +1 -1
  365. package/dist/production/src/model/service/MembershipValidator.cjs +1 -1
  366. package/dist/production/src/model/service/MembershipValidator.cjs.map +1 -1
  367. package/dist/production/src/model/service/MembershipValidator.js +1 -1
  368. package/dist/production/src/model/service/MembershipValidator.js.map +1 -1
  369. package/dist/production/src/model/service/PasswordChangeManager.cjs +21 -12
  370. package/dist/production/src/model/service/PasswordChangeManager.cjs.map +1 -1
  371. package/dist/production/src/model/service/PasswordChangeManager.js +20 -11
  372. package/dist/production/src/model/service/PasswordChangeManager.js.map +1 -1
  373. package/dist/production/src/model/service/PasswordResetManager.cjs +40 -8
  374. package/dist/production/src/model/service/PasswordResetManager.cjs.map +1 -1
  375. package/dist/production/src/model/service/PasswordResetManager.js +40 -8
  376. package/dist/production/src/model/service/PasswordResetManager.js.map +1 -1
  377. package/dist/production/src/model/service/PasswordStrengthValidator.cjs +63 -0
  378. package/dist/production/src/model/service/PasswordStrengthValidator.cjs.map +1 -0
  379. package/dist/production/src/model/service/PasswordStrengthValidator.js +63 -0
  380. package/dist/production/src/model/service/PasswordStrengthValidator.js.map +1 -0
  381. package/dist/production/src/model/service/PasswordlessSignInManager.cjs +89 -24
  382. package/dist/production/src/model/service/PasswordlessSignInManager.cjs.map +1 -1
  383. package/dist/production/src/model/service/PasswordlessSignInManager.js +81 -16
  384. package/dist/production/src/model/service/PasswordlessSignInManager.js.map +1 -1
  385. package/dist/production/src/model/service/PersonAccessManager.cjs +7 -29
  386. package/dist/production/src/model/service/PersonAccessManager.cjs.map +1 -1
  387. package/dist/production/src/model/service/PersonAccessManager.js +7 -29
  388. package/dist/production/src/model/service/PersonAccessManager.js.map +1 -1
  389. package/dist/production/src/model/service/SignInManager.cjs +56 -31
  390. package/dist/production/src/model/service/SignInManager.cjs.map +1 -1
  391. package/dist/production/src/model/service/SignInManager.js +57 -32
  392. package/dist/production/src/model/service/SignInManager.js.map +1 -1
  393. package/dist/production/src/model/service/SignUpManager.cjs +13 -8
  394. package/dist/production/src/model/service/SignUpManager.cjs.map +1 -1
  395. package/dist/production/src/model/service/SignUpManager.js +11 -6
  396. package/dist/production/src/model/service/SignUpManager.js.map +1 -1
  397. package/dist/production/src/model/service/apiKey/ApiKeyManager.cjs +6 -1
  398. package/dist/production/src/model/service/apiKey/ApiKeyManager.cjs.map +1 -1
  399. package/dist/production/src/model/service/apiKey/ApiKeyManager.js +6 -1
  400. package/dist/production/src/model/service/apiKey/ApiKeyManager.js.map +1 -1
  401. package/dist/production/src/model/utils/Response.cjs +2 -1
  402. package/dist/production/src/model/utils/Response.cjs.map +1 -1
  403. package/dist/production/src/model/utils/Response.js +2 -1
  404. package/dist/production/src/model/utils/Response.js.map +1 -1
  405. package/dist/production/src/model/utils/blacklist.cjs +10006 -0
  406. package/dist/production/src/model/utils/blacklist.cjs.map +1 -0
  407. package/dist/production/src/model/utils/blacklist.js +10006 -0
  408. package/dist/production/src/model/utils/blacklist.js.map +1 -0
  409. package/dist/{development/src/model/utils/typeUtils.cjs → production/src/model/utils/hex.cjs} +1 -1
  410. package/dist/production/src/model/utils/hex.cjs.map +1 -0
  411. package/dist/production/src/model/utils/{typeUtils.js → hex.js} +1 -1
  412. package/dist/production/src/model/utils/hex.js.map +1 -0
  413. package/dist/production/src/model/utils/interval.cjs +8 -0
  414. package/dist/production/src/model/utils/interval.cjs.map +1 -0
  415. package/dist/production/src/model/utils/interval.js +8 -0
  416. package/dist/production/src/model/utils/interval.js.map +1 -0
  417. package/dist/production/src/model/utils/{tokenUtils.cjs → token.cjs} +3 -3
  418. package/dist/production/src/model/utils/token.cjs.map +1 -0
  419. package/dist/production/src/model/utils/{tokenUtils.js → token.js} +2 -2
  420. package/dist/production/src/model/utils/token.js.map +1 -0
  421. package/dist/production/src/resolvers/ResolverFactory.cjs +1 -0
  422. package/dist/production/src/resolvers/ResolverFactory.cjs.map +1 -1
  423. package/dist/production/src/resolvers/ResolverFactory.js +2 -1
  424. package/dist/production/src/resolvers/ResolverFactory.js.map +1 -1
  425. package/dist/production/src/resolvers/TenantResolverContextFactory.cjs +10 -2
  426. package/dist/production/src/resolvers/TenantResolverContextFactory.cjs.map +1 -1
  427. package/dist/production/src/resolvers/TenantResolverContextFactory.js +10 -2
  428. package/dist/production/src/resolvers/TenantResolverContextFactory.js.map +1 -1
  429. package/dist/production/src/resolvers/errorUtils.cjs +15 -4
  430. package/dist/production/src/resolvers/errorUtils.cjs.map +1 -1
  431. package/dist/production/src/resolvers/errorUtils.js +15 -4
  432. package/dist/production/src/resolvers/errorUtils.js.map +1 -1
  433. package/dist/production/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.cjs +4 -3
  434. package/dist/production/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.cjs.map +1 -1
  435. package/dist/production/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.js +2 -1
  436. package/dist/production/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.js.map +1 -1
  437. package/dist/production/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.cjs +1 -0
  438. package/dist/production/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.cjs.map +1 -1
  439. package/dist/production/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.js +1 -0
  440. package/dist/production/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.js.map +1 -1
  441. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs +1 -0
  442. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs.map +1 -1
  443. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js +1 -0
  444. package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js.map +1 -1
  445. package/dist/production/src/resolvers/mutation/identity/GlobalRolesMutationResolver.cjs +1 -0
  446. package/dist/production/src/resolvers/mutation/identity/GlobalRolesMutationResolver.cjs.map +1 -1
  447. package/dist/production/src/resolvers/mutation/identity/GlobalRolesMutationResolver.js +1 -0
  448. package/dist/production/src/resolvers/mutation/identity/GlobalRolesMutationResolver.js.map +1 -1
  449. package/dist/production/src/resolvers/mutation/idp/AddIDPMutationResolver.cjs +1 -0
  450. package/dist/production/src/resolvers/mutation/idp/AddIDPMutationResolver.cjs.map +1 -1
  451. package/dist/production/src/resolvers/mutation/idp/AddIDPMutationResolver.js +1 -0
  452. package/dist/production/src/resolvers/mutation/idp/AddIDPMutationResolver.js.map +1 -1
  453. package/dist/production/src/resolvers/mutation/idp/DisableIDPMutationResolver.cjs +1 -0
  454. package/dist/production/src/resolvers/mutation/idp/DisableIDPMutationResolver.cjs.map +1 -1
  455. package/dist/production/src/resolvers/mutation/idp/DisableIDPMutationResolver.js +1 -0
  456. package/dist/production/src/resolvers/mutation/idp/DisableIDPMutationResolver.js.map +1 -1
  457. package/dist/production/src/resolvers/mutation/idp/EnableIDPMutationResolver.cjs +1 -0
  458. package/dist/production/src/resolvers/mutation/idp/EnableIDPMutationResolver.cjs.map +1 -1
  459. package/dist/production/src/resolvers/mutation/idp/EnableIDPMutationResolver.js +1 -0
  460. package/dist/production/src/resolvers/mutation/idp/EnableIDPMutationResolver.js.map +1 -1
  461. package/dist/production/src/resolvers/mutation/idp/UpdateIDPMutationResolver.cjs +1 -0
  462. package/dist/production/src/resolvers/mutation/idp/UpdateIDPMutationResolver.cjs.map +1 -1
  463. package/dist/production/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js +1 -0
  464. package/dist/production/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js.map +1 -1
  465. package/dist/production/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.cjs +1 -0
  466. package/dist/production/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.cjs.map +1 -1
  467. package/dist/production/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.js +1 -0
  468. package/dist/production/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.js.map +1 -1
  469. package/dist/production/src/resolvers/mutation/person/ChangePasswordMutationResolver.cjs +17 -6
  470. package/dist/production/src/resolvers/mutation/person/ChangePasswordMutationResolver.cjs.map +1 -1
  471. package/dist/production/src/resolvers/mutation/person/ChangePasswordMutationResolver.js +17 -6
  472. package/dist/production/src/resolvers/mutation/person/ChangePasswordMutationResolver.js.map +1 -1
  473. package/dist/production/src/resolvers/mutation/person/ChangeProfileMutationResolver.cjs +14 -0
  474. package/dist/production/src/resolvers/mutation/person/ChangeProfileMutationResolver.cjs.map +1 -1
  475. package/dist/production/src/resolvers/mutation/person/ChangeProfileMutationResolver.js +14 -0
  476. package/dist/production/src/resolvers/mutation/person/ChangeProfileMutationResolver.js.map +1 -1
  477. package/dist/production/src/resolvers/mutation/person/DisablePersonMutationResolver.cjs +7 -1
  478. package/dist/production/src/resolvers/mutation/person/DisablePersonMutationResolver.cjs.map +1 -1
  479. package/dist/production/src/resolvers/mutation/person/DisablePersonMutationResolver.js +7 -1
  480. package/dist/production/src/resolvers/mutation/person/DisablePersonMutationResolver.js.map +1 -1
  481. package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.cjs +5 -0
  482. package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.cjs.map +1 -1
  483. package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.js +5 -0
  484. package/dist/production/src/resolvers/mutation/person/IDPMutationResolver.js.map +1 -1
  485. package/dist/production/src/resolvers/mutation/person/InviteMutationResolver.cjs +3 -2
  486. package/dist/production/src/resolvers/mutation/person/InviteMutationResolver.cjs.map +1 -1
  487. package/dist/production/src/resolvers/mutation/person/InviteMutationResolver.js +2 -1
  488. package/dist/production/src/resolvers/mutation/person/InviteMutationResolver.js.map +1 -1
  489. package/dist/production/src/resolvers/mutation/person/OtpMutationResolver.cjs +26 -1
  490. package/dist/production/src/resolvers/mutation/person/OtpMutationResolver.cjs.map +1 -1
  491. package/dist/production/src/resolvers/mutation/person/OtpMutationResolver.js +26 -1
  492. package/dist/production/src/resolvers/mutation/person/OtpMutationResolver.js.map +1 -1
  493. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs +20 -0
  494. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs.map +1 -1
  495. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.js +20 -0
  496. package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.js.map +1 -1
  497. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs +25 -2
  498. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs.map +1 -1
  499. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.js +25 -2
  500. package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.js.map +1 -1
  501. package/dist/production/src/resolvers/mutation/person/SignInMutationResolver.cjs +22 -0
  502. package/dist/production/src/resolvers/mutation/person/SignInMutationResolver.cjs.map +1 -1
  503. package/dist/production/src/resolvers/mutation/person/SignInMutationResolver.js +22 -0
  504. package/dist/production/src/resolvers/mutation/person/SignInMutationResolver.js.map +1 -1
  505. package/dist/production/src/resolvers/mutation/person/SignOutMutationResolver.cjs +1 -0
  506. package/dist/production/src/resolvers/mutation/person/SignOutMutationResolver.cjs.map +1 -1
  507. package/dist/production/src/resolvers/mutation/person/SignOutMutationResolver.js +1 -0
  508. package/dist/production/src/resolvers/mutation/person/SignOutMutationResolver.js.map +1 -1
  509. package/dist/production/src/resolvers/mutation/person/SignUpMutationResolver.cjs +2 -1
  510. package/dist/production/src/resolvers/mutation/person/SignUpMutationResolver.cjs.map +1 -1
  511. package/dist/production/src/resolvers/mutation/person/SignUpMutationResolver.js +2 -1
  512. package/dist/production/src/resolvers/mutation/person/SignUpMutationResolver.js.map +1 -1
  513. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs +3 -1
  514. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs.map +1 -1
  515. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js +3 -1
  516. package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js.map +1 -1
  517. package/dist/production/src/resolvers/mutation/project/CreateProjectMutationResolver.cjs +3 -2
  518. package/dist/production/src/resolvers/mutation/project/CreateProjectMutationResolver.cjs.map +1 -1
  519. package/dist/production/src/resolvers/mutation/project/CreateProjectMutationResolver.js +2 -1
  520. package/dist/production/src/resolvers/mutation/project/CreateProjectMutationResolver.js.map +1 -1
  521. package/dist/production/src/resolvers/mutation/project/SetProjectSecretMutationResolver.cjs +1 -0
  522. package/dist/production/src/resolvers/mutation/project/SetProjectSecretMutationResolver.cjs.map +1 -1
  523. package/dist/production/src/resolvers/mutation/project/SetProjectSecretMutationResolver.js +1 -0
  524. package/dist/production/src/resolvers/mutation/project/SetProjectSecretMutationResolver.js.map +1 -1
  525. package/dist/production/src/resolvers/mutation/project/UpdateProjectMutationResolver.cjs +1 -0
  526. package/dist/production/src/resolvers/mutation/project/UpdateProjectMutationResolver.cjs.map +1 -1
  527. package/dist/production/src/resolvers/mutation/project/UpdateProjectMutationResolver.js +1 -0
  528. package/dist/production/src/resolvers/mutation/project/UpdateProjectMutationResolver.js.map +1 -1
  529. package/dist/production/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.cjs +1 -0
  530. package/dist/production/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.cjs.map +1 -1
  531. package/dist/production/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.js +1 -0
  532. package/dist/production/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.js.map +1 -1
  533. package/dist/production/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.cjs +1 -0
  534. package/dist/production/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.cjs.map +1 -1
  535. package/dist/production/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.js +1 -0
  536. package/dist/production/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.js.map +1 -1
  537. package/dist/production/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.cjs +1 -0
  538. package/dist/production/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.cjs.map +1 -1
  539. package/dist/production/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.js +1 -0
  540. package/dist/production/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.js.map +1 -1
  541. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.cjs +3 -1
  542. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.cjs.map +1 -1
  543. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.js +3 -1
  544. package/dist/production/src/resolvers/query/ConfigurationQueryResolver.js.map +1 -1
  545. package/dist/production/src/resolvers/query/IDPQueryResolver.cjs +1 -0
  546. package/dist/production/src/resolvers/query/IDPQueryResolver.cjs.map +1 -1
  547. package/dist/production/src/resolvers/query/IDPQueryResolver.js +1 -0
  548. package/dist/production/src/resolvers/query/IDPQueryResolver.js.map +1 -1
  549. package/dist/production/src/resolvers/query/MailTemplateQueryResolver.cjs +1 -0
  550. package/dist/production/src/resolvers/query/MailTemplateQueryResolver.cjs.map +1 -1
  551. package/dist/production/src/resolvers/query/MailTemplateQueryResolver.js +1 -0
  552. package/dist/production/src/resolvers/query/MailTemplateQueryResolver.js.map +1 -1
  553. package/dist/production/src/resolvers/query/PersonQueryResolver.cjs +1 -0
  554. package/dist/production/src/resolvers/query/PersonQueryResolver.cjs.map +1 -1
  555. package/dist/production/src/resolvers/query/PersonQueryResolver.js +1 -0
  556. package/dist/production/src/resolvers/query/PersonQueryResolver.js.map +1 -1
  557. package/dist/production/src/resolvers/query/ProjectMembersQueryResolver.cjs +1 -0
  558. package/dist/production/src/resolvers/query/ProjectMembersQueryResolver.cjs.map +1 -1
  559. package/dist/production/src/resolvers/query/ProjectMembersQueryResolver.js +1 -0
  560. package/dist/production/src/resolvers/query/ProjectMembersQueryResolver.js.map +1 -1
  561. package/dist/production/src/resolvers/query/ProjectQueryResolver.cjs +1 -0
  562. package/dist/production/src/resolvers/query/ProjectQueryResolver.cjs.map +1 -1
  563. package/dist/production/src/resolvers/query/ProjectQueryResolver.js +1 -0
  564. package/dist/production/src/resolvers/query/ProjectQueryResolver.js.map +1 -1
  565. package/dist/production/src/resolvers/responseHelpers/SignInResponseFactory.cjs +1 -0
  566. package/dist/production/src/resolvers/responseHelpers/SignInResponseFactory.cjs.map +1 -1
  567. package/dist/production/src/resolvers/responseHelpers/SignInResponseFactory.js +1 -0
  568. package/dist/production/src/resolvers/responseHelpers/SignInResponseFactory.js.map +1 -1
  569. package/dist/production/src/resolvers/types/IdentityTypeResolver.cjs +1 -0
  570. package/dist/production/src/resolvers/types/IdentityTypeResolver.cjs.map +1 -1
  571. package/dist/production/src/resolvers/types/IdentityTypeResolver.js +1 -0
  572. package/dist/production/src/resolvers/types/IdentityTypeResolver.js.map +1 -1
  573. package/dist/production/src/resolvers/types/ProjectTypeResolver.cjs +1 -0
  574. package/dist/production/src/resolvers/types/ProjectTypeResolver.cjs.map +1 -1
  575. package/dist/production/src/resolvers/types/ProjectTypeResolver.js +1 -0
  576. package/dist/production/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
  577. package/dist/production/src/schema/tenant.graphql.cjs +64 -2
  578. package/dist/production/src/schema/tenant.graphql.cjs.map +1 -1
  579. package/dist/production/src/schema/tenant.graphql.js +64 -2
  580. package/dist/production/src/schema/tenant.graphql.js.map +1 -1
  581. package/dist/tests/cases/integration/mocked/sql/createSessionKeySql.d.ts +1 -1
  582. package/dist/tests/cases/integration/mocked/sql/getConfigSql.d.ts +3 -0
  583. package/dist/tests/cases/integration/mocked/sql/getConfigSql.d.ts.map +1 -0
  584. package/dist/tests/cases/integration/mocked/sql/getNextLoginAttemptSql.d.ts +3 -0
  585. package/dist/tests/cases/integration/mocked/sql/getNextLoginAttemptSql.d.ts.map +1 -0
  586. package/dist/tests/src/testTenant.d.ts +2 -0
  587. package/dist/tests/src/testTenant.d.ts.map +1 -1
  588. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  589. package/dist/types/TenantContainer.d.ts +6 -0
  590. package/dist/types/TenantContainer.d.ts.map +1 -1
  591. package/dist/types/migrations/2025-04-16-180000-config-up.d.ts +3 -0
  592. package/dist/types/migrations/2025-04-16-180000-config-up.d.ts.map +1 -0
  593. package/dist/types/migrations/2025-04-17-160000-auth-log.d.ts +3 -0
  594. package/dist/types/migrations/2025-04-17-160000-auth-log.d.ts.map +1 -0
  595. package/dist/types/migrations/runner.d.ts.map +1 -1
  596. package/dist/types/migrations/snapshot.d.ts.map +1 -1
  597. package/dist/types/model/authorization/MembershipMatcher.d.ts.map +1 -1
  598. package/dist/types/model/commands/authLog/CreateAuthLogEntryCommand.d.ts +26 -0
  599. package/dist/types/model/commands/authLog/CreateAuthLogEntryCommand.d.ts.map +1 -0
  600. package/dist/types/model/commands/configuration/UpdateConfigurationCommand.d.ts.map +1 -1
  601. package/dist/types/model/dtos/AuthLogBag.d.ts +3 -0
  602. package/dist/types/model/dtos/AuthLogBag.d.ts.map +1 -0
  603. package/dist/types/model/queries/authLog/NextLoginAttemptQuery.d.ts +7 -0
  604. package/dist/types/model/queries/authLog/NextLoginAttemptQuery.d.ts.map +1 -0
  605. package/dist/types/model/queries/configuration/ConfigurationQuery.d.ts +1 -1
  606. package/dist/types/model/queries/configuration/ConfigurationQuery.d.ts.map +1 -1
  607. package/dist/types/model/service/AuthLogService.d.ts +34 -0
  608. package/dist/types/model/service/AuthLogService.d.ts.map +1 -0
  609. package/dist/types/model/service/ConfigurationManager.d.ts +1 -2
  610. package/dist/types/model/service/ConfigurationManager.d.ts.map +1 -1
  611. package/dist/types/model/service/IDPSignInManager.d.ts +5 -1
  612. package/dist/types/model/service/IDPSignInManager.d.ts.map +1 -1
  613. package/dist/types/model/service/PasswordChangeManager.d.ts +8 -4
  614. package/dist/types/model/service/PasswordChangeManager.d.ts.map +1 -1
  615. package/dist/types/model/service/PasswordResetManager.d.ts +11 -4
  616. package/dist/types/model/service/PasswordResetManager.d.ts.map +1 -1
  617. package/dist/types/model/service/PasswordStrengthValidator.d.ts +11 -0
  618. package/dist/types/model/service/PasswordStrengthValidator.d.ts.map +1 -0
  619. package/dist/types/model/service/PasswordlessSignInManager.d.ts +16 -6
  620. package/dist/types/model/service/PasswordlessSignInManager.d.ts.map +1 -1
  621. package/dist/types/model/service/PersonAccessManager.d.ts +2 -1
  622. package/dist/types/model/service/PersonAccessManager.d.ts.map +1 -1
  623. package/dist/types/model/service/SignInManager.d.ts +9 -4
  624. package/dist/types/model/service/SignInManager.d.ts.map +1 -1
  625. package/dist/types/model/service/SignUpManager.d.ts +7 -3
  626. package/dist/types/model/service/SignUpManager.d.ts.map +1 -1
  627. package/dist/types/model/service/apiKey/ApiKeyManager.d.ts.map +1 -1
  628. package/dist/types/model/type/AuthLog.d.ts +2 -0
  629. package/dist/types/model/type/AuthLog.d.ts.map +1 -0
  630. package/dist/types/model/type/Config.d.ts +28 -0
  631. package/dist/types/model/type/Config.d.ts.map +1 -0
  632. package/dist/types/model/utils/Response.d.ts +4 -3
  633. package/dist/types/model/utils/Response.d.ts.map +1 -1
  634. package/dist/types/model/utils/blacklist.d.ts +2 -0
  635. package/dist/types/model/utils/blacklist.d.ts.map +1 -0
  636. package/dist/types/model/utils/{typeUtils.d.ts → hex.d.ts} +1 -1
  637. package/dist/types/model/utils/hex.d.ts.map +1 -0
  638. package/dist/types/model/utils/index.d.ts +1 -1
  639. package/dist/types/model/utils/index.d.ts.map +1 -1
  640. package/dist/types/model/utils/interval.d.ts +3 -0
  641. package/dist/types/model/utils/interval.d.ts.map +1 -0
  642. package/dist/types/model/utils/{tokenUtils.d.ts → token.d.ts} +2 -2
  643. package/dist/types/model/utils/token.d.ts.map +1 -0
  644. package/dist/types/resolvers/ResolverFactory.d.ts.map +1 -1
  645. package/dist/types/resolvers/TenantResolverContext.d.ts +2 -0
  646. package/dist/types/resolvers/TenantResolverContext.d.ts.map +1 -1
  647. package/dist/types/resolvers/TenantResolverContextFactory.d.ts +6 -1
  648. package/dist/types/resolvers/TenantResolverContextFactory.d.ts.map +1 -1
  649. package/dist/types/resolvers/errorUtils.d.ts +7 -5
  650. package/dist/types/resolvers/errorUtils.d.ts.map +1 -1
  651. package/dist/types/resolvers/mutation/person/ChangePasswordMutationResolver.d.ts.map +1 -1
  652. package/dist/types/resolvers/mutation/person/ChangeProfileMutationResolver.d.ts.map +1 -1
  653. package/dist/types/resolvers/mutation/person/DisablePersonMutationResolver.d.ts.map +1 -1
  654. package/dist/types/resolvers/mutation/person/IDPMutationResolver.d.ts.map +1 -1
  655. package/dist/types/resolvers/mutation/person/OtpMutationResolver.d.ts.map +1 -1
  656. package/dist/types/resolvers/mutation/person/PasswordlessMutationResolver.d.ts.map +1 -1
  657. package/dist/types/resolvers/mutation/person/ResetPasswordMutationResolver.d.ts.map +1 -1
  658. package/dist/types/resolvers/mutation/person/SignInMutationResolver.d.ts.map +1 -1
  659. package/dist/types/resolvers/mutation/person/TogglePasswordlessMutationResolver.d.ts.map +1 -1
  660. package/dist/types/resolvers/types/ProjectTypeResolver.d.ts +2 -2
  661. package/dist/types/resolvers/types/ProjectTypeResolver.d.ts.map +1 -1
  662. package/dist/types/schema/index.d.ts +103 -8
  663. package/dist/types/schema/index.d.ts.map +1 -1
  664. package/dist/types/schema/tenant.graphql.d.ts.map +1 -1
  665. package/dist/types/schema/types.d.ts +8 -0
  666. package/dist/types/schema/types.d.ts.map +1 -0
  667. package/dist/types/tsconfig.tsbuildinfo +1 -1
  668. package/graphql.codegen.yml +7 -3
  669. package/package.json +13 -12
  670. package/src/TenantContainer.ts +16 -10
  671. package/src/migrations/2025-04-16-180000-config-up.ts +39 -0
  672. package/src/migrations/2025-04-17-160000-auth-log.ts +45 -0
  673. package/src/migrations/runner.ts +4 -1
  674. package/src/migrations/snapshot.ts +56 -1
  675. package/src/model/authorization/MembershipMatcher.ts +6 -0
  676. package/src/model/commands/authLog/CreateAuthLogEntryCommand.ts +51 -0
  677. package/src/model/commands/configuration/UpdateConfigurationCommand.ts +20 -2
  678. package/src/model/dtos/AuthLogBag.ts +3 -0
  679. package/src/model/queries/authLog/NextLoginAttemptQuery.ts +63 -0
  680. package/src/model/queries/configuration/ConfigurationQuery.ts +20 -8
  681. package/src/model/service/AuthLogService.ts +62 -0
  682. package/src/model/service/ConfigurationManager.ts +1 -6
  683. package/src/model/service/IDPSignInManager.ts +41 -6
  684. package/src/model/service/MembershipValidator.ts +1 -1
  685. package/src/model/service/PasswordChangeManager.ts +17 -12
  686. package/src/model/service/PasswordResetManager.ts +42 -11
  687. package/src/model/service/PasswordStrengthValidator.ts +85 -0
  688. package/src/model/service/PasswordlessSignInManager.ts +95 -28
  689. package/src/model/service/PersonAccessManager.ts +8 -27
  690. package/src/model/service/SignInManager.ts +68 -33
  691. package/src/model/service/SignUpManager.ts +16 -8
  692. package/src/model/service/apiKey/ApiKeyManager.ts +8 -2
  693. package/src/model/type/AuthLog.ts +14 -0
  694. package/src/model/type/Config.ts +29 -0
  695. package/src/model/utils/Response.ts +10 -3
  696. package/src/model/utils/blacklist.ts +4 -0
  697. package/src/model/utils/index.ts +1 -1
  698. package/src/model/utils/interval.ts +14 -0
  699. package/src/model/utils/{tokenUtils.ts → token.ts} +1 -1
  700. package/src/resolvers/ResolverFactory.ts +2 -1
  701. package/src/resolvers/TenantResolverContext.ts +2 -0
  702. package/src/resolvers/TenantResolverContextFactory.ts +10 -0
  703. package/src/resolvers/errorUtils.ts +23 -5
  704. package/src/resolvers/mutation/idp/AddIDPMutationResolver.ts +1 -1
  705. package/src/resolvers/mutation/idp/UpdateIDPMutationResolver.ts +1 -1
  706. package/src/resolvers/mutation/person/ChangePasswordMutationResolver.ts +17 -15
  707. package/src/resolvers/mutation/person/ChangeProfileMutationResolver.ts +13 -0
  708. package/src/resolvers/mutation/person/DisablePersonMutationResolver.ts +7 -7
  709. package/src/resolvers/mutation/person/IDPMutationResolver.ts +4 -0
  710. package/src/resolvers/mutation/person/OtpMutationResolver.ts +25 -1
  711. package/src/resolvers/mutation/person/PasswordlessMutationResolver.ts +21 -1
  712. package/src/resolvers/mutation/person/ResetPasswordMutationResolver.ts +27 -3
  713. package/src/resolvers/mutation/person/SignInMutationResolver.ts +26 -8
  714. package/src/resolvers/mutation/person/SignUpMutationResolver.ts +1 -1
  715. package/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.ts +2 -2
  716. package/src/resolvers/mutation/project/CreateProjectMutationResolver.ts +1 -1
  717. package/src/resolvers/mutation/project/UpdateProjectMutationResolver.ts +1 -1
  718. package/src/resolvers/query/ConfigurationQueryResolver.ts +2 -2
  719. package/src/resolvers/types/ProjectTypeResolver.ts +2 -2
  720. package/src/schema/index.ts +114 -5
  721. package/src/schema/tenant.graphql.ts +64 -2
  722. package/src/schema/types.ts +4 -0
  723. package/tests/cases/integration/mocked/changeMyPasswordMutation.test.ts +42 -2
  724. package/tests/cases/integration/mocked/changeMyProfileMutation.test.ts +25 -4
  725. package/tests/cases/integration/mocked/changePasswordMutation.test.ts +10 -2
  726. package/tests/cases/integration/mocked/changeProfileMutation.test.ts +7 -1
  727. package/tests/cases/integration/mocked/confirmOtpMutation.test.ts +13 -8
  728. package/tests/cases/integration/mocked/createSessionKeyMutation.test.ts +9 -21
  729. package/tests/cases/integration/mocked/inviteMutations.test.ts +0 -24
  730. package/tests/cases/integration/mocked/signInIdpMutation.test.ts +16 -1
  731. package/tests/cases/integration/mocked/signInMutation.test.ts +54 -22
  732. package/tests/cases/integration/mocked/signOutMutation.test.ts +0 -5
  733. package/tests/cases/integration/mocked/signUpMutation.test.ts +3 -12
  734. package/tests/cases/integration/mocked/sql/createSessionKeySql.ts +1 -1
  735. package/tests/cases/integration/mocked/sql/getConfigSql.ts +29 -0
  736. package/tests/cases/integration/mocked/sql/getNextLoginAttemptSql.ts +20 -0
  737. package/tests/src/testTenant.ts +13 -0
  738. package/dist/development/src/model/utils/password.cjs +0 -12
  739. package/dist/development/src/model/utils/password.cjs.map +0 -1
  740. package/dist/development/src/model/utils/password.js +0 -12
  741. package/dist/development/src/model/utils/password.js.map +0 -1
  742. package/dist/development/src/model/utils/tokenUtils.cjs.map +0 -1
  743. package/dist/development/src/model/utils/tokenUtils.js.map +0 -1
  744. package/dist/development/src/model/utils/typeUtils.cjs.map +0 -1
  745. package/dist/development/src/model/utils/typeUtils.js.map +0 -1
  746. package/dist/production/src/model/utils/password.cjs +0 -12
  747. package/dist/production/src/model/utils/password.cjs.map +0 -1
  748. package/dist/production/src/model/utils/password.js +0 -12
  749. package/dist/production/src/model/utils/password.js.map +0 -1
  750. package/dist/production/src/model/utils/tokenUtils.cjs.map +0 -1
  751. package/dist/production/src/model/utils/tokenUtils.js.map +0 -1
  752. package/dist/production/src/model/utils/typeUtils.cjs.map +0 -1
  753. package/dist/production/src/model/utils/typeUtils.js.map +0 -1
  754. package/dist/types/model/utils/password.d.ts +0 -4
  755. package/dist/types/model/utils/password.d.ts.map +0 -1
  756. package/dist/types/model/utils/tokenUtils.d.ts.map +0 -1
  757. package/dist/types/model/utils/typeUtils.d.ts.map +0 -1
  758. package/src/model/utils/password.ts +0 -8
  759. /package/src/model/utils/{typeUtils.ts → hex.ts} +0 -0
@@ -8,6 +8,7 @@ import "../authorization/PermissionContext.js";
8
8
  import "../authorization/PermissionsFactory.js";
9
9
  import "@contember/schema";
10
10
  import { ResponseError, ResponseOk } from "../utils/Response.js";
11
+ import { AuthLogService } from "./AuthLogService.js";
11
12
  class SignInManager {
12
13
  constructor(apiKeyManager, providers, otpAuthenticator) {
13
14
  this.apiKeyManager = apiKeyManager;
@@ -15,57 +16,81 @@ class SignInManager {
15
16
  this.otpAuthenticator = otpAuthenticator;
16
17
  }
17
18
  async signIn(dbContext, email, password, expiration, otpCode) {
18
- const personRow = await dbContext.queryHandler.fetch(PersonQuery.byEmail(email));
19
- if (personRow === null) {
20
- return new ResponseError("UNKNOWN_EMAIL", `Person with email ${email} not found`);
19
+ const person = await dbContext.queryHandler.fetch(PersonQuery.byEmail(email));
20
+ if (person === null) {
21
+ return new ResponseError("UNKNOWN_EMAIL", `Person with email ${email} not found`, {
22
+ [AuthLogService.Key]: new AuthLogService.Bag({
23
+ personInput: email
24
+ })
25
+ });
21
26
  }
22
- if (!personRow.password_hash) {
23
- return new ResponseError("NO_PASSWORD_SET", `No password set`);
27
+ const authLogData = {
28
+ [AuthLogService.Key]: new AuthLogService.Bag({
29
+ personInput: email,
30
+ personId: person.id
31
+ })
32
+ };
33
+ if (!person.password_hash) {
34
+ return new ResponseError("NO_PASSWORD_SET", `No password set`, authLogData);
24
35
  }
25
- if (personRow.disabled_at !== null) {
26
- return new ResponseError("PERSON_DISABLED", `Person is disabled`);
36
+ if (person.disabled_at !== null) {
37
+ return new ResponseError("PERSON_DISABLED", `Person is disabled`, authLogData);
27
38
  }
28
- const passwordValid = await this.providers.bcryptCompare(password, personRow.password_hash);
39
+ const passwordValid = await this.providers.bcryptCompare(password, person.password_hash);
29
40
  if (!passwordValid) {
30
- return new ResponseError("INVALID_PASSWORD", `Password does not match`);
41
+ return new ResponseError("INVALID_PASSWORD", `Password does not match`, authLogData);
31
42
  }
32
- if (personRow.otp_uri && personRow.otp_activated_at) {
43
+ if (person.otp_uri && person.otp_activated_at) {
33
44
  if (!otpCode) {
34
- return new ResponseError("OTP_REQUIRED", `2FA is enabled. OTP token is required`);
45
+ return new ResponseError("OTP_REQUIRED", `2FA is enabled. OTP token is required`, authLogData);
35
46
  }
36
- if (!this.otpAuthenticator.validate({ uri: personRow.otp_uri }, otpCode)) {
37
- return new ResponseError("INVALID_OTP_TOKEN", "OTP token validation has failed");
47
+ if (!this.otpAuthenticator.validate({ uri: person.otp_uri }, otpCode)) {
48
+ return new ResponseError("INVALID_OTP_TOKEN", "OTP token validation has failed", authLogData);
38
49
  }
39
50
  }
40
- const sessionToken = await this.apiKeyManager.createSessionApiKey(dbContext, personRow.identity_id, expiration);
41
- return new ResponseOk(new SignInResult(personRow, sessionToken));
51
+ const sessionToken = await this.apiKeyManager.createSessionApiKey(dbContext, person.identity_id, expiration);
52
+ return new ResponseOk({ person, token: sessionToken, ...authLogData });
42
53
  }
43
54
  async createSessionToken(dbContext, personIdentifier, expiration, verifier) {
44
- const personRow = await dbContext.queryHandler.fetch(PersonQuery.byUniqueIdentifier(personIdentifier));
45
- if (personRow === null) {
55
+ const person = await dbContext.queryHandler.fetch(PersonQuery.byUniqueIdentifier(personIdentifier));
56
+ if (person === null) {
46
57
  if (personIdentifier.type === "email") {
47
- return new ResponseError("UNKNOWN_EMAIL", `Person with email ${personIdentifier.email} not found`);
58
+ return new ResponseError("UNKNOWN_EMAIL", `Person with email ${personIdentifier.email} not found`, {
59
+ [AuthLogService.Key]: new AuthLogService.Bag({
60
+ personInput: personIdentifier.email
61
+ })
62
+ });
48
63
  } else if (personIdentifier.type === "id") {
49
- return new ResponseError("UNKNOWN_PERSON_ID", `Person with id ${personIdentifier.id} not found`);
64
+ return new ResponseError("UNKNOWN_PERSON_ID", `Person with id ${personIdentifier.id} not found`, {
65
+ [AuthLogService.Key]: new AuthLogService.Bag({
66
+ personInput: personIdentifier.id
67
+ })
68
+ });
50
69
  }
51
70
  throw new ImplementationException();
52
71
  }
53
- if (personRow.disabled_at !== null) {
54
- return new ResponseError("PERSON_DISABLED", `Person with id ${personRow.id} is disabled`);
72
+ const inputValue = personIdentifier.type === "email" ? personIdentifier.email : personIdentifier.id;
73
+ if (person.disabled_at !== null) {
74
+ return new ResponseError("PERSON_DISABLED", `Person with id ${person.id} is disabled`, {
75
+ [AuthLogService.Key]: new AuthLogService.Bag({
76
+ personId: person.id,
77
+ personInput: inputValue
78
+ })
79
+ });
55
80
  }
56
- await verifier?.(personRow);
57
- const sessionToken = await this.apiKeyManager.createSessionApiKey(dbContext, personRow.identity_id, expiration);
58
- return new ResponseOk(new SignInResult(personRow, sessionToken));
59
- }
60
- }
61
- class SignInResult {
62
- constructor(person, token) {
63
- this.person = person;
64
- this.token = token;
81
+ await verifier?.(person);
82
+ const sessionToken = await this.apiKeyManager.createSessionApiKey(dbContext, person.identity_id, expiration);
83
+ return new ResponseOk({
84
+ person,
85
+ token: sessionToken,
86
+ [AuthLogService.Key]: new AuthLogService.Bag({
87
+ personId: person.id,
88
+ personInput: inputValue
89
+ })
90
+ });
65
91
  }
66
92
  }
67
93
  export {
68
- SignInManager,
69
- SignInResult
94
+ SignInManager
70
95
  };
71
96
  //# sourceMappingURL=SignInManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SignInManager.js","sources":["../../../../../../packages/engine-tenant-api/src/model/service/SignInManager.ts"],"sourcesContent":["import { CreateSessionTokenErrorCode, SignInErrorCode } from '../../schema'\nimport { ApiKeyManager, OtpAuthenticator } from '../service'\nimport { PersonQuery, PersonRow, PersonUniqueIdentifier } from '../queries'\nimport { Providers } from '../providers'\nimport { DatabaseContext } from '../utils'\nimport { Response, ResponseError, ResponseOk } from '../utils/Response'\nimport { ImplementationException } from '../../exceptions'\n\nclass SignInManager {\n\tconstructor(\n\t\tprivate readonly apiKeyManager: ApiKeyManager,\n\t\tprivate readonly providers: Providers,\n\t\tprivate readonly otpAuthenticator: OtpAuthenticator,\n\t) {}\n\n\tasync signIn(dbContext: DatabaseContext, email: string, password: string, expiration?: number, otpCode?: string): Promise<SignInResponse> {\n\t\tconst personRow = await dbContext.queryHandler.fetch(PersonQuery.byEmail(email))\n\n\t\tif (personRow === null) {\n\t\t\treturn new ResponseError('UNKNOWN_EMAIL', `Person with email ${email} not found`)\n\t\t}\n\n\t\tif (!personRow.password_hash) {\n\t\t\treturn new ResponseError('NO_PASSWORD_SET', `No password set`)\n\t\t}\n\n\t\tif (personRow.disabled_at !== null) {\n\t\t\treturn new ResponseError('PERSON_DISABLED', `Person is disabled`)\n\t\t}\n\n\t\tconst passwordValid = await this.providers.bcryptCompare(password, personRow.password_hash)\n\n\t\tif (!passwordValid) {\n\t\t\treturn new ResponseError('INVALID_PASSWORD', `Password does not match`)\n\t\t}\n\n\t\tif (personRow.otp_uri && personRow.otp_activated_at) {\n\t\t\tif (!otpCode) {\n\t\t\t\treturn new ResponseError('OTP_REQUIRED', `2FA is enabled. OTP token is required`)\n\t\t\t}\n\n\t\t\tif (!this.otpAuthenticator.validate({ uri: personRow.otp_uri }, otpCode)) {\n\t\t\t\treturn new ResponseError('INVALID_OTP_TOKEN', 'OTP token validation has failed')\n\t\t\t}\n\t\t}\n\n\t\tconst sessionToken = await this.apiKeyManager.createSessionApiKey(dbContext, personRow.identity_id, expiration)\n\n\t\treturn new ResponseOk(new SignInResult(personRow, sessionToken))\n\t}\n\n\tasync createSessionToken(\n\t\tdbContext: DatabaseContext,\n\t\tpersonIdentifier: PersonUniqueIdentifier,\n\t\texpiration?: number,\n\t\tverifier?: (person: PersonRow) => Promise<void>,\n\t): Promise<CreateSessionTokenResponse> {\n\t\tconst personRow = await dbContext.queryHandler.fetch(PersonQuery.byUniqueIdentifier(personIdentifier))\n\n\t\tif (personRow === null) {\n\t\t\tif (personIdentifier.type === 'email') {\n\t\t\t\treturn new ResponseError('UNKNOWN_EMAIL', `Person with email ${personIdentifier.email} not found`)\n\n\t\t\t} else if (personIdentifier.type === 'id') {\n\t\t\t\treturn new ResponseError('UNKNOWN_PERSON_ID', `Person with id ${personIdentifier.id} not found`)\n\t\t\t}\n\n\t\t\tthrow new ImplementationException()\n\t\t}\n\n\t\tif (personRow.disabled_at !== null) {\n\t\t\treturn new ResponseError('PERSON_DISABLED', `Person with id ${personRow.id} is disabled`)\n\t\t}\n\n\t\tawait verifier?.(personRow)\n\n\t\tconst sessionToken = await this.apiKeyManager.createSessionApiKey(dbContext, personRow.identity_id, expiration)\n\t\treturn new ResponseOk(new SignInResult(personRow, sessionToken))\n\t}\n}\n\nexport class SignInResult {\n\tconstructor(\n\t\tpublic readonly person: PersonRow,\n\t\tpublic readonly token: string,\n\t) {}\n}\n\nexport type SignInResponse = Response<SignInResult, SignInErrorCode>\nexport type CreateSessionTokenResponse = Response<SignInResult, CreateSessionTokenEr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AAM;AACnB,UAAA,iBAAiB,SAAS,SAAS;AACtC,eAAO,IAAI,cAAc,iBAAiB,qBAAqB,iBAAiB,KAAK,YAAY;AAAA,MAAA,WAEvF,iBAAiB,SAAS,MAAM;AAC1C,eAAO,IAAI,cAAc,qBAAqB,kBAAkB,iBAAiB,EAAE,YAAY;AAAA,MAAA;AAGhG,YAAM,IAAI,wBAAwB;AAAA,IAAA;AAG/B,QAAA,UAAU,gBAAgB,MAAM;AACnC,aAAO,IAAI,cAAc,mBAAmB,kBAAkB,UAAU,EAAE,cAAc;AAAA,IAAA;AAGzF,UAAM,WAAW,SAAS;AAEpB,UAAA,eAAe,MAAM,KAAK,cAAc,oBAAoB,WAAW,UAAU,aAAa,UAAU;AAC9G,WAAO,IAAI,WAAW,IAAI,aAAa,WAAW,YAAY,CAAC;AAAA,EAAA;AAEjE;AAEO,MAAM,aAAa;AAAA,EACzB,YACiB,QACA,OACf;AAFe,SAAA,SAAA;AACA,SAAA,QAAA;AAAA,EAAA;AAElB;"}
1
+ {"version":3,"file":"SignInManager.js","sources":["../../../../../../packages/engine-tenant-api/src/model/service/SignInManager.ts"],"sourcesContent":["import { CreateSessionTokenErrorCode, SignInErrorCode } from '../../schema'\nimport { ApiKeyManager, OtpAuthenticator } from '../service'\nimport { PersonQuery, PersonRow, PersonUniqueIdentifier } from '../queries'\nimport { Providers } from '../providers'\nimport { DatabaseContext } from '../utils'\nimport { Response, ResponseError, ResponseOk } from '../utils/Response'\nimport { ImplementationException } from '../../exceptions'\nimport { AuthLogService } from './AuthLogService'\n\nclass SignInManager {\n\tconstructor(\n\t\tprivate readonly apiKeyManager: ApiKeyManager,\n\t\tprivate readonly providers: Providers,\n\t\tprivate readonly otpAuthenticator: OtpAuthenticator,\n\t) {}\n\n\tasync signIn(dbContext: DatabaseContext, email: string, password: string, expiration?: number, otpCode?: string): Promise<SignInResponse> {\n\t\tconst person = await dbContext.queryHandler.fetch(PersonQuery.byEmail(email))\n\n\t\tif (person === null) {\n\t\t\treturn new ResponseError('UNKNOWN_EMAIL', `Person with email ${email} not found`, {\n\t\t\t\t[AuthLogService.Key]: new AuthLogService.Bag({\n\t\t\t\t\tpersonInput: email,\n\t\t\t\t}),\n\t\t\t})\n\t\t}\n\n\t\tconst authLogData = {\n\t\t\t[AuthLogService.Key]: new AuthLogService.Bag({\n\t\t\t\tpersonInput: email,\n\t\t\t\tpersonId: person.id,\n\t\t\t}),\n\t\t}\n\t\tif (!person.password_hash) {\n\t\t\treturn new ResponseError('NO_PASSWORD_SET', `No password set`, authLogData)\n\t\t}\n\n\t\tif (person.disabled_at !== null) {\n\t\t\treturn new ResponseError('PERSON_DISABLED', `Person is disabled`, authLogData)\n\t\t}\n\n\t\tconst passwordValid = await this.providers.bcryptCompare(password, person.password_hash)\n\n\t\tif (!passwordValid) {\n\t\t\treturn new ResponseError('INVALID_PASSWORD', `Password does not match`, authLogData)\n\t\t}\n\n\t\tif (person.otp_uri && person.otp_activated_at) {\n\t\t\tif (!otpCode) {\n\t\t\t\treturn new ResponseError('OTP_REQUIRED', `2FA is enabled. OTP token is required`, authLogData)\n\t\t\t}\n\n\t\t\tif (!this.otpAuthenticator.validate({ uri: person.otp_uri }, otpCode)) {\n\t\t\t\treturn new ResponseError('INVALID_OTP_TOKEN', 'OTP token validation has failed', authLogData)\n\t\t\t}\n\t\t}\n\n\t\tconst sessionToken = await this.apiKeyManager.createSessionApiKey(dbContext, person.identity_id, expiration)\n\n\t\treturn new ResponseOk({ person, token: sessionToken, ...authLogData })\n\t}\n\n\tasync createSessionToken(\n\t\tdbContext: DatabaseContext,\n\t\tpersonIdentifier: PersonUniqueIdentifier,\n\t\texpiration?: number,\n\t\tverifier?: (person: PersonRow) => Promise<void>,\n\t): Promise<CreateSessionTokenResponse> {\n\t\tconst person = await dbContext.queryHandler.fetch(PersonQuery.byUniqueIdentifier(personIdentifier))\n\n\t\tif (person === null) {\n\t\t\tif (personIdentifier.type === 'email') {\n\t\t\t\treturn new ResponseError('UNKNOWN_EMAIL', `Person with email ${personIdentifier.email} not found`, {\n\t\t\t\t\t[AuthLogService.Key]: new AuthLogService.Bag({\n\t\t\t\t\t\tpersonInput: personIdentifier.email,\n\t\t\t\t\t}),\n\t\t\t\t})\n\n\t\t\t} else if (personIdentifier.type === 'id') {\n\t\t\t\treturn new ResponseError('UNKNOWN_PERSON_ID', `Person with id ${personIdentifier.id} not found`, {\n\t\t\t\t\t[AuthLogService.Key]: new AuthLogService.Bag({\n\t\t\t\t\t\tpersonInput: personIdentifier.id,\n\t\t\t\t\t}),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tthrow new ImplementationException()\n\t\t}\n\n\t\tconst inputValue = personIdentifier.type === 'email' ? personIdentifier.email : personIdentifier.id\n\t\tif (person.disabled_at !== null) {\n\t\t\treturn new ResponseError('PERSON_DISABLED', `Person with id ${person.id} is disabled`, {\n\t\t\t\t[AuthLogService.Key]: new AuthLogService.Bag({\n\t\t\t\t\tpersonId: person.id,\n\t\t\t\t\tpersonInput: inputValue,\n\t\t\t\t}),\n\t\t\t})\n\t\t}\n\n\t\tawait verifier?.(person)\n\n\t\tconst sessionToken = await this.apiKeyManager.createSessionApiKey(dbContext, person.identity_id, expiration)\n\t\treturn new ResponseOk({\n\t\t\tperson,\n\t\t\ttoken: sessionToken,\n\t\t\t[AuthLogService.Key]: new AuthLogService.Bag({\n\t\t\t\tpersonId: person.id,\n\t\t\t\tpersonInput: inputValue,\n\t\t\t}),\n\t\t})\n\t}\n}\n\nexport interface SignInResult {\n\treadonly person: PersonRow\n\treadonly token: string\n\t[AuthLogService.Key]: AuthLogService.Bag\n}\n\nexport type SignInResponse = Response<SignInResult, SignInErrorCode, {\n\t[AuthLogService.Key]: AuthLogService.Bag\n}>\nexport type CreateSessionTokenResponse = Response<SignInResult, CreateSessionTokenErrorCode, {\n\t[AuthLogService.Key]: AuthLogService.Bag\n}>\n\nexport { SignInManager }\n"],"names":[],"mappings":";;;;;;;;;;;AASA,MAAM,cAAc;AAAA,EACnB,Y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AAa;AAAA,MACb,CAAA;AAAA,IAAA,CACD;AAAA,EAAA;AAEH;"}
@@ -6,30 +6,35 @@ require("node:crypto");
6
6
  const Response = require("../utils/Response.cjs");
7
7
  const CreatePersonCommand = require("../commands/person/CreatePersonCommand.cjs");
8
8
  const CreateIdentityCommand = require("../commands/identity/CreateIdentityCommand.cjs");
9
+ require("../queries/apiKey/ApiKeyQuery.cjs");
10
+ const ConfigurationQuery = require("../queries/configuration/ConfigurationQuery.cjs");
9
11
  require("../authorization/PermissionActions.cjs");
10
12
  require("@contember/authorization");
11
13
  const Roles = require("../authorization/Roles.cjs");
12
14
  require("../authorization/PermissionContext.cjs");
13
15
  require("../authorization/PermissionsFactory.cjs");
14
16
  require("@contember/schema");
15
- const password = require("../utils/password.cjs");
16
17
  class SignUpManager {
17
- constructor(emailValidator) {
18
+ constructor(emailValidator, passwordStrengthValidator) {
18
19
  this.emailValidator = emailValidator;
20
+ this.passwordStrengthValidator = passwordStrengthValidator;
19
21
  }
20
- async signUp(dbContext, { email, password: password$1, roles = [] }) {
22
+ async signUp(dbContext, { email, password, roles = [] }) {
21
23
  const validationError = await this.emailValidator.validateEmail(dbContext, email);
22
24
  if (validationError !== null) {
23
25
  return validationError;
24
26
  }
25
- const plainPassword = password$1.getPlain();
26
- const weakPassword = plainPassword ? password.getPasswordWeaknessMessage(plainPassword) : null;
27
- if (weakPassword) {
28
- return new Response.ResponseError("TOO_WEAK", weakPassword);
27
+ const plainPassword = password.getPlain();
28
+ if (plainPassword) {
29
+ const config = await dbContext.queryHandler.fetch(new ConfigurationQuery.ConfigurationQuery());
30
+ const passwordVerifyResult = await this.passwordStrengthValidator.verify(plainPassword, config.password, "TOO_WEAK");
31
+ if (!passwordVerifyResult.ok) {
32
+ return passwordVerifyResult;
33
+ }
29
34
  }
30
35
  const person = await dbContext.transaction(async (db) => {
31
36
  const identityId = await db.commandBus.execute(new CreateIdentityCommand.CreateIdentityCommand([...roles, Roles.TenantRole.PERSON]));
32
- return await db.commandBus.execute(new CreatePersonCommand.CreatePersonCommand({ identityId, email, password: password$1 }));
37
+ return await db.commandBus.execute(new CreatePersonCommand.CreatePersonCommand({ identityId, email, password }));
33
38
  });
34
39
  return new Response.ResponseOk(new SignUpResult(person));
35
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SignUpManager.cjs","sources":["../../../../../../packages/engine-tenant-api/src/model/service/SignUpManager.ts"],"sourcesContent":["import { CreateIdentityCommand, CreatePersonCommand } from '../commands'\nimport { PersonQuery, PersonRow } from '../queries'\nimport { SignUpErrorCode } from '../../schema'\nimport { TenantRole } from '../authorization'\nimport { getPasswordWeaknessMessage } from '../utils/password'\nimport { Response, ResponseError, ResponseOk } from '../utils/Response'\nimport { DatabaseContext } from '../utils'\nimport { MaybePassword } from '../dtos'\nimport { EmailValidator } from './EmailValidator'\n\ntype SignUpUser = {\n\temail: string\n\tname?: string\n\tpassword: MaybePassword\n\troles?: readonly string[]\n}\n\nexport class SignUpManager {\n\tconstructor(\n\t\tprivate readonly emailValidator: EmailValidator,\n\t) {\n\t}\n\n\tasync signUp(dbContext: DatabaseContext, { email, password, roles = [] }: SignUpUser): Promise<SignUpResponse> {\n\t\tconst validationError = await this.emailValidator.validateEmail(dbContext, email)\n\t\tif (validationError !== null) {\n\t\t\treturn validationError\n\t\t}\n\t\tconst plainPassword = password.getPlain()\n\t\tconst weakPassword = plainPassword ? getPasswordWeaknessMessage(plainPassword) : null\n\t\tif (weakPassword) {\n\t\t\treturn new ResponseError('TOO_WEAK', weakPassword)\n\t\t}\n\t\tconst person = await dbContext.transaction(async db => {\n\t\t\tconst identityId = await db.commandBus.execute(new CreateIdentityCommand([...roles, TenantRole.PERSON]))\n\t\t\treturn await db.commandBus.execute(new CreatePersonCommand({ identityId, email, password }))\n\t\t})\n\t\treturn new ResponseOk(new SignUpResult(person))\n\t}\n}\n\nexport class SignUpResult {\n\tconstructor(public readonly person: Omit<PersonRow, 'roles'>) {}\n}\nexport type SignUpResponse = Response<SignUpResult, SignUpErrorCode>\n"],"names":["password","getPasswordWeaknessMessage","ResponseError","CreateIdentityCommand","TenantRole","CreatePersonCommand","ResponseOk"],"mappings":";;;;;;;;;;;;;;;AAiBO,MAAM,cAAc;AAAA,EAC1B,YACkB,gBAChB;AADgB,SAAA,iBAAA;AAAA,EAAA;AAAA,EAIlB,MAAM,OAAO,WAA4B,EAAE,OAAOA,UAAAA,YAAU,QAAQ,CAAA,KAA2C;AAC9G,UAAM,kBAAkB,MAAM,KAAK,eAAe,cAAc,WAAW,KAAK;AAChF,QAAI,oBAAoB,MAAM;AACtB,aAAA;AAAA,IAAA;AAEF,UAAA,gBAAgBA,WAAS,SAAS;AACxC,UAAM,eAAe,gBAAgBC,oCAA2B,aAAa,IAAI;AACjF,QAAI,cAAc;AACV,aAAA,IAAIC,SAAAA,cAAc,YAAY,YAAY;AAAA,IAAA;AAElD,UAAM,SAAS,MAAM,UAAU,YAAY,OAAM,OAAM;AACtD,YAAM,aAAa,MAAM,GAAG,WAAW,QAAQ,IAAIC,4CAAsB,CAAC,GAAG,OAAOC,iBAAW,MAAM,CAAC,CAAC;AAChG,aAAA,MAAM,GAAG,WAAW,QAAQ,IAAIC,wCAAoB,EAAE,YAAY,iBAAOL,WAAS,CAAC,CAAC;AAAA,IAAA,CAC3F;AACD,WAAO,IAAIM,SAAA,WAAW,IAAI,aAAa,MAAM,CAAC;AAAA,EAAA;AAEhD;AAEO,MAAM,aAAa;AAAA,EACzB,YAA4B,QAAkC;AAAlC,SAAA,SAAA;AAAA,EAAA;AAC7B;;;"}
1
+ {"version":3,"file":"SignUpManager.cjs","sources":["../../../../../../packages/engine-tenant-api/src/model/service/SignUpManager.ts"],"sourcesContent":["import { CreateIdentityCommand, CreatePersonCommand } from '../commands'\nimport { ConfigurationQuery, PersonRow } from '../queries'\nimport { SignUpErrorCode, WeakPasswordReason } from '../../schema'\nimport { TenantRole } from '../authorization'\nimport { Response, ResponseOk } from '../utils/Response'\nimport { DatabaseContext } from '../utils'\nimport { MaybePassword } from '../dtos'\nimport { EmailValidator } from './EmailValidator'\nimport { PasswordStrengthValidator } from './PasswordStrengthValidator'\n\ntype SignUpUser = {\n\temail: string\n\tname?: string\n\tpassword: MaybePassword\n\troles?: readonly string[]\n}\n\nexport class SignUpManager {\n\tconstructor(\n\t\tprivate readonly emailValidator: EmailValidator,\n\t\tprivate readonly passwordStrengthValidator: PasswordStrengthValidator,\n\t) {\n\t}\n\n\tasync signUp(dbContext: DatabaseContext, { email, password, roles = [] }: SignUpUser): Promise<SignUpResponse> {\n\t\tconst validationError = await this.emailValidator.validateEmail(dbContext, email)\n\t\tif (validationError !== null) {\n\t\t\treturn validationError\n\t\t}\n\t\tconst plainPassword = password.getPlain()\n\n\t\tif (plainPassword) {\n\t\t\tconst config = await dbContext.queryHandler.fetch(new ConfigurationQuery())\n\t\t\tconst passwordVerifyResult = await this.passwordStrengthValidator.verify(plainPassword, config.password, 'TOO_WEAK')\n\t\t\tif (!passwordVerifyResult.ok) {\n\t\t\t\treturn passwordVerifyResult\n\t\t\t}\n\t\t}\n\n\t\tconst person = await dbContext.transaction(async db => {\n\t\t\tconst identityId = await db.commandBus.execute(new CreateIdentityCommand([...roles, TenantRole.PERSON]))\n\t\t\treturn await db.commandBus.execute(new CreatePersonCommand({ identityId, email, password }))\n\t\t})\n\t\treturn new ResponseOk(new SignUpResult(person))\n\t}\n}\n\nexport class SignUpResult {\n\tconstructor(public readonly person: Omit<PersonRow, 'roles'>) {}\n}\nexport type SignUpResponse = Response<SignUpResult, SignUpErrorCode, {\n\tweakPasswordReasons?: WeakPasswordReason[]\n}>\n"],"names":["ConfigurationQuery","CreateIdentityCommand","TenantRole","CreatePersonCommand","ResponseOk"],"mappings":";;;;;;;;;;;;;;;;AAiBO,MAAM,cAAc;AAAA,EAC1B,YACkB,gBACA,2BAChB;AAFgB,SAAA,iBAAA;AACA,SAAA,4BAAA;AAAA,EAAA;AAAA,EAIlB,MAAM,OAAO,WAA4B,EAAE,OAAO,UAAU,QAAQ,CAAA,KAA2C;AAC9G,UAAM,kBAAkB,MAAM,KAAK,eAAe,cAAc,WAAW,KAAK;AAChF,QAAI,oBAAoB,MAAM;AACtB,aAAA;AAAA,IAAA;AAEF,UAAA,gBAAgB,SAAS,SAAS;AAExC,QAAI,eAAe;AAClB,YAAM,SAAS,MAAM,UAAU,aAAa,MAAM,IAAIA,mBAAAA,oBAAoB;AACpE,YAAA,uBAAuB,MAAM,KAAK,0BAA0B,OAAO,eAAe,OAAO,UAAU,UAAU;AAC/G,UAAA,CAAC,qBAAqB,IAAI;AACtB,eAAA;AAAA,MAAA;AAAA,IACR;AAGD,UAAM,SAAS,MAAM,UAAU,YAAY,OAAM,OAAM;AACtD,YAAM,aAAa,MAAM,GAAG,WAAW,QAAQ,IAAIC,4CAAsB,CAAC,GAAG,OAAOC,iBAAW,MAAM,CAAC,CAAC;AAChG,aAAA,MAAM,GAAG,WAAW,QAAQ,IAAIC,wCAAoB,EAAE,YAAY,OAAO,SAAS,CAAC,CAAC;AAAA,IAAA,CAC3F;AACD,WAAO,IAAIC,SAAA,WAAW,IAAI,aAAa,MAAM,CAAC;AAAA,EAAA;AAEhD;AAEO,MAAM,aAAa;AAAA,EACzB,YAA4B,QAAkC;AAAlC,SAAA,SAAA;AAAA,EAAA;AAC7B;;;"}
@@ -1,19 +1,21 @@
1
1
  import "../type/ApiKey.js";
2
2
  import "@contember/database";
3
3
  import "node:crypto";
4
- import { ResponseError, ResponseOk } from "../utils/Response.js";
4
+ import { ResponseOk } from "../utils/Response.js";
5
5
  import { CreatePersonCommand } from "../commands/person/CreatePersonCommand.js";
6
6
  import { CreateIdentityCommand } from "../commands/identity/CreateIdentityCommand.js";
7
+ import "../queries/apiKey/ApiKeyQuery.js";
8
+ import { ConfigurationQuery } from "../queries/configuration/ConfigurationQuery.js";
7
9
  import "../authorization/PermissionActions.js";
8
10
  import "@contember/authorization";
9
11
  import { TenantRole } from "../authorization/Roles.js";
10
12
  import "../authorization/PermissionContext.js";
11
13
  import "../authorization/PermissionsFactory.js";
12
14
  import "@contember/schema";
13
- import { getPasswordWeaknessMessage } from "../utils/password.js";
14
15
  class SignUpManager {
15
- constructor(emailValidator) {
16
+ constructor(emailValidator, passwordStrengthValidator) {
16
17
  this.emailValidator = emailValidator;
18
+ this.passwordStrengthValidator = passwordStrengthValidator;
17
19
  }
18
20
  async signUp(dbContext, { email, password, roles = [] }) {
19
21
  const validationError = await this.emailValidator.validateEmail(dbContext, email);
@@ -21,9 +23,12 @@ class SignUpManager {
21
23
  return validationError;
22
24
  }
23
25
  const plainPassword = password.getPlain();
24
- const weakPassword = plainPassword ? getPasswordWeaknessMessage(plainPassword) : null;
25
- if (weakPassword) {
26
- return new ResponseError("TOO_WEAK", weakPassword);
26
+ if (plainPassword) {
27
+ const config = await dbContext.queryHandler.fetch(new ConfigurationQuery());
28
+ const passwordVerifyResult = await this.passwordStrengthValidator.verify(plainPassword, config.password, "TOO_WEAK");
29
+ if (!passwordVerifyResult.ok) {
30
+ return passwordVerifyResult;
31
+ }
27
32
  }
28
33
  const person = await dbContext.transaction(async (db) => {
29
34
  const identityId = await db.commandBus.execute(new CreateIdentityCommand([...roles, TenantRole.PERSON]));
@@ -1 +1 @@
1
- {"version":3,"file":"SignUpManager.js","sources":["../../../../../../packages/engine-tenant-api/src/model/service/SignUpManager.ts"],"sourcesContent":["import { CreateIdentityCommand, CreatePersonCommand } from '../commands'\nimport { PersonQuery, PersonRow } from '../queries'\nimport { SignUpErrorCode } from '../../schema'\nimport { TenantRole } from '../authorization'\nimport { getPasswordWeaknessMessage } from '../utils/password'\nimport { Response, ResponseError, ResponseOk } from '../utils/Response'\nimport { DatabaseContext } from '../utils'\nimport { MaybePassword } from '../dtos'\nimport { EmailValidator } from './EmailValidator'\n\ntype SignUpUser = {\n\temail: string\n\tname?: string\n\tpassword: MaybePassword\n\troles?: readonly string[]\n}\n\nexport class SignUpManager {\n\tconstructor(\n\t\tprivate readonly emailValidator: EmailValidator,\n\t) {\n\t}\n\n\tasync signUp(dbContext: DatabaseContext, { email, password, roles = [] }: SignUpUser): Promise<SignUpResponse> {\n\t\tconst validationError = await this.emailValidator.validateEmail(dbContext, email)\n\t\tif (validationError !== null) {\n\t\t\treturn validationError\n\t\t}\n\t\tconst plainPassword = password.getPlain()\n\t\tconst weakPassword = plainPassword ? getPasswordWeaknessMessage(plainPassword) : null\n\t\tif (weakPassword) {\n\t\t\treturn new ResponseError('TOO_WEAK', weakPassword)\n\t\t}\n\t\tconst person = await dbContext.transaction(async db => {\n\t\t\tconst identityId = await db.commandBus.execute(new CreateIdentityCommand([...roles, TenantRole.PERSON]))\n\t\t\treturn await db.commandBus.execute(new CreatePersonCommand({ identityId, email, password }))\n\t\t})\n\t\treturn new ResponseOk(new SignUpResult(person))\n\t}\n}\n\nexport class SignUpResult {\n\tconstructor(public readonly person: Omit<PersonRow, 'roles'>) {}\n}\nexport type SignUpResponse = Response<SignUpResult, SignUpErrorCode>\n"],"names":[],"mappings":";;;;;;;;;;;;;AAiBO,MAAM,cAAc;AAAA,EAC1B,YACkB,gBAChB;AADgB,SAAA,iBAAA;AAAA,EAAA;AAAA,EAIlB,MAAM,OAAO,WAA4B,EAAE,OAAO,UAAU,QAAQ,CAAA,KAA2C;AAC9G,UAAM,kBAAkB,MAAM,KAAK,eAAe,cAAc,WAAW,KAAK;AAChF,QAAI,oBAAoB,MAAM;AACtB,aAAA;AAAA,IAAA;AAEF,UAAA,gBAAgB,SAAS,SAAS;AACxC,UAAM,eAAe,gBAAgB,2BAA2B,aAAa,IAAI;AACjF,QAAI,cAAc;AACV,aAAA,IAAI,cAAc,YAAY,YAAY;AAAA,IAAA;AAElD,UAAM,SAAS,MAAM,UAAU,YAAY,OAAM,OAAM;AACtD,YAAM,aAAa,MAAM,GAAG,WAAW,QAAQ,IAAI,sBAAsB,CAAC,GAAG,OAAO,WAAW,MAAM,CAAC,CAAC;AAChG,aAAA,MAAM,GAAG,WAAW,QAAQ,IAAI,oBAAoB,EAAE,YAAY,OAAO,SAAS,CAAC,CAAC;AAAA,IAAA,CAC3F;AACD,WAAO,IAAI,WAAW,IAAI,aAAa,MAAM,CAAC;AAAA,EAAA;AAEhD;AAEO,MAAM,aAAa;AAAA,EACzB,YAA4B,QAAkC;AAAlC,SAAA,SAAA;AAAA,EAAA;AAC7B;"}
1
+ {"version":3,"file":"SignUpManager.js","sources":["../../../../../../packages/engine-tenant-api/src/model/service/SignUpManager.ts"],"sourcesContent":["import { CreateIdentityCommand, CreatePersonCommand } from '../commands'\nimport { ConfigurationQuery, PersonRow } from '../queries'\nimport { SignUpErrorCode, WeakPasswordReason } from '../../schema'\nimport { TenantRole } from '../authorization'\nimport { Response, ResponseOk } from '../utils/Response'\nimport { DatabaseContext } from '../utils'\nimport { MaybePassword } from '../dtos'\nimport { EmailValidator } from './EmailValidator'\nimport { PasswordStrengthValidator } from './PasswordStrengthValidator'\n\ntype SignUpUser = {\n\temail: string\n\tname?: string\n\tpassword: MaybePassword\n\troles?: readonly string[]\n}\n\nexport class SignUpManager {\n\tconstructor(\n\t\tprivate readonly emailValidator: EmailValidator,\n\t\tprivate readonly passwordStrengthValidator: PasswordStrengthValidator,\n\t) {\n\t}\n\n\tasync signUp(dbContext: DatabaseContext, { email, password, roles = [] }: SignUpUser): Promise<SignUpResponse> {\n\t\tconst validationError = await this.emailValidator.validateEmail(dbContext, email)\n\t\tif (validationError !== null) {\n\t\t\treturn validationError\n\t\t}\n\t\tconst plainPassword = password.getPlain()\n\n\t\tif (plainPassword) {\n\t\t\tconst config = await dbContext.queryHandler.fetch(new ConfigurationQuery())\n\t\t\tconst passwordVerifyResult = await this.passwordStrengthValidator.verify(plainPassword, config.password, 'TOO_WEAK')\n\t\t\tif (!passwordVerifyResult.ok) {\n\t\t\t\treturn passwordVerifyResult\n\t\t\t}\n\t\t}\n\n\t\tconst person = await dbContext.transaction(async db => {\n\t\t\tconst identityId = await db.commandBus.execute(new CreateIdentityCommand([...roles, TenantRole.PERSON]))\n\t\t\treturn await db.commandBus.execute(new CreatePersonCommand({ identityId, email, password }))\n\t\t})\n\t\treturn new ResponseOk(new SignUpResult(person))\n\t}\n}\n\nexport class SignUpResult {\n\tconstructor(public readonly person: Omit<PersonRow, 'roles'>) {}\n}\nexport type SignUpResponse = Response<SignUpResult, SignUpErrorCode, {\n\tweakPasswordReasons?: WeakPasswordReason[]\n}>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAiBO,MAAM,cAAc;AAAA,EAC1B,YACkB,gBACA,2BAChB;AAFgB,SAAA,iBAAA;AACA,SAAA,4BAAA;AAAA,EAAA;AAAA,EAIlB,MAAM,OAAO,WAA4B,EAAE,OAAO,UAAU,QAAQ,CAAA,KAA2C;AAC9G,UAAM,kBAAkB,MAAM,KAAK,eAAe,cAAc,WAAW,KAAK;AAChF,QAAI,oBAAoB,MAAM;AACtB,aAAA;AAAA,IAAA;AAEF,UAAA,gBAAgB,SAAS,SAAS;AAExC,QAAI,eAAe;AAClB,YAAM,SAAS,MAAM,UAAU,aAAa,MAAM,IAAI,oBAAoB;AACpE,YAAA,uBAAuB,MAAM,KAAK,0BAA0B,OAAO,eAAe,OAAO,UAAU,UAAU;AAC/G,UAAA,CAAC,qBAAqB,IAAI;AACtB,eAAA;AAAA,MAAA;AAAA,IACR;AAGD,UAAM,SAAS,MAAM,UAAU,YAAY,OAAM,OAAM;AACtD,YAAM,aAAa,MAAM,GAAG,WAAW,QAAQ,IAAI,sBAAsB,CAAC,GAAG,OAAO,WAAW,MAAM,CAAC,CAAC;AAChG,aAAA,MAAM,GAAG,WAAW,QAAQ,IAAI,oBAAoB,EAAE,YAAY,OAAO,SAAS,CAAC,CAAC;AAAA,IAAA,CAC3F;AACD,WAAO,IAAI,WAAW,IAAI,aAAa,MAAM,CAAC;AAAA,EAAA;AAEhD;AAEO,MAAM,aAAa;AAAA,EACzB,YAA4B,QAAkC;AAAlC,SAAA,SAAA;AAAA,EAAA;AAC7B;"}
@@ -11,11 +11,13 @@ require("node:crypto");
11
11
  const ApiKey = require("../../type/ApiKey.cjs");
12
12
  const assert = require("node:assert");
13
13
  const ApiKeyQuery = require("../../queries/apiKey/ApiKeyQuery.cjs");
14
+ const ConfigurationQuery = require("../../queries/configuration/ConfigurationQuery.cjs");
14
15
  require("../../authorization/PermissionActions.cjs");
15
16
  require("@contember/authorization");
16
17
  require("../../authorization/PermissionContext.cjs");
17
18
  require("../../authorization/PermissionsFactory.cjs");
18
19
  require("@contember/schema");
20
+ const interval = require("../../utils/interval.cjs");
19
21
  var __defProp = Object.defineProperty;
20
22
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
21
23
  var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
@@ -51,7 +53,10 @@ class ApiKeyManager {
51
53
  return new Response.ResponseOk(new VerifyResult(apiKeyRow.identity_id, apiKeyRow.id, apiKeyRow.roles, apiKeyRow.person_id));
52
54
  }
53
55
  async createSessionApiKey(dbContext, identityId, expiration) {
54
- const command = new CreateApiKeyCommand.CreateApiKeyCommand({ type: ApiKey.ApiKey.Type.SESSION, identityId, expiration });
56
+ const config = await dbContext.queryHandler.fetch(new ConfigurationQuery.ConfigurationQuery());
57
+ const expirationResolved = expiration ?? interval.intervalToSeconds(config.login.defaultTokenExpiration) / 60;
58
+ const expirationCapped = config.login.maxTokenExpiration ? Math.min(expirationResolved, interval.intervalToSeconds(config.login.maxTokenExpiration) / 60) : expirationResolved;
59
+ const command = new CreateApiKeyCommand.CreateApiKeyCommand({ type: ApiKey.ApiKey.Type.SESSION, identityId, expiration: expirationCapped });
55
60
  const token = (await dbContext.commandBus.execute(command)).token;
56
61
  assert(token !== void 0);
57
62
  return token;
@@ -1 +1 @@
1
- {"version":3,"file":"ApiKeyManager.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/apiKey/ApiKeyManager.ts"],"sourcesContent":["import {\n\tCreateApiKeyCommand,\n\tDisableApiKeyCommand,\n\tDisableIdentityApiKeysCommand,\n\tDisableOneOffApiKeyCommand,\n\tProlongApiKeyCommand,\n} from '../../commands'\nimport { ApiKey } from '../../type'\n\nimport { Response, ResponseError, ResponseOk } from '../../utils/Response'\nimport { DatabaseContext, TokenHash } from '../../utils'\nimport { ApiKeyService, CreateApiKeyResponse } from './ApiKeyService'\nimport assert from 'node:assert'\nimport { Acl } from '@contember/schema'\nimport { ApiKeyByIdQuery, ApiKeyByTokenQuery, ApiKeyRow } from '../../queries'\n\nexport class ApiKeyManager {\n\tconstructor(\n\t\tprivate readonly apiKeyService: ApiKeyService,\n\t) {}\n\n\tasync verifyAndProlong(\n\t\tdbContext: DatabaseContext,\n\t\treadDbContext: DatabaseContext,\n\t\ttoken: string,\n\t): Promise<VerifyResponse> {\n\t\tconst apiKeyRow = await readDbContext.queryHandler.fetch(new ApiKeyByTokenQuery(token))\n\t\tif (apiKeyRow === null) {\n\t\t\treturn new ResponseError(VerifyErrorCode.NOT_FOUND, 'API key was not found')\n\t\t}\n\n\t\tif (apiKeyRow.disabled_at !== null) {\n\t\t\treturn new ResponseError(\n\t\t\t\tVerifyErrorCode.DISABLED,\n\t\t\t\t`API key was disabled at ${apiKeyRow.disabled_at.toISOString()}`,\n\t\t\t)\n\t\t}\n\n\t\tconst now = new Date()\n\t\tif (apiKeyRow.expires_at !== null && apiKeyRow.expires_at <= now) {\n\t\t\treturn new ResponseError(VerifyErrorCode.DISABLED, `API key expired at ${apiKeyRow.expires_at.toISOString()}`)\n\t\t}\n\n\t\tsetImmediate(async () => {\n\t\t\tawait dbContext.commandBus.execute(\n\t\t\t\tnew ProlongApiKeyCommand(\n\t\t\t\t\tapiKeyRow.id,\n\t\t\t\t\tapiKeyRow.type,\n\t\t\t\t\tapiKeyRow.expiration,\n\t\t\t\t\tapiKeyRow.expires_at,\n\t\t\t\t),\n\t\t\t)\n\t\t})\n\n\t\treturn new ResponseOk(new VerifyResult(apiKeyRow.identity_id, apiKeyRow.id, apiKeyRow.roles, apiKeyRow.person_id))\n\t}\n\n\tasync createSessionApiKey(dbContext: DatabaseContext, identityId: string, expiration?: number): Promise<string> {\n\t\tconst command = new CreateApiKeyCommand({ type: ApiKey.Type.SESSION, identityId, expiration })\n\t\tconst token = (await dbContext.commandBus.execute(command)).token\n\t\tassert(token !== undefined)\n\t\treturn token\n\t}\n\n\n\tasync findApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<ApiKeyRow | null> {\n\t\treturn await dbContext.queryHandler.fetch(\n\t\t\tnew ApiKeyByIdQuery(apiKeyId),\n\t\t)\n\t}\n\n\tasync disableOneOffApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableOneOffApiKeyCommand(apiKeyId))\n\t}\n\n\tasync disableApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<boolean> {\n\t\treturn await dbContext.commandBus.execute(new DisableApiKeyCommand(apiKeyId))\n\t}\n\n\tasync disableIdentityApiKeys(dbContext: DatabaseContext, identityId: string): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableIdentityApiKeysCommand(identityId))\n\t}\n\n\tasync createGlobalPermanentApiKey(\n\t\tdbContext: DatabaseContext,\n\t\tdescription: string,\n\t\troles: readonly string[],\n\t\ttokenHash?: TokenHash,\n\t): Promise<CreateApiKeyResponse> {\n\t\treturn await dbContext.transaction(async db => {\n\t\t\treturn await this.apiKeyService.createPermanentApiKey(db, description, roles, tokenHash)\n\t\t})\n\t}\n\n\tasync createProjectPermanentApiKey(\n\t\tdbContext: DatabaseContext,\n\t\tprojectId: string,\n\t\tmemberships: readonly Acl.Membership[],\n\t\tdescription: string,\n\t\ttokenHash?: TokenHash,\n\t): Promise<CreateApiKeyResponse> {\n\t\treturn await dbContext.transaction(async db => {\n\t\t\treturn await this.apiKeyService.createProjectPermanentApiKey(db, projectId, memberships, description, tokenHash)\n\t\t})\n\t}\n\n}\n\nexport type VerifyResponse = Response<VerifyResult, VerifyErrorCode>\n\nexport class VerifyResult {\n\treadonly valid = true\n\n\tconstructor(\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly apiKeyId: string,\n\t\tpublic readonly roles: string[],\n\t\tpublic readonly personId: string | null,\n\t) {}\n}\n\nexport const enum VerifyErrorCode {\n\tNOT_FOUND = 'not_found',\n\tDISABLED = 'disabled',\n\tEXPIRED = 'expired',\n\tNO_AUTH_HEADER = 'no_auth_header',\n\tINVALID_AUTH_HEADER = 'invalid_auth_header',\n}\n"],"names":["ApiKeyByTokenQuery","ResponseError","ProlongApiKeyCommand","ResponseOk","CreateApiKeyCommand","ApiKey","ApiKeyByIdQuery","DisableOneOffApiKeyCommand","DisableApiKeyCommand","DisableIdentityApiKeysCommand","VerifyErrorCode"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBO,MAAM,cAAc;AAAA,EAC1B,YACkB,eAChB;AADgB,SAAA,gBAAA;AAAA,EAAA;AAAA,EAGlB,MAAM,iBACL,WACA,eACA,OAC0B;AACpB,UAAA,YAAY,MAAM,cAAc,aAAa,MAAM,IAAIA,YAAAA,mBAAmB,KAAK,CAAC;AACtF,QAAI,cAAc,MAAM;AAChB,aAAA,IAAIC,SAAAA,cAAc,aAA2B,uBAAuB;AAAA,IAAA;AAGxE,QAAA,UAAU,gBAAgB,MAAM;AACnC,aAAO,IAAIA,SAAA;AAAA,QACV;AAAA,QACA,2BAA2B,UAAU,YAAY,YAAA,CAAa;AAAA,MAC/D;AAAA,IAAA;AAGK,UAAA,0BAAU,KAAK;AACrB,QAAI,UAAU,eAAe,QAAQ,UAAU,cAAc,KAAK;AAC1D,aAAA,IAAIA,SAAAA,cAAc,YAA0B,sBAAsB,UAAU,WAAW,YAAa,CAAA,EAAE;AAAA,IAAA;AAG9G,iBAAa,YAAY;AACxB,YAAM,UAAU,WAAW;AAAA,QAC1B,IAAIC,qBAAA;AAAA,UACH,UAAU;AAAA,UACV,UAAU;AAAA,UACV,UAAU;AAAA,UACV,UAAU;AAAA,QAAA;AAAA,MAEZ;AAAA,IAAA,CACA;AAED,WA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a;AAAA,EAGzB,YACiB,YACA,UACA,OACA,UACf;AAJe,SAAA,aAAA;AACA,SAAA,WAAA;AACA,SAAA,QAAA;AACA,SAAA,WAAA;AANjB,kBAAA,MAAS,SAAQ,IAAA;AAAA,EAAA;AAQlB;AAEkB,IAAA,oCAAAC,qBAAX;AACNA,mBAAA,WAAY,IAAA;AACZA,mBAAA,UAAW,IAAA;AACXA,mBAAA,SAAU,IAAA;AACVA,mBAAA,gBAAiB,IAAA;AACjBA,mBAAA,qBAAsB,IAAA;AALLA,SAAAA;AAAA,GAAA,mBAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"ApiKeyManager.cjs","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/apiKey/ApiKeyManager.ts"],"sourcesContent":["import {\n\tCreateApiKeyCommand,\n\tDisableApiKeyCommand,\n\tDisableIdentityApiKeysCommand,\n\tDisableOneOffApiKeyCommand,\n\tProlongApiKeyCommand,\n} from '../../commands'\nimport { ApiKey } from '../../type'\n\nimport { Response, ResponseError, ResponseOk } from '../../utils/Response'\nimport { DatabaseContext, TokenHash } from '../../utils'\nimport { ApiKeyService, CreateApiKeyResponse } from './ApiKeyService'\nimport assert from 'node:assert'\nimport { Acl } from '@contember/schema'\nimport { ApiKeyByIdQuery, ApiKeyByTokenQuery, ApiKeyRow, ConfigurationQuery } from '../../queries'\nimport PostgresInterval from 'postgres-interval'\nimport { Config } from '../../type/Config'\nimport { intervalToSeconds } from '../../utils/interval'\n\nexport class ApiKeyManager {\n\tconstructor(\n\t\tprivate readonly apiKeyService: ApiKeyService,\n\t) {}\n\n\tasync verifyAndProlong(\n\t\tdbContext: DatabaseContext,\n\t\treadDbContext: DatabaseContext,\n\t\ttoken: string,\n\t): Promise<VerifyResponse> {\n\t\tconst apiKeyRow = await readDbContext.queryHandler.fetch(new ApiKeyByTokenQuery(token))\n\t\tif (apiKeyRow === null) {\n\t\t\treturn new ResponseError(VerifyErrorCode.NOT_FOUND, 'API key was not found')\n\t\t}\n\n\t\tif (apiKeyRow.disabled_at !== null) {\n\t\t\treturn new ResponseError(\n\t\t\t\tVerifyErrorCode.DISABLED,\n\t\t\t\t`API key was disabled at ${apiKeyRow.disabled_at.toISOString()}`,\n\t\t\t)\n\t\t}\n\n\t\tconst now = new Date()\n\t\tif (apiKeyRow.expires_at !== null && apiKeyRow.expires_at <= now) {\n\t\t\treturn new ResponseError(VerifyErrorCode.DISABLED, `API key expired at ${apiKeyRow.expires_at.toISOString()}`)\n\t\t}\n\n\t\tsetImmediate(async () => {\n\t\t\tawait dbContext.commandBus.execute(\n\t\t\t\tnew ProlongApiKeyCommand(\n\t\t\t\t\tapiKeyRow.id,\n\t\t\t\t\tapiKeyRow.type,\n\t\t\t\t\tapiKeyRow.expiration,\n\t\t\t\t\tapiKeyRow.expires_at,\n\t\t\t\t),\n\t\t\t)\n\t\t})\n\n\t\treturn new ResponseOk(new VerifyResult(apiKeyRow.identity_id, apiKeyRow.id, apiKeyRow.roles, apiKeyRow.person_id))\n\t}\n\n\tasync createSessionApiKey(dbContext: DatabaseContext, identityId: string, expiration?: number): Promise<string> {\n\t\tconst config = await dbContext.queryHandler.fetch(new ConfigurationQuery())\n\t\tconst expirationResolved = expiration ?? (intervalToSeconds(config.login.defaultTokenExpiration) / 60)\n\t\tconst expirationCapped = config.login.maxTokenExpiration ? Math.min(expirationResolved, intervalToSeconds(config.login.maxTokenExpiration) / 60) : expirationResolved\n\t\tconst command = new CreateApiKeyCommand({ type: ApiKey.Type.SESSION, identityId, expiration: expirationCapped })\n\t\tconst token = (await dbContext.commandBus.execute(command)).token\n\t\tassert(token !== undefined)\n\t\treturn token\n\t}\n\n\n\tasync findApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<ApiKeyRow | null> {\n\t\treturn await dbContext.queryHandler.fetch(\n\t\t\tnew ApiKeyByIdQuery(apiKeyId),\n\t\t)\n\t}\n\n\tasync disableOneOffApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableOneOffApiKeyCommand(apiKeyId))\n\t}\n\n\tasync disableApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<boolean> {\n\t\treturn await dbContext.commandBus.execute(new DisableApiKeyCommand(apiKeyId))\n\t}\n\n\tasync disableIdentityApiKeys(dbContext: DatabaseContext, identityId: string): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableIdentityApiKeysCommand(identityId))\n\t}\n\n\tasync createGlobalPermanentApiKey(\n\t\tdbContext: DatabaseContext,\n\t\tdescription: string,\n\t\troles: readonly string[],\n\t\ttokenHash?: TokenHash,\n\t): Promise<CreateApiKeyResponse> {\n\t\treturn await dbContext.transaction(async db => {\n\t\t\treturn await this.apiKeyService.createPermanentApiKey(db, description, roles, tokenHash)\n\t\t})\n\t}\n\n\tasync createProjectPermanentApiKey(\n\t\tdbContext: DatabaseContext,\n\t\tprojectId: string,\n\t\tmemberships: readonly Acl.Membership[],\n\t\tdescription: string,\n\t\ttokenHash?: TokenHash,\n\t): Promise<CreateApiKeyResponse> {\n\t\treturn await dbContext.transaction(async db => {\n\t\t\treturn await this.apiKeyService.createProjectPermanentApiKey(db, projectId, memberships, description, tokenHash)\n\t\t})\n\t}\n\n}\n\nexport type VerifyResponse = Response<VerifyResult, VerifyErrorCode>\n\nexport class VerifyResult {\n\treadonly valid = true\n\n\tconstructor(\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly apiKeyId: string,\n\t\tpublic readonly roles: string[],\n\t\tpublic readonly personId: string | null,\n\t) {}\n}\n\nexport const enum VerifyErrorCode {\n\tNOT_FOUND = 'not_found',\n\tDISABLED = 'disabled',\n\tEXPIRED = 'expired',\n\tNO_AUTH_HEADER = 'no_auth_header',\n\tINVALID_AUTH_HEADER = 'invalid_auth_header',\n}\n"],"names":["ApiKeyByTokenQuery","ResponseError","ProlongApiKeyCommand","ResponseOk","ConfigurationQuery","intervalToSeconds","CreateApiKeyCommand","ApiKey","ApiKeyByIdQuery","DisableOneOffApiKey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AA;AANjB,kBAAA,MAAS,SAAQ,IAAA;AAAA,EAAA;AAQlB;AAEkB,IAAA,oCAAAC,qBAAX;AACNA,mBAAA,WAAY,IAAA;AACZA,mBAAA,UAAW,IAAA;AACXA,mBAAA,SAAU,IAAA;AACVA,mBAAA,gBAAiB,IAAA;AACjBA,mBAAA,qBAAsB,IAAA;AALLA,SAAAA;AAAA,GAAA,mBAAA,CAAA,CAAA;;;;"}
@@ -9,11 +9,13 @@ import "node:crypto";
9
9
  import { ApiKey } from "../../type/ApiKey.js";
10
10
  import assert from "node:assert";
11
11
  import { ApiKeyByTokenQuery, ApiKeyByIdQuery } from "../../queries/apiKey/ApiKeyQuery.js";
12
+ import { ConfigurationQuery } from "../../queries/configuration/ConfigurationQuery.js";
12
13
  import "../../authorization/PermissionActions.js";
13
14
  import "@contember/authorization";
14
15
  import "../../authorization/PermissionContext.js";
15
16
  import "../../authorization/PermissionsFactory.js";
16
17
  import "@contember/schema";
18
+ import { intervalToSeconds } from "../../utils/interval.js";
17
19
  var __defProp = Object.defineProperty;
18
20
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
19
21
  var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
@@ -49,7 +51,10 @@ class ApiKeyManager {
49
51
  return new ResponseOk(new VerifyResult(apiKeyRow.identity_id, apiKeyRow.id, apiKeyRow.roles, apiKeyRow.person_id));
50
52
  }
51
53
  async createSessionApiKey(dbContext, identityId, expiration) {
52
- const command = new CreateApiKeyCommand({ type: ApiKey.Type.SESSION, identityId, expiration });
54
+ const config = await dbContext.queryHandler.fetch(new ConfigurationQuery());
55
+ const expirationResolved = expiration ?? intervalToSeconds(config.login.defaultTokenExpiration) / 60;
56
+ const expirationCapped = config.login.maxTokenExpiration ? Math.min(expirationResolved, intervalToSeconds(config.login.maxTokenExpiration) / 60) : expirationResolved;
57
+ const command = new CreateApiKeyCommand({ type: ApiKey.Type.SESSION, identityId, expiration: expirationCapped });
53
58
  const token = (await dbContext.commandBus.execute(command)).token;
54
59
  assert(token !== void 0);
55
60
  return token;
@@ -1 +1 @@
1
- {"version":3,"file":"ApiKeyManager.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/apiKey/ApiKeyManager.ts"],"sourcesContent":["import {\n\tCreateApiKeyCommand,\n\tDisableApiKeyCommand,\n\tDisableIdentityApiKeysCommand,\n\tDisableOneOffApiKeyCommand,\n\tProlongApiKeyCommand,\n} from '../../commands'\nimport { ApiKey } from '../../type'\n\nimport { Response, ResponseError, ResponseOk } from '../../utils/Response'\nimport { DatabaseContext, TokenHash } from '../../utils'\nimport { ApiKeyService, CreateApiKeyResponse } from './ApiKeyService'\nimport assert from 'node:assert'\nimport { Acl } from '@contember/schema'\nimport { ApiKeyByIdQuery, ApiKeyByTokenQuery, ApiKeyRow } from '../../queries'\n\nexport class ApiKeyManager {\n\tconstructor(\n\t\tprivate readonly apiKeyService: ApiKeyService,\n\t) {}\n\n\tasync verifyAndProlong(\n\t\tdbContext: DatabaseContext,\n\t\treadDbContext: DatabaseContext,\n\t\ttoken: string,\n\t): Promise<VerifyResponse> {\n\t\tconst apiKeyRow = await readDbContext.queryHandler.fetch(new ApiKeyByTokenQuery(token))\n\t\tif (apiKeyRow === null) {\n\t\t\treturn new ResponseError(VerifyErrorCode.NOT_FOUND, 'API key was not found')\n\t\t}\n\n\t\tif (apiKeyRow.disabled_at !== null) {\n\t\t\treturn new ResponseError(\n\t\t\t\tVerifyErrorCode.DISABLED,\n\t\t\t\t`API key was disabled at ${apiKeyRow.disabled_at.toISOString()}`,\n\t\t\t)\n\t\t}\n\n\t\tconst now = new Date()\n\t\tif (apiKeyRow.expires_at !== null && apiKeyRow.expires_at <= now) {\n\t\t\treturn new ResponseError(VerifyErrorCode.DISABLED, `API key expired at ${apiKeyRow.expires_at.toISOString()}`)\n\t\t}\n\n\t\tsetImmediate(async () => {\n\t\t\tawait dbContext.commandBus.execute(\n\t\t\t\tnew ProlongApiKeyCommand(\n\t\t\t\t\tapiKeyRow.id,\n\t\t\t\t\tapiKeyRow.type,\n\t\t\t\t\tapiKeyRow.expiration,\n\t\t\t\t\tapiKeyRow.expires_at,\n\t\t\t\t),\n\t\t\t)\n\t\t})\n\n\t\treturn new ResponseOk(new VerifyResult(apiKeyRow.identity_id, apiKeyRow.id, apiKeyRow.roles, apiKeyRow.person_id))\n\t}\n\n\tasync createSessionApiKey(dbContext: DatabaseContext, identityId: string, expiration?: number): Promise<string> {\n\t\tconst command = new CreateApiKeyCommand({ type: ApiKey.Type.SESSION, identityId, expiration })\n\t\tconst token = (await dbContext.commandBus.execute(command)).token\n\t\tassert(token !== undefined)\n\t\treturn token\n\t}\n\n\n\tasync findApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<ApiKeyRow | null> {\n\t\treturn await dbContext.queryHandler.fetch(\n\t\t\tnew ApiKeyByIdQuery(apiKeyId),\n\t\t)\n\t}\n\n\tasync disableOneOffApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableOneOffApiKeyCommand(apiKeyId))\n\t}\n\n\tasync disableApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<boolean> {\n\t\treturn await dbContext.commandBus.execute(new DisableApiKeyCommand(apiKeyId))\n\t}\n\n\tasync disableIdentityApiKeys(dbContext: DatabaseContext, identityId: string): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableIdentityApiKeysCommand(identityId))\n\t}\n\n\tasync createGlobalPermanentApiKey(\n\t\tdbContext: DatabaseContext,\n\t\tdescription: string,\n\t\troles: readonly string[],\n\t\ttokenHash?: TokenHash,\n\t): Promise<CreateApiKeyResponse> {\n\t\treturn await dbContext.transaction(async db => {\n\t\t\treturn await this.apiKeyService.createPermanentApiKey(db, description, roles, tokenHash)\n\t\t})\n\t}\n\n\tasync createProjectPermanentApiKey(\n\t\tdbContext: DatabaseContext,\n\t\tprojectId: string,\n\t\tmemberships: readonly Acl.Membership[],\n\t\tdescription: string,\n\t\ttokenHash?: TokenHash,\n\t): Promise<CreateApiKeyResponse> {\n\t\treturn await dbContext.transaction(async db => {\n\t\t\treturn await this.apiKeyService.createProjectPermanentApiKey(db, projectId, memberships, description, tokenHash)\n\t\t})\n\t}\n\n}\n\nexport type VerifyResponse = Response<VerifyResult, VerifyErrorCode>\n\nexport class VerifyResult {\n\treadonly valid = true\n\n\tconstructor(\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly apiKeyId: string,\n\t\tpublic readonly roles: string[],\n\t\tpublic readonly personId: string | null,\n\t) {}\n}\n\nexport const enum VerifyErrorCode {\n\tNOT_FOUND = 'not_found',\n\tDISABLED = 'disabled',\n\tEXPIRED = 'expired',\n\tNO_AUTH_HEADER = 'no_auth_header',\n\tINVALID_AUTH_HEADER = 'invalid_auth_header',\n}\n"],"names":["VerifyErrorCode"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBO,MAAM,cAAc;AAAA,EAC1B,YACkB,eAChB;AADgB,SAAA,gBAAA;AAAA,EAAA;AAAA,EAGlB,MAAM,iBACL,WACA,eACA,OAC0B;AACpB,UAAA,YAAY,MAAM,cAAc,aAAa,MAAM,IAAI,mBAAmB,KAAK,CAAC;AACtF,QAAI,cAAc,MAAM;AAChB,aAAA,IAAI,cAAc,aAA2B,uBAAuB;AAAA,IAAA;AAGxE,QAAA,UAAU,gBAAgB,MAAM;AACnC,aAAO,IAAI;AAAA,QACV;AAAA,QACA,2BAA2B,UAAU,YAAY,YAAA,CAAa;AAAA,MAC/D;AAAA,IAAA;AAGK,UAAA,0BAAU,KAAK;AACrB,QAAI,UAAU,eAAe,QAAQ,UAAU,cAAc,KAAK;AAC1D,aAAA,IAAI,cAAc,YAA0B,sBAAsB,UAAU,WAAW,YAAa,CAAA,EAAE;AAAA,IAAA;AAG9G,iBAAa,YAAY;AACxB,YAAM,UAAU,WAAW;AAAA,QAC1B,IAAI;AAAA,UACH,UAAU;AAAA,UACV,UAAU;AAA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;AAAA,EAAA;AAGH;AAIO,MAAM,aAAa;AAAA,EAGzB,YACiB,YACA,UACA,OACA,UACf;AAJe,SAAA,aAAA;AACA,SAAA,WAAA;AACA,SAAA,QAAA;AACA,SAAA,WAAA;AANjB,kBAAA,MAAS,SAAQ,IAAA;AAAA,EAAA;AAQlB;AAEkB,IAAA,oCAAAA,qBAAX;AACNA,mBAAA,WAAY,IAAA;AACZA,mBAAA,UAAW,IAAA;AACXA,mBAAA,SAAU,IAAA;AACVA,mBAAA,gBAAiB,IAAA;AACjBA,mBAAA,qBAAsB,IAAA;AALLA,SAAAA;AAAA,GAAA,mBAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"ApiKeyManager.js","sources":["../../../../../../../packages/engine-tenant-api/src/model/service/apiKey/ApiKeyManager.ts"],"sourcesContent":["import {\n\tCreateApiKeyCommand,\n\tDisableApiKeyCommand,\n\tDisableIdentityApiKeysCommand,\n\tDisableOneOffApiKeyCommand,\n\tProlongApiKeyCommand,\n} from '../../commands'\nimport { ApiKey } from '../../type'\n\nimport { Response, ResponseError, ResponseOk } from '../../utils/Response'\nimport { DatabaseContext, TokenHash } from '../../utils'\nimport { ApiKeyService, CreateApiKeyResponse } from './ApiKeyService'\nimport assert from 'node:assert'\nimport { Acl } from '@contember/schema'\nimport { ApiKeyByIdQuery, ApiKeyByTokenQuery, ApiKeyRow, ConfigurationQuery } from '../../queries'\nimport PostgresInterval from 'postgres-interval'\nimport { Config } from '../../type/Config'\nimport { intervalToSeconds } from '../../utils/interval'\n\nexport class ApiKeyManager {\n\tconstructor(\n\t\tprivate readonly apiKeyService: ApiKeyService,\n\t) {}\n\n\tasync verifyAndProlong(\n\t\tdbContext: DatabaseContext,\n\t\treadDbContext: DatabaseContext,\n\t\ttoken: string,\n\t): Promise<VerifyResponse> {\n\t\tconst apiKeyRow = await readDbContext.queryHandler.fetch(new ApiKeyByTokenQuery(token))\n\t\tif (apiKeyRow === null) {\n\t\t\treturn new ResponseError(VerifyErrorCode.NOT_FOUND, 'API key was not found')\n\t\t}\n\n\t\tif (apiKeyRow.disabled_at !== null) {\n\t\t\treturn new ResponseError(\n\t\t\t\tVerifyErrorCode.DISABLED,\n\t\t\t\t`API key was disabled at ${apiKeyRow.disabled_at.toISOString()}`,\n\t\t\t)\n\t\t}\n\n\t\tconst now = new Date()\n\t\tif (apiKeyRow.expires_at !== null && apiKeyRow.expires_at <= now) {\n\t\t\treturn new ResponseError(VerifyErrorCode.DISABLED, `API key expired at ${apiKeyRow.expires_at.toISOString()}`)\n\t\t}\n\n\t\tsetImmediate(async () => {\n\t\t\tawait dbContext.commandBus.execute(\n\t\t\t\tnew ProlongApiKeyCommand(\n\t\t\t\t\tapiKeyRow.id,\n\t\t\t\t\tapiKeyRow.type,\n\t\t\t\t\tapiKeyRow.expiration,\n\t\t\t\t\tapiKeyRow.expires_at,\n\t\t\t\t),\n\t\t\t)\n\t\t})\n\n\t\treturn new ResponseOk(new VerifyResult(apiKeyRow.identity_id, apiKeyRow.id, apiKeyRow.roles, apiKeyRow.person_id))\n\t}\n\n\tasync createSessionApiKey(dbContext: DatabaseContext, identityId: string, expiration?: number): Promise<string> {\n\t\tconst config = await dbContext.queryHandler.fetch(new ConfigurationQuery())\n\t\tconst expirationResolved = expiration ?? (intervalToSeconds(config.login.defaultTokenExpiration) / 60)\n\t\tconst expirationCapped = config.login.maxTokenExpiration ? Math.min(expirationResolved, intervalToSeconds(config.login.maxTokenExpiration) / 60) : expirationResolved\n\t\tconst command = new CreateApiKeyCommand({ type: ApiKey.Type.SESSION, identityId, expiration: expirationCapped })\n\t\tconst token = (await dbContext.commandBus.execute(command)).token\n\t\tassert(token !== undefined)\n\t\treturn token\n\t}\n\n\n\tasync findApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<ApiKeyRow | null> {\n\t\treturn await dbContext.queryHandler.fetch(\n\t\t\tnew ApiKeyByIdQuery(apiKeyId),\n\t\t)\n\t}\n\n\tasync disableOneOffApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableOneOffApiKeyCommand(apiKeyId))\n\t}\n\n\tasync disableApiKey(dbContext: DatabaseContext, apiKeyId: string): Promise<boolean> {\n\t\treturn await dbContext.commandBus.execute(new DisableApiKeyCommand(apiKeyId))\n\t}\n\n\tasync disableIdentityApiKeys(dbContext: DatabaseContext, identityId: string): Promise<void> {\n\t\tawait dbContext.commandBus.execute(new DisableIdentityApiKeysCommand(identityId))\n\t}\n\n\tasync createGlobalPermanentApiKey(\n\t\tdbContext: DatabaseContext,\n\t\tdescription: string,\n\t\troles: readonly string[],\n\t\ttokenHash?: TokenHash,\n\t): Promise<CreateApiKeyResponse> {\n\t\treturn await dbContext.transaction(async db => {\n\t\t\treturn await this.apiKeyService.createPermanentApiKey(db, description, roles, tokenHash)\n\t\t})\n\t}\n\n\tasync createProjectPermanentApiKey(\n\t\tdbContext: DatabaseContext,\n\t\tprojectId: string,\n\t\tmemberships: readonly Acl.Membership[],\n\t\tdescription: string,\n\t\ttokenHash?: TokenHash,\n\t): Promise<CreateApiKeyResponse> {\n\t\treturn await dbContext.transaction(async db => {\n\t\t\treturn await this.apiKeyService.createProjectPermanentApiKey(db, projectId, memberships, description, tokenHash)\n\t\t})\n\t}\n\n}\n\nexport type VerifyResponse = Response<VerifyResult, VerifyErrorCode>\n\nexport class VerifyResult {\n\treadonly valid = true\n\n\tconstructor(\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly apiKeyId: string,\n\t\tpublic readonly roles: string[],\n\t\tpublic readonly personId: string | null,\n\t) {}\n}\n\nexport const enum VerifyErrorCode {\n\tNOT_FOUND = 'not_found',\n\tDISABLED = 'disabled',\n\tEXPIRED = 'expired',\n\tNO_AUTH_HEADER = 'no_auth_header',\n\tINVALID_AUTH_HEADER = 'invalid_auth_header',\n}\n"],"names":["VerifyErrorCode"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmBO,MAAM,cAAc;AAAA,EAC1B,YACkB,eAChB;AADgB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AAA,CAAA,CAAA;"}
@@ -10,9 +10,10 @@ class ResponseOk {
10
10
  }
11
11
  }
12
12
  class ResponseError {
13
- constructor(error, errorMessage) {
13
+ constructor(error, errorMessage, metadata) {
14
14
  this.error = error;
15
15
  this.errorMessage = errorMessage;
16
+ this.metadata = metadata;
16
17
  __publicField(this, "ok", false);
17
18
  }
18
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Response.cjs","sources":["../../../../../../packages/engine-tenant-api/src/model/utils/Response.ts"],"sourcesContent":["export type Response<Result, Error> = ResponseOk<Result> | (Error extends never ? never : ResponseError<Error>)\n\nexport class ResponseOk<Result> {\n\tpublic readonly ok = true\n\n\tconstructor(public readonly result: Result) {}\n}\n\nexport class ResponseError<const Error> {\n\tpublic readonly ok = false\n\n\tconstructor(public readonly error: Error, public readonly errorMessage: string) {}\n}\n"],"names":[],"mappings":";;;;;AAEO,MAAM,WAAmB;AAAA,EAG/B,YAA4B,QAAgB;AAAhB,SAAA,SAAA;AAF5B,kBAAA,MAAgB,MAAK,IAAA;AAAA,EAAA;AAGtB;AAEO,MAAM,cAA2B;AAAA,EAGvC,YAA4B,OAA8B,cAAsB;AAApD,SAAA,QAAA;AAA8B,SAAA,eAAA;AAF1D,kBAAA,MAAgB,MAAK,KAAA;AAAA,EAAA;AAGtB;;;"}
1
+ {"version":3,"file":"Response.cjs","sources":["../../../../../../packages/engine-tenant-api/src/model/utils/Response.ts"],"sourcesContent":["export type Response<Result, Error, ErrorMetadata extends {} | undefined = undefined> =\n\t| ResponseOk<Result>\n\t| (Error extends never ? never : ResponseError<Error, ErrorMetadata>)\n\nexport class ResponseOk<Result> {\n\tpublic readonly ok = true\n\n\tconstructor(public readonly result: Result) {}\n}\n\nexport class ResponseError<const Error, Metadata extends {} | undefined = undefined> {\n\tpublic readonly ok = false\n\n\tconstructor(\n\t\tpublic readonly error: Error,\n\t\tpublic readonly errorMessage: string,\n\t\tpublic readonly metadata?: Metadata,\n\t) {}\n}\n\n"],"names":[],"mappings":";;;;;AAIO,MAAM,WAAmB;AAAA,EAG/B,YAA4B,QAAgB;AAAhB,SAAA,SAAA;AAF5B,kBAAA,MAAgB,MAAK,IAAA;AAAA,EAAA;AAGtB;AAEO,MAAM,cAAwE;AAAA,EAGpF,YACiB,OACA,cACA,UACf;AAHe,SAAA,QAAA;AACA,SAAA,eAAA;AACA,SAAA,WAAA;AALjB,kBAAA,MAAgB,MAAK,KAAA;AAAA,EAAA;AAOtB;;;"}
@@ -8,9 +8,10 @@ class ResponseOk {
8
8
  }
9
9
  }
10
10
  class ResponseError {
11
- constructor(error, errorMessage) {
11
+ constructor(error, errorMessage, metadata) {
12
12
  this.error = error;
13
13
  this.errorMessage = errorMessage;
14
+ this.metadata = metadata;
14
15
  __publicField(this, "ok", false);
15
16
  }
16
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Response.js","sources":["../../../../../../packages/engine-tenant-api/src/model/utils/Response.ts"],"sourcesContent":["export type Response<Result, Error> = ResponseOk<Result> | (Error extends never ? never : ResponseError<Error>)\n\nexport class ResponseOk<Result> {\n\tpublic readonly ok = true\n\n\tconstructor(public readonly result: Result) {}\n}\n\nexport class ResponseError<const Error> {\n\tpublic readonly ok = false\n\n\tconstructor(public readonly error: Error, public readonly errorMessage: string) {}\n}\n"],"names":[],"mappings":";;;AAEO,MAAM,WAAmB;AAAA,EAG/B,YAA4B,QAAgB;AAAhB,SAAA,SAAA;AAF5B,kBAAA,MAAgB,MAAK,IAAA;AAAA,EAAA;AAGtB;AAEO,MAAM,cAA2B;AAAA,EAGvC,YAA4B,OAA8B,cAAsB;AAApD,SAAA,QAAA;AAA8B,SAAA,eAAA;AAF1D,kBAAA,MAAgB,MAAK,KAAA;AAAA,EAAA;AAGtB;"}
1
+ {"version":3,"file":"Response.js","sources":["../../../../../../packages/engine-tenant-api/src/model/utils/Response.ts"],"sourcesContent":["export type Response<Result, Error, ErrorMetadata extends {} | undefined = undefined> =\n\t| ResponseOk<Result>\n\t| (Error extends never ? never : ResponseError<Error, ErrorMetadata>)\n\nexport class ResponseOk<Result> {\n\tpublic readonly ok = true\n\n\tconstructor(public readonly result: Result) {}\n}\n\nexport class ResponseError<const Error, Metadata extends {} | undefined = undefined> {\n\tpublic readonly ok = false\n\n\tconstructor(\n\t\tpublic readonly error: Error,\n\t\tpublic readonly errorMessage: string,\n\t\tpublic readonly metadata?: Metadata,\n\t) {}\n}\n\n"],"names":[],"mappings":";;;AAIO,MAAM,WAAmB;AAAA,EAG/B,YAA4B,QAAgB;AAAhB,SAAA,SAAA;AAF5B,kBAAA,MAAgB,MAAK,IAAA;AAAA,EAAA;AAGtB;AAEO,MAAM,cAAwE;AAAA,EAGpF,YACiB,OACA,cACA,UACf;AAHe,SAAA,QAAA;AACA,SAAA,eAAA;AACA,SAAA,WAAA;AALjB,kBAAA,MAAgB,MAAK,KAAA;AAAA,EAAA;AAOtB;"}