@colveor/core 1.1.0 → 1.2.0

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 (837) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +6 -0
  3. package/dist/bootstrap/bootstrap-colveor-app.d.ts.map +1 -1
  4. package/dist/bootstrap/bootstrap-colveor-app.js +22 -3
  5. package/dist/bootstrap/bootstrap-colveor-app.js.map +1 -1
  6. package/dist/common/decorators/index.d.ts +6 -0
  7. package/dist/common/decorators/index.d.ts.map +1 -1
  8. package/dist/common/decorators/index.js +8 -1
  9. package/dist/common/decorators/index.js.map +1 -1
  10. package/dist/common/decorators/ip-rate-limit-bucket.decorator.d.ts +9 -0
  11. package/dist/common/decorators/ip-rate-limit-bucket.decorator.d.ts.map +1 -0
  12. package/dist/common/decorators/ip-rate-limit-bucket.decorator.js +12 -0
  13. package/dist/common/decorators/ip-rate-limit-bucket.decorator.js.map +1 -0
  14. package/dist/common/guards/login-ip-rate-limit.guard.d.ts +12 -6
  15. package/dist/common/guards/login-ip-rate-limit.guard.d.ts.map +1 -1
  16. package/dist/common/guards/login-ip-rate-limit.guard.js +65 -21
  17. package/dist/common/guards/login-ip-rate-limit.guard.js.map +1 -1
  18. package/dist/common/guards/otp-ip-rate-limit.guard.d.ts +3 -2
  19. package/dist/common/guards/otp-ip-rate-limit.guard.d.ts.map +1 -1
  20. package/dist/common/guards/otp-ip-rate-limit.guard.js +17 -15
  21. package/dist/common/guards/otp-ip-rate-limit.guard.js.map +1 -1
  22. package/dist/common/guards/permissions.guard.d.ts.map +1 -1
  23. package/dist/common/guards/permissions.guard.js +12 -2
  24. package/dist/common/guards/permissions.guard.js.map +1 -1
  25. package/dist/common/interceptors/timeout.interceptor.d.ts +1 -1
  26. package/dist/common/interceptors/timeout.interceptor.d.ts.map +1 -1
  27. package/dist/common/interceptors/timeout.interceptor.js +5 -1
  28. package/dist/common/interceptors/timeout.interceptor.js.map +1 -1
  29. package/dist/common/interfaces/request-user.d.ts +4 -3
  30. package/dist/common/interfaces/request-user.d.ts.map +1 -1
  31. package/dist/common/utils/cache-version.util.d.ts +12 -0
  32. package/dist/common/utils/cache-version.util.d.ts.map +1 -0
  33. package/dist/common/utils/cache-version.util.js +34 -0
  34. package/dist/common/utils/cache-version.util.js.map +1 -0
  35. package/dist/common/utils/postgres-error.util.d.ts +5 -0
  36. package/dist/common/utils/postgres-error.util.d.ts.map +1 -0
  37. package/dist/common/utils/postgres-error.util.js +13 -0
  38. package/dist/common/utils/postgres-error.util.js.map +1 -0
  39. package/dist/common/utils/singleflight.util.d.ts +6 -0
  40. package/dist/common/utils/singleflight.util.d.ts.map +1 -0
  41. package/dist/common/utils/singleflight.util.js +21 -0
  42. package/dist/common/utils/singleflight.util.js.map +1 -0
  43. package/dist/common/validators/is-exclusive-auth-params.validator.js +1 -1
  44. package/dist/common/validators/is-exclusive-auth-params.validator.js.map +1 -1
  45. package/dist/common/validators/is-exclusive-delete-confirm-params.validator.js +1 -1
  46. package/dist/common/validators/is-exclusive-delete-confirm-params.validator.js.map +1 -1
  47. package/dist/config/app.config.d.ts +38 -0
  48. package/dist/config/app.config.d.ts.map +1 -1
  49. package/dist/config/app.config.js +24 -0
  50. package/dist/config/app.config.js.map +1 -1
  51. package/dist/config/database.config.d.ts +6 -0
  52. package/dist/config/database.config.d.ts.map +1 -1
  53. package/dist/config/database.config.js +3 -0
  54. package/dist/config/database.config.js.map +1 -1
  55. package/dist/config/env-flags.util.d.ts +4 -0
  56. package/dist/config/env-flags.util.d.ts.map +1 -1
  57. package/dist/config/env-flags.util.js +7 -0
  58. package/dist/config/env-flags.util.js.map +1 -1
  59. package/dist/config/env.validation.d.ts +24 -1
  60. package/dist/config/env.validation.d.ts.map +1 -1
  61. package/dist/config/env.validation.js +92 -2
  62. package/dist/config/env.validation.js.map +1 -1
  63. package/dist/config/in-memory-redis.client.d.ts +23 -4
  64. package/dist/config/in-memory-redis.client.d.ts.map +1 -1
  65. package/dist/config/in-memory-redis.client.js +148 -4
  66. package/dist/config/in-memory-redis.client.js.map +1 -1
  67. package/dist/config/redis.module.d.ts.map +1 -1
  68. package/dist/config/redis.module.js +5 -0
  69. package/dist/config/redis.module.js.map +1 -1
  70. package/dist/core.module.d.ts +5 -0
  71. package/dist/core.module.d.ts.map +1 -1
  72. package/dist/core.module.js +5 -0
  73. package/dist/core.module.js.map +1 -1
  74. package/dist/database/migrations/1785006199371-auth-mfa-oauth.d.ts +7 -0
  75. package/dist/database/migrations/1785006199371-auth-mfa-oauth.d.ts.map +1 -0
  76. package/dist/database/migrations/1785006199371-auth-mfa-oauth.js +24 -0
  77. package/dist/database/migrations/1785006199371-auth-mfa-oauth.js.map +1 -0
  78. package/dist/database/migrations/1785006199372-auth-mfa-backup-codes.d.ts +7 -0
  79. package/dist/database/migrations/1785006199372-auth-mfa-backup-codes.d.ts.map +1 -0
  80. package/dist/database/migrations/1785006199372-auth-mfa-backup-codes.js +16 -0
  81. package/dist/database/migrations/1785006199372-auth-mfa-backup-codes.js.map +1 -0
  82. package/dist/database/migrations/1785006199373-auth-gap-fixes.d.ts +7 -0
  83. package/dist/database/migrations/1785006199373-auth-gap-fixes.d.ts.map +1 -0
  84. package/dist/database/migrations/1785006199373-auth-gap-fixes.js +14 -0
  85. package/dist/database/migrations/1785006199373-auth-gap-fixes.js.map +1 -0
  86. package/dist/database/migrations/1785006199374-auth-sessions-indexes.d.ts +13 -0
  87. package/dist/database/migrations/1785006199374-auth-sessions-indexes.d.ts.map +1 -0
  88. package/dist/database/migrations/1785006199374-auth-sessions-indexes.js +35 -0
  89. package/dist/database/migrations/1785006199374-auth-sessions-indexes.js.map +1 -0
  90. package/dist/database/migrations/1785006199375-auth-identity-and-audit.d.ts +11 -0
  91. package/dist/database/migrations/1785006199375-auth-identity-and-audit.d.ts.map +1 -0
  92. package/dist/database/migrations/1785006199375-auth-identity-and-audit.js +60 -0
  93. package/dist/database/migrations/1785006199375-auth-identity-and-audit.js.map +1 -0
  94. package/dist/database/migrations/1785006199376-auth-settings-security-defaults.d.ts +14 -0
  95. package/dist/database/migrations/1785006199376-auth-settings-security-defaults.d.ts.map +1 -0
  96. package/dist/database/migrations/1785006199376-auth-settings-security-defaults.js +39 -0
  97. package/dist/database/migrations/1785006199376-auth-settings-security-defaults.js.map +1 -0
  98. package/dist/database/migrations/1785006199377-auth-security-hardening.d.ts +13 -0
  99. package/dist/database/migrations/1785006199377-auth-security-hardening.d.ts.map +1 -0
  100. package/dist/database/migrations/1785006199377-auth-security-hardening.js +69 -0
  101. package/dist/database/migrations/1785006199377-auth-security-hardening.js.map +1 -0
  102. package/dist/database/migrations/1785006199378-auth-family-denylist-and-hardening.d.ts +11 -0
  103. package/dist/database/migrations/1785006199378-auth-family-denylist-and-hardening.d.ts.map +1 -0
  104. package/dist/database/migrations/1785006199378-auth-family-denylist-and-hardening.js +51 -0
  105. package/dist/database/migrations/1785006199378-auth-family-denylist-and-hardening.js.map +1 -0
  106. package/dist/database/migrations/1785006199379-authz-lifecycle-hardening.d.ts +12 -0
  107. package/dist/database/migrations/1785006199379-authz-lifecycle-hardening.d.ts.map +1 -0
  108. package/dist/database/migrations/1785006199379-authz-lifecycle-hardening.js +37 -0
  109. package/dist/database/migrations/1785006199379-authz-lifecycle-hardening.js.map +1 -0
  110. package/dist/database/migrations/1785006199380-auth-remaining-gaps.d.ts +12 -0
  111. package/dist/database/migrations/1785006199380-auth-remaining-gaps.d.ts.map +1 -0
  112. package/dist/database/migrations/1785006199380-auth-remaining-gaps.js +74 -0
  113. package/dist/database/migrations/1785006199380-auth-remaining-gaps.js.map +1 -0
  114. package/dist/database/migrations/1785006199381-settings-blast-radius.d.ts +12 -0
  115. package/dist/database/migrations/1785006199381-settings-blast-radius.d.ts.map +1 -0
  116. package/dist/database/migrations/1785006199381-settings-blast-radius.js +52 -0
  117. package/dist/database/migrations/1785006199381-settings-blast-radius.js.map +1 -0
  118. package/dist/database/migrations/1785006199382-oauth-client-ids-lock.d.ts +11 -0
  119. package/dist/database/migrations/1785006199382-oauth-client-ids-lock.d.ts.map +1 -0
  120. package/dist/database/migrations/1785006199382-oauth-client-ids-lock.js +36 -0
  121. package/dist/database/migrations/1785006199382-oauth-client-ids-lock.js.map +1 -0
  122. package/dist/database/migrations/1785006199383-settings-role-and-verified-lock.d.ts +12 -0
  123. package/dist/database/migrations/1785006199383-settings-role-and-verified-lock.d.ts.map +1 -0
  124. package/dist/database/migrations/1785006199383-settings-role-and-verified-lock.js +39 -0
  125. package/dist/database/migrations/1785006199383-settings-role-and-verified-lock.js.map +1 -0
  126. package/dist/database/migrations/1785006199384-settings-providers-and-test-otp-lock.d.ts +12 -0
  127. package/dist/database/migrations/1785006199384-settings-providers-and-test-otp-lock.d.ts.map +1 -0
  128. package/dist/database/migrations/1785006199384-settings-providers-and-test-otp-lock.js +39 -0
  129. package/dist/database/migrations/1785006199384-settings-providers-and-test-otp-lock.js.map +1 -0
  130. package/dist/database/migrations/1785006199385-settings-auth-surface-lock.d.ts +13 -0
  131. package/dist/database/migrations/1785006199385-settings-auth-surface-lock.d.ts.map +1 -0
  132. package/dist/database/migrations/1785006199385-settings-auth-surface-lock.js +72 -0
  133. package/dist/database/migrations/1785006199385-settings-auth-surface-lock.js.map +1 -0
  134. package/dist/database/migrations/1785006199386-audit-events.d.ts +10 -0
  135. package/dist/database/migrations/1785006199386-audit-events.d.ts.map +1 -0
  136. package/dist/database/migrations/1785006199386-audit-events.js +60 -0
  137. package/dist/database/migrations/1785006199386-audit-events.js.map +1 -0
  138. package/dist/database/migrations/1785006199387-audit-resource-id-varchar.d.ts +10 -0
  139. package/dist/database/migrations/1785006199387-audit-resource-id-varchar.d.ts.map +1 -0
  140. package/dist/database/migrations/1785006199387-audit-resource-id-varchar.js +25 -0
  141. package/dist/database/migrations/1785006199387-audit-resource-id-varchar.js.map +1 -0
  142. package/dist/database/migrations/1785006199388-audit-enterprise.d.ts +11 -0
  143. package/dist/database/migrations/1785006199388-audit-enterprise.d.ts.map +1 -0
  144. package/dist/database/migrations/1785006199388-audit-enterprise.js +157 -0
  145. package/dist/database/migrations/1785006199388-audit-enterprise.js.map +1 -0
  146. package/dist/database/migrations/1785006199389-drop-admin-logs.d.ts +10 -0
  147. package/dist/database/migrations/1785006199389-drop-admin-logs.d.ts.map +1 -0
  148. package/dist/database/migrations/1785006199389-drop-admin-logs.js +38 -0
  149. package/dist/database/migrations/1785006199389-drop-admin-logs.js.map +1 -0
  150. package/dist/database/migrations/1785006199390-audit-hardening.d.ts +14 -0
  151. package/dist/database/migrations/1785006199390-audit-hardening.d.ts.map +1 -0
  152. package/dist/database/migrations/1785006199390-audit-hardening.js +345 -0
  153. package/dist/database/migrations/1785006199390-audit-hardening.js.map +1 -0
  154. package/dist/database/migrations/1785006199391-audit-owner-schema-create.d.ts +10 -0
  155. package/dist/database/migrations/1785006199391-audit-owner-schema-create.d.ts.map +1 -0
  156. package/dist/database/migrations/1785006199391-audit-owner-schema-create.js +39 -0
  157. package/dist/database/migrations/1785006199391-audit-owner-schema-create.js.map +1 -0
  158. package/dist/database/migrations/1785006199392-profile-photo-url.d.ts +11 -0
  159. package/dist/database/migrations/1785006199392-profile-photo-url.d.ts.map +1 -0
  160. package/dist/database/migrations/1785006199392-profile-photo-url.js +33 -0
  161. package/dist/database/migrations/1785006199392-profile-photo-url.js.map +1 -0
  162. package/dist/database/migrations/1785006199393-profile-cover-url.d.ts +11 -0
  163. package/dist/database/migrations/1785006199393-profile-cover-url.d.ts.map +1 -0
  164. package/dist/database/migrations/1785006199393-profile-cover-url.js +33 -0
  165. package/dist/database/migrations/1785006199393-profile-cover-url.js.map +1 -0
  166. package/dist/database/migrations/1785006199394-profile-is-public-default-false.d.ts +11 -0
  167. package/dist/database/migrations/1785006199394-profile-is-public-default-false.d.ts.map +1 -0
  168. package/dist/database/migrations/1785006199394-profile-is-public-default-false.js +24 -0
  169. package/dist/database/migrations/1785006199394-profile-is-public-default-false.js.map +1 -0
  170. package/dist/database/migrations/1785006199395-delivery-scale-indexes.d.ts +10 -0
  171. package/dist/database/migrations/1785006199395-delivery-scale-indexes.d.ts.map +1 -0
  172. package/dist/database/migrations/1785006199395-delivery-scale-indexes.js +35 -0
  173. package/dist/database/migrations/1785006199395-delivery-scale-indexes.js.map +1 -0
  174. package/dist/database/migrations/1785006199396-delivery-recipient-index.d.ts +11 -0
  175. package/dist/database/migrations/1785006199396-delivery-recipient-index.d.ts.map +1 -0
  176. package/dist/database/migrations/1785006199396-delivery-recipient-index.js +23 -0
  177. package/dist/database/migrations/1785006199396-delivery-recipient-index.js.map +1 -0
  178. package/dist/database/seeds/roles.seed.d.ts +6 -0
  179. package/dist/database/seeds/roles.seed.d.ts.map +1 -1
  180. package/dist/database/seeds/roles.seed.js +22 -5
  181. package/dist/database/seeds/roles.seed.js.map +1 -1
  182. package/dist/database/seeds/settings.seed.d.ts +5 -0
  183. package/dist/database/seeds/settings.seed.d.ts.map +1 -1
  184. package/dist/database/seeds/settings.seed.js +500 -25
  185. package/dist/database/seeds/settings.seed.js.map +1 -1
  186. package/dist/database/seeds/templates/html-template.reader.d.ts +1 -0
  187. package/dist/database/seeds/templates/html-template.reader.d.ts.map +1 -1
  188. package/dist/database/seeds/templates/html-template.reader.js +3 -1
  189. package/dist/database/seeds/templates/html-template.reader.js.map +1 -1
  190. package/dist/database/seeds/templates/html-template.reader.ts +5 -1
  191. package/dist/database/typeorm.util.d.ts.map +1 -1
  192. package/dist/database/typeorm.util.js +6 -0
  193. package/dist/database/typeorm.util.js.map +1 -1
  194. package/dist/index.d.ts +8 -1
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +39 -4
  197. package/dist/index.js.map +1 -1
  198. package/dist/modules/admin/controllers/admin.controller.d.ts +15 -7
  199. package/dist/modules/admin/controllers/admin.controller.d.ts.map +1 -1
  200. package/dist/modules/admin/controllers/admin.controller.js +74 -17
  201. package/dist/modules/admin/controllers/admin.controller.js.map +1 -1
  202. package/dist/modules/admin/services/admin-log.service.d.ts +14 -7
  203. package/dist/modules/admin/services/admin-log.service.d.ts.map +1 -1
  204. package/dist/modules/admin/services/admin-log.service.js +41 -38
  205. package/dist/modules/admin/services/admin-log.service.js.map +1 -1
  206. package/dist/modules/audit/audit.manifest.d.ts +8 -0
  207. package/dist/modules/audit/audit.manifest.d.ts.map +1 -0
  208. package/dist/modules/audit/audit.manifest.js +31 -0
  209. package/dist/modules/audit/audit.manifest.js.map +1 -0
  210. package/dist/modules/audit/audit.module.d.ts +8 -0
  211. package/dist/modules/audit/audit.module.d.ts.map +1 -0
  212. package/dist/modules/audit/audit.module.js +57 -0
  213. package/dist/modules/audit/audit.module.js.map +1 -0
  214. package/dist/modules/audit/constants/audit-actions.d.ts +79 -0
  215. package/dist/modules/audit/constants/audit-actions.d.ts.map +1 -0
  216. package/dist/modules/audit/constants/audit-actions.js +89 -0
  217. package/dist/modules/audit/constants/audit-actions.js.map +1 -0
  218. package/dist/modules/audit/constants/audit-mutation.d.ts +10 -0
  219. package/dist/modules/audit/constants/audit-mutation.d.ts.map +1 -0
  220. package/dist/modules/audit/constants/audit-mutation.js +13 -0
  221. package/dist/modules/audit/constants/audit-mutation.js.map +1 -0
  222. package/dist/modules/audit/controllers/audit.controller.d.ts +13 -0
  223. package/dist/modules/audit/controllers/audit.controller.d.ts.map +1 -0
  224. package/dist/modules/audit/controllers/audit.controller.js +149 -0
  225. package/dist/modules/audit/controllers/audit.controller.js.map +1 -0
  226. package/dist/modules/audit/decorators/audit.decorator.d.ts +27 -0
  227. package/dist/modules/audit/decorators/audit.decorator.d.ts.map +1 -0
  228. package/dist/modules/audit/decorators/audit.decorator.js +18 -0
  229. package/dist/modules/audit/decorators/audit.decorator.js.map +1 -0
  230. package/dist/modules/audit/dto/audit.dto.d.ts +54 -0
  231. package/dist/modules/audit/dto/audit.dto.d.ts.map +1 -0
  232. package/dist/modules/audit/dto/audit.dto.js +129 -0
  233. package/dist/modules/audit/dto/audit.dto.js.map +1 -0
  234. package/dist/modules/audit/entities/audit-event.entity.d.ts +33 -0
  235. package/dist/modules/audit/entities/audit-event.entity.d.ts.map +1 -0
  236. package/dist/modules/audit/entities/audit-event.entity.js +125 -0
  237. package/dist/modules/audit/entities/audit-event.entity.js.map +1 -0
  238. package/dist/modules/audit/entities/audit-outbox.entity.d.ts +16 -0
  239. package/dist/modules/audit/entities/audit-outbox.entity.d.ts.map +1 -0
  240. package/dist/modules/audit/entities/audit-outbox.entity.js +65 -0
  241. package/dist/modules/audit/entities/audit-outbox.entity.js.map +1 -0
  242. package/dist/modules/audit/index.d.ts +13 -0
  243. package/dist/modules/audit/index.d.ts.map +1 -0
  244. package/dist/modules/audit/index.js +23 -0
  245. package/dist/modules/audit/index.js.map +1 -0
  246. package/dist/modules/audit/interceptors/audit.interceptor.d.ts +11 -0
  247. package/dist/modules/audit/interceptors/audit.interceptor.d.ts.map +1 -0
  248. package/dist/modules/audit/interceptors/audit.interceptor.js +75 -0
  249. package/dist/modules/audit/interceptors/audit.interceptor.js.map +1 -0
  250. package/dist/modules/audit/listeners/auth-audit.listener.d.ts +31 -0
  251. package/dist/modules/audit/listeners/auth-audit.listener.d.ts.map +1 -0
  252. package/dist/modules/audit/listeners/auth-audit.listener.js +338 -0
  253. package/dist/modules/audit/listeners/auth-audit.listener.js.map +1 -0
  254. package/dist/modules/audit/services/audit-archive.service.d.ts +28 -0
  255. package/dist/modules/audit/services/audit-archive.service.d.ts.map +1 -0
  256. package/dist/modules/audit/services/audit-archive.service.js +132 -0
  257. package/dist/modules/audit/services/audit-archive.service.js.map +1 -0
  258. package/dist/modules/audit/services/audit-hash-backfill.service.d.ts +22 -0
  259. package/dist/modules/audit/services/audit-hash-backfill.service.d.ts.map +1 -0
  260. package/dist/modules/audit/services/audit-hash-backfill.service.js +79 -0
  261. package/dist/modules/audit/services/audit-hash-backfill.service.js.map +1 -0
  262. package/dist/modules/audit/services/audit-leader.service.d.ts +28 -0
  263. package/dist/modules/audit/services/audit-leader.service.d.ts.map +1 -0
  264. package/dist/modules/audit/services/audit-leader.service.js +99 -0
  265. package/dist/modules/audit/services/audit-leader.service.js.map +1 -0
  266. package/dist/modules/audit/services/audit-outbox.worker.d.ts +29 -0
  267. package/dist/modules/audit/services/audit-outbox.worker.d.ts.map +1 -0
  268. package/dist/modules/audit/services/audit-outbox.worker.js +144 -0
  269. package/dist/modules/audit/services/audit-outbox.worker.js.map +1 -0
  270. package/dist/modules/audit/services/audit-partition.service.d.ts +18 -0
  271. package/dist/modules/audit/services/audit-partition.service.d.ts.map +1 -0
  272. package/dist/modules/audit/services/audit-partition.service.js +70 -0
  273. package/dist/modules/audit/services/audit-partition.service.js.map +1 -0
  274. package/dist/modules/audit/services/audit-write.service.d.ts +60 -0
  275. package/dist/modules/audit/services/audit-write.service.d.ts.map +1 -0
  276. package/dist/modules/audit/services/audit-write.service.js +463 -0
  277. package/dist/modules/audit/services/audit-write.service.js.map +1 -0
  278. package/dist/modules/audit/services/audit.service.d.ts +60 -0
  279. package/dist/modules/audit/services/audit.service.d.ts.map +1 -0
  280. package/dist/modules/audit/services/audit.service.js +373 -0
  281. package/dist/modules/audit/services/audit.service.js.map +1 -0
  282. package/dist/modules/audit/utils/audit-hash.util.d.ts +20 -0
  283. package/dist/modules/audit/utils/audit-hash.util.d.ts.map +1 -0
  284. package/dist/modules/audit/utils/audit-hash.util.js +44 -0
  285. package/dist/modules/audit/utils/audit-hash.util.js.map +1 -0
  286. package/dist/modules/auth/auth-core/auth-core.module.d.ts.map +1 -1
  287. package/dist/modules/auth/auth-core/auth-core.module.js +16 -4
  288. package/dist/modules/auth/auth-core/auth-core.module.js.map +1 -1
  289. package/dist/modules/auth/auth-core/constants/jwt-redis.keys.d.ts +22 -0
  290. package/dist/modules/auth/auth-core/constants/jwt-redis.keys.d.ts.map +1 -0
  291. package/dist/modules/auth/auth-core/constants/jwt-redis.keys.js +25 -0
  292. package/dist/modules/auth/auth-core/constants/jwt-redis.keys.js.map +1 -0
  293. package/dist/modules/auth/auth-core/services/access-token.validator.d.ts +19 -0
  294. package/dist/modules/auth/auth-core/services/access-token.validator.d.ts.map +1 -0
  295. package/dist/modules/auth/auth-core/services/access-token.validator.js +110 -0
  296. package/dist/modules/auth/auth-core/services/access-token.validator.js.map +1 -0
  297. package/dist/modules/auth/auth-core/services/family-denylist.reader.d.ts +10 -0
  298. package/dist/modules/auth/auth-core/services/family-denylist.reader.d.ts.map +1 -0
  299. package/dist/modules/auth/auth-core/services/family-denylist.reader.js +44 -0
  300. package/dist/modules/auth/auth-core/services/family-denylist.reader.js.map +1 -0
  301. package/dist/modules/auth/auth-core/services/session-epoch.reader.d.ts +10 -0
  302. package/dist/modules/auth/auth-core/services/session-epoch.reader.d.ts.map +1 -0
  303. package/dist/modules/auth/auth-core/services/session-epoch.reader.js +44 -0
  304. package/dist/modules/auth/auth-core/services/session-epoch.reader.js.map +1 -0
  305. package/dist/modules/auth/auth-core/strategies/jwt.strategy.d.ts +7 -8
  306. package/dist/modules/auth/auth-core/strategies/jwt.strategy.d.ts.map +1 -1
  307. package/dist/modules/auth/auth-core/strategies/jwt.strategy.js +34 -34
  308. package/dist/modules/auth/auth-core/strategies/jwt.strategy.js.map +1 -1
  309. package/dist/modules/auth/auth.manifest.d.ts +6 -0
  310. package/dist/modules/auth/auth.manifest.d.ts.map +1 -1
  311. package/dist/modules/auth/auth.manifest.js +38 -2
  312. package/dist/modules/auth/auth.manifest.js.map +1 -1
  313. package/dist/modules/auth/auth.module.d.ts.map +1 -1
  314. package/dist/modules/auth/auth.module.js +39 -4
  315. package/dist/modules/auth/auth.module.js.map +1 -1
  316. package/dist/modules/auth/controllers/account.controller.d.ts +15 -1
  317. package/dist/modules/auth/controllers/account.controller.d.ts.map +1 -1
  318. package/dist/modules/auth/controllers/account.controller.js +65 -7
  319. package/dist/modules/auth/controllers/account.controller.js.map +1 -1
  320. package/dist/modules/auth/controllers/auth.controller.d.ts +7 -3
  321. package/dist/modules/auth/controllers/auth.controller.d.ts.map +1 -1
  322. package/dist/modules/auth/controllers/auth.controller.js +76 -16
  323. package/dist/modules/auth/controllers/auth.controller.js.map +1 -1
  324. package/dist/modules/auth/controllers/forgot-password.controller.d.ts +4 -2
  325. package/dist/modules/auth/controllers/forgot-password.controller.d.ts.map +1 -1
  326. package/dist/modules/auth/controllers/forgot-password.controller.js +32 -11
  327. package/dist/modules/auth/controllers/forgot-password.controller.js.map +1 -1
  328. package/dist/modules/auth/controllers/mfa.controller.d.ts +18 -0
  329. package/dist/modules/auth/controllers/mfa.controller.d.ts.map +1 -0
  330. package/dist/modules/auth/controllers/mfa.controller.js +192 -0
  331. package/dist/modules/auth/controllers/mfa.controller.js.map +1 -0
  332. package/dist/modules/auth/controllers/oauth.controller.d.ts +22 -0
  333. package/dist/modules/auth/controllers/oauth.controller.d.ts.map +1 -0
  334. package/dist/modules/auth/controllers/oauth.controller.js +192 -0
  335. package/dist/modules/auth/controllers/oauth.controller.js.map +1 -0
  336. package/dist/modules/auth/controllers/otp.controller.d.ts +6 -3
  337. package/dist/modules/auth/controllers/otp.controller.d.ts.map +1 -1
  338. package/dist/modules/auth/controllers/otp.controller.js +32 -33
  339. package/dist/modules/auth/controllers/otp.controller.js.map +1 -1
  340. package/dist/modules/auth/controllers/pin.controller.d.ts.map +1 -1
  341. package/dist/modules/auth/controllers/pin.controller.js +10 -2
  342. package/dist/modules/auth/controllers/pin.controller.js.map +1 -1
  343. package/dist/modules/auth/controllers/session.controller.d.ts +12 -4
  344. package/dist/modules/auth/controllers/session.controller.d.ts.map +1 -1
  345. package/dist/modules/auth/controllers/session.controller.js +130 -31
  346. package/dist/modules/auth/controllers/session.controller.js.map +1 -1
  347. package/dist/modules/auth/dto/auth-config.dto.d.ts +11 -2
  348. package/dist/modules/auth/dto/auth-config.dto.d.ts.map +1 -1
  349. package/dist/modules/auth/dto/auth-config.dto.js +78 -3
  350. package/dist/modules/auth/dto/auth-config.dto.js.map +1 -1
  351. package/dist/modules/auth/dto/index.d.ts +2 -0
  352. package/dist/modules/auth/dto/index.d.ts.map +1 -1
  353. package/dist/modules/auth/dto/index.js +2 -0
  354. package/dist/modules/auth/dto/index.js.map +1 -1
  355. package/dist/modules/auth/dto/login.dto.d.ts +8 -1
  356. package/dist/modules/auth/dto/login.dto.d.ts.map +1 -1
  357. package/dist/modules/auth/dto/login.dto.js +48 -3
  358. package/dist/modules/auth/dto/login.dto.js.map +1 -1
  359. package/dist/modules/auth/dto/mfa.dto.d.ts +61 -0
  360. package/dist/modules/auth/dto/mfa.dto.d.ts.map +1 -0
  361. package/dist/modules/auth/dto/mfa.dto.js +326 -0
  362. package/dist/modules/auth/dto/mfa.dto.js.map +1 -0
  363. package/dist/modules/auth/dto/oauth.dto.d.ts +45 -0
  364. package/dist/modules/auth/dto/oauth.dto.d.ts.map +1 -0
  365. package/dist/modules/auth/dto/oauth.dto.js +249 -0
  366. package/dist/modules/auth/dto/oauth.dto.js.map +1 -0
  367. package/dist/modules/auth/dto/otp.dto.d.ts +3 -1
  368. package/dist/modules/auth/dto/otp.dto.d.ts.map +1 -1
  369. package/dist/modules/auth/dto/otp.dto.js +19 -0
  370. package/dist/modules/auth/dto/otp.dto.js.map +1 -1
  371. package/dist/modules/auth/dto/password.dto.d.ts +28 -0
  372. package/dist/modules/auth/dto/password.dto.d.ts.map +1 -1
  373. package/dist/modules/auth/dto/password.dto.js +191 -5
  374. package/dist/modules/auth/dto/password.dto.js.map +1 -1
  375. package/dist/modules/auth/dto/register.dto.d.ts +1 -0
  376. package/dist/modules/auth/dto/register.dto.d.ts.map +1 -1
  377. package/dist/modules/auth/dto/register.dto.js +1 -0
  378. package/dist/modules/auth/dto/register.dto.js.map +1 -1
  379. package/dist/modules/auth/dto/session.dto.d.ts +20 -0
  380. package/dist/modules/auth/dto/session.dto.d.ts.map +1 -0
  381. package/dist/modules/auth/dto/session.dto.js +98 -0
  382. package/dist/modules/auth/dto/session.dto.js.map +1 -0
  383. package/dist/modules/auth/dto/token.dto.d.ts +38 -1
  384. package/dist/modules/auth/dto/token.dto.d.ts.map +1 -1
  385. package/dist/modules/auth/dto/token.dto.js +21 -1
  386. package/dist/modules/auth/dto/token.dto.js.map +1 -1
  387. package/dist/modules/auth/entities/index.d.ts +2 -0
  388. package/dist/modules/auth/entities/index.d.ts.map +1 -1
  389. package/dist/modules/auth/entities/index.js +2 -0
  390. package/dist/modules/auth/entities/index.js.map +1 -1
  391. package/dist/modules/auth/entities/password-reset-token.entity.d.ts +2 -0
  392. package/dist/modules/auth/entities/password-reset-token.entity.d.ts.map +1 -1
  393. package/dist/modules/auth/entities/password-reset-token.entity.js +6 -0
  394. package/dist/modules/auth/entities/password-reset-token.entity.js.map +1 -1
  395. package/dist/modules/auth/entities/user-mfa.entity.d.ts +19 -0
  396. package/dist/modules/auth/entities/user-mfa.entity.d.ts.map +1 -0
  397. package/dist/modules/auth/entities/user-mfa.entity.js +73 -0
  398. package/dist/modules/auth/entities/user-mfa.entity.js.map +1 -0
  399. package/dist/modules/auth/entities/user-oauth-identity.entity.d.ts +24 -0
  400. package/dist/modules/auth/entities/user-oauth-identity.entity.d.ts.map +1 -0
  401. package/dist/modules/auth/entities/user-oauth-identity.entity.js +84 -0
  402. package/dist/modules/auth/entities/user-oauth-identity.entity.js.map +1 -0
  403. package/dist/modules/auth/events/auth.events.d.ts +84 -19
  404. package/dist/modules/auth/events/auth.events.d.ts.map +1 -1
  405. package/dist/modules/auth/events/auth.events.js +17 -9
  406. package/dist/modules/auth/events/auth.events.js.map +1 -1
  407. package/dist/modules/auth/services/account.service.d.ts +74 -14
  408. package/dist/modules/auth/services/account.service.d.ts.map +1 -1
  409. package/dist/modules/auth/services/account.service.js +247 -31
  410. package/dist/modules/auth/services/account.service.js.map +1 -1
  411. package/dist/modules/auth/services/dpop.service.d.ts +41 -0
  412. package/dist/modules/auth/services/dpop.service.d.ts.map +1 -0
  413. package/dist/modules/auth/services/dpop.service.js +159 -0
  414. package/dist/modules/auth/services/dpop.service.js.map +1 -0
  415. package/dist/modules/auth/services/index.d.ts +2 -0
  416. package/dist/modules/auth/services/index.d.ts.map +1 -1
  417. package/dist/modules/auth/services/index.js +2 -0
  418. package/dist/modules/auth/services/index.js.map +1 -1
  419. package/dist/modules/auth/services/legacy-hash-cleanup.service.d.ts +28 -0
  420. package/dist/modules/auth/services/legacy-hash-cleanup.service.d.ts.map +1 -0
  421. package/dist/modules/auth/services/legacy-hash-cleanup.service.js +163 -0
  422. package/dist/modules/auth/services/legacy-hash-cleanup.service.js.map +1 -0
  423. package/dist/modules/auth/services/login.service.d.ts +29 -34
  424. package/dist/modules/auth/services/login.service.d.ts.map +1 -1
  425. package/dist/modules/auth/services/login.service.js +173 -61
  426. package/dist/modules/auth/services/login.service.js.map +1 -1
  427. package/dist/modules/auth/services/mfa.service.d.ts +111 -0
  428. package/dist/modules/auth/services/mfa.service.d.ts.map +1 -0
  429. package/dist/modules/auth/services/mfa.service.js +662 -0
  430. package/dist/modules/auth/services/mfa.service.js.map +1 -0
  431. package/dist/modules/auth/services/oauth/apple-id-token.verifier.d.ts +11 -0
  432. package/dist/modules/auth/services/oauth/apple-id-token.verifier.d.ts.map +1 -0
  433. package/dist/modules/auth/services/oauth/apple-id-token.verifier.js +56 -0
  434. package/dist/modules/auth/services/oauth/apple-id-token.verifier.js.map +1 -0
  435. package/dist/modules/auth/services/oauth/google-id-token.verifier.d.ts +12 -0
  436. package/dist/modules/auth/services/oauth/google-id-token.verifier.d.ts.map +1 -0
  437. package/dist/modules/auth/services/oauth/google-id-token.verifier.js +64 -0
  438. package/dist/modules/auth/services/oauth/google-id-token.verifier.js.map +1 -0
  439. package/dist/modules/auth/services/oauth/microsoft-id-token.verifier.d.ts +11 -0
  440. package/dist/modules/auth/services/oauth/microsoft-id-token.verifier.d.ts.map +1 -0
  441. package/dist/modules/auth/services/oauth/microsoft-id-token.verifier.js +76 -0
  442. package/dist/modules/auth/services/oauth/microsoft-id-token.verifier.js.map +1 -0
  443. package/dist/modules/auth/services/oauth/oidc-id-token.verifier.d.ts +16 -0
  444. package/dist/modules/auth/services/oauth/oidc-id-token.verifier.d.ts.map +1 -0
  445. package/dist/modules/auth/services/oauth/oidc-id-token.verifier.js +92 -0
  446. package/dist/modules/auth/services/oauth/oidc-id-token.verifier.js.map +1 -0
  447. package/dist/modules/auth/services/oauth/verified-oauth-identity.d.ts +9 -0
  448. package/dist/modules/auth/services/oauth/verified-oauth-identity.d.ts.map +1 -0
  449. package/dist/modules/auth/services/oauth/verified-oauth-identity.js +3 -0
  450. package/dist/modules/auth/services/oauth/verified-oauth-identity.js.map +1 -0
  451. package/dist/modules/auth/services/oauth.service.d.ts +83 -0
  452. package/dist/modules/auth/services/oauth.service.d.ts.map +1 -0
  453. package/dist/modules/auth/services/oauth.service.js +471 -0
  454. package/dist/modules/auth/services/oauth.service.js.map +1 -0
  455. package/dist/modules/auth/services/otp-auth.service.d.ts +13 -3
  456. package/dist/modules/auth/services/otp-auth.service.d.ts.map +1 -1
  457. package/dist/modules/auth/services/otp-auth.service.js +41 -7
  458. package/dist/modules/auth/services/otp-auth.service.js.map +1 -1
  459. package/dist/modules/auth/services/password-reset-audit-retention.service.d.ts +22 -0
  460. package/dist/modules/auth/services/password-reset-audit-retention.service.d.ts.map +1 -0
  461. package/dist/modules/auth/services/password-reset-audit-retention.service.js +117 -0
  462. package/dist/modules/auth/services/password-reset-audit-retention.service.js.map +1 -0
  463. package/dist/modules/auth/services/password.service.d.ts +25 -5
  464. package/dist/modules/auth/services/password.service.d.ts.map +1 -1
  465. package/dist/modules/auth/services/password.service.js +154 -20
  466. package/dist/modules/auth/services/password.service.js.map +1 -1
  467. package/dist/modules/auth/services/pin-auth.service.d.ts +10 -3
  468. package/dist/modules/auth/services/pin-auth.service.d.ts.map +1 -1
  469. package/dist/modules/auth/services/pin-auth.service.js +110 -13
  470. package/dist/modules/auth/services/pin-auth.service.js.map +1 -1
  471. package/dist/modules/auth/services/registration.service.d.ts +10 -2
  472. package/dist/modules/auth/services/registration.service.d.ts.map +1 -1
  473. package/dist/modules/auth/services/registration.service.js +113 -25
  474. package/dist/modules/auth/services/registration.service.js.map +1 -1
  475. package/dist/modules/auth/services/turnstile.service.d.ts +17 -0
  476. package/dist/modules/auth/services/turnstile.service.d.ts.map +1 -0
  477. package/dist/modules/auth/services/turnstile.service.js +94 -0
  478. package/dist/modules/auth/services/turnstile.service.js.map +1 -0
  479. package/dist/modules/auth/utils/auth-params.util.d.ts +13 -6
  480. package/dist/modules/auth/utils/auth-params.util.d.ts.map +1 -1
  481. package/dist/modules/auth/utils/auth-params.util.js +27 -4
  482. package/dist/modules/auth/utils/auth-params.util.js.map +1 -1
  483. package/dist/modules/auth/utils/auth-supported.util.d.ts +12 -1
  484. package/dist/modules/auth/utils/auth-supported.util.d.ts.map +1 -1
  485. package/dist/modules/auth/utils/auth-supported.util.js +36 -4
  486. package/dist/modules/auth/utils/auth-supported.util.js.map +1 -1
  487. package/dist/modules/auth/utils/backup-code-hash.util.d.ts +10 -0
  488. package/dist/modules/auth/utils/backup-code-hash.util.d.ts.map +1 -0
  489. package/dist/modules/auth/utils/backup-code-hash.util.js +31 -0
  490. package/dist/modules/auth/utils/backup-code-hash.util.js.map +1 -0
  491. package/dist/modules/auth/utils/backup-codes.util.d.ts +5 -0
  492. package/dist/modules/auth/utils/backup-codes.util.d.ts.map +1 -0
  493. package/dist/modules/auth/utils/backup-codes.util.js +22 -0
  494. package/dist/modules/auth/utils/backup-codes.util.js.map +1 -0
  495. package/dist/modules/auth/utils/dpop.util.d.ts +22 -0
  496. package/dist/modules/auth/utils/dpop.util.d.ts.map +1 -0
  497. package/dist/modules/auth/utils/dpop.util.js +73 -0
  498. package/dist/modules/auth/utils/dpop.util.js.map +1 -0
  499. package/dist/modules/auth/utils/mfa-secret.util.d.ts +22 -0
  500. package/dist/modules/auth/utils/mfa-secret.util.d.ts.map +1 -0
  501. package/dist/modules/auth/utils/mfa-secret.util.js +59 -0
  502. package/dist/modules/auth/utils/mfa-secret.util.js.map +1 -0
  503. package/dist/modules/auth/utils/mfa-verify-params.util.d.ts +26 -0
  504. package/dist/modules/auth/utils/mfa-verify-params.util.d.ts.map +1 -0
  505. package/dist/modules/auth/utils/mfa-verify-params.util.js +49 -0
  506. package/dist/modules/auth/utils/mfa-verify-params.util.js.map +1 -0
  507. package/dist/modules/auth/utils/step-up-purpose.util.d.ts +5 -0
  508. package/dist/modules/auth/utils/step-up-purpose.util.d.ts.map +1 -0
  509. package/dist/modules/auth/utils/step-up-purpose.util.js +18 -0
  510. package/dist/modules/auth/utils/step-up-purpose.util.js.map +1 -0
  511. package/dist/modules/auth/utils/totp.util.d.ts +16 -0
  512. package/dist/modules/auth/utils/totp.util.d.ts.map +1 -0
  513. package/dist/modules/auth/utils/totp.util.js +88 -0
  514. package/dist/modules/auth/utils/totp.util.js.map +1 -0
  515. package/dist/modules/delivery/composers/otp-delivery.composer.d.ts +28 -1
  516. package/dist/modules/delivery/composers/otp-delivery.composer.d.ts.map +1 -1
  517. package/dist/modules/delivery/composers/otp-delivery.composer.js +48 -2
  518. package/dist/modules/delivery/composers/otp-delivery.composer.js.map +1 -1
  519. package/dist/modules/delivery/constants/delivery-worker.constants.d.ts +29 -0
  520. package/dist/modules/delivery/constants/delivery-worker.constants.d.ts.map +1 -0
  521. package/dist/modules/delivery/constants/delivery-worker.constants.js +51 -0
  522. package/dist/modules/delivery/constants/delivery-worker.constants.js.map +1 -0
  523. package/dist/modules/delivery/delivery.module.d.ts.map +1 -1
  524. package/dist/modules/delivery/delivery.module.js +1 -15
  525. package/dist/modules/delivery/delivery.module.js.map +1 -1
  526. package/dist/modules/delivery/entities/notification-delivery-log.entity.d.ts.map +1 -1
  527. package/dist/modules/delivery/entities/notification-delivery-log.entity.js +3 -1
  528. package/dist/modules/delivery/entities/notification-delivery-log.entity.js.map +1 -1
  529. package/dist/modules/delivery/notification-delivery.service.d.ts +12 -1
  530. package/dist/modules/delivery/notification-delivery.service.d.ts.map +1 -1
  531. package/dist/modules/delivery/notification-delivery.service.js +121 -40
  532. package/dist/modules/delivery/notification-delivery.service.js.map +1 -1
  533. package/dist/modules/delivery/processors/delivery-job.runner.d.ts +22 -1
  534. package/dist/modules/delivery/processors/delivery-job.runner.d.ts.map +1 -1
  535. package/dist/modules/delivery/processors/delivery-job.runner.js +144 -42
  536. package/dist/modules/delivery/processors/delivery-job.runner.js.map +1 -1
  537. package/dist/modules/delivery/processors/delivery.processor.d.ts.map +1 -1
  538. package/dist/modules/delivery/processors/delivery.processor.js +6 -1
  539. package/dist/modules/delivery/processors/delivery.processor.js.map +1 -1
  540. package/dist/modules/delivery/processors/otp-delivery-job.runner.d.ts +11 -0
  541. package/dist/modules/delivery/processors/otp-delivery-job.runner.d.ts.map +1 -1
  542. package/dist/modules/delivery/processors/otp-delivery-job.runner.js +90 -16
  543. package/dist/modules/delivery/processors/otp-delivery-job.runner.js.map +1 -1
  544. package/dist/modules/delivery/processors/otp-delivery.processor.d.ts.map +1 -1
  545. package/dist/modules/delivery/processors/otp-delivery.processor.js +6 -1
  546. package/dist/modules/delivery/processors/otp-delivery.processor.js.map +1 -1
  547. package/dist/modules/delivery/queues/sync-jobs.queue.d.ts +7 -1
  548. package/dist/modules/delivery/queues/sync-jobs.queue.d.ts.map +1 -1
  549. package/dist/modules/delivery/queues/sync-jobs.queue.js +11 -2
  550. package/dist/modules/delivery/queues/sync-jobs.queue.js.map +1 -1
  551. package/dist/modules/delivery/services/delivery-audit-retention.service.d.ts +7 -3
  552. package/dist/modules/delivery/services/delivery-audit-retention.service.d.ts.map +1 -1
  553. package/dist/modules/delivery/services/delivery-audit-retention.service.js +33 -10
  554. package/dist/modules/delivery/services/delivery-audit-retention.service.js.map +1 -1
  555. package/dist/modules/delivery/services/notification-audit.service.d.ts +7 -4
  556. package/dist/modules/delivery/services/notification-audit.service.d.ts.map +1 -1
  557. package/dist/modules/delivery/services/notification-audit.service.js +83 -26
  558. package/dist/modules/delivery/services/notification-audit.service.js.map +1 -1
  559. package/dist/modules/delivery/utils/payload-snapshot.util.d.ts +2 -0
  560. package/dist/modules/delivery/utils/payload-snapshot.util.d.ts.map +1 -1
  561. package/dist/modules/delivery/utils/payload-snapshot.util.js +22 -3
  562. package/dist/modules/delivery/utils/payload-snapshot.util.js.map +1 -1
  563. package/dist/modules/file-upload/controllers/file-upload.controller.d.ts +7 -1
  564. package/dist/modules/file-upload/controllers/file-upload.controller.d.ts.map +1 -1
  565. package/dist/modules/file-upload/controllers/file-upload.controller.js +5 -7
  566. package/dist/modules/file-upload/controllers/file-upload.controller.js.map +1 -1
  567. package/dist/modules/file-upload/dto/file-upload.dto.d.ts +2 -0
  568. package/dist/modules/file-upload/dto/file-upload.dto.d.ts.map +1 -1
  569. package/dist/modules/file-upload/dto/file-upload.dto.js +20 -0
  570. package/dist/modules/file-upload/dto/file-upload.dto.js.map +1 -1
  571. package/dist/modules/file-upload/file-upload.module.d.ts.map +1 -1
  572. package/dist/modules/file-upload/file-upload.module.js +12 -2
  573. package/dist/modules/file-upload/file-upload.module.js.map +1 -1
  574. package/dist/modules/file-upload/services/file-upload.service.d.ts +24 -6
  575. package/dist/modules/file-upload/services/file-upload.service.d.ts.map +1 -1
  576. package/dist/modules/file-upload/services/file-upload.service.js +164 -36
  577. package/dist/modules/file-upload/services/file-upload.service.js.map +1 -1
  578. package/dist/modules/file-upload/services/upload-orphan-cleanup.service.d.ts +4 -2
  579. package/dist/modules/file-upload/services/upload-orphan-cleanup.service.d.ts.map +1 -1
  580. package/dist/modules/file-upload/services/upload-orphan-cleanup.service.js +30 -5
  581. package/dist/modules/file-upload/services/upload-orphan-cleanup.service.js.map +1 -1
  582. package/dist/modules/file-upload/utils/image-optimize.util.d.ts.map +1 -1
  583. package/dist/modules/file-upload/utils/image-optimize.util.js +7 -1
  584. package/dist/modules/file-upload/utils/image-optimize.util.js.map +1 -1
  585. package/dist/modules/health/health.controller.d.ts +5 -1
  586. package/dist/modules/health/health.controller.d.ts.map +1 -1
  587. package/dist/modules/health/health.controller.js +57 -3
  588. package/dist/modules/health/health.controller.js.map +1 -1
  589. package/dist/modules/invitations/controllers/invitations.controller.d.ts +19 -4
  590. package/dist/modules/invitations/controllers/invitations.controller.d.ts.map +1 -1
  591. package/dist/modules/invitations/controllers/invitations.controller.js +19 -10
  592. package/dist/modules/invitations/controllers/invitations.controller.js.map +1 -1
  593. package/dist/modules/invitations/dto/invitation.dto.d.ts +13 -0
  594. package/dist/modules/invitations/dto/invitation.dto.d.ts.map +1 -1
  595. package/dist/modules/invitations/dto/invitation.dto.js +69 -2
  596. package/dist/modules/invitations/dto/invitation.dto.js.map +1 -1
  597. package/dist/modules/invitations/services/invitations.service.d.ts +24 -6
  598. package/dist/modules/invitations/services/invitations.service.d.ts.map +1 -1
  599. package/dist/modules/invitations/services/invitations.service.js +96 -20
  600. package/dist/modules/invitations/services/invitations.service.js.map +1 -1
  601. package/dist/modules/jobs/queues/jobs.queue.d.ts +7 -2
  602. package/dist/modules/jobs/queues/jobs.queue.d.ts.map +1 -1
  603. package/dist/modules/jobs/queues/jobs.queue.js +25 -10
  604. package/dist/modules/jobs/queues/jobs.queue.js.map +1 -1
  605. package/dist/modules/notifications/controllers/notifications.controller.d.ts +3 -1
  606. package/dist/modules/notifications/controllers/notifications.controller.d.ts.map +1 -1
  607. package/dist/modules/notifications/controllers/notifications.controller.js +25 -2
  608. package/dist/modules/notifications/controllers/notifications.controller.js.map +1 -1
  609. package/dist/modules/notifications/dto/notification-query.dto.d.ts.map +1 -1
  610. package/dist/modules/notifications/dto/notification-query.dto.js +1 -0
  611. package/dist/modules/notifications/dto/notification-query.dto.js.map +1 -1
  612. package/dist/modules/notifications/entities/device-token.entity.d.ts.map +1 -1
  613. package/dist/modules/notifications/entities/device-token.entity.js +3 -1
  614. package/dist/modules/notifications/entities/device-token.entity.js.map +1 -1
  615. package/dist/modules/notifications/services/fcm.service.d.ts +2 -0
  616. package/dist/modules/notifications/services/fcm.service.d.ts.map +1 -1
  617. package/dist/modules/notifications/services/fcm.service.js +28 -7
  618. package/dist/modules/notifications/services/fcm.service.js.map +1 -1
  619. package/dist/modules/notifications/services/notifications.service.d.ts +16 -3
  620. package/dist/modules/notifications/services/notifications.service.d.ts.map +1 -1
  621. package/dist/modules/notifications/services/notifications.service.js +95 -24
  622. package/dist/modules/notifications/services/notifications.service.js.map +1 -1
  623. package/dist/modules/observability/metrics/metrics.service.d.ts +2 -0
  624. package/dist/modules/observability/metrics/metrics.service.d.ts.map +1 -1
  625. package/dist/modules/observability/metrics/metrics.service.js +11 -0
  626. package/dist/modules/observability/metrics/metrics.service.js.map +1 -1
  627. package/dist/modules/otp/constants/otp.constants.d.ts +7 -5
  628. package/dist/modules/otp/constants/otp.constants.d.ts.map +1 -1
  629. package/dist/modules/otp/constants/otp.constants.js +11 -8
  630. package/dist/modules/otp/constants/otp.constants.js.map +1 -1
  631. package/dist/modules/otp/interfaces/otp.service.interface.d.ts +1 -1
  632. package/dist/modules/otp/interfaces/otp.service.interface.d.ts.map +1 -1
  633. package/dist/modules/otp/otp.service.d.ts +10 -2
  634. package/dist/modules/otp/otp.service.d.ts.map +1 -1
  635. package/dist/modules/otp/otp.service.js +48 -4
  636. package/dist/modules/otp/otp.service.js.map +1 -1
  637. package/dist/modules/otp/services/otp.rate-limiter.d.ts +2 -0
  638. package/dist/modules/otp/services/otp.rate-limiter.d.ts.map +1 -1
  639. package/dist/modules/otp/services/otp.rate-limiter.js +19 -0
  640. package/dist/modules/otp/services/otp.rate-limiter.js.map +1 -1
  641. package/dist/modules/otp/services/otp.session.store.d.ts +9 -3
  642. package/dist/modules/otp/services/otp.session.store.d.ts.map +1 -1
  643. package/dist/modules/otp/services/otp.session.store.js +34 -42
  644. package/dist/modules/otp/services/otp.session.store.js.map +1 -1
  645. package/dist/modules/otp/utils/otp-code-hash.util.d.ts +11 -0
  646. package/dist/modules/otp/utils/otp-code-hash.util.d.ts.map +1 -0
  647. package/dist/modules/otp/utils/otp-code-hash.util.js +68 -0
  648. package/dist/modules/otp/utils/otp-code-hash.util.js.map +1 -0
  649. package/dist/modules/profile/controllers/profile.controller.d.ts +9 -3
  650. package/dist/modules/profile/controllers/profile.controller.d.ts.map +1 -1
  651. package/dist/modules/profile/controllers/profile.controller.js +140 -8
  652. package/dist/modules/profile/controllers/profile.controller.js.map +1 -1
  653. package/dist/modules/profile/dto/create-user-profile.dto.d.ts +10 -0
  654. package/dist/modules/profile/dto/create-user-profile.dto.d.ts.map +1 -1
  655. package/dist/modules/profile/dto/create-user-profile.dto.js +43 -1
  656. package/dist/modules/profile/dto/create-user-profile.dto.js.map +1 -1
  657. package/dist/modules/profile/dto/public-user-profile.dto.d.ts +24 -0
  658. package/dist/modules/profile/dto/public-user-profile.dto.d.ts.map +1 -0
  659. package/dist/modules/profile/dto/public-user-profile.dto.js +115 -0
  660. package/dist/modules/profile/dto/public-user-profile.dto.js.map +1 -0
  661. package/dist/modules/profile/dto/user-profile-response.dto.d.ts +4 -0
  662. package/dist/modules/profile/dto/user-profile-response.dto.d.ts.map +1 -1
  663. package/dist/modules/profile/dto/user-profile-response.dto.js +4 -0
  664. package/dist/modules/profile/dto/user-profile-response.dto.js.map +1 -1
  665. package/dist/modules/profile/dto/username-available.dto.d.ts +6 -0
  666. package/dist/modules/profile/dto/username-available.dto.d.ts.map +1 -0
  667. package/dist/modules/profile/dto/username-available.dto.js +31 -0
  668. package/dist/modules/profile/dto/username-available.dto.js.map +1 -0
  669. package/dist/modules/profile/entities/user-profiles.entity.d.ts +10 -0
  670. package/dist/modules/profile/entities/user-profiles.entity.d.ts.map +1 -1
  671. package/dist/modules/profile/entities/user-profiles.entity.js +29 -1
  672. package/dist/modules/profile/entities/user-profiles.entity.js.map +1 -1
  673. package/dist/modules/profile/index.d.ts +1 -0
  674. package/dist/modules/profile/index.d.ts.map +1 -1
  675. package/dist/modules/profile/index.js +1 -0
  676. package/dist/modules/profile/index.js.map +1 -1
  677. package/dist/modules/profile/profile.manifest.d.ts +2 -2
  678. package/dist/modules/profile/profile.manifest.js +2 -2
  679. package/dist/modules/profile/profile.manifest.js.map +1 -1
  680. package/dist/modules/profile/profile.module.d.ts.map +1 -1
  681. package/dist/modules/profile/profile.module.js +7 -2
  682. package/dist/modules/profile/profile.module.js.map +1 -1
  683. package/dist/modules/profile/services/profile.service.d.ts +56 -4
  684. package/dist/modules/profile/services/profile.service.d.ts.map +1 -1
  685. package/dist/modules/profile/services/profile.service.js +247 -20
  686. package/dist/modules/profile/services/profile.service.js.map +1 -1
  687. package/dist/modules/realtime/adapters/redis-io.adapter.d.ts +26 -0
  688. package/dist/modules/realtime/adapters/redis-io.adapter.d.ts.map +1 -0
  689. package/dist/modules/realtime/adapters/redis-io.adapter.js +124 -0
  690. package/dist/modules/realtime/adapters/redis-io.adapter.js.map +1 -0
  691. package/dist/modules/realtime/constants/realtime.constants.d.ts +36 -0
  692. package/dist/modules/realtime/constants/realtime.constants.d.ts.map +1 -0
  693. package/dist/modules/realtime/constants/realtime.constants.js +42 -0
  694. package/dist/modules/realtime/constants/realtime.constants.js.map +1 -0
  695. package/dist/modules/realtime/controllers/realtime.controller.d.ts +21 -0
  696. package/dist/modules/realtime/controllers/realtime.controller.d.ts.map +1 -0
  697. package/dist/modules/realtime/controllers/realtime.controller.js +113 -0
  698. package/dist/modules/realtime/controllers/realtime.controller.js.map +1 -0
  699. package/dist/modules/realtime/gateway/realtime.gateway.d.ts +42 -0
  700. package/dist/modules/realtime/gateway/realtime.gateway.d.ts.map +1 -0
  701. package/dist/modules/realtime/gateway/realtime.gateway.js +289 -0
  702. package/dist/modules/realtime/gateway/realtime.gateway.js.map +1 -0
  703. package/dist/modules/realtime/index.d.ts +12 -0
  704. package/dist/modules/realtime/index.d.ts.map +1 -0
  705. package/dist/modules/realtime/index.js +35 -0
  706. package/dist/modules/realtime/index.js.map +1 -0
  707. package/dist/modules/realtime/realtime.manifest.d.ts +8 -0
  708. package/dist/modules/realtime/realtime.manifest.d.ts.map +1 -0
  709. package/dist/modules/realtime/realtime.manifest.js +31 -0
  710. package/dist/modules/realtime/realtime.manifest.js.map +1 -0
  711. package/dist/modules/realtime/realtime.module.d.ts +14 -0
  712. package/dist/modules/realtime/realtime.module.d.ts.map +1 -0
  713. package/dist/modules/realtime/realtime.module.js +126 -0
  714. package/dist/modules/realtime/realtime.module.js.map +1 -0
  715. package/dist/modules/realtime/services/realtime-handler.registry.d.ts +16 -0
  716. package/dist/modules/realtime/services/realtime-handler.registry.d.ts.map +1 -0
  717. package/dist/modules/realtime/services/realtime-handler.registry.js +55 -0
  718. package/dist/modules/realtime/services/realtime-handler.registry.js.map +1 -0
  719. package/dist/modules/realtime/services/realtime-presence.service.d.ts +15 -0
  720. package/dist/modules/realtime/services/realtime-presence.service.d.ts.map +1 -0
  721. package/dist/modules/realtime/services/realtime-presence.service.js +86 -0
  722. package/dist/modules/realtime/services/realtime-presence.service.js.map +1 -0
  723. package/dist/modules/realtime/services/realtime-rate-limiter.service.d.ts +12 -0
  724. package/dist/modules/realtime/services/realtime-rate-limiter.service.d.ts.map +1 -0
  725. package/dist/modules/realtime/services/realtime-rate-limiter.service.js +63 -0
  726. package/dist/modules/realtime/services/realtime-rate-limiter.service.js.map +1 -0
  727. package/dist/modules/realtime/services/realtime.service.d.ts +88 -0
  728. package/dist/modules/realtime/services/realtime.service.d.ts.map +1 -0
  729. package/dist/modules/realtime/services/realtime.service.js +343 -0
  730. package/dist/modules/realtime/services/realtime.service.js.map +1 -0
  731. package/dist/modules/realtime/types/realtime.types.d.ts +50 -0
  732. package/dist/modules/realtime/types/realtime.types.d.ts.map +1 -0
  733. package/dist/modules/realtime/types/realtime.types.js +14 -0
  734. package/dist/modules/realtime/types/realtime.types.js.map +1 -0
  735. package/dist/modules/realtime/utils/handshake-error.util.d.ts +5 -0
  736. package/dist/modules/realtime/utils/handshake-error.util.d.ts.map +1 -0
  737. package/dist/modules/realtime/utils/handshake-error.util.js +45 -0
  738. package/dist/modules/realtime/utils/handshake-error.util.js.map +1 -0
  739. package/dist/modules/roles/controllers/modules.controller.d.ts +4 -3
  740. package/dist/modules/roles/controllers/modules.controller.d.ts.map +1 -1
  741. package/dist/modules/roles/controllers/modules.controller.js +21 -10
  742. package/dist/modules/roles/controllers/modules.controller.js.map +1 -1
  743. package/dist/modules/roles/controllers/permissions.controller.d.ts +4 -3
  744. package/dist/modules/roles/controllers/permissions.controller.d.ts.map +1 -1
  745. package/dist/modules/roles/controllers/permissions.controller.js +21 -10
  746. package/dist/modules/roles/controllers/permissions.controller.js.map +1 -1
  747. package/dist/modules/roles/controllers/roles.controller.d.ts +5 -4
  748. package/dist/modules/roles/controllers/roles.controller.d.ts.map +1 -1
  749. package/dist/modules/roles/controllers/roles.controller.js +26 -13
  750. package/dist/modules/roles/controllers/roles.controller.js.map +1 -1
  751. package/dist/modules/roles/controllers/user-roles.controller.d.ts +3 -2
  752. package/dist/modules/roles/controllers/user-roles.controller.d.ts.map +1 -1
  753. package/dist/modules/roles/controllers/user-roles.controller.js +14 -6
  754. package/dist/modules/roles/controllers/user-roles.controller.js.map +1 -1
  755. package/dist/modules/roles/services/modules.service.d.ts +8 -5
  756. package/dist/modules/roles/services/modules.service.d.ts.map +1 -1
  757. package/dist/modules/roles/services/modules.service.js +58 -12
  758. package/dist/modules/roles/services/modules.service.js.map +1 -1
  759. package/dist/modules/roles/services/permissions.service.d.ts +8 -5
  760. package/dist/modules/roles/services/permissions.service.d.ts.map +1 -1
  761. package/dist/modules/roles/services/permissions.service.js +61 -12
  762. package/dist/modules/roles/services/permissions.service.js.map +1 -1
  763. package/dist/modules/roles/services/roles.service.d.ts +19 -9
  764. package/dist/modules/roles/services/roles.service.d.ts.map +1 -1
  765. package/dist/modules/roles/services/roles.service.js +137 -47
  766. package/dist/modules/roles/services/roles.service.js.map +1 -1
  767. package/dist/modules/roles/services/user-roles.service.d.ts +12 -4
  768. package/dist/modules/roles/services/user-roles.service.d.ts.map +1 -1
  769. package/dist/modules/roles/services/user-roles.service.js +58 -26
  770. package/dist/modules/roles/services/user-roles.service.js.map +1 -1
  771. package/dist/modules/sessions/entities/refresh-token.entity.d.ts +7 -1
  772. package/dist/modules/sessions/entities/refresh-token.entity.d.ts.map +1 -1
  773. package/dist/modules/sessions/entities/refresh-token.entity.js +10 -0
  774. package/dist/modules/sessions/entities/refresh-token.entity.js.map +1 -1
  775. package/dist/modules/sessions/entities/revoked-refresh-family.entity.d.ts +12 -0
  776. package/dist/modules/sessions/entities/revoked-refresh-family.entity.d.ts.map +1 -0
  777. package/dist/modules/sessions/entities/revoked-refresh-family.entity.js +46 -0
  778. package/dist/modules/sessions/entities/revoked-refresh-family.entity.js.map +1 -0
  779. package/dist/modules/sessions/services/refresh-token-retention.service.d.ts +20 -0
  780. package/dist/modules/sessions/services/refresh-token-retention.service.d.ts.map +1 -0
  781. package/dist/modules/sessions/services/refresh-token-retention.service.js +97 -0
  782. package/dist/modules/sessions/services/refresh-token-retention.service.js.map +1 -0
  783. package/dist/modules/sessions/services/token.service.d.ts +150 -16
  784. package/dist/modules/sessions/services/token.service.d.ts.map +1 -1
  785. package/dist/modules/sessions/services/token.service.js +505 -74
  786. package/dist/modules/sessions/services/token.service.js.map +1 -1
  787. package/dist/modules/sessions/sessions.module.d.ts.map +1 -1
  788. package/dist/modules/sessions/sessions.module.js +4 -2
  789. package/dist/modules/sessions/sessions.module.js.map +1 -1
  790. package/dist/modules/sessions/utils/refresh-token-hash.util.d.ts +13 -0
  791. package/dist/modules/sessions/utils/refresh-token-hash.util.d.ts.map +1 -0
  792. package/dist/modules/sessions/utils/refresh-token-hash.util.js +37 -0
  793. package/dist/modules/sessions/utils/refresh-token-hash.util.js.map +1 -0
  794. package/dist/modules/settings/constants/settings.defaults.d.ts +57 -3
  795. package/dist/modules/settings/constants/settings.defaults.d.ts.map +1 -1
  796. package/dist/modules/settings/constants/settings.defaults.js +58 -3
  797. package/dist/modules/settings/constants/settings.defaults.js.map +1 -1
  798. package/dist/modules/settings/constants/settings.keys.d.ts +138 -2
  799. package/dist/modules/settings/constants/settings.keys.d.ts.map +1 -1
  800. package/dist/modules/settings/constants/settings.keys.js +140 -2
  801. package/dist/modules/settings/constants/settings.keys.js.map +1 -1
  802. package/dist/modules/settings/controllers/settings.controller.d.ts +5 -1
  803. package/dist/modules/settings/controllers/settings.controller.d.ts.map +1 -1
  804. package/dist/modules/settings/controllers/settings.controller.js +134 -5
  805. package/dist/modules/settings/controllers/settings.controller.js.map +1 -1
  806. package/dist/modules/settings/services/settings.service.d.ts +17 -7
  807. package/dist/modules/settings/services/settings.service.d.ts.map +1 -1
  808. package/dist/modules/settings/services/settings.service.js +80 -14
  809. package/dist/modules/settings/services/settings.service.js.map +1 -1
  810. package/dist/modules/settings/utils/settings-secret.util.d.ts +13 -0
  811. package/dist/modules/settings/utils/settings-secret.util.d.ts.map +1 -0
  812. package/dist/modules/settings/utils/settings-secret.util.js +80 -0
  813. package/dist/modules/settings/utils/settings-secret.util.js.map +1 -0
  814. package/dist/modules/users/controllers/users.controller.d.ts +4 -2
  815. package/dist/modules/users/controllers/users.controller.d.ts.map +1 -1
  816. package/dist/modules/users/controllers/users.controller.js +89 -10
  817. package/dist/modules/users/controllers/users.controller.js.map +1 -1
  818. package/dist/modules/users/dto/user.dto.d.ts +3 -0
  819. package/dist/modules/users/dto/user.dto.d.ts.map +1 -1
  820. package/dist/modules/users/dto/user.dto.js +27 -4
  821. package/dist/modules/users/dto/user.dto.js.map +1 -1
  822. package/dist/modules/users/entities/user.entity.d.ts +7 -1
  823. package/dist/modules/users/entities/user.entity.d.ts.map +1 -1
  824. package/dist/modules/users/entities/user.entity.js +10 -0
  825. package/dist/modules/users/entities/user.entity.js.map +1 -1
  826. package/dist/modules/users/services/users.service.d.ts +15 -2
  827. package/dist/modules/users/services/users.service.d.ts.map +1 -1
  828. package/dist/modules/users/services/users.service.js +152 -37
  829. package/dist/modules/users/services/users.service.js.map +1 -1
  830. package/dist/modules/users/users.module.d.ts.map +1 -1
  831. package/dist/modules/users/users.module.js +1 -2
  832. package/dist/modules/users/users.module.js.map +1 -1
  833. package/package.json +19 -7
  834. package/dist/modules/admin/entities/admin-log.entity.d.ts +0 -20
  835. package/dist/modules/admin/entities/admin-log.entity.d.ts.map +0 -1
  836. package/dist/modules/admin/entities/admin-log.entity.js +0 -65
  837. package/dist/modules/admin/entities/admin-log.entity.js.map +0 -1
