@wildo-ai/saas-backend-lib 1.1.12 → 1.1.13

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 (226) hide show
  1. package/dist/esm/base-classes/models/manual-controllers.backend.definition.d.ts.map +1 -1
  2. package/dist/esm/base-classes/models/manual-controllers.backend.definition.js +2 -0
  3. package/dist/esm/base-classes/models/manual-controllers.backend.definition.js.map +1 -1
  4. package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.d.ts +4 -0
  5. package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.d.ts.map +1 -1
  6. package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.js +20 -5
  7. package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.js.map +1 -1
  8. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.d.ts +3 -0
  9. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.d.ts.map +1 -1
  10. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.js +10 -1
  11. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.js.map +1 -1
  12. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.d.ts +22 -0
  13. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.d.ts.map +1 -1
  14. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.js +25 -1
  15. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.js.map +1 -1
  16. package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.d.ts +38 -3
  17. package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.d.ts.map +1 -1
  18. package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.js +68 -5
  19. package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.js.map +1 -1
  20. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.d.ts +2 -2
  21. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.d.ts.map +1 -1
  22. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js +6 -3
  23. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js.map +1 -1
  24. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts +83 -0
  25. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts.map +1 -1
  26. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js +217 -14
  27. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js.map +1 -1
  28. package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.d.ts +32 -0
  29. package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.d.ts.map +1 -0
  30. package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.js +36 -0
  31. package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.js.map +1 -0
  32. package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.d.ts +38 -0
  33. package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.d.ts.map +1 -0
  34. package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.js +83 -0
  35. package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.js.map +1 -0
  36. package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.d.ts +36 -0
  37. package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.d.ts.map +1 -0
  38. package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.js +51 -0
  39. package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.js.map +1 -0
  40. package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.d.ts +46 -0
  41. package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.d.ts.map +1 -1
  42. package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.js +68 -0
  43. package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.js.map +1 -1
  44. package/dist/esm/compliance/approval-seals/approval-seal-store.backend.d.ts +27 -0
  45. package/dist/esm/compliance/approval-seals/approval-seal-store.backend.d.ts.map +1 -1
  46. package/dist/esm/compliance/approval-seals/approval-seal-store.backend.js +42 -3
  47. package/dist/esm/compliance/approval-seals/approval-seal-store.backend.js.map +1 -1
  48. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.d.ts +26 -1
  49. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.d.ts.map +1 -1
  50. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.js +10 -0
  51. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.js.map +1 -1
  52. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.d.ts +10 -1
  53. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.d.ts.map +1 -1
  54. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.js +60 -28
  55. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.js.map +1 -1
  56. package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.d.ts +90 -0
  57. package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.d.ts.map +1 -0
  58. package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.js +373 -0
  59. package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.js.map +1 -0
  60. package/dist/esm/compliance/approval-seals/decision-presentation.backend.d.ts +29 -2
  61. package/dist/esm/compliance/approval-seals/decision-presentation.backend.d.ts.map +1 -1
  62. package/dist/esm/compliance/approval-seals/decision-presentation.backend.js +40 -3
  63. package/dist/esm/compliance/approval-seals/decision-presentation.backend.js.map +1 -1
  64. package/dist/esm/compliance/electronic-signatures/pdf-signature-structure.backend.d.ts.map +1 -1
  65. package/dist/esm/compliance/electronic-signatures/pdf-signature-structure.backend.js +34 -6
  66. package/dist/esm/compliance/electronic-signatures/pdf-signature-structure.backend.js.map +1 -1
  67. package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.d.ts +30 -6
  68. package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.d.ts.map +1 -1
  69. package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.js +67 -22
  70. package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.js.map +1 -1
  71. package/dist/esm/compliance/electronic-signatures/signature-request-poll.batch.backend.service.d.ts.map +1 -1
  72. package/dist/esm/compliance/electronic-signatures/signature-request-poll.batch.backend.service.js +18 -1
  73. package/dist/esm/compliance/electronic-signatures/signature-request-poll.batch.backend.service.js.map +1 -1
  74. package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.d.ts +66 -1
  75. package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.d.ts.map +1 -1
  76. package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.js +161 -14
  77. package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.js.map +1 -1
  78. package/dist/esm/compliance/electronic-signatures/signed-document-validation.backend.d.ts +47 -0
  79. package/dist/esm/compliance/electronic-signatures/signed-document-validation.backend.d.ts.map +1 -1
  80. package/dist/esm/compliance/electronic-signatures/signed-document-validation.backend.js.map +1 -1
  81. package/dist/esm/external-providers/services/content-safety.backend.service.d.ts +27 -2
  82. package/dist/esm/external-providers/services/content-safety.backend.service.d.ts.map +1 -1
  83. package/dist/esm/external-providers/services/content-safety.backend.service.js +46 -1
  84. package/dist/esm/external-providers/services/content-safety.backend.service.js.map +1 -1
  85. package/dist/esm/external-providers/services/embeddings.backend.service.d.ts.map +1 -1
  86. package/dist/esm/external-providers/services/embeddings.backend.service.js +2 -0
  87. package/dist/esm/external-providers/services/embeddings.backend.service.js.map +1 -1
  88. package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts +11 -0
  89. package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts.map +1 -1
  90. package/dist/esm/external-providers/services/external-providers-registry.backend.service.js +23 -0
  91. package/dist/esm/external-providers/services/external-providers-registry.backend.service.js.map +1 -1
  92. package/dist/esm/external-providers/services/provider-service-account-token.backend.d.ts +19 -1
  93. package/dist/esm/external-providers/services/provider-service-account-token.backend.d.ts.map +1 -1
  94. package/dist/esm/external-providers/services/provider-service-account-token.backend.js +41 -1
  95. package/dist/esm/external-providers/services/provider-service-account-token.backend.js.map +1 -1
  96. package/dist/esm/files/utils/file-parent-read-context.backend.d.ts +27 -2
  97. package/dist/esm/files/utils/file-parent-read-context.backend.d.ts.map +1 -1
  98. package/dist/esm/files/utils/file-parent-read-context.backend.js +23 -4
  99. package/dist/esm/files/utils/file-parent-read-context.backend.js.map +1 -1
  100. package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.d.ts +26 -0
  101. package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.d.ts.map +1 -1
  102. package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.js +100 -8
  103. package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.js.map +1 -1
  104. package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.d.ts +3 -1
  105. package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.d.ts.map +1 -1
  106. package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.js +8 -2
  107. package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.js.map +1 -1
  108. package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts +43 -0
  109. package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts.map +1 -1
  110. package/dist/esm/flows-actors/models/function-tools.backend.definitions.js +37 -0
  111. package/dist/esm/flows-actors/models/function-tools.backend.definitions.js.map +1 -1
  112. package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.d.ts +7 -0
  113. package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.d.ts.map +1 -1
  114. package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.js +8 -3
  115. package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.js.map +1 -1
  116. package/dist/esm/flows-actors/services/agents.backend.service.d.ts +31 -6
  117. package/dist/esm/flows-actors/services/agents.backend.service.d.ts.map +1 -1
  118. package/dist/esm/flows-actors/services/agents.backend.service.js +78 -30
  119. package/dist/esm/flows-actors/services/agents.backend.service.js.map +1 -1
  120. package/dist/esm/flows-actors/services/autonomous-agent-turn.backend.service.d.ts.map +1 -1
  121. package/dist/esm/flows-actors/services/autonomous-agent-turn.backend.service.js +4 -0
  122. package/dist/esm/flows-actors/services/autonomous-agent-turn.backend.service.js.map +1 -1
  123. package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts +28 -2
  124. package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts.map +1 -1
  125. package/dist/esm/flows-actors/services/conversational-execution.backend.service.js +132 -22
  126. package/dist/esm/flows-actors/services/conversational-execution.backend.service.js.map +1 -1
  127. package/dist/esm/flows-actors/services/flow-actor-executions.custom-impl.backend.service.d.ts.map +1 -1
  128. package/dist/esm/flows-actors/services/flow-actor-executions.custom-impl.backend.service.js +12 -8
  129. package/dist/esm/flows-actors/services/flow-actor-executions.custom-impl.backend.service.js.map +1 -1
  130. package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts +5 -0
  131. package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts.map +1 -1
  132. package/dist/esm/flows-actors/services/flows-actors-registry.service.js +18 -2
  133. package/dist/esm/flows-actors/services/flows-actors-registry.service.js.map +1 -1
  134. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts +33 -0
  135. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts.map +1 -1
  136. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js +58 -0
  137. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js.map +1 -1
  138. package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.d.ts +12 -1
  139. package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.d.ts.map +1 -1
  140. package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.js +23 -4
  141. package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.js.map +1 -1
  142. package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.d.ts +12 -1
  143. package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.d.ts.map +1 -1
  144. package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.js +55 -17
  145. package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.js.map +1 -1
  146. package/dist/esm/inbound/services/inbound-delivery-store.backend.service.d.ts +22 -1
  147. package/dist/esm/inbound/services/inbound-delivery-store.backend.service.d.ts.map +1 -1
  148. package/dist/esm/inbound/services/inbound-delivery-store.backend.service.js +52 -9
  149. package/dist/esm/inbound/services/inbound-delivery-store.backend.service.js.map +1 -1
  150. package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.d.ts +79 -0
  151. package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.d.ts.map +1 -0
  152. package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.js +211 -0
  153. package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.js.map +1 -0
  154. package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.d.ts +2 -2
  155. package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.d.ts.map +1 -1
  156. package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.js +9 -1
  157. package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.js.map +1 -1
  158. package/dist/esm/index.d.ts +1 -0
  159. package/dist/esm/index.d.ts.map +1 -1
  160. package/dist/esm/index.js +1 -0
  161. package/dist/esm/index.js.map +1 -1
  162. package/dist/esm/inject/models/container.d.ts.map +1 -1
  163. package/dist/esm/inject/models/container.js +6 -0
  164. package/dist/esm/inject/models/container.js.map +1 -1
  165. package/dist/esm/inject/models/service-types.d.ts +5 -0
  166. package/dist/esm/inject/models/service-types.d.ts.map +1 -1
  167. package/dist/esm/inject/models/service-types.js +3 -0
  168. package/dist/esm/inject/models/service-types.js.map +1 -1
  169. package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts +5 -0
  170. package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts.map +1 -1
  171. package/dist/esm/monitoring/observability/models/observability.backend.schemas.js.map +1 -1
  172. package/dist/esm/monitoring/observability/services/metrics.service.d.ts +34 -1
  173. package/dist/esm/monitoring/observability/services/metrics.service.d.ts.map +1 -1
  174. package/dist/esm/monitoring/observability/services/metrics.service.js +49 -0
  175. package/dist/esm/monitoring/observability/services/metrics.service.js.map +1 -1
  176. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts +6 -1
  177. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts.map +1 -1
  178. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js +15 -4
  179. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js.map +1 -1
  180. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.d.ts.map +1 -1
  181. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.js +3 -1
  182. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.js.map +1 -1
  183. package/dist/esm/runtime/services/http-server.backend.service.d.ts +3 -1
  184. package/dist/esm/runtime/services/http-server.backend.service.d.ts.map +1 -1
  185. package/dist/esm/runtime/services/http-server.backend.service.js +11 -3
  186. package/dist/esm/runtime/services/http-server.backend.service.js.map +1 -1
  187. package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.d.ts +22 -0
  188. package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.d.ts.map +1 -1
  189. package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.js +54 -0
  190. package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.js.map +1 -1
  191. package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.d.ts +51 -0
  192. package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.d.ts.map +1 -1
  193. package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.js +87 -15
  194. package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.js.map +1 -1
  195. package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.d.ts.map +1 -1
  196. package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.js +5 -2
  197. package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.js.map +1 -1
  198. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.d.ts.map +1 -1
  199. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js +65 -24
  200. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js.map +1 -1
  201. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts +64 -1
  202. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts.map +1 -1
  203. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js +84 -2
  204. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js.map +1 -1
  205. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts +14 -0
  206. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts.map +1 -1
  207. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js +13 -5
  208. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js.map +1 -1
  209. package/dist/esm/users/services/anonymous-consent.custom-impl.backend.service.d.ts.map +1 -1
  210. package/dist/esm/users/services/anonymous-consent.custom-impl.backend.service.js +6 -2
  211. package/dist/esm/users/services/anonymous-consent.custom-impl.backend.service.js.map +1 -1
  212. package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.d.ts +7 -0
  213. package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.d.ts.map +1 -1
  214. package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.js +65 -20
  215. package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.js.map +1 -1
  216. package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.d.ts.map +1 -1
  217. package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.js +11 -4
  218. package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.js.map +1 -1
  219. package/dist/esm/users/services/user-self-custom-implementations.backend.d.ts.map +1 -1
  220. package/dist/esm/users/services/user-self-custom-implementations.backend.js +4 -2
  221. package/dist/esm/users/services/user-self-custom-implementations.backend.js.map +1 -1
  222. package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.d.ts.map +1 -1
  223. package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.js +16 -0
  224. package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.js.map +1 -1
  225. package/dist/tsconfig.build.tsbuildinfo +1 -1
  226. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"siem-delivery-dlq.custom-impl.backend.service.js","sourceRoot":"","sources":["../../../../../../src/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,2BAA2B,EAC3B,SAAS,EACT,4BAA4B,EAC5B,0BAA0B,EAC1B,qCAAqC,EACrC,kCAAkC,EAClC,kCAAkC,EAClC,qBAAqB,EACrB,kCAAkC,GAInC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,yCAAyC,EACzC,yDAAyD,GAE1D,MAAM,4GAA4G,CAA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S,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;wBACpG,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC;wBAErC,qEAAqE;wBACrE,OAAO;4BACL,WAAW;4BACX,OAAO,EAAE,UAAU,WAAW,qBAAqB,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS,GAAG;yBAC1H,CAAC;oBACJ,CAAC;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * SIEM Delivery DLQ — RETRY_SINGLE / RETRY_ALL / PURGE_ALL custom implementations.\n *\n * Makes the operator drain/clear surfaces on the SIEM delivery dead-letter queue\n * real (both polymorphic variants: ORGANIZATION_SIEM_DELIVERY_DLQ +\n * APPLICATION_SIEM_DELIVERY_DLQ). They are declared on\n * `siem-delivery-dlq.shared.resources-config.schemas.ts`; this file authors the\n * REPLACE_CORE_OPERATIONS handlers that back them.\n *\n * ── Why \"retry\" means RE-ENQUEUE, not \"reset a status\" ────────────────────────\n * The M2M webhook delivery-log sibling\n * (`m2m-webhook-delivery-log.custom-impl.backend.service.ts`) resets the SAME row\n * its worker drains (`resetForRetry`: CAS a FAILED row back to PENDING) because the\n * M2M worker owns that row's status machine. The SIEM delivery worker\n * (`SIEMWebhookDeliveryBackendService.processDelivery`) does NOT: SIEM delivery is\n * enqueue-per-event via the `siem.webhook-delivery` custom batch, the worker holds\n * no back-reference to any DLQ row, and there is NO SIEM DLQ retry-sweep batch. So\n * \"retry\" here = rebuild the delivery job from the DLQ row's STORED envelope and\n * re-enqueue it onto the SIEM delivery queue (through the single job-contract seam\n * {@link AuditEventDispatcherBackendService.enqueueSiemWebhookDelivery}).\n *\n * ── Delete-on-requeue ─────────────────────────────────────────────────────────\n * After a successful re-enqueue the DLQ row is DELETED, not flipped to a status.\n * Because the worker has no back-ref and no sweep exists, a status transition would\n * leave the row stuck forever; and a re-delivery that fails is re-captured by\n * `_enqueueToDLQ` as a BRAND-NEW row. So the honest model is: a DLQ row represents a\n * delivery that is CURRENTLY dead-lettered — the moment we put it back in flight it\n * leaves the queue. Enqueue is the load-bearing step (its failure fails the op and\n * leaves the row intact for another attempt); the delete is best-effort cleanup (a\n * delete failure only leaves a stale, purgeable row — never an un-retried event).\n *\n * ── A QUARANTINED row is never re-sent from its stored envelope (#2959) ─────────\n * A row whose job failed its integrity check (`SiemDeliveryDlqStatus.QUARANTINED`) was written from a payload nobody\n * vouched for: anyone able to write to the queue can plant one, in any tenant's queue, with any envelope. Re-enqueueing\n * it would sign it afresh and deliver a forged security event to that tenant's real SIEM. So both RETRY verbs hand a\n * quarantined row to {@link AuditEventDispatcherBackendService.redeliverQuarantinedDeadLetter}, which re-derives the event\n * from the application's own audit store by `eventId` and delivers it only to an organization that store records the\n * event as routed to. When it cannot (no such event, not routed here, filtered out, application scope), the row stays\n * quarantined: RETRY_SINGLE answers 409 naming why, RETRY_ALL counts it as skipped, and both log it.\n *\n * ── PURGE_ALL clears the WHOLE scope ──────────────────────────────────────────\n * PURGE_ALL drops every row in the caller's scope (not only EXHAUSTED). The op name,\n * empty request DTO (no age/status narrowing), and CRITICAL risk tier all say\n * \"clear the queue\"; and unlike M2M there is no in-flight row to protect (SIEM DLQ\n * rows are inert — no worker owns them, no sweep touches them), so every status is\n * equally safe to remove. A partial purge that left PENDING_RETRY rows would leave\n * rows nothing will ever retry — a worse trap.\n *\n * ── Tenant safety ─────────────────────────────────────────────────────────────\n * Every read/list/delete is narrowed to the operation's scope FK\n * (organizationId / applicationId) belt-and-braces on top of the execution context's\n * own scope enforcement — an `entryId` from another tenant reads as not-found and a\n * purge/retry can never cross a scope boundary.\n */\n\nimport {\n AuthScopeType,\n CoreResourceType,\n ErrorCustomMessageReference,\n ErrorType,\n ResourceOperationVariantType,\n SiemDeliveryDlq_Operations,\n SiemDeliveryDlq_RetrySingleRequestDto,\n SiemDeliveryDlq_RetryAllRequestDto,\n SiemDeliveryDlq_PurgeAllRequestDto,\n SiemDeliveryDlqStatus,\n coreResourceShared_FieldIdentifier,\n type SecurityAuditEventEnvelope,\n type SiemDeliveryDlqBase,\n type SiemExportConfigBase,\n} from '@wildo-ai/saas-models';\nimport type { Container } from 'inversify';\nimport {\n createResourceCustomServiceImplementation,\n ResourceCustomServiceImplementationHookTransactionPosture,\n type ResourceCustomServiceImplementationFactory,\n} from '~wildo-backend-lib/base-classes/services/services/resource-operation-custom-implementation.factory.backend';\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { BackendResourceRepository } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport type { LoggerService } from '~wildo-backend-lib/monitoring/logger/services/logger.service';\nimport type { AuthOrganizationConfigurationService } from '~wildo-backend-lib/security/authentications/services/admin-config/auth-organization-configuration.service';\nimport {\n SiemQuarantinedDeadLetterOutcome,\n type AuditEventDispatcherBackendService,\n} from '~wildo-backend-lib/compliance/audit-trails/services/audit-event-dispatcher.backend.service';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport { projectCaughtErrorLogFields } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { engineRepositoriesRegistry } from '~wildo-backend-lib/base-classes/services/services/engine-repositories-registry.backend.utils';\n\n// ── SIEM delivery DLQ polymorphic variants (resource type ↔ scope) ────────────\n\ninterface SiemDlqVariant {\n resourceType: CoreResourceType;\n scopeType: AuthScopeType;\n}\n\n/**\n * One factory per polymorphic variant. The resource type selects the collection;\n * the scope type drives config loading, the scope-FK filter, and the re-enqueued\n * job's scope so it can never drift from the row it targets.\n *\n * Both variants are wired identically, but the APPLICATION one is RESERVED / DORMANT\n * in practice: an `APPLICATION_SIEM_DELIVERY_DLQ` row can only exist if an app-scoped\n * delivery failed, and no producer emits app-scoped deliveries today (the sole SIEM\n * producer is org-scoped). So the APP RETRY/PURGE paths never have rows to act on —\n * they are the retry half of reserved plumbing. See `AuditEventDispatcherBackendService.\n * dispatchToOrganizationAuditSinks` for the rationale + how an app producer would attach.\n */\nconst SIEM_DLQ_VARIANTS: readonly SiemDlqVariant[] = [\n { resourceType: CoreResourceType.ORGANIZATION_SIEM_DELIVERY_DLQ, scopeType: AuthScopeType.ORGANIZATION },\n { resourceType: CoreResourceType.APPLICATION_SIEM_DELIVERY_DLQ, scopeType: AuthScopeType.APPLICATION },\n] as const;\n\n/** The operation's resolved scope: its type, id, and the row's scope-FK column name. */\ninterface ResolvedSiemDlqScope {\n scopeType: AuthScopeType;\n scopeId: string;\n scopeFkField: string;\n}\n\n/**\n * Resolve the operation's scope from the (admin) execution context. Returns `null`\n * when the context carries no scope id — a routing/authorization invariant violation\n * for these org/app-scoped operations, which the caller surfaces as a VALIDATION error.\n */\nfunction resolveScope(\n scopeType: AuthScopeType,\n executionContext: { organizationId?: string | null; applicationId?: string | null },\n): ResolvedSiemDlqScope | null {\n const scopeId = scopeType === AuthScopeType.ORGANIZATION\n ? executionContext.organizationId\n : executionContext.applicationId;\n if (!scopeId) return null;\n const scopeFkField = scopeType === AuthScopeType.ORGANIZATION\n ? coreResourceShared_FieldIdentifier[CoreResourceType.ORGANIZATIONS]\n : coreResourceShared_FieldIdentifier[CoreResourceType.APPLICATION];\n return { scopeType, scopeId, scopeFkField };\n}\n\n/** The scope-FK filter fragment narrowing every read/list/delete to this tenant. */\nfunction scopeFilter(scope: ResolvedSiemDlqScope): Record<string, string> {\n return { [scope.scopeFkField]: scope.scopeId };\n}\n\n/** Resolve the two domain collaborators the drain paths need from the DI container. */\nfunction getDeps(container: Container): {\n orgConfigService: AuthOrganizationConfigurationService;\n dispatcher: AuditEventDispatcherBackendService;\n} {\n return {\n orgConfigService: container.get<AuthOrganizationConfigurationService>(\n SAAS_SERVICE_TYPES.AuthOrganizationConfigurationService,\n ),\n dispatcher: container.get<AuditEventDispatcherBackendService>(\n SAAS_SERVICE_TYPES.AuditEventDispatcherService,\n ),\n };\n}\n\n/**\n * The DLQ row stores the delivery envelope in `eventPayload` (`z.unknown()` in the\n * schema). Return it typed when present and object-shaped, else `null` (a corrupt /\n * missing payload has nothing to re-deliver).\n */\nfunction extractEnvelope(row: SiemDeliveryDlqBase): SecurityAuditEventEnvelope | null {\n const envelope = row.eventPayload as SecurityAuditEventEnvelope | undefined | null;\n return envelope && typeof envelope === 'object' ? envelope : null;\n}\n\n/**\n * Re-enqueue one stored envelope onto the SIEM delivery queue for this scope,\n * through the dispatcher's single job-contract seam (payload shape + delivery MAC +\n * batch ref). May throw on enqueue failure — callers decide isolation.\n */\nasync function enqueueEnvelope(\n dispatcher: AuditEventDispatcherBackendService,\n scope: ResolvedSiemDlqScope,\n siemConfig: SiemExportConfigBase,\n envelope: SecurityAuditEventEnvelope,\n): Promise<void> {\n await dispatcher.enqueueSiemWebhookDelivery({\n envelope,\n // The payload's `organizationId` is a routing/label field; the authoritative\n // delivery scope is `scopeType`/`scopeId`. Prefer the envelope's own org (for the\n // APP variant that is the app's owning org), falling back to the scope id.\n organizationId: envelope.organizationId ?? scope.scopeId,\n siemConfig,\n scopeType: scope.scopeType,\n scopeId: scope.scopeId,\n });\n}\n\n/** What {@link requeueRow} did: `keptQuarantined` is set exactly when a quarantined row stayed (#2959). */\ninterface SiemDlqRequeueResult {\n requeued: boolean;\n keptQuarantined?: SiemQuarantinedDeadLetterOutcome;\n}\n\n/**\n * Put one dead-lettered row back in flight, by the only path its status allows: a QUARANTINED row is re-derived from the\n * audit store (#2959) and every other row re-sends its stored envelope. `requeued: false` carries the quarantine outcome\n * that kept the row, or none when a row that is not quarantined has no stored envelope. May throw on enqueue failure.\n */\nasync function requeueRow(\n dispatcher: AuditEventDispatcherBackendService,\n scope: ResolvedSiemDlqScope,\n siemConfig: SiemExportConfigBase,\n row: SiemDeliveryDlqBase,\n): Promise<SiemDlqRequeueResult> {\n if (row.status === SiemDeliveryDlqStatus.QUARANTINED) {\n // The stored envelope is never read here: `eventId` is the row's own column, and only what the audit store holds under\n // it is delivered.\n const outcome = await dispatcher.redeliverQuarantinedDeadLetter({\n eventId: row.eventId,\n scopeType: scope.scopeType,\n scopeId: scope.scopeId,\n siemConfig,\n });\n return outcome === SiemQuarantinedDeadLetterOutcome.REQUEUED ? { requeued: true } : { requeued: false, keptQuarantined: outcome };\n }\n const envelope = extractEnvelope(row);\n if (!envelope) return { requeued: false };\n await enqueueEnvelope(dispatcher, scope, siemConfig, envelope);\n return { requeued: true };\n}\n\n/** The operator-facing sentence for a quarantined row that stays (#2959). */\nfunction describeKeptQuarantine(outcome: SiemQuarantinedDeadLetterOutcome): string {\n switch (outcome) {\n case SiemQuarantinedDeadLetterOutcome.NO_AUDIT_RECORD:\n return 'This SIEM DLQ entry failed its integrity check and the audit log holds no event under its id, so there is no genuine event to re-deliver; it stays quarantined.';\n case SiemQuarantinedDeadLetterOutcome.NOT_ROUTED_TO_SCOPE:\n return 'This SIEM DLQ entry failed its integrity check and the audit log does not record its event as routed to this scope, so it is not re-delivered here; it stays quarantined.';\n case SiemQuarantinedDeadLetterOutcome.EXCLUDED_BY_FILTER:\n return 'This SIEM DLQ entry failed its integrity check, and the SIEM export filter for this scope excludes the event the audit log holds under its id; it stays quarantined.';\n case SiemQuarantinedDeadLetterOutcome.SCOPE_HAS_NO_PRODUCER:\n return 'This SIEM DLQ entry failed its integrity check, and no event can be re-derived for this scope; it stays quarantined.';\n case SiemQuarantinedDeadLetterOutcome.REQUEUED:\n return 'This SIEM DLQ entry was re-derived from the audit log and re-queued.';\n }\n}\n\n/**\n * Delete-on-requeue cleanup: remove the rows we just re-enqueued. NON-FATAL — the\n * re-enqueue already happened, so a delete failure leaves a stale (operator-purgeable)\n * row rather than un-retrying a delivered-again event. Scope-FK filtered belt-and-braces.\n */\nasync function deleteRequeuedRows(\n repo: BackendResourceRepository,\n executionContext: ExecutionContext<any>,\n scope: ResolvedSiemDlqScope,\n ids: string[],\n logger: LoggerService,\n): Promise<void> {\n if (ids.length === 0) return;\n try {\n await repo.deleteMany(executionContext, { _id: { $in: ids }, ...scopeFilter(scope) });\n } catch (error) {\n logger.warn('SIEM DLQ delete-on-requeue failed (non-fatal) — entries re-queued but not removed', {\n scopeType: scope.scopeType,\n scopeId: scope.scopeId,\n entryIds: ids,\n ...projectCaughtErrorLogFields(error),\n });\n }\n}\n\n// ════════════════════════════════════════════════════════════════════\n// RETRY_SINGLE — re-enqueue one dead-lettered entry, then delete it\n// ════════════════════════════════════════════════════════════════════\n\nexport function createSiemDlqRetrySingleFactories(): ResourceCustomServiceImplementationFactory[] {\n return SIEM_DLQ_VARIANTS.map(({ resourceType, scopeType }): ResourceCustomServiceImplementationFactory => {\n return (_resourcesRegistryService, container: Container) => {\n return createResourceCustomServiceImplementation({\n operationPath: {\n resourceIdentifier: resourceType,\n operationIdentifier: SiemDeliveryDlq_Operations.RETRY_SINGLE,\n variantType: ResourceOperationVariantType.API_CALL,\n isOperationDefault: true,\n },\n requestDtoSchema: SiemDeliveryDlq_RetrySingleRequestDto,\n handlers: {\n replaceCoreOperations: async (_id, input, executionContext, _operationPath, utils) => {\n // The entry is addressed by the request DTO's `entryId` (not the URL id),\n // mirroring the M2M RETRY sibling.\n const { entryId } = input as { entryId: string };\n\n const scope = resolveScope(scopeType, executionContext);\n if (!scope) {\n throw utils.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: `SIEM DLQ RETRY_SINGLE requires a ${scopeType}-scoped execution context.` },\n });\n }\n\n const repo = engineRepositoriesRegistry(utils).getRepositoryOrThrow(resourceType, executionContext);\n\n // Scoped read (id AND scope FK): a cross-tenant entryId reads as not-found.\n const row = await repo.read<SiemDeliveryDlqBase>(executionContext, {\n id: entryId,\n filter: scopeFilter(scope),\n });\n if (!row) {\n throw utils.errorBuilder.buildError(ErrorType.NOT_FOUND, executionContext, {\n customMessageReference: ErrorCustomMessageReference.NOT_FOUND,\n context: { message: 'SIEM DLQ entry not found in this scope.', entryId },\n });\n }\n if (row.status === SiemDeliveryDlqStatus.DELIVERED) {\n throw utils.errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {\n customMessageReference: ErrorCustomMessageReference.CONFLICT,\n context: {\n message: 'This SIEM DLQ entry was already delivered on a later attempt; there is nothing to retry.',\n entryId,\n status: row.status,\n },\n });\n }\n\n const { orgConfigService, dispatcher } = getDeps(container);\n const siemConfig = await orgConfigService.loadSiemExportConfig(\n executionContext,\n scope.scopeType,\n scope.scopeId,\n );\n // `loadSiemExportConfig` lazily materialises a DISABLED default (empty\n // webhookUrl) for a never-configured scope, so guard on a real destination:\n // without a URL there is nowhere to re-deliver.\n if (!siemConfig || !siemConfig.webhookUrl) {\n throw utils.errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {\n customMessageReference: ErrorCustomMessageReference.CONFLICT,\n context: {\n message: 'SIEM export has no webhook URL configured for this scope; configure it before retrying.',\n entryId,\n },\n });\n }\n\n // Enqueue FIRST — a failure here throws (op fails, row left intact for a\n // later attempt). Only on success do we delete-on-requeue.\n const requeue = await requeueRow(dispatcher, scope, siemConfig, row);\n if (!requeue.requeued && requeue.keptQuarantined === undefined) {\n throw utils.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: 'SIEM DLQ entry has no stored envelope to re-deliver.', entryId },\n });\n }\n if (!requeue.requeued && requeue.keptQuarantined !== undefined) {\n const kept = requeue.keptQuarantined;\n utils.logger.warn('SIEM DLQ RETRY_SINGLE: a quarantined entry stays quarantined (#2959)', {\n scopeType: scope.scopeType, scopeId: scope.scopeId, entryId, eventId: row.eventId, outcome: kept,\n });\n throw utils.errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {\n customMessageReference: ErrorCustomMessageReference.CONFLICT,\n context: { message: describeKeptQuarantine(kept), entryId, outcome: kept },\n });\n }\n await deleteRequeuedRows(repo, executionContext, scope, [entryId], utils.logger);\n\n // Matches the declared customResponseDto `{ message, entryId }`.\n return { message: 'SIEM DLQ entry re-queued for delivery.', entryId };\n },\n },\n });\n };\n });\n}\n\n// ════════════════════════════════════════════════════════════════════\n// RETRY_ALL — re-enqueue every non-delivered entry in scope, then delete them\n// ════════════════════════════════════════════════════════════════════\n\nexport function createSiemDlqRetryAllFactories(): ResourceCustomServiceImplementationFactory[] {\n return SIEM_DLQ_VARIANTS.map(({ resourceType, scopeType }): ResourceCustomServiceImplementationFactory => {\n return (_resourcesRegistryService, container: Container) => {\n return createResourceCustomServiceImplementation({\n operationPath: {\n resourceIdentifier: resourceType,\n operationIdentifier: SiemDeliveryDlq_Operations.RETRY_ALL,\n variantType: ResourceOperationVariantType.API_CALL,\n isOperationDefault: true,\n },\n requestDtoSchema: SiemDeliveryDlq_RetryAllRequestDto,\n /*\n * #2297: stays outside a transaction. Each entry is re-published to the delivery queue, and which rows are then\n * deleted depends on which publishes went through: a rolled-back or retried attempt would publish every envelope\n * again and keep the rows. (It is a multi-row write as well, so it would stay best effort for that reason too.)\n */\n hookTransactionPosture: ResourceCustomServiceImplementationHookTransactionPosture.STAYS_OUTSIDE_TRANSACTION,\n handlers: {\n replaceCoreOperations: async (_id, _input, executionContext, _operationPath, utils) => {\n const scope = resolveScope(scopeType, executionContext);\n if (!scope) {\n throw utils.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: `SIEM DLQ RETRY_ALL requires a ${scopeType}-scoped execution context.` },\n });\n }\n\n const repo = engineRepositoriesRegistry(utils).getRepositoryOrThrow(resourceType, executionContext);\n\n // Enumerate the scope's rows. LIST projects to summary fields (_id, status),\n // which is all we need to pick candidates; the full envelope is re-read per row.\n const rows = await repo.list<SiemDeliveryDlqBase>(executionContext, scopeFilter(scope));\n const total = rows.length;\n if (total === 0) {\n return { retriedCount: 0, skippedCount: 0, message: 'The SIEM dead-letter queue is empty for this scope.' };\n }\n\n const { orgConfigService, dispatcher } = getDeps(container);\n const siemConfig = await orgConfigService.loadSiemExportConfig(\n executionContext,\n scope.scopeType,\n scope.scopeId,\n );\n if (!siemConfig || !siemConfig.webhookUrl) {\n // No destination → nothing can be re-queued. Report as a bulk summary\n // (not an error): the whole queue is skipped.\n return {\n retriedCount: 0,\n skippedCount: total,\n message: 'SIEM export has no webhook URL configured for this scope; no entries were re-queued.',\n };\n }\n\n // PENDING_RETRY + EXHAUSTED re-send their stored envelope; QUARANTINED is re-derived from the audit store\n // (#2959); DELIVERED has nothing to retry.\n const requeuedIds: string[] = [];\n for (const summary of rows) {\n if (summary.status === SiemDeliveryDlqStatus.DELIVERED) continue;\n\n // Summary lacks eventPayload — read the full row for its stored envelope.\n const row = await repo.read<SiemDeliveryDlqBase>(executionContext, {\n id: summary._id,\n filter: scopeFilter(scope),\n });\n if (!row) continue; // vanished mid-sweep → skip\n\n try {\n const requeue = await requeueRow(dispatcher, scope, siemConfig, row);\n if (requeue.requeued) {\n requeuedIds.push(summary._id);\n } else if (requeue.keptQuarantined) {\n // A quarantined row that cannot be re-derived stays where it is (#2959).\n utils.logger.warn('SIEM DLQ RETRY_ALL: a quarantined entry stays quarantined (#2959)', {\n scopeType: scope.scopeType, scopeId: scope.scopeId, entryId: summary._id, eventId: row.eventId, outcome: requeue.keptQuarantined,\n });\n }\n } catch (error) {\n // Per-entry isolation: one enqueue failure never aborts the sweep.\n utils.logger.warn('SIEM DLQ RETRY_ALL: failed to re-enqueue one entry (skipped)', {\n scopeType: scope.scopeType,\n scopeId: scope.scopeId,\n entryId: summary._id,\n ...projectCaughtErrorLogFields(error),\n });\n }\n }\n\n await deleteRequeuedRows(repo, executionContext, scope, requeuedIds, utils.logger);\n\n const retriedCount = requeuedIds.length;\n const skippedCount = total - retriedCount;\n // Matches the declared customResponseDto `{ retriedCount, skippedCount, message }`.\n return {\n retriedCount,\n skippedCount,\n message: `Re-queued ${retriedCount} of ${total} SIEM dead-letter ${total === 1 ? 'entry' : 'entries'} for this ${scope.scopeType}; skipped ${skippedCount}.`,\n };\n },\n },\n });\n };\n });\n}\n\n// ════════════════════════════════════════════════════════════════════\n// PURGE_ALL — irreversibly clear every entry in scope\n// ════════════════════════════════════════════════════════════════════\n\nexport function createSiemDlqPurgeAllFactories(): ResourceCustomServiceImplementationFactory[] {\n return SIEM_DLQ_VARIANTS.map(({ resourceType, scopeType }): ResourceCustomServiceImplementationFactory => {\n return (_resourcesRegistryService, container: Container) => {\n return createResourceCustomServiceImplementation({\n operationPath: {\n resourceIdentifier: resourceType,\n operationIdentifier: SiemDeliveryDlq_Operations.PURGE_ALL,\n variantType: ResourceOperationVariantType.API_CALL,\n isOperationDefault: true,\n },\n requestDtoSchema: SiemDeliveryDlq_PurgeAllRequestDto,\n // #2297: the delete is the whole operation and it goes through utils.serviceOptions. It is still a multi-row write\n // with no selection ceiling, so it stays best effort for THAT reason until such writes are bounded.\n hookTransactionPosture: ResourceCustomServiceImplementationHookTransactionPosture.RUNS_INSIDE_TRANSACTION,\n handlers: {\n replaceCoreOperations: async (_id, _input, executionContext, _operationPath, utils) => {\n const scope = resolveScope(scopeType, executionContext);\n if (!scope) {\n throw utils.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: `SIEM DLQ PURGE_ALL requires a ${scopeType}-scoped execution context.` },\n });\n }\n\n const repo = engineRepositoriesRegistry(utils).getRepositoryOrThrow(resourceType, executionContext);\n\n // Whole-scope clear. Unlike RETRY's cleanup this delete IS the operation,\n // so a failure propagates (the op did not succeed). Scope-FK filtered so a\n // purge can never cross tenants.\n const purgedIds = await repo.deleteMany(executionContext, scopeFilter(scope), utils.serviceOptions);\n const purgedCount = purgedIds.length;\n\n // Matches the declared customResponseDto `{ purgedCount, message }`.\n return {\n purgedCount,\n message: `Purged ${purgedCount} SIEM dead-letter ${purgedCount === 1 ? 'entry' : 'entries'} for this ${scope.scopeType}.`,\n };\n },\n },\n });\n };\n });\n}\n"]}
