@acorex-platform/module-security-management-server 0.0.15 → 2.0.0-next.42

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 (453) hide show
  1. package/contracts/src/AXM_USER_ACCESS_STATE_DEFINITION_KEY.js.map +1 -1
  2. package/contracts/src/AXM_USER_EFFECTIVE_STATE_DEFINITION_KEY.js.map +1 -1
  3. package/contracts/src/ROLE_PERMISSIONS_PAGE_COMPONENT_KEY.d.ts +2 -0
  4. package/contracts/src/ROLE_PERMISSIONS_PAGE_COMPONENT_KEY.js +6 -0
  5. package/contracts/src/ROLE_PERMISSIONS_PAGE_COMPONENT_KEY.js.map +1 -0
  6. package/contracts/src/USER_ROLES_PAGE_COMPONENT_KEY.d.ts +1 -0
  7. package/contracts/src/USER_ROLES_PAGE_COMPONENT_KEY.js +5 -0
  8. package/contracts/src/USER_ROLES_PAGE_COMPONENT_KEY.js.map +1 -0
  9. package/contracts/src/create-application-role-rows.util.d.ts +15 -0
  10. package/contracts/src/create-application-role-rows.util.js +67 -0
  11. package/contracts/src/create-application-role-rows.util.js.map +1 -0
  12. package/contracts/src/device-session-admin-scope.d.ts +15 -0
  13. package/contracts/src/device-session-admin-scope.js +16 -0
  14. package/contracts/src/device-session-admin-scope.js.map +1 -0
  15. package/contracts/src/entities/device-sessions/device-sessions.entity.js +50 -1
  16. package/contracts/src/entities/device-sessions/device-sessions.entity.js.map +1 -1
  17. package/contracts/src/entities/device-sessions/device-sessions.types.d.ts +7 -0
  18. package/contracts/src/entities/device-sessions/device-sessions.types.js.map +1 -1
  19. package/contracts/src/entities/device-sessions/index.d.ts +0 -1
  20. package/contracts/src/entities/device-sessions/index.js +0 -1
  21. package/contracts/src/entities/device-sessions/index.js.map +1 -1
  22. package/contracts/src/entities/identity-provider/identity-provider.entity.d.ts +2 -0
  23. package/contracts/src/entities/identity-provider/identity-provider.entity.js +453 -0
  24. package/contracts/src/entities/identity-provider/identity-provider.entity.js.map +1 -0
  25. package/contracts/src/entities/identity-provider/identity-provider.types.d.ts +61 -0
  26. package/contracts/src/entities/identity-provider/identity-provider.types.js +14 -0
  27. package/contracts/src/entities/identity-provider/identity-provider.types.js.map +1 -0
  28. package/contracts/src/entities/identity-provider/index.d.ts +1 -0
  29. package/contracts/src/entities/identity-provider/index.js +5 -0
  30. package/contracts/src/entities/identity-provider/index.js.map +1 -0
  31. package/contracts/src/entities/index.d.ts +4 -0
  32. package/contracts/src/entities/index.js +4 -0
  33. package/contracts/src/entities/index.js.map +1 -1
  34. package/contracts/src/entities/policy/index.d.ts +0 -1
  35. package/contracts/src/entities/policy/index.js +0 -1
  36. package/contracts/src/entities/policy/index.js.map +1 -1
  37. package/contracts/src/entities/policy/policy.entity.js +15 -0
  38. package/contracts/src/entities/policy/policy.entity.js.map +1 -1
  39. package/contracts/src/entities/policy/policy.types.js.map +1 -1
  40. package/contracts/src/entities/profile/index.d.ts +0 -1
  41. package/contracts/src/entities/profile/index.js +0 -1
  42. package/contracts/src/entities/profile/index.js.map +1 -1
  43. package/contracts/src/entities/profile/profile.entity.js +15 -0
  44. package/contracts/src/entities/profile/profile.entity.js.map +1 -1
  45. package/contracts/src/entities/profile/profile.types.js.map +1 -1
  46. package/contracts/src/entities/role-permission/index.d.ts +1 -0
  47. package/contracts/src/entities/role-permission/index.js +5 -0
  48. package/contracts/src/entities/role-permission/index.js.map +1 -0
  49. package/contracts/src/entities/role-permission/role-permission.entity.d.ts +2 -0
  50. package/contracts/src/entities/role-permission/role-permission.entity.js +163 -0
  51. package/contracts/src/entities/role-permission/role-permission.entity.js.map +1 -0
  52. package/contracts/src/entities/role-permission/role-permission.types.d.ts +11 -0
  53. package/contracts/src/entities/role-permission/role-permission.types.js +5 -0
  54. package/contracts/src/entities/role-permission/role-permission.types.js.map +1 -0
  55. package/contracts/src/entities/roles/index.d.ts +0 -1
  56. package/contracts/src/entities/roles/index.js +0 -1
  57. package/contracts/src/entities/roles/index.js.map +1 -1
  58. package/contracts/src/entities/roles/roles.entity.js +73 -144
  59. package/contracts/src/entities/roles/roles.entity.js.map +1 -1
  60. package/contracts/src/entities/roles/roles.types.d.ts +4 -1
  61. package/contracts/src/entities/roles/roles.types.js.map +1 -1
  62. package/contracts/src/entities/user-role/index.d.ts +1 -0
  63. package/{src/lib/seed/tenant → contracts/src/entities/user-role}/index.js +1 -1
  64. package/contracts/src/entities/user-role/index.js.map +1 -0
  65. package/contracts/src/entities/user-role/user-role.entity.d.ts +2 -0
  66. package/contracts/src/entities/user-role/user-role.entity.js +164 -0
  67. package/contracts/src/entities/user-role/user-role.entity.js.map +1 -0
  68. package/contracts/src/entities/user-role/user-role.types.d.ts +11 -0
  69. package/contracts/src/entities/user-role/user-role.types.js +5 -0
  70. package/contracts/src/entities/user-role/user-role.types.js.map +1 -0
  71. package/contracts/src/entities/user-two-factor/index.d.ts +2 -0
  72. package/contracts/src/entities/user-two-factor/index.js +8 -0
  73. package/contracts/src/entities/user-two-factor/index.js.map +1 -0
  74. package/contracts/src/entities/user-two-factor/user-two-factor.entity.d.ts +6 -0
  75. package/contracts/src/entities/user-two-factor/user-two-factor.entity.js +103 -0
  76. package/contracts/src/entities/user-two-factor/user-two-factor.entity.js.map +1 -0
  77. package/contracts/src/entities/user-two-factor/user-two-factor.types.d.ts +24 -0
  78. package/contracts/src/entities/user-two-factor/user-two-factor.types.js +4 -0
  79. package/contracts/src/entities/user-two-factor/user-two-factor.types.js.map +1 -0
  80. package/contracts/src/entities/users/index.d.ts +1 -1
  81. package/contracts/src/entities/users/index.js +1 -1
  82. package/contracts/src/entities/users/index.js.map +1 -1
  83. package/contracts/src/entities/users/user-provisioning-list-actions.d.ts +8 -0
  84. package/contracts/src/entities/users/user-provisioning-list-actions.js +95 -0
  85. package/contracts/src/entities/users/user-provisioning-list-actions.js.map +1 -0
  86. package/contracts/src/entities/users/users.entity.js +341 -283
  87. package/contracts/src/entities/users/users.entity.js.map +1 -1
  88. package/contracts/src/entities/users/users.types.d.ts +24 -1
  89. package/contracts/src/entities/users/users.types.js.map +1 -1
  90. package/contracts/src/entity-catalog.d.ts +7 -0
  91. package/contracts/src/entity-catalog.js +28 -0
  92. package/contracts/src/entity-catalog.js.map +1 -0
  93. package/contracts/src/entity-entry.device-sessions.d.ts +1 -0
  94. package/contracts/src/entity-entry.device-sessions.js +6 -0
  95. package/contracts/src/entity-entry.device-sessions.js.map +1 -0
  96. package/contracts/src/entity-entry.identity-provider.d.ts +1 -0
  97. package/contracts/src/entity-entry.identity-provider.js +6 -0
  98. package/contracts/src/entity-entry.identity-provider.js.map +1 -0
  99. package/contracts/src/entity-entry.policy.d.ts +1 -0
  100. package/contracts/src/entity-entry.policy.js +6 -0
  101. package/contracts/src/entity-entry.policy.js.map +1 -0
  102. package/contracts/src/entity-entry.profile.d.ts +1 -0
  103. package/contracts/src/entity-entry.profile.js +6 -0
  104. package/contracts/src/entity-entry.profile.js.map +1 -0
  105. package/contracts/src/entity-entry.role-permission.d.ts +1 -0
  106. package/contracts/src/entity-entry.role-permission.js +6 -0
  107. package/contracts/src/entity-entry.role-permission.js.map +1 -0
  108. package/contracts/src/entity-entry.roles.d.ts +1 -0
  109. package/contracts/src/entity-entry.roles.js +6 -0
  110. package/contracts/src/entity-entry.roles.js.map +1 -0
  111. package/contracts/src/entity-entry.user-role.d.ts +1 -0
  112. package/contracts/src/entity-entry.user-role.js +6 -0
  113. package/contracts/src/entity-entry.user-role.js.map +1 -0
  114. package/contracts/src/entity-entry.user-two-factor.d.ts +1 -0
  115. package/contracts/src/entity-entry.user-two-factor.js +6 -0
  116. package/contracts/src/entity-entry.user-two-factor.js.map +1 -0
  117. package/contracts/src/entity-entry.users.d.ts +1 -0
  118. package/contracts/src/entity-entry.users.js +6 -0
  119. package/contracts/src/entity-entry.users.js.map +1 -0
  120. package/contracts/src/features.keys.d.ts +4 -0
  121. package/contracts/src/features.keys.js +4 -0
  122. package/contracts/src/features.keys.js.map +1 -1
  123. package/contracts/src/index.d.ts +13 -1
  124. package/contracts/src/index.js +13 -1
  125. package/contracts/src/index.js.map +1 -1
  126. package/contracts/src/invite-application-role-rows.util.d.ts +16 -0
  127. package/contracts/src/invite-application-role-rows.util.js +68 -0
  128. package/contracts/src/invite-application-role-rows.util.js.map +1 -0
  129. package/contracts/src/invite-assignable-roles.util.d.ts +34 -0
  130. package/contracts/src/invite-assignable-roles.util.js +75 -0
  131. package/contracts/src/invite-assignable-roles.util.js.map +1 -0
  132. package/contracts/src/lib/context.definitions.d.ts +2 -0
  133. package/contracts/src/lib/context.definitions.js +15 -0
  134. package/contracts/src/lib/context.definitions.js.map +1 -0
  135. package/contracts/src/manifest.d.ts +6 -0
  136. package/contracts/src/manifest.js +24 -0
  137. package/contracts/src/manifest.js.map +1 -0
  138. package/contracts/src/menu.keys.d.ts +1 -0
  139. package/contracts/src/menu.keys.js +1 -0
  140. package/contracts/src/menu.keys.js.map +1 -1
  141. package/contracts/src/permission.keys.d.ts +48 -18
  142. package/contracts/src/permission.keys.js +49 -21
  143. package/contracts/src/permission.keys.js.map +1 -1
  144. package/contracts/src/resolve-user-effective-state.d.ts +10 -0
  145. package/contracts/src/resolve-user-effective-state.js +46 -0
  146. package/contracts/src/resolve-user-effective-state.js.map +1 -0
  147. package/contracts/src/root-config.d.ts +33 -0
  148. package/contracts/src/root-config.js +33 -0
  149. package/contracts/src/root-config.js.map +1 -1
  150. package/contracts/src/server-commands.d.ts +340 -0
  151. package/contracts/src/server-commands.js +88 -0
  152. package/contracts/src/server-commands.js.map +1 -0
  153. package/contracts/src/settings.keys.d.ts +16 -0
  154. package/contracts/src/settings.keys.js +21 -0
  155. package/contracts/src/settings.keys.js.map +1 -0
  156. package/contracts/src/user-access-state.js.map +1 -1
  157. package/contracts/src/user-effective-state.js.map +1 -1
  158. package/contracts/src/user-invitation.d.ts +41 -0
  159. package/contracts/src/user-invitation.js +18 -0
  160. package/contracts/src/user-invitation.js.map +1 -0
  161. package/contracts/src/user-password-reset.d.ts +9 -0
  162. package/contracts/src/user-password-reset.js +5 -0
  163. package/contracts/src/user-password-reset.js.map +1 -0
  164. package/package.json +16 -11
  165. package/server/src/index.d.ts +3 -0
  166. package/server/src/index.js +11 -0
  167. package/server/src/index.js.map +1 -0
  168. package/server/src/lib/effective-access-history/effective-access-history.service.d.ts +35 -0
  169. package/server/src/lib/effective-access-history/effective-access-history.service.js +486 -0
  170. package/server/src/lib/effective-access-history/effective-access-history.service.js.map +1 -0
  171. package/server/src/lib/effective-access-history/effective-access-history.types.d.ts +64 -0
  172. package/server/src/lib/effective-access-history/effective-access-history.types.js +5 -0
  173. package/server/src/lib/effective-access-history/effective-access-history.types.js.map +1 -0
  174. package/server/src/lib/effective-access-history/version-as-of.util.d.ts +37 -0
  175. package/server/src/lib/effective-access-history/version-as-of.util.js +167 -0
  176. package/server/src/lib/effective-access-history/version-as-of.util.js.map +1 -0
  177. package/server/src/lib/entities/index.d.ts +1 -0
  178. package/server/src/lib/entities/index.js +5 -0
  179. package/{src/lib/seed/tenant → server/src/lib/entities}/index.js.map +1 -1
  180. package/server/src/lib/entities/security-management.entity-catalog.d.ts +1 -0
  181. package/server/src/lib/entities/security-management.entity-catalog.js +12 -0
  182. package/server/src/lib/entities/security-management.entity-catalog.js.map +1 -0
  183. package/server/src/lib/handlers/security-report.handlers.d.ts +36 -0
  184. package/server/src/lib/handlers/security-report.handlers.js +164 -0
  185. package/server/src/lib/handlers/security-report.handlers.js.map +1 -0
  186. package/server/src/lib/identity-provider/auth-oauth-clients.constants.d.ts +5 -0
  187. package/server/src/lib/identity-provider/auth-oauth-clients.constants.js +11 -0
  188. package/server/src/lib/identity-provider/auth-oauth-clients.constants.js.map +1 -0
  189. package/server/src/lib/identity-provider/identity-provider-catalog.service.d.ts +20 -0
  190. package/server/src/lib/identity-provider/identity-provider-catalog.service.js +169 -0
  191. package/server/src/lib/identity-provider/identity-provider-catalog.service.js.map +1 -0
  192. package/server/src/lib/identity-provider/identity-provider-ids.constants.d.ts +8 -0
  193. package/server/src/lib/identity-provider/identity-provider-ids.constants.js +19 -0
  194. package/server/src/lib/identity-provider/identity-provider-ids.constants.js.map +1 -0
  195. package/server/src/lib/identity-provider/identity-provider-stub.bootstrap.d.ts +12 -0
  196. package/server/src/lib/identity-provider/identity-provider-stub.bootstrap.js +48 -0
  197. package/server/src/lib/identity-provider/identity-provider-stub.bootstrap.js.map +1 -0
  198. package/server/src/lib/identity-provider/identity-provider.constants.d.ts +1 -0
  199. package/server/src/lib/identity-provider/identity-provider.constants.js +7 -0
  200. package/server/src/lib/identity-provider/identity-provider.constants.js.map +1 -0
  201. package/server/src/lib/middlewares/device-sessions-active.middleware.d.ts +15 -0
  202. package/server/src/lib/middlewares/device-sessions-active.middleware.js +76 -0
  203. package/server/src/lib/middlewares/device-sessions-active.middleware.js.map +1 -0
  204. package/server/src/lib/middlewares/device-sessions-app-scope.middleware.d.ts +29 -0
  205. package/server/src/lib/middlewares/device-sessions-app-scope.middleware.js +137 -0
  206. package/server/src/lib/middlewares/device-sessions-app-scope.middleware.js.map +1 -0
  207. package/server/src/lib/middlewares/device-sessions-app-scope.util.d.ts +41 -0
  208. package/server/src/lib/middlewares/device-sessions-app-scope.util.js +69 -0
  209. package/server/src/lib/middlewares/device-sessions-app-scope.util.js.map +1 -0
  210. package/server/src/lib/middlewares/device-sessions-token-revoke.middleware.d.ts +18 -0
  211. package/server/src/lib/middlewares/device-sessions-token-revoke.middleware.js +90 -0
  212. package/server/src/lib/middlewares/device-sessions-token-revoke.middleware.js.map +1 -0
  213. package/server/src/lib/middlewares/user-assigned-roles.middleware.d.ts +36 -0
  214. package/server/src/lib/middlewares/user-assigned-roles.middleware.js +359 -0
  215. package/server/src/lib/middlewares/user-assigned-roles.middleware.js.map +1 -0
  216. package/server/src/lib/middlewares/user-effective-state.middleware.d.ts +13 -0
  217. package/server/src/lib/middlewares/user-effective-state.middleware.js +57 -0
  218. package/server/src/lib/middlewares/user-effective-state.middleware.js.map +1 -0
  219. package/server/src/lib/middlewares/user-invitation-list.middleware.d.ts +32 -0
  220. package/server/src/lib/middlewares/user-invitation-list.middleware.js +250 -0
  221. package/server/src/lib/middlewares/user-invitation-list.middleware.js.map +1 -0
  222. package/server/src/lib/middlewares/user-profile-write.middleware.d.ts +18 -0
  223. package/server/src/lib/middlewares/user-profile-write.middleware.js +206 -0
  224. package/server/src/lib/middlewares/user-profile-write.middleware.js.map +1 -0
  225. package/server/src/lib/password-reset/change-own-password.command.d.ts +8 -0
  226. package/server/src/lib/password-reset/change-own-password.command.js +38 -0
  227. package/server/src/lib/password-reset/change-own-password.command.js.map +1 -0
  228. package/server/src/lib/password-reset/complete-password-reset.command.d.ts +8 -0
  229. package/server/src/lib/password-reset/complete-password-reset.command.js +37 -0
  230. package/server/src/lib/password-reset/complete-password-reset.command.js.map +1 -0
  231. package/server/src/lib/password-reset/get-own-password-status.command.d.ts +8 -0
  232. package/server/src/lib/password-reset/get-own-password-status.command.js +31 -0
  233. package/server/src/lib/password-reset/get-own-password-status.command.js.map +1 -0
  234. package/server/src/lib/password-reset/send-password-reset-email.command.d.ts +20 -0
  235. package/server/src/lib/password-reset/send-password-reset-email.command.js +43 -0
  236. package/server/src/lib/password-reset/send-password-reset-email.command.js.map +1 -0
  237. package/server/src/lib/password-reset/user-change-password.service.d.ts +24 -0
  238. package/server/src/lib/password-reset/user-change-password.service.js +92 -0
  239. package/server/src/lib/password-reset/user-change-password.service.js.map +1 -0
  240. package/server/src/lib/password-reset/user-password-reset.service.d.ts +26 -0
  241. package/server/src/lib/password-reset/user-password-reset.service.js +221 -0
  242. package/server/src/lib/password-reset/user-password-reset.service.js.map +1 -0
  243. package/server/src/lib/queries/get-permission-holders-history.query.d.ts +4 -0
  244. package/server/src/lib/queries/get-permission-holders-history.query.definition.d.ts +5 -0
  245. package/server/src/lib/queries/get-permission-holders-history.query.definition.js +38 -0
  246. package/server/src/lib/queries/get-permission-holders-history.query.definition.js.map +1 -0
  247. package/server/src/lib/queries/get-permission-holders-history.query.js +25 -0
  248. package/server/src/lib/queries/get-permission-holders-history.query.js.map +1 -0
  249. package/server/src/lib/queries/get-role-holders-history.query.d.ts +4 -0
  250. package/server/src/lib/queries/get-role-holders-history.query.definition.d.ts +5 -0
  251. package/server/src/lib/queries/get-role-holders-history.query.definition.js +38 -0
  252. package/server/src/lib/queries/get-role-holders-history.query.definition.js.map +1 -0
  253. package/server/src/lib/queries/get-role-holders-history.query.js +25 -0
  254. package/server/src/lib/queries/get-role-holders-history.query.js.map +1 -0
  255. package/server/src/lib/queries/get-user-effective-permissions-history.query.d.ts +4 -0
  256. package/server/src/lib/queries/get-user-effective-permissions-history.query.definition.d.ts +5 -0
  257. package/server/src/lib/queries/get-user-effective-permissions-history.query.definition.js +35 -0
  258. package/server/src/lib/queries/get-user-effective-permissions-history.query.definition.js.map +1 -0
  259. package/server/src/lib/queries/get-user-effective-permissions-history.query.js +26 -0
  260. package/server/src/lib/queries/get-user-effective-permissions-history.query.js.map +1 -0
  261. package/server/src/lib/queries/get-user-effective-roles-history.query.d.ts +4 -0
  262. package/server/src/lib/queries/get-user-effective-roles-history.query.definition.d.ts +5 -0
  263. package/server/src/lib/queries/get-user-effective-roles-history.query.definition.js +36 -0
  264. package/server/src/lib/queries/get-user-effective-roles-history.query.definition.js.map +1 -0
  265. package/server/src/lib/queries/get-user-effective-roles-history.query.js +25 -0
  266. package/server/src/lib/queries/get-user-effective-roles-history.query.js.map +1 -0
  267. package/server/src/lib/queries/get-user-password-change-history.query.d.ts +4 -0
  268. package/server/src/lib/queries/get-user-password-change-history.query.definition.d.ts +5 -0
  269. package/server/src/lib/queries/get-user-password-change-history.query.definition.js +33 -0
  270. package/server/src/lib/queries/get-user-password-change-history.query.definition.js.map +1 -0
  271. package/server/src/lib/queries/get-user-password-change-history.query.js +23 -0
  272. package/server/src/lib/queries/get-user-password-change-history.query.js.map +1 -0
  273. package/server/src/lib/queries/security-query.helpers.d.ts +47 -0
  274. package/server/src/lib/queries/security-query.helpers.js +184 -0
  275. package/server/src/lib/queries/security-query.helpers.js.map +1 -0
  276. package/server/src/lib/reports/password-change-history.service.d.ts +14 -0
  277. package/server/src/lib/reports/password-change-history.service.js +74 -0
  278. package/server/src/lib/reports/password-change-history.service.js.map +1 -0
  279. package/server/src/lib/reports/permission-display-catalog.d.ts +7 -0
  280. package/server/src/lib/reports/permission-display-catalog.js +101 -0
  281. package/server/src/lib/reports/permission-display-catalog.js.map +1 -0
  282. package/server/src/lib/reports/security-report-definition.provider.d.ts +5 -0
  283. package/server/src/lib/reports/security-report-definition.provider.js +23 -0
  284. package/server/src/lib/reports/security-report-definition.provider.js.map +1 -0
  285. package/server/src/lib/reports/security-report-parameter-groups.d.ts +343 -0
  286. package/server/src/lib/reports/security-report-parameter-groups.js +167 -0
  287. package/server/src/lib/reports/security-report-parameter-groups.js.map +1 -0
  288. package/server/src/lib/reports/security-report-scope.constants.d.ts +5 -0
  289. package/server/src/lib/reports/security-report-scope.constants.js +11 -0
  290. package/server/src/lib/reports/security-report-scope.constants.js.map +1 -0
  291. package/server/src/lib/reports/security-report.definitions.d.ts +12 -0
  292. package/server/src/lib/reports/security-report.definitions.js +386 -0
  293. package/server/src/lib/reports/security-report.definitions.js.map +1 -0
  294. package/server/src/lib/security-management-entity-storage.bootstrap.d.ts +26 -0
  295. package/server/src/lib/security-management-entity-storage.bootstrap.js +56 -0
  296. package/server/src/lib/security-management-entity-storage.bootstrap.js.map +1 -0
  297. package/server/src/lib/security-management-server.module.d.ts +7 -0
  298. package/server/src/lib/security-management-server.module.js +190 -0
  299. package/server/src/lib/security-management-server.module.js.map +1 -0
  300. package/server/src/lib/two-factor/admin-reset-two-factor.command.d.ts +8 -0
  301. package/server/src/lib/two-factor/admin-reset-two-factor.command.js +35 -0
  302. package/server/src/lib/two-factor/admin-reset-two-factor.command.js.map +1 -0
  303. package/server/src/lib/two-factor/confirm-two-factor-enrollment.command.d.ts +8 -0
  304. package/server/src/lib/two-factor/confirm-two-factor-enrollment.command.js +34 -0
  305. package/server/src/lib/two-factor/confirm-two-factor-enrollment.command.js.map +1 -0
  306. package/server/src/lib/two-factor/disable-two-factor.command.d.ts +8 -0
  307. package/server/src/lib/two-factor/disable-two-factor.command.js +31 -0
  308. package/server/src/lib/two-factor/disable-two-factor.command.js.map +1 -0
  309. package/server/src/lib/two-factor/generate-two-factor-recovery-codes.command.d.ts +8 -0
  310. package/server/src/lib/two-factor/generate-two-factor-recovery-codes.command.js +34 -0
  311. package/server/src/lib/two-factor/generate-two-factor-recovery-codes.command.js.map +1 -0
  312. package/server/src/lib/two-factor/get-two-factor-status.command.d.ts +8 -0
  313. package/server/src/lib/two-factor/get-two-factor-status.command.js +31 -0
  314. package/server/src/lib/two-factor/get-two-factor-status.command.js.map +1 -0
  315. package/server/src/lib/two-factor/recovery-codes.util.d.ts +11 -0
  316. package/server/src/lib/two-factor/recovery-codes.util.js +73 -0
  317. package/server/src/lib/two-factor/recovery-codes.util.js.map +1 -0
  318. package/server/src/lib/two-factor/start-two-factor-enrollment.command.d.ts +8 -0
  319. package/server/src/lib/two-factor/start-two-factor-enrollment.command.js +31 -0
  320. package/server/src/lib/two-factor/start-two-factor-enrollment.command.js.map +1 -0
  321. package/server/src/lib/two-factor/totp.util.d.ts +32 -0
  322. package/server/src/lib/two-factor/totp.util.js +128 -0
  323. package/server/src/lib/two-factor/totp.util.js.map +1 -0
  324. package/server/src/lib/two-factor/two-factor-encryption.util.d.ts +25 -0
  325. package/server/src/lib/two-factor/two-factor-encryption.util.js +123 -0
  326. package/server/src/lib/two-factor/two-factor-encryption.util.js.map +1 -0
  327. package/server/src/lib/two-factor/two-factor-gate.bootstrap.d.ts +9 -0
  328. package/server/src/lib/two-factor/two-factor-gate.bootstrap.js +65 -0
  329. package/server/src/lib/two-factor/two-factor-gate.bootstrap.js.map +1 -0
  330. package/server/src/lib/two-factor/two-factor-redis.store.d.ts +63 -0
  331. package/server/src/lib/two-factor/two-factor-redis.store.js +321 -0
  332. package/server/src/lib/two-factor/two-factor-redis.store.js.map +1 -0
  333. package/server/src/lib/two-factor/user-two-factor.service.d.ts +62 -0
  334. package/server/src/lib/two-factor/user-two-factor.service.js +573 -0
  335. package/server/src/lib/two-factor/user-two-factor.service.js.map +1 -0
  336. package/server/src/lib/two-factor/verify-two-factor-login.command.d.ts +18 -0
  337. package/server/src/lib/two-factor/verify-two-factor-login.command.js +54 -0
  338. package/server/src/lib/two-factor/verify-two-factor-login.command.js.map +1 -0
  339. package/server/src/lib/user-invitation/accept-invitation.command.d.ts +8 -0
  340. package/server/src/lib/user-invitation/accept-invitation.command.js +41 -0
  341. package/server/src/lib/user-invitation/accept-invitation.command.js.map +1 -0
  342. package/server/src/lib/user-invitation/accept-my-invitation.command.d.ts +8 -0
  343. package/server/src/lib/user-invitation/accept-my-invitation.command.js +40 -0
  344. package/server/src/lib/user-invitation/accept-my-invitation.command.js.map +1 -0
  345. package/server/src/lib/user-invitation/approve-join-request.command.d.ts +8 -0
  346. package/server/src/lib/user-invitation/approve-join-request.command.js +41 -0
  347. package/server/src/lib/user-invitation/approve-join-request.command.js.map +1 -0
  348. package/server/src/lib/user-invitation/cancel-invitation.command.d.ts +8 -0
  349. package/server/src/lib/user-invitation/cancel-invitation.command.js +37 -0
  350. package/server/src/lib/user-invitation/cancel-invitation.command.js.map +1 -0
  351. package/server/src/lib/user-invitation/cancel-my-join-request.command.d.ts +8 -0
  352. package/server/src/lib/user-invitation/cancel-my-join-request.command.js +40 -0
  353. package/server/src/lib/user-invitation/cancel-my-join-request.command.js.map +1 -0
  354. package/server/src/lib/user-invitation/create-user-in-tenant.command.d.ts +8 -0
  355. package/server/src/lib/user-invitation/create-user-in-tenant.command.js +37 -0
  356. package/server/src/lib/user-invitation/create-user-in-tenant.command.js.map +1 -0
  357. package/server/src/lib/user-invitation/decline-invitation.command.d.ts +8 -0
  358. package/server/src/lib/user-invitation/decline-invitation.command.js +37 -0
  359. package/server/src/lib/user-invitation/decline-invitation.command.js.map +1 -0
  360. package/server/src/lib/user-invitation/invite-user.command.d.ts +8 -0
  361. package/server/src/lib/user-invitation/invite-user.command.js +37 -0
  362. package/server/src/lib/user-invitation/invite-user.command.js.map +1 -0
  363. package/server/src/lib/user-invitation/list-invite-assignable-roles.command.d.ts +8 -0
  364. package/server/src/lib/user-invitation/list-invite-assignable-roles.command.js +41 -0
  365. package/server/src/lib/user-invitation/list-invite-assignable-roles.command.js.map +1 -0
  366. package/server/src/lib/user-invitation/list-my-join-requests.command.d.ts +8 -0
  367. package/server/src/lib/user-invitation/list-my-join-requests.command.js +40 -0
  368. package/server/src/lib/user-invitation/list-my-join-requests.command.js.map +1 -0
  369. package/server/src/lib/user-invitation/list-my-pending-invitations.command.d.ts +8 -0
  370. package/server/src/lib/user-invitation/list-my-pending-invitations.command.js +37 -0
  371. package/server/src/lib/user-invitation/list-my-pending-invitations.command.js.map +1 -0
  372. package/server/src/lib/user-invitation/list-tenant-entitled-applications.command.d.ts +8 -0
  373. package/server/src/lib/user-invitation/list-tenant-entitled-applications.command.js +41 -0
  374. package/server/src/lib/user-invitation/list-tenant-entitled-applications.command.js.map +1 -0
  375. package/server/src/lib/user-invitation/lookup-tenant-by-unique-name.command.d.ts +8 -0
  376. package/server/src/lib/user-invitation/lookup-tenant-by-unique-name.command.js +40 -0
  377. package/server/src/lib/user-invitation/lookup-tenant-by-unique-name.command.js.map +1 -0
  378. package/server/src/lib/user-invitation/reject-join-request.command.d.ts +8 -0
  379. package/server/src/lib/user-invitation/reject-join-request.command.js +41 -0
  380. package/server/src/lib/user-invitation/reject-join-request.command.js.map +1 -0
  381. package/server/src/lib/user-invitation/request-tenant-membership.command.d.ts +8 -0
  382. package/server/src/lib/user-invitation/request-tenant-membership.command.js +40 -0
  383. package/server/src/lib/user-invitation/request-tenant-membership.command.js.map +1 -0
  384. package/server/src/lib/user-invitation/resend-invitation.command.d.ts +12 -0
  385. package/server/src/lib/user-invitation/resend-invitation.command.js +37 -0
  386. package/server/src/lib/user-invitation/resend-invitation.command.js.map +1 -0
  387. package/server/src/lib/user-invitation/user-invitation-application-access.util.d.ts +25 -0
  388. package/server/src/lib/user-invitation/user-invitation-application-access.util.js +121 -0
  389. package/server/src/lib/user-invitation/user-invitation-application-access.util.js.map +1 -0
  390. package/server/src/lib/user-invitation/user-invitation.service.d.ts +162 -0
  391. package/server/src/lib/user-invitation/user-invitation.service.js +1658 -0
  392. package/server/src/lib/user-invitation/user-invitation.service.js.map +1 -0
  393. package/contracts/src/datasource.keys.d.ts +0 -4
  394. package/contracts/src/datasource.keys.js +0 -10
  395. package/contracts/src/datasource.keys.js.map +0 -1
  396. package/src/index.d.ts +0 -5
  397. package/src/index.js +0 -13
  398. package/src/index.js.map +0 -1
  399. package/src/lib/security-management-server.module.d.ts +0 -2
  400. package/src/lib/security-management-server.module.js +0 -23
  401. package/src/lib/security-management-server.module.js.map +0 -1
  402. package/src/lib/seed/index.d.ts +0 -22
  403. package/src/lib/seed/index.js +0 -24
  404. package/src/lib/seed/index.js.map +0 -1
  405. package/src/lib/seed/policy/index.d.ts +0 -2
  406. package/src/lib/seed/policy/index.js +0 -6
  407. package/src/lib/seed/policy/index.js.map +0 -1
  408. package/src/lib/seed/policy/policy.mock.d.ts +0 -7
  409. package/src/lib/seed/policy/policy.mock.js +0 -40
  410. package/src/lib/seed/policy/policy.mock.js.map +0 -1
  411. package/src/lib/seed/policy/policy.seed.d.ts +0 -5
  412. package/src/lib/seed/policy/policy.seed.js +0 -31
  413. package/src/lib/seed/policy/policy.seed.js.map +0 -1
  414. package/src/lib/seed/role/index.d.ts +0 -4
  415. package/src/lib/seed/role/index.js +0 -8
  416. package/src/lib/seed/role/index.js.map +0 -1
  417. package/src/lib/seed/role/role-ids.constants.d.ts +0 -14
  418. package/src/lib/seed/role/role-ids.constants.js +0 -20
  419. package/src/lib/seed/role/role-ids.constants.js.map +0 -1
  420. package/src/lib/seed/role/role-permission-keys.constants.d.ts +0 -578
  421. package/src/lib/seed/role/role-permission-keys.constants.js +0 -620
  422. package/src/lib/seed/role/role-permission-keys.constants.js.map +0 -1
  423. package/src/lib/seed/role/role.mock.d.ts +0 -4
  424. package/src/lib/seed/role/role.mock.js +0 -321
  425. package/src/lib/seed/role/role.mock.js.map +0 -1
  426. package/src/lib/seed/role/role.seed.d.ts +0 -5
  427. package/src/lib/seed/role/role.seed.js +0 -31
  428. package/src/lib/seed/role/role.seed.js.map +0 -1
  429. package/src/lib/seed/security-management-seed.provider.d.ts +0 -4
  430. package/src/lib/seed/security-management-seed.provider.js +0 -18
  431. package/src/lib/seed/security-management-seed.provider.js.map +0 -1
  432. package/src/lib/seed/security-management-seed.tokens.d.ts +0 -1
  433. package/src/lib/seed/security-management-seed.tokens.js +0 -7
  434. package/src/lib/seed/security-management-seed.tokens.js.map +0 -1
  435. package/src/lib/seed/security-management.seed-catalog.d.ts +0 -2
  436. package/src/lib/seed/security-management.seed-catalog.js +0 -17
  437. package/src/lib/seed/security-management.seed-catalog.js.map +0 -1
  438. package/src/lib/seed/tenant/index.d.ts +0 -1
  439. package/src/lib/seed/tenant/tenant-ids.constants.d.ts +0 -11
  440. package/src/lib/seed/tenant/tenant-ids.constants.js +0 -17
  441. package/src/lib/seed/tenant/tenant-ids.constants.js.map +0 -1
  442. package/src/lib/seed/user/index.d.ts +0 -4
  443. package/src/lib/seed/user/index.js +0 -13
  444. package/src/lib/seed/user/index.js.map +0 -1
  445. package/src/lib/seed/user/resolve-user-effective-state.util.d.ts +0 -14
  446. package/src/lib/seed/user/resolve-user-effective-state.util.js +0 -61
  447. package/src/lib/seed/user/resolve-user-effective-state.util.js.map +0 -1
  448. package/src/lib/seed/user/user.mock.d.ts +0 -20
  449. package/src/lib/seed/user/user.mock.js +0 -332
  450. package/src/lib/seed/user/user.mock.js.map +0 -1
  451. package/src/lib/seed/user/user.seed.d.ts +0 -5
  452. package/src/lib/seed/user/user.seed.js +0 -31
  453. package/src/lib/seed/user/user.seed.js.map +0 -1