@@ -14,6 +14,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.OtpAuthService = void 0;
16
16
  const common_1 = require("@nestjs/common");
17
+ const audit_actions_1 = require("../../audit/constants/audit-actions");
18
+ const audit_service_1 = require("../../audit/services/audit.service");
17
19
  const structured_logger_service_1 = require("../../observability/logging/structured-logger.service");
18
20
  const otp_service_interface_1 = require("../../otp/interfaces/otp.service.interface");
19
21
  const otp_utils_1 = require("../../otp/utils/otp.utils");
@@ -31,13 +33,15 @@ let OtpAuthService = class OtpAuthService {
31
33
  settingsService;
32
34
  loginService;
33
35
  logger;
34
- constructor(otpService, usersService, tokenService, settingsService, loginService, logger) {
36
+ audit;
37
+ constructor(otpService, usersService, tokenService, settingsService, loginService, logger, audit) {
35
38
  this.otpService = otpService;
36
39
  this.usersService = usersService;
37
40
  this.tokenService = tokenService;
38
41
  this.settingsService = settingsService;
39
42
  this.loginService = loginService;
40
43
  this.logger = logger;
44
+ this.audit = audit;
41
45
  }
42
46
  sendOtp(identifier, channel) {
43
47
  return this.otpService.generateOtp(identifier, channel);
@@ -59,10 +63,28 @@ let OtpAuthService = class OtpAuthService {
59
63
  throw new common_1.UnauthorizedException('This account uses email and password authentication. Please sign in with email and password.');
60
64
  }
61
65
  if (channel === 'sms' && !user.isPhoneVerified) {
62
- await this.usersService.verifyPhone(user.id);
66
+ await this.usersService.markPhoneVerified(user.id);
67
+ user.isPhoneVerified = true;
68
+ this.audit.record({
69
+ action: audit_actions_1.AUDIT_ACTIONS.PHONE_VERIFIED,
70
+ actorType: 'USER',
71
+ actorId: user.id,
72
+ resourceType: 'user',
73
+ resourceId: user.id,
74
+ metadata: { method: 'otp_verify' },
75
+ });
63
76
  }
64
77
  else if (channel === 'email' && !user.isEmailVerified) {
65
- await this.usersService.verifyEmail(user.id);
78
+ await this.usersService.markEmailVerified(user.id);
79
+ user.isEmailVerified = true;
80
+ this.audit.record({
81
+ action: audit_actions_1.AUDIT_ACTIONS.EMAIL_VERIFIED,
82
+ actorType: 'USER',
83
+ actorId: user.id,
84
+ resourceType: 'user',
85
+ resourceId: user.id,
86
+ metadata: { method: 'otp_verify' },
87
+ });
66
88
  }
67
89
  verifyResult.data.verificationToken =
68
90
  channel === 'email'
@@ -84,6 +106,17 @@ let OtpAuthService = class OtpAuthService {
84
106
  verifyResult.data.hasAccount = false;
85
107
  return verifyResult;
86
108
  }
109
+ /**
110
+ * Validates an OTP and returns the verified subject + channel (no auth bridge tokens).
111
+ * Used by change-email / change-phone style identity updates.
112
+ */
113
+ async verifyOtpChallengeWithSubject(verificationId, otp) {
114
+ const result = await this.otpService.verifyOtp(verificationId, otp);
115
+ return {
116
+ subject: result.data.subject,
117
+ channel: result.data.channel,
118
+ };
119
+ }
87
120
  /**
88
121
  * Validates an OTP code against a session token as a security challenge.
89
122
  * Used by flows that need identity proof without user lookup (e.g. account deletion).
@@ -97,7 +130,7 @@ let OtpAuthService = class OtpAuthService {
97
130
  /**
98
131
  * Dev-only: send-otp → verify-otp → login in one call for test.otp_identifiers entries.
99
132
  */
100
- async testLogin(identifier, channel, otp, deviceInfo, ipAddress) {
133
+ async testLogin(identifier, channel, otp, deviceInfo, ipAddress, dpopJkt) {
101
134
  this.otpService.assertTestCredentials(identifier, channel, otp);
102
135
  this.logger.info('Dev test login attempt', {
103
136
  event: 'auth.test_login.attempt',
@@ -117,13 +150,13 @@ let OtpAuthService = class OtpAuthService {
117
150
  if (!verifyResult.data.verificationToken) {
118
151
  throw new common_1.UnauthorizedException('Phone verification token missing');
119
152
  }
120
- return this.loginService.loginWithPhoneVerificationToken(verifyResult.data.verificationToken, deviceInfo, ipAddress);
153
+ return this.loginService.loginWithPhoneVerificationToken(verifyResult.data.verificationToken, deviceInfo, ipAddress, dpopJkt);
121
154
  }
122
155
  const user = await this.usersService.findBy({ email: verifyResult.data.subject });
123
156
  if (!user) {
124
157
  throw new common_1.UnauthorizedException('User not found');
125
158
  }
126
- return this.loginService.completeLoginForUser(user, user_entity_1.UserAuthMethod.EMAIL, deviceInfo, ipAddress);
159
+ return this.loginService.continueAfterFirstFactor(user, user_entity_1.UserAuthMethod.EMAIL, deviceInfo, ipAddress, { dpopJkt });
127
160
  }
128
161
  };
129
162
  exports.OtpAuthService = OtpAuthService;
@@ -135,6 +168,7 @@ exports.OtpAuthService = OtpAuthService = __decorate([
135
168
  token_service_1.TokenService,
136
169
  settings_service_1.SettingsService,
137
170
  login_service_1.LoginService,
138
- structured_logger_service_1.StructuredLoggerService])
171
+ structured_logger_service_1.StructuredLoggerService,
172
+ audit_service_1.AuditService])
139
173
  ], OtpAuthService);
140
174
  //# sourceMappingURL=otp-auth.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"otp-auth.service.js","sourceRoot":"","sources":["../../../../src/modules/auth/services/otp-auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgG;AAEhG,qGAAgG;AAChG,sFAIoD;AACpD,yDAA2D;AAC3D,yEAAqE;AACrE,0EAAsE;AACtE,+EAA2E;AAC3E,kEAAkE;AAClE,sEAAkE;AAElE,gEAAgE;AAChE,mDAA+C;AAGxC,IAAM,cAAc,GAApB,MAAM,cAAc;IAGR;IACA;IACA;IACA;IACA;IACA;IAPlB,YAEkB,UAAuB,EACvB,YAA0B,EAC1B,YAA0B,EAC1B,eAAgC,EAChC,YAA0B,EAC1B,MAA+B;QAL/B,eAAU,GAAV,UAAU,CAAa;QACvB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,oBAAe,GAAf,eAAe,CAAiB;QAChC,iBAAY,GAAZ,YAAY,CAAc;QAC1B,WAAM,GAAN,MAAM,CAAyB;IAC9C,CAAC;IAEJ,OAAO,CAAC,UAAkB,EAAE,OAAwB;QACn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AgB,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAC5C,IAAI,EACJ,4BAAc,CAAC,KAAK,EACpB,UAAU,EACV,SAAS,CACT,CAAC;IACH,CAAC;CACD,CAAA;AAtIY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAGV,WAAA,IAAA,eAAM,EAAC,mCAAW,CAAC,CAAA;qCACS,mCAAW;QACT,4BAAY;QACZ,4BAAY;QACT,kCAAe;QAClB,4BAAY;QAClB,mDAAuB;GARrC,cAAc,CAsI1B"}
1
+ {"version":3,"file":"otp-auth.service.js","sourceRoot":"","sources":["../../../../src/modules/auth/services/otp-auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgG;AAEhG,uEAAoE;AACpE,sEAAkE;AAClE,qGAAgG;AAChG,sFAIoD;AACpD,yDAA2D;AAC3D,yEAAqE;AACrE,0EAAsE;AACtE,+EAA2E;AAC3E,kEAAkE;AAClE,sEAAkE;AAElE,gEAAgE;AAChE,mDAA+C;AAGxC,IAAM,cAAc,GAApB,MAAM,cAAc;IAGR;IACA;IACA;IACA;IACA;IACA;IACA;IARlB,YAEkB,UAAuB,EACvB,YAA0B,EAC1B,YAA0B,EAC1B,eAAgC,EAChC,YAA0B,EAC1B,MAA+B,EAC/B,KAAmB;QANnB,eAAU,GAAV,UAAU,CAAa;QACvB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,oBAAe,GAAf,eAAe,CAAiB;QAChC,iBAAY,GAAZ,YAAY,CAAc;QAC1B,WAAM,GAAN,MAAM,CAAyB;QAC/B,UAAK,GAAL,KAAK,CAAc;IAClC,CAAC;IAEJ,OAAO,CAAC,UAAkB,EAAE,OAAwB;QACnD,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,SAAS,CAAC,cA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4BAAY;GATzB,cAAc,CA2K1B"}
@@ -0,0 +1,22 @@
1
+ import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
2
+ import type IORedis from 'ioredis';
3
+ import { Repository } from 'typeorm';
4
+ import { StructuredLoggerService } from '../../observability/logging/structured-logger.service';
5
+ import { SettingsService } from '../../settings/services/settings.service';
6
+ import { PasswordResetToken } from '../entities/password-reset-token.entity';
7
+ /**
8
+ * Always runs — audit retention must not depend on observability toggles.
9
+ * Deletes in bounded batches; single-leader across replicas via Redis NX.
10
+ */
11
+ export declare class PasswordResetAuditRetentionService implements OnModuleInit, OnModuleDestroy {
12
+ private readonly resetAuditRepo;
13
+ private readonly settingsService;
14
+ private readonly logger;
15
+ private readonly redis;
16
+ private timer;
17
+ constructor(resetAuditRepo: Repository<PasswordResetToken>, settingsService: SettingsService, logger: StructuredLoggerService, redis: IORedis);
18
+ onModuleInit(): void;
19
+ onModuleDestroy(): void;
20
+ private purge;
21
+ }
22
+ //# sourceMappingURL=password-reset-audit-retention.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-reset-audit-retention.service.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/password-reset-audit-retention.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAO7E;;;GAGG;AACH,qBACa,kCAAmC,YAAW,YAAY,EAAE,eAAe;IAKtF,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACD,OAAO,CAAC,QAAQ,CAAC,KAAK;IAP7C,OAAO,CAAC,KAAK,CAA+C;gBAI1C,cAAc,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAC9C,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,uBAAuB,EACT,KAAK,EAAE,OAAO;IAGtD,YAAY,IAAI,IAAI;IAOpB,eAAe,IAAI,IAAI;YAOT,KAAK;CAyDnB"}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PasswordResetAuditRetentionService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const typeorm_1 = require("@nestjs/typeorm");
18
+ const typeorm_2 = require("typeorm");
19
+ const redis_module_1 = require("../../../config/redis.module");
20
+ const structured_logger_service_1 = require("../../observability/logging/structured-logger.service");
21
+ const settings_keys_1 = require("../../settings/constants/settings.keys");
22
+ const settings_service_1 = require("../../settings/services/settings.service");
23
+ const password_reset_token_entity_1 = require("../entities/password-reset-token.entity");
24
+ const DEFAULT_PURGE_INTERVAL_MS = 24 * 60 * 60 * 1000;
25
+ const DEFAULT_BATCH_SIZE = 1000;
26
+ const LEADER_KEY = 'auth:password_reset:retention:leader';
27
+ const LEADER_TTL_SEC = 900;
28
+ /**
29
+ * Always runs — audit retention must not depend on observability toggles.
30
+ * Deletes in bounded batches; single-leader across replicas via Redis NX.
31
+ */
32
+ let PasswordResetAuditRetentionService = class PasswordResetAuditRetentionService {
33
+ resetAuditRepo;
34
+ settingsService;
35
+ logger;
36
+ redis;
37
+ timer = null;
38
+ constructor(resetAuditRepo, settingsService, logger, redis) {
39
+ this.resetAuditRepo = resetAuditRepo;
40
+ this.settingsService = settingsService;
41
+ this.logger = logger;
42
+ this.redis = redis;
43
+ }
44
+ onModuleInit() {
45
+ void this.purge();
46
+ this.timer = setInterval(() => {
47
+ void this.purge();
48
+ }, DEFAULT_PURGE_INTERVAL_MS);
49
+ }
50
+ onModuleDestroy() {
51
+ if (this.timer) {
52
+ clearInterval(this.timer);
53
+ this.timer = null;
54
+ }
55
+ }
56
+ async purge() {
57
+ try {
58
+ let acquired;
59
+ try {
60
+ acquired = await this.redis.set(LEADER_KEY, '1', 'EX', LEADER_TTL_SEC, 'NX');
61
+ }
62
+ catch (err) {
63
+ this.logger.warn('Password-reset audit retention skipped — leader lock unavailable', {
64
+ event: 'auth.password_reset.audit_retention_lock_failed',
65
+ err: err instanceof Error ? err : undefined,
66
+ });
67
+ return;
68
+ }
69
+ if (acquired !== 'OK')
70
+ return;
71
+ const days = this.settingsService.get(settings_keys_1.SETTING_KEYS.AUTH_PASSWORD_RESET_AUDIT_RETENTION_DAYS);
72
+ if (!days || days <= 0)
73
+ return;
74
+ const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000);
75
+ const limit = DEFAULT_BATCH_SIZE;
76
+ let totalDeleted = 0;
77
+ for (;;) {
78
+ const rows = await this.resetAuditRepo
79
+ .createQueryBuilder('prt')
80
+ .select('prt.id', 'id')
81
+ .where('prt.used_at < :cutoff', { cutoff })
82
+ .limit(limit)
83
+ .getRawMany();
84
+ if (rows.length === 0)
85
+ break;
86
+ const ids = rows.map((r) => r.id);
87
+ const result = await this.resetAuditRepo.delete(ids);
88
+ totalDeleted += result.affected ?? 0;
89
+ await this.redis.expire(LEADER_KEY, LEADER_TTL_SEC);
90
+ if (rows.length < limit)
91
+ break;
92
+ }
93
+ if (totalDeleted > 0) {
94
+ this.logger.info('Password-reset audit retention completed', {
95
+ event: 'auth.password_reset.audit_retention_purged',
96
+ metadata: { deleted: totalDeleted, retentionDays: days },
97
+ });
98
+ }
99
+ }
100
+ catch (err) {
101
+ this.logger.error('Password-reset audit retention failed', {
102
+ event: 'auth.password_reset.audit_retention_failed',
103
+ err: err instanceof Error ? err : undefined,
104
+ });
105
+ }
106
+ }
107
+ };
108
+ exports.PasswordResetAuditRetentionService = PasswordResetAuditRetentionService;
109
+ exports.PasswordResetAuditRetentionService = PasswordResetAuditRetentionService = __decorate([
110
+ (0, common_1.Injectable)(),
111
+ __param(0, (0, typeorm_1.InjectRepository)(password_reset_token_entity_1.PasswordResetToken)),
112
+ __param(3, (0, common_1.Inject)(redis_module_1.REDIS_CLIENT)),
113
+ __metadata("design:paramtypes", [typeorm_2.Repository,
114
+ settings_service_1.SettingsService,
115
+ structured_logger_service_1.StructuredLoggerService, Function])
116
+ ], PasswordResetAuditRetentionService);
117
+ //# sourceMappingURL=password-reset-audit-retention.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-reset-audit-retention.service.js","sourceRoot":"","sources":["../../../../src/modules/auth/services/password-reset-audit-retention.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmF;AACnF,6CAAmD;AAEnD,qCAAqC;AAErC,+DAA4D;AAC5D,qGAAgG;AAChG,0EAAsE;AACtE,+EAA2E;AAC3E,yFAA6E;AAE7E,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACtD,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,UAAU,GAAG,sCAAsC,CAAC;AAC1D,MAAM,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AAO,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE;iBACxD,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE;gBAC1D,KAAK,EAAE,4CAA4C;gBACnD,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;aAC3C,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD,CAAA;AAlFY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,mBAAU,GAAE;IAKV,WAAA,IAAA,0BAAgB,EAAC,gDAAkB,CAAC,CAAA;IAIpC,WAAA,IAAA,eAAM,EAAC,2BAAY,CAAC,CAAA;qCAHY,oBAAU;QACT,kCAAe;QACxB,mDAAuB;GAPrC,kCAAkC,CAkF9C"}
@@ -1,4 +1,5 @@
1
1
  import { ConfigService } from '@nestjs/config';
2
+ import { EventEmitter2 } from '@nestjs/event-emitter';
2
3
  import IORedis from 'ioredis';
3
4
  import { Repository } from 'typeorm';
4
5
  import { NotificationDeliveryService } from '../../delivery';
@@ -6,8 +7,9 @@ import { StructuredLoggerService } from '../../observability/logging/structured-
6
7
  import { TokenService } from '../../sessions/services/token.service';
7
8
  import { SettingsService } from '../../settings/services/settings.service';
8
9
  import { UsersService } from '../../users/services/users.service';
9
- import { ChangePasswordDto, ForgotPasswordDto, ResetPasswordDto, ResetPasswordWithPhoneDto } from '../dto/password.dto';
10
+ import { ChangePasswordDto, ForgotPasswordDto, ResetPasswordDto, ResetPasswordWithPhoneDto, SetPasswordDto } from '../dto/password.dto';
10
11
  import { PasswordResetToken } from '../entities/password-reset-token.entity';
12
+ import { MfaService } from './mfa.service';
11
13
  export declare class PasswordService {
12
14
  private readonly usersService;
13
15
  private readonly tokenService;
@@ -17,11 +19,13 @@ export declare class PasswordService {
17
19
  private readonly configService;
18
20
  private readonly notificationDelivery;
19
21
  private readonly logger;
20
- constructor(usersService: UsersService, tokenService: TokenService, resetAuditRepo: Repository<PasswordResetToken>, redis: IORedis, settingsService: SettingsService, configService: ConfigService, notificationDelivery: NotificationDeliveryService | null, logger: StructuredLoggerService);
22
+ private readonly mfaService;
23
+ private readonly eventEmitter;
24
+ constructor(usersService: UsersService, tokenService: TokenService, resetAuditRepo: Repository<PasswordResetToken>, redis: IORedis, settingsService: SettingsService, configService: ConfigService, notificationDelivery: NotificationDeliveryService | null, logger: StructuredLoggerService, mfaService: MfaService, eventEmitter?: EventEmitter2 | null);
21
25
  /**
22
26
  * Initiates password reset. Always returns the same message to prevent user enumeration.
23
27
  */
24
- forgotPassword(dto: ForgotPasswordDto): Promise<{
28
+ forgotPassword(dto: ForgotPasswordDto, ipAddress?: string): Promise<{
25
29
  message: string;
26
30
  }>;
27
31
  /**
@@ -31,14 +35,30 @@ export declare class PasswordService {
31
35
  message: string;
32
36
  }>;
33
37
  /**
34
- * Resets password using a verificationToken from the OTP flow.
38
+ * Sets/resets password using the login bridge token from verify-otp when hasAccount=true.
39
+ *
40
+ * Flow: POST /auth/send-otp (sms) → POST /auth/verify-otp →
41
+ * POST /auth/reset-password/phone { verificationToken, newPassword }.
35
42
  */
36
- resetPasswordWithPhone(dto: ResetPasswordWithPhoneDto, _ipAddress?: string): Promise<{
43
+ resetPasswordWithPhone(dto: ResetPasswordWithPhoneDto, ipAddress?: string): Promise<{
37
44
  message: string;
38
45
  }>;
39
46
  changePassword(userId: string, dto: ChangePasswordDto): Promise<{
40
47
  message: string;
41
48
  }>;
49
+ /**
50
+ * First-time password for OAuth / phone accounts that have no passwordHash yet.
51
+ * Does not change immutable authMethod — password becomes an additional login factor.
52
+ */
53
+ setPassword(userId: string, dto: SetPasswordDto): Promise<{
54
+ message: string;
55
+ }>;
56
+ private applyPasswordAndRevokeSessions;
57
+ /** SIM-swap friction: limit phone OTP password resets per account. */
58
+ private assertPhoneResetCooldown;
59
+ private markPhoneResetCooldown;
60
+ private emitPasswordEvent;
61
+ private emitPasswordForgotEvent;
42
62
  /**
43
63
  * Stores a native password reset token in Redis.
44
64
  * Key: pwd_reset:<rawToken> Value: userId TTL: 30 min
@@ -1 +1 @@
1
- {"version":3,"file":"password.service.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/password.service.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK/C,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAI7E,qBACa,eAAe;IAE1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAE7B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAE/B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAVN,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAE1B,cAAc,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAE9C,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,eAAe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OAKG;IACG,sBAAsB,CAC3B,GAAG,EAAE,yBAAyB,EAC9B,SAAS,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAqCzB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IA+B1F;;;OAGG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;YAuCtE,8BAA8B;IAQ5C,sEAAsE;YACxD,wBAAwB;YAiBxB,sBAAsB;IAQpC,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,uBAAuB;IAc/B;;;;OAIG;YACW,qBAAqB;IAqCnC;;;;OAIG;YACW,uBAAuB;IAUrC,OAAO,CAAC,YAAY;CAGpB"}
@@ -54,16 +54,18 @@ const config_1 = require("@nestjs/config");
54
54
  const typeorm_1 = require("@nestjs/typeorm");
55
55
  const argon2 = __importStar(require("argon2"));
56
56
  const crypto_1 = require("crypto");
57
- const crypto_2 = require("crypto");
58
57
  const ioredis_1 = __importDefault(require("ioredis"));
59
58
  const typeorm_2 = require("typeorm");
60
59
  const redis_module_1 = require("../../../config/redis.module");
61
60
  const structured_logger_service_1 = require("../../observability/logging/structured-logger.service");
61
+ const refresh_token_entity_1 = require("../../sessions/entities/refresh-token.entity");
62
62
  const token_service_1 = require("../../sessions/services/token.service");
63
63
  const settings_keys_1 = require("../../settings/constants/settings.keys");
64
64
  const settings_service_1 = require("../../settings/services/settings.service");
65
65
  const users_service_1 = require("../../users/services/users.service");
66
66
  const password_reset_token_entity_1 = require("../entities/password-reset-token.entity");
67
+ const auth_events_1 = require("../events/auth.events");
68
+ const mfa_service_1 = require("./mfa.service");
67
69
  const KEY_PWD_RESET = 'pwd_reset:';
68
70
  let PasswordService = class PasswordService {
69
71
  usersService;
@@ -74,7 +76,9 @@ let PasswordService = class PasswordService {
74
76
  configService;
75
77
  notificationDelivery;
76
78
  logger;
77
- constructor(usersService, tokenService, resetAuditRepo, redis, settingsService, configService, notificationDelivery, logger) {
79
+ mfaService;
80
+ eventEmitter;
81
+ constructor(usersService, tokenService, resetAuditRepo, redis, settingsService, configService, notificationDelivery, logger, mfaService, eventEmitter = null) {
78
82
  this.usersService = usersService;
79
83
  this.tokenService = tokenService;
80
84
  this.resetAuditRepo = resetAuditRepo;
@@ -83,20 +87,24 @@ let PasswordService = class PasswordService {
83
87
  this.configService = configService;
84
88
  this.notificationDelivery = notificationDelivery;
85
89
  this.logger = logger;
90
+ this.mfaService = mfaService;
91
+ this.eventEmitter = eventEmitter;
86
92
  }
87
93
  // ─── Forgot Password ─────────────────────────────────────────────────────
88
94
  /**
89
95
  * Initiates password reset. Always returns the same message to prevent user enumeration.
90
96
  */
91
- async forgotPassword(dto) {
97
+ async forgotPassword(dto, ipAddress) {
92
98
  const SAFE_RESPONSE = {
93
99
  message: 'If this email is registered, a reset link has been sent.',
94
100
  };
101
+ const identityHash = this.hashIdentity(dto.email);
95
102
  const user = await this.usersService.findBy({ email: dto.email });
96
103
  if (!user) {
104
+ // Logs only — do not enqueue compliance audit for unknown emails (enumeration flood).
97
105
  this.logger.info('Forgot password — unknown email', {
98
106
  event: 'auth.password.forgot_unknown_email',
99
- metadata: { email: this.hashIdentity(dto.email) },
107
+ metadata: { email: identityHash },
100
108
  });
101
109
  return SAFE_RESPONSE;
102
110
  }
@@ -105,6 +113,12 @@ let PasswordService = class PasswordService {
105
113
  event: 'auth.password.forgot_initiated',
106
114
  metadata: { userId: user.id },
107
115
  });
116
+ this.emitPasswordForgotEvent({
117
+ userId: user.id,
118
+ identityHash,
119
+ outcome: 'sent',
120
+ ipAddress,
121
+ });
108
122
  return SAFE_RESPONSE;
109
123
  }
110
124
  // ─── Reset Password (email token) ─────────────────────────────────────────
@@ -116,56 +130,173 @@ let PasswordService = class PasswordService {
116
130
  const user = await this.usersService.findById(userId);
117
131
  if (!user)
118
132
  throw new common_1.NotFoundException('User not found.');
119
- await this.usersService.setPasswordHash(userId, await argon2.hash(dto.newPassword));
120
- await this.resetAuditRepo.save(this.resetAuditRepo.create({ userId, usedAt: new Date(), ipAddress }));
133
+ await this.applyPasswordAndRevokeSessions(userId, dto.newPassword);
134
+ await this.resetAuditRepo.save(this.resetAuditRepo.create({
135
+ userId,
136
+ usedAt: new Date(),
137
+ ipAddress,
138
+ method: 'email_token',
139
+ }));
121
140
  this.logger.info('Password reset successful', {
122
141
  event: 'auth.password.reset_success',
123
142
  metadata: { userId, method: 'email_token' },
124
143
  });
125
- return { message: 'Password reset successfully.' };
144
+ this.emitPasswordEvent('reset_email', userId, ipAddress);
145
+ return { message: 'Password reset successfully. All sessions have been revoked.' };
126
146
  }
127
147
  // ─── Reset Password (phone OTP) ───────────────────────────────────────────
128
148
  /**
129
- * Resets password using a verificationToken from the OTP flow.
149
+ * Sets/resets password using the login bridge token from verify-otp when hasAccount=true.
150
+ *
151
+ * Flow: POST /auth/send-otp (sms) → POST /auth/verify-otp →
152
+ * POST /auth/reset-password/phone { verificationToken, newPassword }.
130
153
  */
131
- async resetPasswordWithPhone(dto, _ipAddress) {
132
- const phoneNumber = await this.tokenService.verifyPhoneVerifiedToken(dto.verificationToken);
133
- const user = await this.usersService.findBy({ phoneNumber });
154
+ async resetPasswordWithPhone(dto, ipAddress) {
155
+ const userId = await this.tokenService
156
+ .verifyTemporaryToken(dto.verificationToken)
157
+ .catch(() => {
158
+ throw new common_1.UnauthorizedException('Invalid or expired verificationToken. Complete POST /auth/verify-otp for your registered phone (hasAccount=true) and use that verificationToken here — not verificationId, and not a hasAccount=false token.');
159
+ });
160
+ const user = await this.usersService.findById(userId);
134
161
  if (!user)
135
- throw new common_1.NotFoundException('No account found for this phone number.');
136
- await this.usersService.setPasswordHash(user.id, await argon2.hash(dto.newPassword));
162
+ throw new common_1.NotFoundException('User not found.');
163
+ await this.assertPhoneResetCooldown(userId);
164
+ await this.applyPasswordAndRevokeSessions(userId, dto.newPassword);
165
+ await this.markPhoneResetCooldown(userId);
166
+ await this.resetAuditRepo.save(this.resetAuditRepo.create({
167
+ userId,
168
+ usedAt: new Date(),
169
+ ipAddress,
170
+ method: 'phone_otp',
171
+ }));
137
172
  this.logger.info('Password reset successful', {
138
173
  event: 'auth.password.reset_success',
139
- metadata: { userId: user.id, method: 'phone_otp' },
174
+ metadata: { userId, method: 'phone_otp' },
140
175
  });
141
- return { message: 'Password reset successfully.' };
176
+ this.emitPasswordEvent('reset_phone', userId, ipAddress);
177
+ return { message: 'Password reset successfully. All sessions have been revoked.' };
142
178
  }
143
179
  // ─── Change Password (authenticated) ─────────────────────────────────────
144
180
  async changePassword(userId, dto) {
181
+ await this.mfaService.assertSensitiveReauth(userId, {
182
+ purpose: 'change_password',
183
+ stepUpToken: dto.stepUpToken,
184
+ password: dto.currentPassword,
185
+ });
145
186
  const user = await this.usersService.findByIdWithPassword(userId);
146
187
  if (!user)
147
188
  throw new common_1.NotFoundException('User not found.');
148
189
  if (!user.passwordHash) {
149
- throw new common_1.BadRequestException('Account has no password. Use phone OTP to reset.');
190
+ throw new common_1.BadRequestException('Account has no password. Use POST /auth/account/set-password to create one.');
150
191
  }
151
192
  const valid = await argon2.verify(user.passwordHash, dto.currentPassword);
152
193
  if (!valid)
153
194
  throw new common_1.UnauthorizedException('Current password is incorrect');
154
- await this.usersService.setPasswordHash(userId, await argon2.hash(dto.newPassword));
195
+ await this.applyPasswordAndRevokeSessions(userId, dto.newPassword);
155
196
  this.logger.info('Password changed', {
156
197
  event: 'auth.password.changed',
157
198
  metadata: { userId },
158
199
  });
159
- return { message: 'Password changed successfully.' };
200
+ this.emitPasswordEvent('change', userId);
201
+ return { message: 'Password changed successfully. All sessions have been revoked.' };
202
+ }
203
+ /**
204
+ * First-time password for OAuth / phone accounts that have no passwordHash yet.
205
+ * Does not change immutable authMethod — password becomes an additional login factor.
206
+ */
207
+ async setPassword(userId, dto) {
208
+ await this.mfaService.assertSensitiveReauth(userId, {
209
+ purpose: 'set_password',
210
+ stepUpToken: dto.stepUpToken,
211
+ verificationId: dto.verificationId,
212
+ otp: dto.otp,
213
+ provider: dto.provider,
214
+ idToken: dto.idToken,
215
+ });
216
+ const user = await this.usersService.findByIdWithPassword(userId);
217
+ if (!user)
218
+ throw new common_1.NotFoundException('User not found.');
219
+ if (user.passwordHash) {
220
+ throw new common_1.ConflictException('Account already has a password. Use POST /auth/account/change-password instead.');
221
+ }
222
+ if (!user.email) {
223
+ throw new common_1.BadRequestException('Add and verify an email on this account before setting a password (password login requires email).');
224
+ }
225
+ await this.applyPasswordAndRevokeSessions(userId, dto.newPassword);
226
+ this.logger.info('Password set', {
227
+ event: 'auth.password.set',
228
+ metadata: { userId },
229
+ });
230
+ this.emitPasswordEvent('set', userId);
231
+ return {
232
+ message: 'Password set successfully. You can sign in with email/password in addition to your primary auth method. All sessions have been revoked.',
233
+ };
160
234
  }
161
235
  // ─── Private Helpers ─────────────────────────────────────────────────────
236
+ async applyPasswordAndRevokeSessions(userId, newPassword) {
237
+ await this.usersService.setPasswordHash(userId, await argon2.hash(newPassword));
238
+ await this.tokenService.revokeAllUserTokens(userId, refresh_token_entity_1.RevokeReason.PASSWORD_CHANGED);
239
+ }
240
+ /** SIM-swap friction: limit phone OTP password resets per account. */
241
+ async assertPhoneResetCooldown(userId) {
242
+ const seconds = this.settingsService.get(settings_keys_1.SETTING_KEYS.AUTH_PASSWORD_RESET_PHONE_COOLDOWN_SECONDS);
243
+ if (!seconds || seconds <= 0)
244
+ return;
245
+ const ttl = await this.redis.ttl(`pwd_reset_phone_cd:${userId}`);
246
+ if (ttl > 0) {
247
+ throw new common_1.HttpException({
248
+ message: `Phone password reset is temporarily locked. Try again in ${ttl}s.`,
249
+ retryAfter: ttl,
250
+ }, common_1.HttpStatus.TOO_MANY_REQUESTS);
251
+ }
252
+ }
253
+ async markPhoneResetCooldown(userId) {
254
+ const seconds = this.settingsService.get(settings_keys_1.SETTING_KEYS.AUTH_PASSWORD_RESET_PHONE_COOLDOWN_SECONDS);
255
+ if (!seconds || seconds <= 0)
256
+ return;
257
+ await this.redis.set(`pwd_reset_phone_cd:${userId}`, '1', 'EX', seconds);
258
+ }
259
+ emitPasswordEvent(method, userId, ipAddress) {
260
+ if (!this.eventEmitter)
261
+ return;
262
+ const event = method === 'reset_email' || method === 'reset_phone'
263
+ ? auth_events_1.AUTH_EVENTS.PASSWORD_RESET
264
+ : auth_events_1.AUTH_EVENTS.PASSWORD_CHANGED;
265
+ const payload = {
266
+ userId,
267
+ at: new Date(),
268
+ method,
269
+ ipAddress,
270
+ };
271
+ void this.eventEmitter.emitAsync(event, payload).catch((err) => {
272
+ this.logger.error('Auth password event listener failed', {
273
+ event: 'auth.password.event_failed',
274
+ metadata: { listener: event },
275
+ err: err instanceof Error ? err : undefined,
276
+ });
277
+ });
278
+ }
279
+ emitPasswordForgotEvent(args) {
280
+ if (!this.eventEmitter)
281
+ return;
282
+ const payload = { ...args, at: new Date() };
283
+ void this.eventEmitter
284
+ .emitAsync(auth_events_1.AUTH_EVENTS.PASSWORD_FORGOT_INITIATED, payload)
285
+ .catch((err) => {
286
+ this.logger.error('Auth password forgot event listener failed', {
287
+ event: 'auth.password.event_failed',
288
+ metadata: { listener: auth_events_1.AUTH_EVENTS.PASSWORD_FORGOT_INITIATED },
289
+ err: err instanceof Error ? err : undefined,
290
+ });
291
+ });
292
+ }
162
293
  /**
163
294
  * Stores a native password reset token in Redis.
164
295
  * Key: pwd_reset:<rawToken> Value: userId TTL: 30 min
165
296
  * NX ensures no accidental overwrite on UUID collision (astronomically unlikely).
166
297
  */
167
298
  async storeNativeResetToken(userId, email) {
168
- const rawToken = (0, crypto_2.randomUUID)();
299
+ const rawToken = (0, crypto_1.randomUUID)();
169
300
  const ttl = this.settingsService.get(settings_keys_1.SETTING_KEYS.TOKENS_PASSWORD_RESET_TTL_SECONDS);
170
301
  const result = await this.redis.set(`${KEY_PWD_RESET}${rawToken}`, userId, 'EX', ttl, 'NX');
171
302
  if (result !== 'OK') {
@@ -215,11 +346,14 @@ exports.PasswordService = PasswordService = __decorate([
215
346
  __param(2, (0, typeorm_1.InjectRepository)(password_reset_token_entity_1.PasswordResetToken)),
216
347
  __param(3, (0, common_1.Inject)(redis_module_1.REDIS_CLIENT)),
217
348
  __param(6, (0, common_1.Optional)()),
349
+ __param(8, (0, common_1.Inject)((0, common_1.forwardRef)(() => mfa_service_1.MfaService))),
350
+ __param(9, (0, common_1.Optional)()),
218
351
  __metadata("design:paramtypes", [users_service_1.UsersService,
219
352
  token_service_1.TokenService,
220
353
  typeorm_2.Repository,
221
354
  ioredis_1.default,
222
355
  settings_service_1.SettingsService,
223
- config_1.ConfigService, Object, structured_logger_service_1.StructuredLoggerService])
356
+ config_1.ConfigService, Object, structured_logger_service_1.StructuredLoggerService,
357
+ mfa_service_1.MfaService, Object])
224
358
  ], PasswordService);
225
359
  //# sourceMappingURL=password.service.js.map