1
+ {"version":3,"file":"siem-delivery-dlq.custom-impl.backend.service.js","sourceRoot":"","sources":["../../../../../../src/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,2BAA2B,EAC3B,SAAS,EACT,4BAA4B,EAC5B,0BAA0B,EAC1B,qCAAqC,EACrC,kCAAkC,EAClC,kCAAkC,EAClC,qBAAqB,EACrB,kCAAkC,GAInC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,yCAAyC,EACzC,yDAAyD,GAE1D,MAAM,4GAA4G,CAAC;AACpH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAIpF,OAAO,EACL,gCAAgC,GAEjC,MAAM,4FAA4F,CAAC;AAEpG,OAAO,EAAE,2BAA2B,EAAE,MAAM,8EAA8E,CAAC;AAC3H,OAAO,EAAE,0BAA0B,EAAE,MAAM,8FAA8F,CAAC;AAS1I;;;;;;;;;;;GAWG;AACH,MAAM,iBAAiB,GAA8B;IACnD,EAAE,YAAY,EAAE,gBAAgB,CAAC,8BAA8B,EAAE,SAAS,EAAE,aAAa,CAAC,YAAY,EAAE;IACxG,EAAE,YAAY,EAAE,gBAAgB,CAAC,6BAA6B,EAAE,SAAS,EAAE,aAAa,CAAC,WAAW,EAAE;CAC9F,CAAC;AASX;;;;GAIG;AACH,SAAS,YAAY,CACnB,SAAwB,EACxB,gBAAmF;IAEnF,MAAM,OAAO,GAAG,SAAS,KAAK,aAAa,CAAC,YAAY;QACtD,CAAC,CAAC,gBAAgB,CAAC,cAAc;QACjC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC;IACnC,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,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AE,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE;wBACpF,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;wBACxD,IAAI,CAAC,KAAK,EAAE,CAAC;4BACX,MAAM,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,gBAAgB,EAAE;gCAC1E,sBAAsB,EAAE,2BAA2B,CAAC,UAAU;gCAC9D,OAAO,EAAE,EAAE,OAAO,EAAE,iCAAiC,SAAS,4BAA4B,EAAE;6BAC7F,CAAC,CAAC;wBACL,CAAC;wBAED,MAAM,IAAI,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;wBAEpG,0EAA0E;wBAC1E,2EAA2E;wBAC3E,iCAAiC;wBACjC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;wBACpG,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC;wBAErC,qEAAqE;wBACrE,OAAO;4BACL,WAAW;4BACX,OAAO,EAAE,UAAU,WAAW,qBAAqB,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,aAAa,KAAK,CAAC,SAAS,GAAG;yBAC1H,CAAC;oBACJ,CAAC;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * SIEM Delivery DLQ — RETRY_SINGLE / RETRY_ALL / PURGE_ALL custom implementations.\n *\n * Makes the operator drain/clear surfaces on the SIEM delivery dead-letter queue\n * real (both polymorphic variants: ORGANIZATION_SIEM_DELIVERY_DLQ +\n * APPLICATION_SIEM_DELIVERY_DLQ). They are declared on\n * `siem-delivery-dlq.shared.resources-config.schemas.ts`; this file authors the\n * REPLACE_CORE_OPERATIONS handlers that back them.\n *\n * ── Why \"retry\" means RE-ENQUEUE, not \"reset a status\" ────────────────────────\n * The M2M webhook delivery-log sibling\n * (`m2m-webhook-delivery-log.custom-impl.backend.service.ts`) resets the SAME row\n * its worker drains (`resetForRetry`: CAS a FAILED row back to PENDING) because the\n * M2M worker owns that row's status machine. The SIEM delivery worker\n * (`SIEMWebhookDeliveryBackendService.processDelivery`) does NOT: SIEM delivery is\n * enqueue-per-event via the `siem.webhook-delivery` custom batch, the worker holds\n * no back-reference to any DLQ row, and there is NO SIEM DLQ retry-sweep batch. So\n * \"retry\" here = rebuild the delivery job from the DLQ row's STORED envelope and\n * re-enqueue it onto the SIEM delivery queue (through the single job-contract seam\n * {@link AuditEventDispatcherBackendService.enqueueSiemWebhookDelivery}).\n *\n * ── Delete-on-requeue ─────────────────────────────────────────────────────────\n * After a successful re-enqueue the DLQ row is DELETED, not flipped to a status.\n * Because the worker has no back-ref and no sweep exists, a status transition would\n * leave the row stuck forever; and a re-delivery that fails is re-captured by\n * `_enqueueToDLQ` as a BRAND-NEW row. So the honest model is: a DLQ row represents a\n * delivery that is CURRENTLY dead-lettered — the moment we put it back in flight it\n * leaves the queue. Enqueue is the load-bearing step (its failure fails the op and\n * leaves the row intact for another attempt); the delete is best-effort cleanup (a\n * delete failure only leaves a stale, purgeable row — never an un-retried event).\n *\n * ── A QUARANTINED row is never re-sent from its stored envelope (#2959) ─────────\n * A row whose job failed its integrity check (`SiemDeliveryDlqStatus.QUARANTINED`) was written from a payload nobody\n * vouched for: anyone able to write to the queue can plant one, in any tenant's queue, with any envelope. Re-enqueueing\n * it would sign it afresh and deliver a forged security event to that tenant's real SIEM. So both RETRY verbs hand a\n * quarantined row to {@link AuditEventDispatcherBackendService.redeliverQuarantinedDeadLetter}, which re-derives the event\n * from the application's own audit store by `eventId` and delivers it only to an organization that store records the\n * event as routed to. When it cannot (no such event, not routed here, filtered out, application scope), the row stays\n * quarantined: RETRY_SINGLE answers 409 naming why, RETRY_ALL counts it as skipped, and both log it.\n *\n * ── PURGE_ALL clears the WHOLE scope ──────────────────────────────────────────\n * PURGE_ALL drops every row in the caller's scope (not only EXHAUSTED). The op name,\n * empty request DTO (no age/status narrowing), and CRITICAL risk tier all say\n * \"clear the queue\"; and unlike M2M there is no in-flight row to protect (SIEM DLQ\n * rows are inert — no worker owns them, no sweep touches them), so every status is\n * equally safe to remove. A partial purge that left PENDING_RETRY rows would leave\n * rows nothing will ever retry — a worse trap.\n *\n * ── Tenant safety ─────────────────────────────────────────────────────────────\n * Every read/list/delete is narrowed to the operation's scope FK\n * (organizationId / applicationId) belt-and-braces on top of the execution context's\n * own scope enforcement — an `entryId` from another tenant reads as not-found and a\n * purge/retry can never cross a scope boundary.\n */\n\nimport {\n AuthScopeType,\n CoreResourceType,\n ErrorCustomMessageReference,\n ErrorType,\n ResourceOperationVariantType,\n SiemDeliveryDlq_Operations,\n SiemDeliveryDlq_RetrySingleRequestDto,\n SiemDeliveryDlq_RetryAllRequestDto,\n SiemDeliveryDlq_PurgeAllRequestDto,\n SiemDeliveryDlqStatus,\n coreResourceShared_FieldIdentifier,\n type SecurityAuditEventEnvelope,\n type SiemDeliveryDlqBase,\n type SiemExportConfigBase,\n} from '@wildo-ai/saas-models';\nimport type { Container } from 'inversify';\nimport {\n createResourceCustomServiceImplementation,\n ResourceCustomServiceImplementationHookTransactionPosture,\n type ResourceCustomServiceImplementationFactory,\n} from '~wildo-backend-lib/base-classes/services/services/resource-operation-custom-implementation.factory.backend';\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { BackendResourceRepository } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport type { LoggerService } from '~wildo-backend-lib/monitoring/logger/services/logger.service';\nimport type { AuthOrganizationConfigurationService } from '~wildo-backend-lib/security/authentications/services/admin-config/auth-organization-configuration.service';\nimport {\n SiemQuarantinedDeadLetterOutcome,\n type AuditEventDispatcherBackendService,\n} from '~wildo-backend-lib/compliance/audit-trails/services/audit-event-dispatcher.backend.service';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport { projectCaughtErrorLogFields } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { engineRepositoriesRegistry } from '~wildo-backend-lib/base-classes/services/services/engine-repositories-registry.backend.utils';\n\n// ── SIEM delivery DLQ polymorphic variants (resource type ↔ scope) ────────────\n\ninterface SiemDlqVariant {\n resourceType: CoreResourceType;\n scopeType: AuthScopeType;\n}\n\n/**\n * One factory per polymorphic variant. The resource type selects the collection;\n * the scope type drives config loading, the scope-FK filter, and the re-enqueued\n * job's scope so it can never drift from the row it targets.\n *\n * Both variants are wired identically, but the APPLICATION one is RESERVED / DORMANT\n * in practice: an `APPLICATION_SIEM_DELIVERY_DLQ` row can only exist if an app-scoped\n * delivery failed, and no producer emits app-scoped deliveries today (the sole SIEM\n * producer is org-scoped). So the APP RETRY/PURGE paths never have rows to act on —\n * they are the retry half of reserved plumbing. See `AuditEventDispatcherBackendService.\n * dispatchToOrganizationAuditSinks` for the rationale + how an app producer would attach.\n */\nconst SIEM_DLQ_VARIANTS: readonly SiemDlqVariant[] = [\n { resourceType: CoreResourceType.ORGANIZATION_SIEM_DELIVERY_DLQ, scopeType: AuthScopeType.ORGANIZATION },\n { resourceType: CoreResourceType.APPLICATION_SIEM_DELIVERY_DLQ, scopeType: AuthScopeType.APPLICATION },\n] as const;\n\n/** The operation's resolved scope: its type, id, and the row's scope-FK column name. */\ninterface ResolvedSiemDlqScope {\n scopeType: AuthScopeType;\n scopeId: string;\n scopeFkField: string;\n}\n\n/**\n * Resolve the operation's scope from the (admin) execution context. Returns `null`\n * when the context carries no scope id — a routing/authorization invariant violation\n * for these org/app-scoped operations, which the caller surfaces as a VALIDATION error.\n */\nfunction resolveScope(\n scopeType: AuthScopeType,\n executionContext: { organizationId?: string | null; applicationId?: string | null },\n): ResolvedSiemDlqScope | null {\n const scopeId = scopeType === AuthScopeType.ORGANIZATION\n ? executionContext.organizationId\n : executionContext.applicationId;\n if (!scopeId) return null;\n const scopeFkField = scopeType === AuthScopeType.ORGANIZATION\n ? coreResourceShared_FieldIdentifier[CoreResourceType.ORGANIZATIONS]\n : coreResourceShared_FieldIdentifier[CoreResourceType.APPLICATION];\n return { scopeType, scopeId, scopeFkField };\n}\n\n/** The scope-FK filter fragment narrowing every read/list/delete to this tenant. */\nfunction scopeFilter(scope: ResolvedSiemDlqScope): Record<string, string> {\n return { [scope.scopeFkField]: scope.scopeId };\n}\n\n/** Resolve the two domain collaborators the drain paths need from the DI container. */\nfunction getDeps(container: Container): {\n orgConfigService: AuthOrganizationConfigurationService;\n dispatcher: AuditEventDispatcherBackendService;\n} {\n return {\n orgConfigService: container.get<AuthOrganizationConfigurationService>(\n SAAS_SERVICE_TYPES.AuthOrganizationConfigurationService,\n ),\n dispatcher: container.get<AuditEventDispatcherBackendService>(\n SAAS_SERVICE_TYPES.AuditEventDispatcherService,\n ),\n };\n}\n\n/**\n * The DLQ row stores the delivery envelope in `eventPayload` (`z.unknown()` in the\n * schema). Return it typed when present and object-shaped, else `null` (a corrupt /\n * missing payload has nothing to re-deliver).\n */\nfunction extractEnvelope(row: SiemDeliveryDlqBase): SecurityAuditEventEnvelope | null {\n const envelope = row.eventPayload as SecurityAuditEventEnvelope | undefined | null;\n return envelope && typeof envelope === 'object' ? envelope : null;\n}\n\n/**\n * Re-enqueue one stored envelope onto the SIEM delivery queue for this scope,\n * through the dispatcher's single job-contract seam (payload shape + delivery MAC +\n * batch ref). May throw on enqueue failure — callers decide isolation.\n */\nasync function enqueueEnvelope(\n dispatcher: AuditEventDispatcherBackendService,\n scope: ResolvedSiemDlqScope,\n siemConfig: SiemExportConfigBase,\n envelope: SecurityAuditEventEnvelope,\n): Promise<void> {\n await dispatcher.enqueueSiemWebhookDelivery({\n envelope,\n // The payload's `organizationId` is a routing/label field; the authoritative\n // delivery scope is `scopeType`/`scopeId`. Prefer the envelope's own org (for the\n // APP variant that is the app's owning org), falling back to the scope id.\n organizationId: envelope.organizationId ?? scope.scopeId,\n siemConfig,\n scopeType: scope.scopeType,\n scopeId: scope.scopeId,\n });\n}\n\n/** What {@link requeueRow} did: `keptQuarantined` is set exactly when a quarantined row stayed (#2959). */\ninterface SiemDlqRequeueResult {\n requeued: boolean;\n keptQuarantined?: SiemQuarantinedDeadLetterOutcome;\n}\n\n/**\n * Put one dead-lettered row back in flight, by the only path its status allows: a QUARANTINED row is re-derived from the\n * audit store (#2959) and every other row re-sends its stored envelope. `requeued: false` carries the quarantine outcome\n * that kept the row, or none when a row that is not quarantined has no stored envelope. May throw on enqueue failure.\n */\nasync function requeueRow(\n dispatcher: AuditEventDispatcherBackendService,\n scope: ResolvedSiemDlqScope,\n siemConfig: SiemExportConfigBase,\n row: SiemDeliveryDlqBase,\n): Promise<SiemDlqRequeueResult> {\n if (row.status === SiemDeliveryDlqStatus.QUARANTINED) {\n // The stored envelope is never read here: `eventId` is the row's own column, and only what the audit store holds under\n // it is delivered.\n const outcome = await dispatcher.redeliverQuarantinedDeadLetter({\n eventId: row.eventId,\n scopeType: scope.scopeType,\n scopeId: scope.scopeId,\n siemConfig,\n });\n return outcome === SiemQuarantinedDeadLetterOutcome.REQUEUED ? { requeued: true } : { requeued: false, keptQuarantined: outcome };\n }\n const envelope = extractEnvelope(row);\n if (!envelope) return { requeued: false };\n await enqueueEnvelope(dispatcher, scope, siemConfig, envelope);\n return { requeued: true };\n}\n\n/** The operator-facing sentence for a quarantined row that stays (#2959). */\nfunction describeKeptQuarantine(outcome: SiemQuarantinedDeadLetterOutcome): string {\n switch (outcome) {\n case SiemQuarantinedDeadLetterOutcome.NO_AUDIT_RECORD:\n return 'This SIEM DLQ entry failed its integrity check and the audit log holds no event under its id, so there is no genuine event to re-deliver; it stays quarantined.';\n case SiemQuarantinedDeadLetterOutcome.NOT_ROUTED_TO_SCOPE:\n return 'This SIEM DLQ entry failed its integrity check and the audit log does not record its event as routed to this scope, so it is not re-delivered here; it stays quarantined.';\n case SiemQuarantinedDeadLetterOutcome.EXCLUDED_BY_FILTER:\n return 'This SIEM DLQ entry failed its integrity check, and the SIEM export filter for this scope excludes the event the audit log holds under its id; it stays quarantined.';\n case SiemQuarantinedDeadLetterOutcome.SCOPE_HAS_NO_PRODUCER:\n return 'This SIEM DLQ entry failed its integrity check, and no event can be re-derived for this scope; it stays quarantined.';\n case SiemQuarantinedDeadLetterOutcome.REQUEUED:\n return 'This SIEM DLQ entry was re-derived from the audit log and re-queued.';\n }\n}\n\n/**\n * Delete-on-requeue cleanup: remove the rows we just re-enqueued. NON-FATAL — the\n * re-enqueue already happened, so a delete failure leaves a stale (operator-purgeable)\n * row rather than un-retrying a delivered-again event. Scope-FK filtered belt-and-braces.\n */\nasync function deleteRequeuedRows(\n repo: BackendResourceRepository,\n executionContext: ExecutionContext<any>,\n scope: ResolvedSiemDlqScope,\n ids: string[],\n logger: LoggerService,\n): Promise<void> {\n if (ids.length === 0) return;\n try {\n await repo.deleteMany(executionContext, { _id: { $in: ids }, ...scopeFilter(scope) });\n } catch (error) {\n logger.warn('SIEM DLQ delete-on-requeue failed (non-fatal) — entries re-queued but not removed', {\n scopeType: scope.scopeType,\n scopeId: scope.scopeId,\n entryIds: ids,\n ...projectCaughtErrorLogFields(error),\n });\n }\n}\n\n// ════════════════════════════════════════════════════════════════════\n// RETRY_SINGLE — re-enqueue one dead-lettered entry, then delete it\n// ════════════════════════════════════════════════════════════════════\n\nexport function createSiemDlqRetrySingleFactories(): ResourceCustomServiceImplementationFactory[] {\n return SIEM_DLQ_VARIANTS.map(({ resourceType, scopeType }): ResourceCustomServiceImplementationFactory => {\n return (_resourcesRegistryService, container: Container) => {\n return createResourceCustomServiceImplementation({\n operationPath: {\n resourceIdentifier: resourceType,\n operationIdentifier: SiemDeliveryDlq_Operations.RETRY_SINGLE,\n variantType: ResourceOperationVariantType.API_CALL,\n isOperationDefault: true,\n },\n requestDtoSchema: SiemDeliveryDlq_RetrySingleRequestDto,\n handlers: {\n replaceCoreOperations: async (_id, input, executionContext, _operationPath, utils) => {\n // The entry is addressed by the request DTO's `entryId` (not the URL id),\n // mirroring the M2M RETRY sibling.\n const { entryId } = input as { entryId: string };\n\n const scope = resolveScope(scopeType, executionContext);\n if (!scope) {\n throw utils.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: `SIEM DLQ RETRY_SINGLE requires a ${scopeType}-scoped execution context.` },\n });\n }\n\n const repo = engineRepositoriesRegistry(utils).getRepositoryOrThrow(resourceType, executionContext);\n\n // Scoped read (id AND scope FK): a cross-tenant entryId reads as not-found.\n const row = await repo.read<SiemDeliveryDlqBase>(executionContext, {\n id: entryId,\n filter: scopeFilter(scope),\n });\n if (!row) {\n throw utils.errorBuilder.buildError(ErrorType.NOT_FOUND, executionContext, {\n customMessageReference: ErrorCustomMessageReference.NOT_FOUND,\n context: { message: 'SIEM DLQ entry not found in this scope.', entryId },\n });\n }\n if (row.status === SiemDeliveryDlqStatus.DELIVERED) {\n throw utils.errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {\n customMessageReference: ErrorCustomMessageReference.CONFLICT,\n context: {\n message: 'This SIEM DLQ entry was already delivered on a later attempt; there is nothing to retry.',\n entryId,\n status: row.status,\n },\n });\n }\n\n const { orgConfigService, dispatcher } = getDeps(container);\n const siemConfig = await orgConfigService.loadSiemExportConfig(\n executionContext,\n scope.scopeType,\n scope.scopeId,\n );\n // `loadSiemExportConfig` lazily materialises a DISABLED default (empty\n // webhookUrl) for a never-configured scope, so guard on a real destination:\n // without a URL there is nowhere to re-deliver.\n if (!siemConfig || !siemConfig.webhookUrl) {\n throw utils.errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {\n customMessageReference: ErrorCustomMessageReference.CONFLICT,\n context: {\n message: 'SIEM export has no webhook URL configured for this scope; configure it before retrying.',\n entryId,\n },\n });\n }\n\n // Enqueue FIRST — a failure here throws (op fails, row left intact for a\n // later attempt). Only on success do we delete-on-requeue.\n const requeue = await requeueRow(dispatcher, scope, siemConfig, row);\n if (!requeue.requeued && requeue.keptQuarantined === undefined) {\n throw utils.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: 'SIEM DLQ entry has no stored envelope to re-deliver.', entryId },\n });\n }\n if (!requeue.requeued && requeue.keptQuarantined !== undefined) {\n const kept = requeue.keptQuarantined;\n utils.logger.warn('SIEM DLQ RETRY_SINGLE: a quarantined entry stays quarantined (#2959)', {\n scopeType: scope.scopeType, scopeId: scope.scopeId, entryId, eventId: row.eventId, outcome: kept,\n });\n throw utils.errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {\n customMessageReference: ErrorCustomMessageReference.CONFLICT,\n context: { message: describeKeptQuarantine(kept), entryId, outcome: kept },\n });\n }\n await deleteRequeuedRows(repo, executionContext, scope, [entryId], utils.logger);\n\n // Matches the declared customResponseDto `{ message, entryId }`.\n return { message: 'SIEM DLQ entry re-queued for delivery.', entryId };\n },\n },\n });\n };\n });\n}\n\n// ════════════════════════════════════════════════════════════════════\n// RETRY_ALL — re-enqueue every non-delivered entry in scope, then delete them\n// ════════════════════════════════════════════════════════════════════\n\nexport function createSiemDlqRetryAllFactories(): ResourceCustomServiceImplementationFactory[] {\n return SIEM_DLQ_VARIANTS.map(({ resourceType, scopeType }): ResourceCustomServiceImplementationFactory => {\n return (_resourcesRegistryService, container: Container) => {\n return createResourceCustomServiceImplementation({\n operationPath: {\n resourceIdentifier: resourceType,\n operationIdentifier: SiemDeliveryDlq_Operations.RETRY_ALL,\n variantType: ResourceOperationVariantType.API_CALL,\n isOperationDefault: true,\n },\n requestDtoSchema: SiemDeliveryDlq_RetryAllRequestDto,\n /*\n * #2297: stays outside a transaction. Each entry is re-published to the delivery queue, and which rows are then\n * deleted depends on which publishes went through: a rolled-back or retried attempt would publish every envelope\n * again and keep the rows. (It is a multi-row write as well, so it would stay best effort for that reason too.)\n */\n hookTransactionPosture: ResourceCustomServiceImplementationHookTransactionPosture.STAYS_OUTSIDE_TRANSACTION,\n handlers: {\n replaceCoreOperations: async (_id, _input, executionContext, _operationPath, utils) => {\n const scope = resolveScope(scopeType, executionContext);\n if (!scope) {\n throw utils.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: `SIEM DLQ RETRY_ALL requires a ${scopeType}-scoped execution context.` },\n });\n }\n\n const repo = engineRepositoriesRegistry(utils).getRepositoryOrThrow(resourceType, executionContext);\n\n // Enumerate the scope's rows. LIST projects to summary fields (_id, status),\n // which is all we need to pick candidates; the full envelope is re-read per row.\n const rows = await repo.list<SiemDeliveryDlqBase>(executionContext, scopeFilter(scope));\n const total = rows.length;\n if (total === 0) {\n return { retriedCount: 0, skippedCount: 0, message: 'The SIEM dead-letter queue is empty for this scope.' };\n }\n\n const { orgConfigService, dispatcher } = getDeps(container);\n const siemConfig = await orgConfigService.loadSiemExportConfig(\n executionContext,\n scope.scopeType,\n scope.scopeId,\n );\n if (!siemConfig || !siemConfig.webhookUrl) {\n // No destination → nothing can be re-queued. Report as a bulk summary\n // (not an error): the whole queue is skipped.\n return {\n retriedCount: 0,\n skippedCount: total,\n message: 'SIEM export has no webhook URL configured for this scope; no entries were re-queued.',\n };\n }\n\n // PENDING_RETRY + EXHAUSTED re-send their stored envelope; QUARANTINED is re-derived from the audit store\n // (#2959); DELIVERED has nothing to retry.\n const requeuedIds: string[] = [];\n for (const summary of rows) {\n if (summary.status === SiemDeliveryDlqStatus.DELIVERED) continue;\n\n // Summary lacks eventPayload — read the full row for its stored envelope.\n const row = await repo.read<SiemDeliveryDlqBase>(executionContext, {\n id: summary._id,\n filter: scopeFilter(scope),\n });\n if (!row) continue; // vanished mid-sweep → skip\n\n try {\n const requeue = await requeueRow(dispatcher, scope, siemConfig, row);\n if (requeue.requeued) {\n requeuedIds.push(summary._id);\n } else if (requeue.keptQuarantined) {\n // A quarantined row that cannot be re-derived stays where it is (#2959).\n utils.logger.warn('SIEM DLQ RETRY_ALL: a quarantined entry stays quarantined (#2959)', {\n scopeType: scope.scopeType, scopeId: scope.scopeId, entryId: summary._id, eventId: row.eventId, outcome: requeue.keptQuarantined,\n });\n }\n } catch (error) {\n // Per-entry isolation: one enqueue failure never aborts the sweep.\n utils.logger.warn('SIEM DLQ RETRY_ALL: failed to re-enqueue one entry (skipped)', {\n scopeType: scope.scopeType,\n scopeId: scope.scopeId,\n entryId: summary._id,\n ...projectCaughtErrorLogFields(error),\n });\n }\n }\n\n await deleteRequeuedRows(repo, executionContext, scope, requeuedIds, utils.logger);\n\n const retriedCount = requeuedIds.length;\n const skippedCount = total - retriedCount;\n // Matches the declared customResponseDto `{ retriedCount, skippedCount, message }`.\n return {\n retriedCount,\n skippedCount,\n message: `Re-queued ${retriedCount} of ${total} SIEM dead-letter ${total === 1 ? 'entry' : 'entries'} for this ${scope.scopeType}; skipped ${skippedCount}.`,\n };\n },\n },\n });\n };\n });\n}\n\n// ════════════════════════════════════════════════════════════════════\n// PURGE_ALL — irreversibly clear every entry in scope\n// ════════════════════════════════════════════════════════════════════\n\nexport function createSiemDlqPurgeAllFactories(): ResourceCustomServiceImplementationFactory[] {\n return SIEM_DLQ_VARIANTS.map(({ resourceType, scopeType }): ResourceCustomServiceImplementationFactory => {\n return (_resourcesRegistryService, container: Container) => {\n return createResourceCustomServiceImplementation({\n operationPath: {\n resourceIdentifier: resourceType,\n operationIdentifier: SiemDeliveryDlq_Operations.PURGE_ALL,\n variantType: ResourceOperationVariantType.API_CALL,\n isOperationDefault: true,\n },\n requestDtoSchema: SiemDeliveryDlq_PurgeAllRequestDto,\n // #2297: the delete is the whole operation and it goes through utils.serviceOptions. It stays best effort as an\n // unbounded multi-row write: the HOOK selects the whole scope, so the framework's per-transaction chunking (wave 4,\n // `MULTI_ROW_WRITE_ROWS_PER_TRANSACTION`) cannot reach it, and a `maximumRowsWrittenPerAttempt` would make \"purge\n // all\" purge a page. Bounding it means changing what the operation answers (a partial purge reporting what\n // remains, or a background job), not declaring a number here.\n hookTransactionPosture: ResourceCustomServiceImplementationHookTransactionPosture.RUNS_INSIDE_TRANSACTION,\n handlers: {\n replaceCoreOperations: async (_id, _input, executionContext, _operationPath, utils) => {\n const scope = resolveScope(scopeType, executionContext);\n if (!scope) {\n throw utils.errorBuilder.buildError(ErrorType.VALIDATION, executionContext, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: `SIEM DLQ PURGE_ALL requires a ${scopeType}-scoped execution context.` },\n });\n }\n\n const repo = engineRepositoriesRegistry(utils).getRepositoryOrThrow(resourceType, executionContext);\n\n // Whole-scope clear. Unlike RETRY's cleanup this delete IS the operation,\n // so a failure propagates (the op did not succeed). Scope-FK filtered so a\n // purge can never cross tenants.\n const purgedIds = await repo.deleteMany(executionContext, scopeFilter(scope), utils.serviceOptions);\n const purgedCount = purgedIds.length;\n\n // Matches the declared customResponseDto `{ purgedCount, message }`.\n return {\n purgedCount,\n message: `Purged ${purgedCount} SIEM dead-letter ${purgedCount === 1 ? 'entry' : 'entries'} for this ${scope.scopeType}.`,\n };\n },\n },\n });\n };\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sso-config-domain-verification.custom-impl.backend.service.d.ts","sourceRoot":"","sources":["../../../../../../src/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAmBH,OAAO,EAGL,KAAK,0CAA0C,EAChD,MAAM,4GAA4G,CAAC;AA4uBpH,wBAAgB,0CAA0C,IAAI,0CAA0C,EAAE,CASzG;AAED;;;GAGG;AACH,wBAAgB,wCAAwC,IAAI,0CAA0C,EAAE,CAEvG"}
1
+ {"version":3,"file":"sso-config-domain-verification.custom-impl.backend.service.d.ts","sourceRoot":"","sources":["../../../../../../src/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAmBH,OAAO,EAGL,KAAK,0CAA0C,EAChD,MAAM,4GAA4G,CAAC;AAsyBpH,wBAAgB,0CAA0C,IAAI,0CAA0C,EAAE,CASzG;AAED;;;GAGG;AACH,wBAAgB,wCAAwC,IAAI,0CAA0C,EAAE,CAEvG"}
@@ -33,6 +33,7 @@
33
33
  import { AuthScopeType, CoreResourceType, DomainVerificationStatus, ErrorCustomMessageReference, ErrorType, ResourceOperationVariantType, SsoConfig_Operations, SsoConfig_RepairUnreadableConfigurationRequestDto, SsoConfigRepairRefusal, SSO_CONFIG_BLOCKS, SsoConfigBlock, ssoConfigBlockFaults, } from '@wildo-ai/saas-models';
34
34
  import { SAAS_SERVICE_TYPES } from '../../../../inject/models/service-types.js';
35
35
  import { createResourceCustomServiceImplementation, ResourceCustomServiceImplementationHookTransactionPosture, } from '../../../../base-classes/services/services/resource-operation-custom-implementation.factory.backend.js';
36
+ import { ResourceOperationBeforeTransactionalCoreDisposition, } from '../../../../base-classes/services/services/resource-operation-custom-implementation-base.backend.service.js';
36
37
  import { registerTransactionPostCommitEffect } from '../../../../databases/models/transaction.shared.schemas.js';
37
38
  import { DnsLookupUnavailableError } from '../../../../security/dns/dns-txt-lookup.backend.service.js';
38
39
  import { emitAuthorityChangeAuditWhenDurable } from '../../../../organizations/services/authority-change-audit.backend.utils.js';
@@ -215,13 +216,21 @@ function createVerifyDomainFactory(variant) {
215
216
  },
216
217
  debugLabel: `${variant.resourceType}.verifyDomain`,
217
218
  /*
218
- * #2297: stays outside a transaction. The prefix asks DNS (up to ~10 s, which would hold the row lock, and a retried
219
- * attempt would ask again and could read another answer), and the domain reservation it takes must AUTOCOMMIT (a
220
- * unique violation aborts a PostgreSQL transaction, so the loser could not answer its refusal from inside one;
221
- * `DomainVerificationBackendService.reserveDomain`). Both feed the write. Moving them into a `beforeTransactionalCore`
222
- * phase is the split that would let this write keep its audit row.
219
+ * #2297: split so the write keeps its audit row through a crash. Two effects feed the write and must stay OUTSIDE the
220
+ * transaction: the DNS lookup (up to ~10 s, which would hold the row lock, and a retried attempt would ask again and
221
+ * could read another answer) and the domain reservation, which must AUTOCOMMIT (a unique violation aborts a PostgreSQL
222
+ * transaction, so the loser could not answer its refusal from inside one; `DomainVerificationBackendService.reserveDomain`).
223
+ * - `beforeTransactionalCore` (outside, once, before the transaction): the challenge check, the exclusivity read, the
224
+ * DNS lookup and the reservation, in that order, exactly as the prefix used to run them. Its answer (the challenge
225
+ * it checked and what DNS said) rides to the core as the phase's frozen continuation.
226
+ * - PREFIX (inside, retried with the attempt): re-reads the row the attempt holds and applies that answer, but only
227
+ * while the row still holds the SAME challenge: a re-claim committed in between replaced the nonce, and an answer
228
+ * about the old one says nothing about the new one, so the attempt refuses rather than verify against it.
229
+ * Nothing else leaves the database, so the transaction is the framework's and the row is kept with its commit.
223
230
  */
224
- hookTransactionPosture: ResourceCustomServiceImplementationHookTransactionPosture.STAYS_OUTSIDE_TRANSACTION,
231
+ transactionalCore: true,
232
+ transactionParticipants: {},
233
+ hookTransactionPosture: ResourceCustomServiceImplementationHookTransactionPosture.RUNS_INSIDE_TRANSACTION,
225
234
  /**
226
235
  * The prefix WRITES `domains`, and nothing else can.
227
236
  *
@@ -236,23 +245,10 @@ function createVerifyDomainFactory(variant) {
236
245
  authoritativeFields: ['domains'],
237
246
  coreWritePinsRowVersion: true,
238
247
  handlers: {
239
- prefixCoreOperations: async (_id, input, executionContext, _operationPath, utils) => {
248
+ beforeTransactionalCore: async (_id, input, executionContext, _operationPath, utils) => {
240
249
  const { domain, scopeId, domains } = resolveDomainRequest(variant, input, executionContext, utils);
241
250
  const service = getDomainVerificationService(container);
242
- const expectedToken = service.getVerificationToken(domains, domain);
243
- if (!expectedToken) {
244
- // A claim mints the nonce, so verifying without one is not a failed check — it is a
245
- // request for a challenge that was never raised. Saying so is what stops an operator
246
- // publishing a record and waiting for a verification that can never pass.
247
- throw utils.errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {
248
- context: {
249
- code: 'SSO_DOMAIN_NOT_CLAIMED',
250
- reason: 'sso_domain_not_claimed',
251
- message: 'No verification challenge exists for this domain in this scope. Claim it first.',
252
- domain,
253
- },
254
- });
255
- }
251
+ const expectedToken = requireVerificationChallenge(service, domains, domain, executionContext, utils);
256
252
  // Re-checked HERE, not only at claim: a claim takes no lock, so another scope may have
257
253
  // completed its own verification since. This is the write that confers routing authority
258
254
  // and therefore the one that must be exclusive.
@@ -283,19 +279,64 @@ function createVerifyDomainFactory(variant) {
283
279
  if (verified && await service.reserveDomain(variant.scopeType, scopeId, domain)) {
284
280
  throw domainHeldElsewhere(domain, executionContext, utils);
285
281
  }
282
+ return {
283
+ disposition: ResourceOperationBeforeTransactionalCoreDisposition.CONTINUE,
284
+ coreInputPatch: {},
285
+ continuation: { domain, checkedToken: expectedToken, verified, recordsFound },
286
+ };
287
+ },
288
+ prefixCoreOperations: async (_id, input, executionContext, _operationPath, utils) => {
289
+ const { domain, domains } = resolveDomainRequest(variant, input, executionContext, utils);
290
+ const service = getDomainVerificationService(container);
291
+ const checked = utils.beforeTransactionalCore?.continuation;
292
+ if (!checked || checked.domain !== domain) {
293
+ throw utils.errorBuilder.buildError(ErrorType.INTERNAL, executionContext, {
294
+ context: { reason: 'sso_domain_verification_unchecked', message: 'The domain challenge was not checked before the write.', domain },
295
+ });
296
+ }
297
+ // The challenge the DNS answer is about must still be the row's: a claim committed since the check replaced it.
298
+ if (requireVerificationChallenge(service, domains, domain, executionContext, utils) !== checked.checkedToken) {
299
+ throw utils.errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {
300
+ context: {
301
+ code: 'SSO_DOMAIN_CHALLENGE_CHANGED',
302
+ reason: 'sso_domain_challenge_changed',
303
+ message: 'This domain was claimed again while it was being verified, so its challenge changed. Verify it again.',
304
+ domain,
305
+ },
306
+ });
307
+ }
286
308
  putBridged(bridgeKey(variant.resourceType, SsoConfig_Operations.VERIFY_DOMAIN, executionContext), {
287
309
  domain,
288
- status: verified ? DomainVerificationStatus.VERIFIED : DomainVerificationStatus.FAILED,
310
+ status: checked.verified ? DomainVerificationStatus.VERIFIED : DomainVerificationStatus.FAILED,
289
311
  dnsName: service.verificationDnsName(domain),
290
- dnsRecordsFound: recordsFound,
312
+ dnsRecordsFound: checked.recordsFound,
291
313
  });
292
- return { domains: service.planVerificationOutcome(domains, domain, verified) };
314
+ return { domains: service.planVerificationOutcome(domains, domain, checked.verified) };
293
315
  },
294
316
  postfixCoreOperations: async (_id, updatedRow, executionContext, _operationPath, _utils) => takeBridged(bridgeKey(variant.resourceType, SsoConfig_Operations.VERIFY_DOMAIN, executionContext)) ?? updatedRow,
295
317
  },
296
318
  });
297
319
  return factory;
298
320
  }
321
+ /**
322
+ * The verification challenge the row holds for `domain`, or a refusal. A claim mints the nonce, so verifying without one is
323
+ * not a failed check — it is a request for a challenge that was never raised. Saying so is what stops an operator publishing
324
+ * a record and waiting for a verification that can never pass.
325
+ */
326
+ function requireVerificationChallenge(service, domains, domain, executionContext, utils) {
327
+ const expectedToken = service.getVerificationToken(domains, domain);
328
+ if (!expectedToken) {
329
+ throw utils.errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {
330
+ context: {
331
+ code: 'SSO_DOMAIN_NOT_CLAIMED',
332
+ reason: 'sso_domain_not_claimed',
333
+ message: 'No verification challenge exists for this domain in this scope. Claim it first.',
334
+ domain,
335
+ },
336
+ });
337
+ }
338
+ return expectedToken;
339
+ }
299
340
  // ════════════════════════════════════════════════════════════════════
300
341
  // revokeDomain
301
342
  // ════════════════════════════════════════════════════════════════════