@@ -0,0 +1,573 @@
1
+ "use strict";
2
+ var UserTwoFactorService_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.UserTwoFactorService = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const crypto_1 = require("crypto");
7
+ const common_1 = require("@nestjs/common");
8
+ const event_emitter_1 = require("@nestjs/event-emitter");
9
+ const lodash_1 = require("lodash");
10
+ const core_1 = require("@acorex-platform/framework-server/core");
11
+ const security_1 = require("@acorex-platform/framework-server/security");
12
+ const core_2 = require("@acorex-platform/framework-shared/core");
13
+ const module_auth_contracts_1 = require("@acorex-platform/module-auth-client/contracts");
14
+ const module_security_management_contracts_1 = require("@acorex-platform/module-security-management-client/contracts");
15
+ const module_settings_management_server_1 = require("@acorex-platform/module-settings-management-server");
16
+ const recovery_codes_util_1 = require("./recovery-codes.util");
17
+ const totp_util_1 = require("./totp.util");
18
+ const two_factor_encryption_util_1 = require("./two-factor-encryption.util");
19
+ const two_factor_redis_store_1 = require("./two-factor-redis.store");
20
+ //#endregion
21
+ //#region ----- Constants -----
22
+ const USER_ENTITY = 'SecurityManagement.User';
23
+ const USER_TWO_FACTOR_ENTITY = 'SecurityManagement.UserTwoFactor';
24
+ const ENABLED_SETTING_KEY = module_auth_contracts_1.AXPAuthSettings.UserTwoFactorEnabled;
25
+ //#endregion
26
+ //#region ----- User two-factor service -----
27
+ let UserTwoFactorService = UserTwoFactorService_1 = class UserTwoFactorService {
28
+ constructor(entityStorage, settingsStore, redisStore, deviceSessions, auth, events) {
29
+ this.entityStorage = entityStorage;
30
+ this.settingsStore = settingsStore;
31
+ this.redisStore = redisStore;
32
+ this.deviceSessions = deviceSessions;
33
+ this.auth = auth;
34
+ this.events = events;
35
+ this.logger = new common_1.Logger(UserTwoFactorService_1.name);
36
+ }
37
+ //#region ----- Status -----
38
+ getStatus(userId) {
39
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
40
+ var _a, _b;
41
+ const uid = (userId === null || userId === void 0 ? void 0 : userId.trim()) || this.readSessionUserId();
42
+ if (!uid) {
43
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotSignedIn };
44
+ }
45
+ const { enabled, row } = yield this.resolveEffectiveTwoFactorState(uid);
46
+ const recoveryCodes = (_a = row === null || row === void 0 ? void 0 : row.recoveryCodes) !== null && _a !== void 0 ? _a : [];
47
+ const unusedRecoveryCodeCount = recoveryCodes.filter((c) => !c.usedAt).length;
48
+ return {
49
+ success: true,
50
+ data: {
51
+ enabled,
52
+ enrolled: !!row,
53
+ verifiedAt: (_b = row === null || row === void 0 ? void 0 : row.verifiedAt) !== null && _b !== void 0 ? _b : null,
54
+ hasRecoveryCodes: recoveryCodes.length > 0,
55
+ unusedRecoveryCodeCount,
56
+ },
57
+ };
58
+ });
59
+ }
60
+ //#endregion
61
+ //#region ----- Enrollment -----
62
+ startEnrollment(input) {
63
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
64
+ var _a, _b;
65
+ const userId = this.readSessionUserId();
66
+ if (!userId) {
67
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotSignedIn };
68
+ }
69
+ const password = String((_a = input.password) !== null && _a !== void 0 ? _a : '');
70
+ if (!password) {
71
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.InvalidInput };
72
+ }
73
+ const user = yield this.getUser(userId);
74
+ if (!user) {
75
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotSignedIn };
76
+ }
77
+ if (!(yield this.verifyUserPassword(user, password))) {
78
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.IncorrectPassword };
79
+ }
80
+ if (yield this.findByUserId(userId)) {
81
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.AlreadyEnabled };
82
+ }
83
+ const secretBytes = (0, totp_util_1.generateTotpSecretBytes)();
84
+ const secretBase32 = (0, totp_util_1.base32Encode)(secretBytes);
85
+ const encrypted = (0, two_factor_encryption_util_1.encryptTwoFactorSecret)(secretBytes);
86
+ const enrollmentId = (0, crypto_1.randomUUID)();
87
+ const now = Date.now();
88
+ const expiresAt = new Date(now + two_factor_redis_store_1.TWO_FACTOR_TTL_MS).toISOString();
89
+ yield this.redisStore.saveEnrollment(enrollmentId, {
90
+ userId,
91
+ secret: encrypted,
92
+ createdAt: new Date(now).toISOString(),
93
+ expiresAt,
94
+ });
95
+ const accountName = String(user.username || user.email || userId).trim() || userId;
96
+ const issuer = ((_b = process.env['AUTH_2FA_ISSUER']) === null || _b === void 0 ? void 0 : _b.trim()) || 'ACoreX';
97
+ const otpauthUri = (0, totp_util_1.buildOtpAuthUri)({
98
+ secretBase32,
99
+ accountName,
100
+ issuer,
101
+ });
102
+ return {
103
+ success: true,
104
+ data: { enrollmentId, otpauthUri, secretBase32, expiresAt },
105
+ };
106
+ });
107
+ }
108
+ confirmEnrollment(input) {
109
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
110
+ var _a, _b;
111
+ const userId = this.readSessionUserId();
112
+ if (!userId) {
113
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotSignedIn };
114
+ }
115
+ const enrollmentId = String((_a = input.enrollmentId) !== null && _a !== void 0 ? _a : '').trim();
116
+ const code = String((_b = input.code) !== null && _b !== void 0 ? _b : '').trim();
117
+ if (!enrollmentId || !code) {
118
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.InvalidInput };
119
+ }
120
+ const enrollment = yield this.redisStore.getEnrollment(enrollmentId);
121
+ if (!enrollment || enrollment.userId !== userId) {
122
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.EnrollmentExpired };
123
+ }
124
+ if (yield this.findByUserId(userId)) {
125
+ yield this.redisStore.deleteEnrollment(enrollmentId);
126
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.AlreadyEnabled };
127
+ }
128
+ let secretBytes;
129
+ try {
130
+ secretBytes = (0, two_factor_encryption_util_1.decryptTwoFactorSecret)(enrollment.secret);
131
+ }
132
+ catch (error) {
133
+ this.logger.warn(`2FA enrollment decrypt failed for user ${userId}: ${String(error)}`);
134
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.EnrollmentExpired };
135
+ }
136
+ const verified = (0, totp_util_1.verifyTotp)(secretBytes, code);
137
+ if (!verified.valid || verified.step == null) {
138
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.IncorrectCode };
139
+ }
140
+ const consumed = yield this.redisStore.consumeEnrollment(enrollmentId);
141
+ if (!consumed) {
142
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.EnrollmentExpired };
143
+ }
144
+ const verifiedAt = new Date().toISOString();
145
+ const id = (0, crypto_1.randomUUID)();
146
+ const envelope = (0, two_factor_encryption_util_1.encryptTwoFactorSecret)(secretBytes);
147
+ try {
148
+ yield this.entityStorage.insertOneAsEngine(USER_TWO_FACTOR_ENTITY, {
149
+ id,
150
+ userId,
151
+ method: 'authenticator',
152
+ encryptedSecret: envelope.encryptedSecret,
153
+ iv: envelope.iv,
154
+ authTag: envelope.authTag,
155
+ keyVersion: envelope.keyVersion,
156
+ verifiedAt,
157
+ lastAcceptedStep: verified.step,
158
+ recoveryCodes: [],
159
+ scopeInfo: {},
160
+ });
161
+ yield this.writeEnabledSetting(userId, true);
162
+ }
163
+ catch (error) {
164
+ this.logger.error(`2FA confirm enrollment failed for user ${userId}: ${String(error)}`);
165
+ try {
166
+ const row = yield this.findByUserId(userId);
167
+ if (row === null || row === void 0 ? void 0 : row.id) {
168
+ yield this.entityStorage.deleteOneAsEngine(USER_TWO_FACTOR_ENTITY, row.id);
169
+ }
170
+ yield this.writeEnabledSetting(userId, false);
171
+ }
172
+ catch (rollbackError) {
173
+ this.logger.error(`2FA confirm rollback failed for user ${userId}: ${String(rollbackError)}`);
174
+ }
175
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.InvalidInput };
176
+ }
177
+ this.emitSecurityAlert({
178
+ kind: 'two_factor_enabled',
179
+ userId,
180
+ at: verifiedAt,
181
+ });
182
+ this.logger.log(`2FA enabled for user ${userId}`);
183
+ return { success: true, data: { enabled: true, verifiedAt } };
184
+ });
185
+ }
186
+ //#endregion
187
+ //#region ----- Disable / generate recovery / admin reset -----
188
+ disable(input) {
189
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
190
+ const userId = this.readSessionUserId();
191
+ if (!userId) {
192
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotSignedIn };
193
+ }
194
+ const proof = yield this.verifySensitiveProof(userId, input.password, input.totpCode);
195
+ if (!proof.ok) {
196
+ return { success: false, code: proof.code };
197
+ }
198
+ const { enabled, row } = yield this.resolveEffectiveTwoFactorState(userId);
199
+ if (!enabled && !row) {
200
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotEnabled };
201
+ }
202
+ yield this.wipeEnrollment(userId, row);
203
+ yield this.redisStore.invalidateChallengesForUser(userId);
204
+ this.emitSecurityAlert({
205
+ kind: 'two_factor_disabled',
206
+ userId,
207
+ at: new Date().toISOString(),
208
+ });
209
+ this.logger.log(`2FA disabled for user ${userId}`);
210
+ return { success: true, data: { enabled: false } };
211
+ });
212
+ }
213
+ generateRecoveryCodes(input) {
214
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
215
+ var _a;
216
+ const userId = this.readSessionUserId();
217
+ if (!userId) {
218
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotSignedIn };
219
+ }
220
+ const proof = yield this.verifySensitiveProof(userId, input.password, input.totpCode);
221
+ if (!proof.ok) {
222
+ return { success: false, code: proof.code };
223
+ }
224
+ const { enabled, row } = yield this.resolveEffectiveTwoFactorState(userId);
225
+ if (!enabled || !(row === null || row === void 0 ? void 0 : row.id)) {
226
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotEnabled };
227
+ }
228
+ const previousCodes = (_a = row.recoveryCodes) !== null && _a !== void 0 ? _a : [];
229
+ const hadExistingCodes = previousCodes.length > 0;
230
+ const generated = yield (0, recovery_codes_util_1.generateRecoveryCodeSet)();
231
+ yield this.entityStorage.updateOneAsEngine(USER_TWO_FACTOR_ENTITY, row.id, {
232
+ recoveryCodes: generated.stored,
233
+ });
234
+ // First-time issue after enroll is not a "regenerate" — skip the security alert toast.
235
+ if (hadExistingCodes) {
236
+ this.emitSecurityAlert({
237
+ kind: 'two_factor_recovery_codes_regenerated',
238
+ userId,
239
+ at: new Date().toISOString(),
240
+ });
241
+ this.logger.log(`2FA recovery codes regenerated for user ${userId}`);
242
+ }
243
+ else {
244
+ this.logger.log(`2FA recovery codes issued for user ${userId}`);
245
+ }
246
+ return { success: true, data: { codes: generated.plaintext } };
247
+ });
248
+ }
249
+ adminReset(input) {
250
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
251
+ var _a;
252
+ const targetUserId = String((_a = input.userId) !== null && _a !== void 0 ? _a : '').trim();
253
+ if (!targetUserId) {
254
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.InvalidInput };
255
+ }
256
+ const user = yield this.getUser(targetUserId);
257
+ if (!user) {
258
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.UserNotFound };
259
+ }
260
+ const { enabled, row } = yield this.resolveEffectiveTwoFactorState(targetUserId);
261
+ if (!enabled || !row) {
262
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotEnabled };
263
+ }
264
+ if (input.dryRun) {
265
+ return { success: true, data: { reset: false } };
266
+ }
267
+ yield this.wipeEnrollment(targetUserId, row);
268
+ yield this.redisStore.invalidateChallengesForUser(targetUserId);
269
+ yield this.revokeAllUserSessions(targetUserId);
270
+ const actorId = this.readSessionUserId();
271
+ this.emitSecurityAlert({
272
+ kind: 'two_factor_admin_reset',
273
+ userId: targetUserId,
274
+ at: new Date().toISOString(),
275
+ });
276
+ this.logger.log(`2FA admin reset for user ${targetUserId}${actorId ? ` by ${actorId}` : ''}`);
277
+ return { success: true, data: { reset: true } };
278
+ });
279
+ }
280
+ //#endregion
281
+ //#region ----- Login challenge -----
282
+ /**
283
+ * After password OK: if user setting Enabled=true, create Redis challenge (fail-closed without row).
284
+ * Returns null when 2FA is not required.
285
+ */
286
+ createLoginChallengeAfterPassword(user, options) {
287
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
288
+ var _a;
289
+ const userId = String((_a = user.id) !== null && _a !== void 0 ? _a : '').trim();
290
+ if (!userId) {
291
+ return null;
292
+ }
293
+ const { enabled, row } = yield this.resolveEffectiveTwoFactorState(userId);
294
+ if (!enabled) {
295
+ return null;
296
+ }
297
+ if (!row) {
298
+ this.logger.error(`Invalid 2FA configuration: Enabled=true without UserTwoFactor row for user ${userId}`);
299
+ throw Object.assign(new Error(module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.InvalidConfiguration), {
300
+ code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.InvalidConfiguration,
301
+ });
302
+ }
303
+ const challengeId = (0, crypto_1.randomUUID)();
304
+ const now = Date.now();
305
+ yield this.redisStore.saveLoginChallenge(challengeId, {
306
+ userId,
307
+ username: user.username,
308
+ rememberMe: options === null || options === void 0 ? void 0 : options.rememberMe,
309
+ createdAt: new Date(now).toISOString(),
310
+ expiresAt: new Date(now + two_factor_redis_store_1.TWO_FACTOR_TTL_MS).toISOString(),
311
+ });
312
+ return { requiresTwoFactor: true, challengeId };
313
+ });
314
+ }
315
+ verifyLoginChallenge(challengeId, code) {
316
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
317
+ const id = String(challengeId !== null && challengeId !== void 0 ? challengeId : '').trim();
318
+ const rawCode = String(code !== null && code !== void 0 ? code : '').trim();
319
+ if (!id || !rawCode) {
320
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.InvalidInput };
321
+ }
322
+ const challenge = yield this.redisStore.getLoginChallenge(id);
323
+ if (!challenge) {
324
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.ChallengeExpired };
325
+ }
326
+ const { userId } = challenge;
327
+ const { enabled, row } = yield this.resolveEffectiveTwoFactorState(userId);
328
+ if (enabled && !row) {
329
+ this.logger.error(`Invalid 2FA configuration during login: Enabled=true without row for user ${userId}`);
330
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.InvalidConfiguration };
331
+ }
332
+ if (!enabled || !(row === null || row === void 0 ? void 0 : row.id)) {
333
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotEnabled };
334
+ }
335
+ const policy = yield (0, security_1.resolveAuthLockoutPolicy)();
336
+ const attempts = yield this.redisStore.getAttemptCounters(id, userId);
337
+ if (attempts.challengeAttempts >= policy.maxLoginAttempts ||
338
+ attempts.userAttempts >= policy.maxLoginAttempts) {
339
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.RateLimited };
340
+ }
341
+ const isTotp = /^\d{6}$/.test(rawCode.replace(/\s+/g, ''));
342
+ let accepted = false;
343
+ let acceptedStep;
344
+ if (isTotp) {
345
+ let secretBytes;
346
+ try {
347
+ secretBytes = (0, two_factor_encryption_util_1.decryptTwoFactorSecret)(row);
348
+ }
349
+ catch (error) {
350
+ this.logger.error(`2FA secret decrypt failed for user ${userId}: ${String(error)}`);
351
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.InvalidConfiguration };
352
+ }
353
+ const verified = (0, totp_util_1.verifyTotp)(secretBytes, rawCode);
354
+ if (verified.valid && verified.step != null) {
355
+ const last = row.lastAcceptedStep;
356
+ if (typeof last === 'number' && verified.step <= last) {
357
+ accepted = false;
358
+ }
359
+ else {
360
+ const locked = yield this.redisStore.tryAcquireStepLock(userId, verified.step, totp_util_1.TOTP_PERIOD_SECONDS * 2 * 1000);
361
+ if (locked) {
362
+ accepted = true;
363
+ acceptedStep = verified.step;
364
+ }
365
+ }
366
+ }
367
+ }
368
+ else {
369
+ const normalized = (0, recovery_codes_util_1.normalizeRecoveryCode)(rawCode);
370
+ const locked = yield this.redisStore.tryAcquireRecoveryLock(userId, normalized, two_factor_redis_store_1.TWO_FACTOR_TTL_MS);
371
+ if (locked) {
372
+ const consumed = yield (0, recovery_codes_util_1.consumeRecoveryCode)(row.recoveryCodes, rawCode);
373
+ if (consumed.matched) {
374
+ yield this.entityStorage.updateOneAsEngine(USER_TWO_FACTOR_ENTITY, row.id, {
375
+ recoveryCodes: consumed.next,
376
+ });
377
+ accepted = true;
378
+ }
379
+ }
380
+ }
381
+ if (!accepted) {
382
+ yield this.redisStore.incrementAttemptCounters(id, userId);
383
+ this.logger.warn(`2FA verification failed for user ${userId}`);
384
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.IncorrectCode };
385
+ }
386
+ if (acceptedStep != null) {
387
+ yield this.entityStorage.updateOneAsEngine(USER_TWO_FACTOR_ENTITY, row.id, {
388
+ lastAcceptedStep: acceptedStep,
389
+ });
390
+ }
391
+ const consumedChallenge = yield this.redisStore.consumeLoginChallenge(id);
392
+ if (!consumedChallenge) {
393
+ return { success: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.ChallengeExpired };
394
+ }
395
+ yield this.redisStore.clearAttemptCounters(id, userId);
396
+ return {
397
+ success: true,
398
+ data: {
399
+ userId,
400
+ rememberMe: consumedChallenge.rememberMe,
401
+ },
402
+ };
403
+ });
404
+ }
405
+ //#endregion
406
+ //#region ----- Private helpers -----
407
+ wipeEnrollment(userId, row) {
408
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
409
+ yield this.writeEnabledSetting(userId, false);
410
+ if (row === null || row === void 0 ? void 0 : row.id) {
411
+ yield this.entityStorage.deleteOneAsEngine(USER_TWO_FACTOR_ENTITY, row.id);
412
+ }
413
+ });
414
+ }
415
+ revokeAllUserSessions(userId) {
416
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
417
+ const sessions = yield this.deviceSessions.listActiveSessionsForUser(userId);
418
+ for (const session of sessions) {
419
+ const revokedSid = yield this.deviceSessions.revokeOwnedSessionById(userId, session.id);
420
+ if (revokedSid == null) {
421
+ continue;
422
+ }
423
+ if (revokedSid !== '') {
424
+ yield this.auth.invalidateLoginSession(revokedSid);
425
+ this.auth.notifyRemoteSessionTerminated(userId, revokedSid);
426
+ }
427
+ }
428
+ });
429
+ }
430
+ verifySensitiveProof(userId, password, totpCode) {
431
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
432
+ const pwd = String(password !== null && password !== void 0 ? password : '');
433
+ const totp = String(totpCode !== null && totpCode !== void 0 ? totpCode : '').trim();
434
+ if (!pwd && !totp) {
435
+ return { ok: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.ProofRequired };
436
+ }
437
+ if (pwd) {
438
+ const user = yield this.getUser(userId);
439
+ if (!user) {
440
+ return { ok: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotSignedIn };
441
+ }
442
+ if (!(yield this.verifyUserPassword(user, pwd))) {
443
+ return { ok: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.IncorrectPassword };
444
+ }
445
+ return { ok: true };
446
+ }
447
+ const row = yield this.findByUserId(userId);
448
+ if (!row) {
449
+ return { ok: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.NotEnabled };
450
+ }
451
+ let secretBytes;
452
+ try {
453
+ secretBytes = (0, two_factor_encryption_util_1.decryptTwoFactorSecret)(row);
454
+ }
455
+ catch (_a) {
456
+ return { ok: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.IncorrectCode };
457
+ }
458
+ const verified = (0, totp_util_1.verifyTotp)(secretBytes, totp);
459
+ if (!verified.valid || verified.step == null) {
460
+ return { ok: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.IncorrectCode };
461
+ }
462
+ if (typeof row.lastAcceptedStep === 'number' && verified.step <= row.lastAcceptedStep) {
463
+ return { ok: false, code: module_security_management_contracts_1.AXM_TWO_FACTOR_ERROR_CODES.IncorrectCode };
464
+ }
465
+ if (row.id) {
466
+ yield this.entityStorage.updateOneAsEngine(USER_TWO_FACTOR_ENTITY, row.id, {
467
+ lastAcceptedStep: verified.step,
468
+ });
469
+ }
470
+ return { ok: true };
471
+ });
472
+ }
473
+ findByUserId(userId) {
474
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
475
+ var _a;
476
+ const result = yield this.entityStorage.queryAsEngine(USER_TWO_FACTOR_ENTITY, {
477
+ skip: 0,
478
+ take: 1,
479
+ filter: {
480
+ logic: 'and',
481
+ filters: [{ field: 'userId', operator: { type: 'equal' }, value: userId }],
482
+ },
483
+ });
484
+ const item = ((_a = result.items) !== null && _a !== void 0 ? _a : [])[0];
485
+ return (item === null || item === void 0 ? void 0 : item.id) ? item : null;
486
+ });
487
+ }
488
+ getUser(userId) {
489
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
490
+ return (yield this.entityStorage.getOneAsEngine(USER_ENTITY, userId));
491
+ });
492
+ }
493
+ verifyUserPassword(user, password) {
494
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
495
+ const stored = (0, lodash_1.get)(user, 'password');
496
+ return (0, core_2.verifyPassword)(password, stored);
497
+ });
498
+ }
499
+ userSettingsPartition(userId) {
500
+ return {
501
+ scope: 'U',
502
+ documentId: `U:${userId}`,
503
+ userId,
504
+ };
505
+ }
506
+ readEnabledSetting(userId) {
507
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
508
+ var _a;
509
+ const document = yield this.settingsStore.findByPartition(this.userSettingsPartition(userId));
510
+ const value = (_a = document === null || document === void 0 ? void 0 : document.values) === null || _a === void 0 ? void 0 : _a[ENABLED_SETTING_KEY];
511
+ return value === true || value === 'true';
512
+ });
513
+ }
514
+ /**
515
+ * Effective 2FA on/off for UI + login.
516
+ * Heals drift when a verified enrollment row exists but the user setting is missing/false
517
+ * (otherwise profile shows "Not enabled" while StartEnrollment returns AlreadyEnabled).
518
+ */
519
+ resolveEffectiveTwoFactorState(userId) {
520
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
521
+ const row = yield this.findByUserId(userId);
522
+ let enabled = yield this.readEnabledSetting(userId);
523
+ if (row && !enabled) {
524
+ this.logger.warn(`Healing 2FA Enabled setting for user ${userId} (UserTwoFactor enrollment exists)`);
525
+ try {
526
+ yield this.writeEnabledSetting(userId, true);
527
+ enabled = true;
528
+ }
529
+ catch (error) {
530
+ this.logger.error(`Failed to heal 2FA Enabled setting for user ${userId}: ${String(error)}`);
531
+ // Enrollment is the source of truth for "is set up" when the setting write fails.
532
+ enabled = true;
533
+ }
534
+ }
535
+ return { enabled, row };
536
+ });
537
+ }
538
+ writeEnabledSetting(userId, enabled) {
539
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
540
+ yield this.settingsStore.upsertValues(this.userSettingsPartition(userId), {
541
+ [ENABLED_SETTING_KEY]: enabled,
542
+ });
543
+ });
544
+ }
545
+ readSessionUserId() {
546
+ var _a, _b;
547
+ const req = (0, core_1.getEntityStorageRequest)();
548
+ const userId = (_b = (_a = req === null || req === void 0 ? void 0 : req[security_1.CURRENT_SESSION_KEY]) === null || _a === void 0 ? void 0 : _a.userId) === null || _b === void 0 ? void 0 : _b.trim();
549
+ return userId || undefined;
550
+ }
551
+ emitSecurityAlert(payload) {
552
+ var _a;
553
+ try {
554
+ (_a = this.events) === null || _a === void 0 ? void 0 : _a.emit(security_1.AUTH_SECURITY_ALERT_EVENT, payload);
555
+ }
556
+ catch (error) {
557
+ this.logger.debug(`2FA security alert emit failed: ${String(error)}`);
558
+ }
559
+ }
560
+ };
561
+ exports.UserTwoFactorService = UserTwoFactorService;
562
+ exports.UserTwoFactorService = UserTwoFactorService = UserTwoFactorService_1 = tslib_1.__decorate([
563
+ (0, common_1.Injectable)(),
564
+ tslib_1.__param(5, (0, common_1.Optional)()),
565
+ tslib_1.__metadata("design:paramtypes", [core_1.EntityStorageMiddlewareService,
566
+ module_settings_management_server_1.SettingsManagementStoreService,
567
+ two_factor_redis_store_1.TwoFactorRedisStore,
568
+ security_1.DeviceSessionService,
569
+ security_1.AuthService,
570
+ event_emitter_1.EventEmitter2])
571
+ ], UserTwoFactorService);
572
+ //#endregion
573
+ //# sourceMappingURL=user-two-factor.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-two-factor.service.js","sourceRoot":"","sources":["../../../../../../../libs/modules/security-management/server/src/lib/two-factor/user-two-factor.service.ts"],"names":[],"mappings":";;;;;AAAA,mCAAoC;AACpC,2CAA8D;AAC9D,yDAAsD;AACtD,mCAA6B;AAE7B,iEAAiH;AACjH,yEASoD;AACpD,iEAAwE;AACxE,kFAAyE;AACzE,gHAe+D;AAC/D,0GAAoG;AAEpG,+DAA4G;AAC5G,2CAMqB;AACrB,6EAGsC;AACtC,qEAAkF;AAsBlF,YAAY;AAEZ,+BAA+B;AAE/B,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAC9C,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AAClE,MAAM,mBAAmB,GAAG,uCAAe,CAAC,oBAAoB,CAAC;AAEjE,YAAY;AAEZ,6CAA6C;AAGtC,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAG/B,YACmB,aAA6C,EAC7C,aAA6C,EAC7C,UAA+B,EAC/B,cAAoC,EACpC,IAAiB,EACtB,MAAuC;QALlC,kBAAa,GAAb,aAAa,CAAgC;QAC7C,kBAAa,GAAb,aAAa,CAAgC;QAC7C,eAAU,GAAV,UAAU,CAAqB;QAC/B,mBAAc,GAAd,cAAc,CAAsB;QACpC,SAAI,GAAJ,IAAI,CAAa;QACL,WAAM,GAAN,MAAM,CAAgB;QARpC,WAAM,GAAG,IAAI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AAG,CAAG,8BAAmB,CAAC,0CAAE,MAAM,0CAAE,IAAI,EAAE,CAAC;QAC1D,OAAO,MAAM,IAAI,SAAS,CAAC;IAC7B,CAAC;IAEO,iBAAiB,CAAC,OAAsC;;QAC9D,IAAI,CAAC;YACH,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,CAAC,oCAAyB,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;CAGF,CAAA;AAhnBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAUR,mBAAA,IAAA,iBAAQ,GAAE,CAAA;6CALqB,qCAA8B;QAC9B,kEAA8B;QACjC,4CAAmB;QACf,+BAAoB;QAC9B,sBAAW;QACI,6BAAa;GAT1C,oBAAoB,CAgnBhC;AAED,YAAY"}
@@ -0,0 +1,18 @@
1
+ import type { AXPCommand, AXPCommandExecuteResultPromise } from '@acorex-platform/framework-shared/runtime';
2
+ import { AuthCookieService, AuthService, AuthLocalCredentialsService, TokenService, type AuthTokenResponseDto } from '@acorex-platform/framework-server/security';
3
+ import { type AXMVerifyTwoFactorLoginInput } from '@acorex-platform/module-security-management-client/contracts';
4
+ import { UserTwoFactorService } from './user-two-factor.service';
5
+ /**
6
+ * Public command that completes login after a 2FA challenge.
7
+ * Prefer {@link AUTH_VERIFY_TWO_FACTOR_DEFAULT} for cookie-aware SPA sign-in;
8
+ * this key remains available for catalog/runtime callers.
9
+ */
10
+ export declare class VerifyTwoFactorLoginCommand implements AXPCommand<AXMVerifyTwoFactorLoginInput, AuthTokenResponseDto> {
11
+ private readonly twoFactor;
12
+ private readonly auth;
13
+ private readonly credentials;
14
+ private readonly cookies;
15
+ private readonly tokens;
16
+ constructor(twoFactor: UserTwoFactorService, auth: AuthService, credentials: AuthLocalCredentialsService, cookies: AuthCookieService, tokens: TokenService);
17
+ execute(input?: AXMVerifyTwoFactorLoginInput): AXPCommandExecuteResultPromise<AuthTokenResponseDto>;
18
+ }