@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":"inbound-delivery-receiver.backend.service.js","sourceRoot":"","sources":["../../../../src/inbound/services/inbound-delivery-receiver.backend.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,qCAAqC,EACrC,8BAA8B,EAC9B,+BAA+B,EAC/B,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,EACjB,uCAAuC,EACvC,4CAA4C,EAC5C,+BAA+B,EAC/B,mBAA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**\n * The inbound receiver (#1596): from raw request to a stored, deduplicated, scope-resolved delivery —\n * and an HTTP answer the sender can act on.\n *\n * ```\n * size / media type ─► secret ─► verify ─► parse ─► select handler ─► payload schema\n * ─► dedup key ─► resolve scope (no fallback) ─► insert once ─► enqueue ─► 200\n * ```\n *\n * The answers are chosen for what they tell a SENDER to do:\n *\n * | answer | when | sender's reading |\n * |---|---|---|\n * | 200 | stored, duplicate, unroutable, or an event no handler takes | done; do not retry |\n * | 400 | verified but not what the handler declared | a retry will not help |\n * | 401 | signature, timestamp or secret refused | not accepted |\n * | 413 / 415 | too large / not JSON | a retry will not help |\n * | 500 | something on OUR side failed before the row existed | retry later |\n *\n * Handler execution never happens here: an agent-backed handler outlasts any provider's delivery\n * timeout, and a handler failure is the worker's to retry, not the sender's.\n *\n * A provider endpoint may replace the 200's body with the answer its own contract requires (#2659): a Slack\n * `url_verification` handshake is answered with its challenge and stored nowhere; every other accepted request\n * gets the endpoint's `acknowledge` answer (an empty 200 for Slack, an invoke response for a Teams card action).\n * The answer is a pure function of the verified request, so it is due in milliseconds whatever the handler does.\n *\n * A chat SEARCH (#2666 S7, a Teams message-extension search) is the one request answered with what it asked for: it is\n * routed by the endpoint's own resolver, answered by the chat search lane within the vendor's deadline, written through\n * the endpoint's `answerChatSearch`, and stored nowhere.\n */\nimport { inject, injectable, optional } from 'inversify';\nimport {\n InboundChatInputKind,\n ChatBotOwnerScope,\n CoreResourceType,\n ErrorType,\n deriveInboundEndpointSecretEnvVarName,\n InboundDeliveryRejectionReason,\n InboundDeliveryUnroutableReason,\n InboundHandlerScopeMode,\n InboundResolvedScopeKind,\n InboundSenderAssurance,\n InboundSourceKind,\n isAuthorityConferringOrganizationStatus,\n PROVIDER_CONNECTION_ROUTING_FACT_PROVENANCES,\n isAuthorityConferringUserStatus,\n isWildoBackendError,\n jsonParsingSchemaOf,\n ResourcePrimaryScope,\n SortOrder,\n type InboundDeliveryResolvedScope,\n type OrganizationStatus,\n type ResourceType,\n type UserStatus,\n} from '@wildo-ai/saas-models';\nimport {\n HOOK_REREAD_TRIGGER_DEFAULT_COALESCING_WINDOW_SECONDS,\n HOOK_REREAD_TRIGGER_DEFAULT_RATE_LIMIT,\n Hook_ContentType,\n isReReadTriggerEndpoint,\n type Hook_Acknowledgement,\n type Hook_Endpoint,\n type Hook_InboundChatCommand,\n type Hook_InboundChatMessage,\n type Hook_InboundPersonalConversation,\n Hook_ChatSearchAnswerKind,\n type Hook_ChatSearchAnswer,\n} from '@wildo-ai/external-connectors-models';\nimport { chatConversationOrderingKeyOf } from '~wildo-backend-lib/flows-actors/services/chat-conversation-store.backend.service';\n\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { LoggerService } from '~wildo-backend-lib/monitoring/logger/services/logger.service';\nimport type { RepositoriesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport type { ResourcesRegistryBackendService } from '~wildo-backend-lib/resources/services/resources-registry.backend.service';\nimport type { ApplicationIdentityBackendService } from '~wildo-backend-lib/applications/services/application-identity.backend.service';\nimport type { AuditLogsBackendService } from '~wildo-backend-lib/compliance/audit-trails/services/audit-logs.backend.service';\nimport type { QueueBackendService } from '~wildo-backend-lib/queue/queue.backend.service';\nimport { ProviderInboundRequestKind, type ProviderInboundRequest, type WebhookHandlerBackendService } from '~wildo-backend-lib/notifications/webhooks/services/webhook-handler.backend.service';\nimport { decodeInboundBody, inboundContentTypeOf, providerEndpointKeptHeaders } from '~wildo-backend-lib/inbound/models/inbound-body-decoding.backend';\nimport type { RateLimitBackendService } from '~wildo-backend-lib/errors/services/rate-limit.backend.service';\nimport { projectCaughtErrorLogFields } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { isMalformedIdLookupError } from '~wildo-backend-lib/base-classes/services/repositories/resource-write-integrity.backend';\nimport {\n inboundSourceKey,\n normalizeInboundSubjectKeys,\n scopesAdmittedByHandler,\n type AnyInboundHandlerDefinition,\n type InboundResolvedScope,\n type InboundScopeLookups,\n type VerifiedInboundDelivery,\n} from '~wildo-backend-lib/inbound/models/inbound-handler.backend.definitions';\nimport { InboundScopeStandingPolicy, inboundScopeStandingPolicyOf } from '~wildo-backend-lib/inbound/models/inbound-engine-handler.backend';\nimport { headersKeptForScheme, verifyInboundDelivery } from '~wildo-backend-lib/inbound/verification/inbound-verification-schemes.backend';\nimport type { InboundApplicationEndpoint, InboundHandlerRegistryBackendService } from './inbound-handler-registry.backend.service';\nimport { InboundDeliveryInsertOutcome, type InboundDeliveryStoreBackendService } from './inbound-delivery-store.backend.service';\nimport { InboundDeliveryAudit } from './inbound-delivery-audit.backend';\nimport { enqueueInboundDeliveryDispatch } from './inbound-delivery-dispatch-queue.backend';\nimport type { ChatIdentityLinkBackendService } from './chat-identity-link.backend.service';\nimport { ChatSearchRouteKind, type ChatSearchLaneBackendService, type ChatSearchRoute } from '~wildo-backend-lib/inbound/chat-commands/chat-search-lane.backend.service';\nimport { CHAT_COMMAND_TRY_AGAIN_LABEL_REF, chatCommandLabelKey } from '~wildo-backend-lib/inbound/chat-commands/chat-command-words.backend.utils';\nimport { ChatCommandFormLaneOutcome, type ChatCommandFormLaneBackendService } from '~wildo-backend-lib/inbound/chat-commands/chat-command-form-lane.backend.service';\n\n/** The request, as the route hands it over. Header names lower-cased. */\nexport interface InboundRawRequest {\n /** The exact bytes received, or `undefined` when the body parser kept none. */\n readonly rawBody: Buffer | undefined;\n readonly headers: Readonly<Record<string, string | string[] | undefined>>;\n /** The body parser refused the body for its size before any bytes were kept (the parser's own ceiling). */\n readonly bodyTooLarge?: boolean;\n /**\n * The path and query string the request arrived on, exactly as received (`req.originalUrl`). Read only by a scheme\n * that signs the URL it was sent to (Twilio's, #3394); never stored.\n */\n readonly requestTarget?: string;\n}\n\nexport interface InboundReceiveAnswer {\n readonly status: number;\n readonly body: Readonly<Record<string, unknown>>;\n /**\n * The provider endpoint's own answer (#2659), written INSTEAD of `body` with a 200. Present only on a request the\n * engine accepted; a refusal always carries the engine's answer.\n */\n readonly acknowledgement?: Hook_Acknowledgement;\n}\n\n/** The engine's 200 answer, carrying the endpoint's acknowledgement when it declares one. Never replaces a refusal. */\nfunction acknowledgedBy(answer: InboundReceiveAnswer, acknowledgement: Hook_Acknowledgement | undefined): InboundReceiveAnswer {\n return acknowledgement && answer.status === 200 ? { ...answer, acknowledgement } : answer;\n}\n\nconst ANSWER = {\n received: { status: 200, body: { received: true } },\n duplicate: { status: 200, body: { received: true, duplicate: true } },\n ignored: { status: 200, body: { received: true, ignored: true } },\n unauthorized: { status: 401, body: { error: 'Invalid signature' } },\n malformed: { status: 400, body: { error: 'Malformed delivery' } },\n tooLarge: { status: 413, body: { error: 'Payload too large' } },\n unsupported: { status: 415, body: { error: 'Unsupported media type' } },\n retryLater: { status: 500, body: { error: 'Processing failed' } },\n} as const satisfies Record<string, InboundReceiveAnswer>;\n\n/** The longest dedup or ordering key the ledger stores (the schema's bound). */\nexport const INBOUND_KEY_MAX_LENGTH = 512;\n\nfunction isStorableInboundKey(key: string | undefined): key is string {\n return typeof key === 'string' && key.length > 0 && key.length <= INBOUND_KEY_MAX_LENGTH;\n}\n\n/**\n * What EVERY request to a re-read trigger endpoint is answered (#2909): known or unknown reference, rate-limited,\n * malformed, stored or not. Its sender is unverified, so no answer may tell it anything, least of all which references\n * exist (a store failure answered 500 would say that one did).\n */\nexport const REREAD_TRIGGER_ANSWER: InboundReceiveAnswer = { status: 202, body: { received: true } };\n/** The largest notification a re-read trigger endpoint reads when its provider declares no `maxBodyBytes`. */\nexport const REREAD_TRIGGER_DEFAULT_MAX_BODY_BYTES = 16 * 1024;\n/** The longest reference kept: the delivery id appends the window's instant to it, within the ledger's key bound. */\nexport const REREAD_TRIGGER_MAX_REFERENCE_LENGTH = INBOUND_KEY_MAX_LENGTH - 32;\n\n/**\n * A re-read trigger's delivery id (#2909): the reference and the start of the coalescing window the notification arrived\n * in. Two notifications for one reference inside one window are one delivery, so a reference is re-read at most once per\n * window, whatever a sender sends.\n */\nexport function reReadTriggerDeliveryId(reference: string, receivedAt: Date, coalescingWindowSeconds: number): string {\n const windowMs = coalescingWindowSeconds * 1_000;\n return `${reference}@${new Date(Math.floor(receivedAt.getTime() / windowMs) * windowMs).toISOString()}`;\n}\n\nfunction headerString(headers: InboundRawRequest['headers'], name: string): string | undefined {\n const value = headers[name];\n return Array.isArray(value) ? value[0] : value;\n}\n\nfunction readPath(value: unknown, dotPath: string): unknown {\n return dotPath.split('.').reduce<unknown>((current, key) => (current && typeof current === 'object' ? (current as Record<string, unknown>)[key] : undefined), value);\n}\n\n/** What a routing lookup found: one owner, none, or rows of two different owners (which names none). */\nenum ScopeOwnerOutcome {\n ONE = 'one',\n NONE = 'none',\n AMBIGUOUS = 'ambiguous',\n}\n\n@injectable()\nexport class InboundDeliveryReceiverBackendService {\n private readonly audit: InboundDeliveryAudit;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.InboundHandlerRegistryService) private readonly registry: InboundHandlerRegistryBackendService,\n @inject(SAAS_SERVICE_TYPES.InboundDeliveryStoreService) private readonly store: InboundDeliveryStoreBackendService,\n @inject(SAAS_SERVICE_TYPES.RepositoriesRegistryHandlerService) private readonly repositoriesRegistry: Pick<RepositoriesRegistryHandlerBackendService, 'findManyForInfrastructure' | 'readUnscopedByKey'>,\n @inject(SAAS_SERVICE_TYPES.ResourceRegistryService) private readonly resourcesRegistry: Pick<ResourcesRegistryBackendService, 'getResourceConfiguration'>,\n /**\n * The APPLICATION RECORD's id, stamped into an application-variant row's `applicationId` scope\n * column. Never `AppConfigurationService.applicationId`: that is the PLATFORM's id for this\n * process, and a row stamped with it is invisible to the application-scope list that filters by\n * the record id (see `platform-application-id-readers.guard.test.ts`).\n */\n @inject(SAAS_SERVICE_TYPES.ApplicationIdentityService) private readonly applicationIdentity: Pick<ApplicationIdentityBackendService, 'getCanonicalApplicationId'>,\n @inject(SAAS_SERVICE_TYPES.QueueBackendService) @optional() private readonly queue?: Pick<QueueBackendService, 'enqueueCustomBatch'>,\n @inject(SAAS_SERVICE_TYPES.AuditLogsService) @optional() auditLogs?: AuditLogsBackendService,\n @inject(SAAS_SERVICE_TYPES.WebhookHandlerService) @optional() private readonly webhookHandler?: WebhookHandlerBackendService,\n /** #2664 S5b: where a verified personal conversation is recorded, on the sender's chat identity link. */\n @inject(SAAS_SERVICE_TYPES.ChatIdentityLinkService) @optional() private readonly chatLinks?: Pick<ChatIdentityLinkBackendService, 'rememberPersonalConversation'>,\n /** #2666 S7: where a chat search is answered, in the request. Optional: without it a search is answered \"try again\". */\n @inject(SAAS_SERVICE_TYPES.ChatSearchLane) @optional() private readonly chatSearchLane?: Pick<ChatSearchLaneBackendService, 'answer'>,\n /** #2909: the per-endpoint limit of a re-read trigger. Absent, every such notification is dropped (fail closed). */\n @inject(SAAS_SERVICE_TYPES.RateLimitBackendService) @optional() private readonly rateLimits?: Pick<RateLimitBackendService, 'checkPolicyForSubject'>,\n /** #2770: where a chat command's form is opened while the person waits. Optional: without it every command runs as typed. */\n @inject(SAAS_SERVICE_TYPES.ChatCommandFormLane) @optional() private readonly chatCommandFormLane?: Pick<ChatCommandFormLaneBackendService, 'open'>,\n ) {\n this.audit = new InboundDeliveryAudit(auditLogs);\n }\n\n /** The clock; a property so tests can pin time without DI trying to inject it. */\n clock: () => Date = () => new Date();\n\n // ─────────────────────────────────────────────────────────────────────────\n // Application endpoints: POST /webhooks/app/{endpointKey}\n // ─────────────────────────────────────────────────────────────────────────\n\n async receiveApplicationEndpoint(endpoint: InboundApplicationEndpoint, request: InboundRawRequest): Promise<InboundReceiveAnswer> {\n const base = { sourceKind: InboundSourceKind.APPLICATION_ENDPOINT, sourceKey: endpoint.sourceKey };\n const reject = async (reason: InboundDeliveryRejectionReason, answer: InboundReceiveAnswer): Promise<InboundReceiveAnswer> => {\n await this.audit.rejected({ ...base, reason });\n return answer;\n };\n\n // Media type first: only JSON keeps its raw bytes, and a scheme cannot verify what was not kept.\n const contentType = (headerString(request.headers, 'content-type') ?? '').split(';')[0]!.trim().toLowerCase();\n if (contentType !== 'application/json') return reject(InboundDeliveryRejectionReason.UNSUPPORTED_MEDIA_TYPE, ANSWER.unsupported);\n\n const declaredLength = Number(headerString(request.headers, 'content-length'));\n if (request.bodyTooLarge || (Number.isFinite(declaredLength) && declaredLength > endpoint.maxBodyBytes) || (request.rawBody && request.rawBody.length > endpoint.maxBodyBytes)) {\n return reject(InboundDeliveryRejectionReason.BODY_TOO_LARGE, ANSWER.tooLarge);\n }\n // No re-serialization fallback: a JSON.stringify of the parsed body does not byte-match what the\n // sender signed, so \"verifying\" it would verify our own bytes.\n if (!request.rawBody) {\n this.logger.error('Inbound delivery refused: the raw request body was not kept, so it cannot be verified', { sourceKey: endpoint.sourceKey });\n return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n }\n\n // I1 at request time: a secret can be removed after mount, and an empty secret is never a key.\n const secretEnvVar = deriveInboundEndpointSecretEnvVarName(endpoint.endpointKey);\n const secret = process.env[secretEnvVar] ?? '';\n if (!secret) {\n this.logger.error('Inbound delivery refused: the endpoint has no verification secret', { sourceKey: endpoint.sourceKey, secretEnvVar });\n return reject(InboundDeliveryRejectionReason.SECRET_NOT_CONFIGURED, ANSWER.unauthorized);\n }\n const receivedAt = this.clock();\n // assurance-control: WILDO.SECURITY.FAIL_CLOSED — no dispatch without a verified signature (I1).\n const verification = verifyInboundDelivery(endpoint.source.verification, { rawBody: request.rawBody, headers: request.headers, secret, now: receivedAt });\n if (verification.ok === false) return reject(verification.reason, ANSWER.unauthorized);\n\n let json: unknown;\n try {\n json = JSON.parse(request.rawBody.toString('utf8'));\n } catch {\n return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n }\n const eventTypeValue = readPath(json, endpoint.eventTypePath);\n const eventType = typeof eventTypeValue === 'string' ? eventTypeValue : undefined;\n const handler = this.registry.selectApplicationEndpointHandler(endpoint, eventType);\n if (!handler) {\n // An event no handler declared is not ours to store; acknowledging stops the sender retrying it.\n return ANSWER.ignored;\n }\n\n const delivery: VerifiedInboundDelivery = {\n sourceKind: InboundSourceKind.APPLICATION_ENDPOINT,\n sourceKey: endpoint.sourceKey,\n ...(verification.deliveryId !== undefined ? { providerDeliveryId: verification.deliveryId } : {}),\n ...(verification.signedAt !== undefined ? { signedAt: verification.signedAt } : {}),\n receivedAt,\n rawBody: request.rawBody,\n headers: this.keptHeaders(request.headers, headersKeptForScheme(endpoint.source.verification)),\n ...(eventType !== undefined ? { eventType } : {}),\n json,\n };\n return this.admit(handler, delivery, base, reject);\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Provider endpoints bound to a handler: POST /webhooks/{providerRef}/{endpointKey}\n // ─────────────────────────────────────────────────────────────────────────\n\n /**\n * A provider-declared endpoint whose events a handler takes. Verification is the provider's registered adapter\n * (Stripe's SDK `constructEvent`, for one) or, for an engine-verified scheme (Svix, Slack v0, the Bot Framework\n * token), engine code; both refuse an empty secret at request time. Everything after it is the durable path.\n */\n async receiveProviderEndpoint(providerRef: string, endpoint: Hook_Endpoint, handler: AnyInboundHandlerDefinition, request: InboundRawRequest): Promise<InboundReceiveAnswer> {\n const sourceKey = inboundSourceKey(handler.source);\n const base = { sourceKind: InboundSourceKind.PROVIDER_ENDPOINT, sourceKey };\n // The receipt instant, taken before verification: a chat search's deadline is spent from it, verification included.\n const receivedAt = this.clock();\n const reject = async (reason: InboundDeliveryRejectionReason, answer: InboundReceiveAnswer): Promise<InboundReceiveAnswer> => {\n await this.audit.rejected({ ...base, reason });\n return answer;\n };\n // An unsigned notification that only triggers a re-read (#2909): handled by the engine, verified by nothing.\n if (isReReadTriggerEndpoint(endpoint)) return this.receiveReReadTrigger(providerRef, endpoint, handler, request, base, receivedAt, reject);\n if (!this.webhookHandler) return ANSWER.retryLater;\n // The media types the endpoint declares (#2659), JSON when it declares none. Checked FIRST, like the application\n // endpoint's: a body the engine would not decode is refused without being interpreted, and a type neither global\n // parser reads (so no raw bytes were kept) is answered 415, not a misleading 400.\n const contentType = inboundContentTypeOf(request.headers['content-type']);\n if (!contentType || !(endpoint.contentTypes ?? [Hook_ContentType.JSON]).includes(contentType)) {\n return reject(InboundDeliveryRejectionReason.UNSUPPORTED_MEDIA_TYPE, ANSWER.unsupported);\n }\n // Over the body parser's own limit (#3395): refused before anything was read into the request.\n if (request.bodyTooLarge) return reject(InboundDeliveryRejectionReason.BODY_TOO_LARGE, ANSWER.tooLarge);\n if (!request.rawBody) return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n // The endpoint's own cap, when its provider declares one: it is the ledger that stores the body.\n if (endpoint.maxBodyBytes !== undefined && request.rawBody.length > endpoint.maxBodyBytes) {\n return reject(InboundDeliveryRejectionReason.BODY_TOO_LARGE, ANSWER.tooLarge);\n }\n\n let verified: ProviderInboundRequest;\n // assurance-control: WILDO.SECURITY.FAIL_CLOSED — a provider event (billing's, since #1629; Slack's and Teams', #2659) is stored and dispatched only after its signature or token verified (I1).\n try {\n verified = await this.webhookHandler.verifyAndParseForInboundHandler({\n providerRef,\n endpointKey: endpoint.key,\n endpoint,\n rawBody: request.rawBody,\n headers: request.headers as Record<string, string>,\n contentType,\n // An organization's own bot routes by the connection reporting it, through the same lookup a resolver uses (#2663).\n findOrganizationIdByConnectionFact: this.lookups.findOrganizationIdByConnectionFact,\n ...(request.requestTarget === undefined ? {} : { requestTarget: request.requestTarget }),\n });\n } catch (error) {\n if (isWildoBackendError(error) && error.type === ErrorType.AUTHORIZATION) {\n const refusal = error.context as { secretConfigured?: boolean; reason?: InboundDeliveryRejectionReason } | undefined;\n // An engine-verified endpoint (#1600) names its refusal; an adapter-verified one only says whether a secret existed.\n const reason = refusal?.secretConfigured === false\n ? InboundDeliveryRejectionReason.SECRET_NOT_CONFIGURED\n : refusal?.reason === InboundDeliveryRejectionReason.TIMESTAMP_OUT_OF_WINDOW\n ? InboundDeliveryRejectionReason.TIMESTAMP_OUT_OF_WINDOW\n : InboundDeliveryRejectionReason.SIGNATURE_INVALID;\n return reject(reason, ANSWER.unauthorized);\n }\n // Ours, not the sender's: a key set that could not be fetched, an endpoint function that threw.\n this.logger.error('Inbound provider delivery could not be verified or read', { sourceKey, ...projectCaughtErrorLogFields(error) });\n return ANSWER.retryLater;\n }\n\n switch (verified.kind) {\n case ProviderInboundRequestKind.HANDSHAKE:\n // A reachability check, already verified: answered as the provider requires, and stored nowhere.\n this.logger.info('Inbound provider handshake answered', { sourceKey });\n return acknowledgedBy(ANSWER.received, verified.answer);\n case ProviderInboundRequestKind.MALFORMED:\n return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n case ProviderInboundRequestKind.IGNORED:\n return acknowledgedBy(ANSWER.ignored, verified.acknowledgement);\n case ProviderInboundRequestKind.EVENT: {\n // #2770: a command whose form the vendor must open while the person waits (a Slack modal) is answered here, and\n // stored nowhere: its submission comes back as a command of its own. Declined, it is stored and run as typed.\n if (verified.chatCommand && await this.openedChatCommandForm(providerRef, endpoint, handler, verified, request, contentType, sourceKey, receivedAt)) {\n return acknowledgedBy(ANSWER.received, verified.acknowledgement);\n }\n const delivery: VerifiedInboundDelivery = {\n sourceKind: InboundSourceKind.PROVIDER_ENDPOINT,\n sourceKey,\n providerDeliveryId: verified.eventId,\n receivedAt,\n rawBody: request.rawBody,\n // The media type is kept: the dispatcher decodes the stored bytes as what they were received as.\n headers: providerEndpointKeptHeaders(request.headers),\n eventType: verified.providerEventType,\n json: verified.body,\n ...(verified.verifiedAudience === undefined ? {} : { verifiedAudience: verified.verifiedAudience }),\n };\n return acknowledgedBy(await this.admit(handler, delivery, base, reject, verified.personalConversation, verified.chatMessage, verified.chatCommand), verified.acknowledgement);\n }\n case ProviderInboundRequestKind.CHAT_SEARCH:\n return this.answerChatSearch(providerRef, endpoint, handler, verified, request, sourceKey, receivedAt);\n default: {\n // A shape the receiver does not know is OUR defect (a verifier and a receiver out of step), never something to\n // answer with: throwing reaches the route's error handler as a 500, where returning it would write no status.\n const unhandled: never = verified;\n throw new Error(`Unknown provider inbound request kind: ${JSON.stringify((unhandled as { kind?: unknown } | null)?.kind)}`);\n }\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n\n /**\n * A notification nobody can verify, that only names an object to re-read (#2909, `Hook_TriggerStrategy.WEBHOOK_TRIGGERS_POLL`).\n *\n * Nothing in it is trusted: it is rate-limited per endpoint before anything is read, its reference is looked up by the\n * handler's own resolver (the record must already be this application's, or it is dropped), and only that reference is\n * stored, under an id derived from it and the coalescing window. The handler re-reads the object from the vendor's\n * authenticated API; that answer, never the notification, is what it records. Every outcome is answered 202.\n *\n * What the answer does not hide (review F7, a stated residual): its TIMING. A known reference costs a store write, an\n * audit row and an enqueue; an unknown one a lookup and an aggregated refusal. A sender who already holds a candidate\n * reference (a signer sees theirs) may tell from latency whether this application uses it. It learns nothing it could\n * act on: the notification is never believed, and a known reference only causes a re-read at the vendor it came from.\n *\n * assurance-control: WILDO.SECURITY.FAIL_CLOSED — an unverified notification changes nothing by itself: it is dropped\n * unless it names a known record, and then only triggers an authenticated re-read.\n */\n private async receiveReReadTrigger(\n providerRef: string,\n endpoint: Hook_Endpoint,\n handler: AnyInboundHandlerDefinition,\n request: InboundRawRequest,\n base: { sourceKind: InboundSourceKind; sourceKey: string },\n receivedAt: Date,\n reject: (reason: InboundDeliveryRejectionReason, answer: InboundReceiveAnswer) => Promise<InboundReceiveAnswer>,\n ): Promise<InboundReceiveAnswer> {\n const drop = async (reason: InboundDeliveryRejectionReason): Promise<InboundReceiveAnswer> => {\n await reject(reason, REREAD_TRIGGER_ANSWER);\n return REREAD_TRIGGER_ANSWER;\n };\n // The route gate withholds an endpoint without one, so this is a declaration that changed after mount.\n const trigger = endpoint.reReadTrigger;\n if (!trigger) return drop(InboundDeliveryRejectionReason.MALFORMED);\n\n // The endpoint's rate, FIRST: a flood is counted and dropped before anything of it is read or looked up.\n if (!(await this.admittedByReReadTriggerRate(providerRef, endpoint.key, trigger))) return drop(InboundDeliveryRejectionReason.RATE_LIMITED);\n\n const contentType = inboundContentTypeOf(request.headers['content-type']);\n if (!contentType || !(endpoint.contentTypes ?? [Hook_ContentType.JSON]).includes(contentType)) return drop(InboundDeliveryRejectionReason.UNSUPPORTED_MEDIA_TYPE);\n if (request.bodyTooLarge || (request.rawBody && request.rawBody.length > (endpoint.maxBodyBytes ?? REREAD_TRIGGER_DEFAULT_MAX_BODY_BYTES))) {\n return drop(InboundDeliveryRejectionReason.BODY_TOO_LARGE);\n }\n if (!request.rawBody) return drop(InboundDeliveryRejectionReason.MALFORMED);\n const decoded = decodeInboundBody(request.rawBody, contentType);\n if (!decoded.ok) return drop(InboundDeliveryRejectionReason.MALFORMED);\n\n let reference: string | null;\n try {\n reference = trigger.identifyReference({ rawBody: new Uint8Array(request.rawBody), headers: request.headers, contentType, body: decoded.body });\n } catch {\n reference = null;\n }\n if (typeof reference !== 'string' || reference.length === 0 || reference.length > REREAD_TRIGGER_MAX_REFERENCE_LENGTH) {\n return drop(InboundDeliveryRejectionReason.UNKNOWN_REFERENCE);\n }\n\n // Only the reference is kept: the notification's other bytes are unverified and nothing reads them.\n const json = { reference };\n const delivery: VerifiedInboundDelivery = {\n sourceKind: InboundSourceKind.PROVIDER_ENDPOINT,\n sourceKey: base.sourceKey,\n providerDeliveryId: reReadTriggerDeliveryId(reference, receivedAt, trigger.coalescingWindowSeconds ?? HOOK_REREAD_TRIGGER_DEFAULT_COALESCING_WINDOW_SECONDS),\n receivedAt,\n rawBody: Buffer.from(JSON.stringify(json), 'utf8'),\n headers: { 'content-type': Hook_ContentType.JSON },\n json,\n };\n // One re-read of a reference at a time: its deliveries are ordered by the reference.\n const admission = { orderingKey: reference, dropUnknown: () => drop(InboundDeliveryRejectionReason.UNKNOWN_REFERENCE) };\n const leading = await this.admit(handler, delivery, base, reject, undefined, undefined, undefined, admission);\n if (leading === ANSWER.duplicate) {\n // The TRAILING edge (#2909 review F3): this window's re-read is already stored and may already have run, so a later\n // notification would be lost, and the vendor never retries. One more delivery is kept for the NEXT window, due at\n // its start: the reference is re-read once per window at most, and the last notification of a window is never lost.\n // A third notification in the window finds that one too, and is a duplicate of it.\n const windowSeconds = trigger.coalescingWindowSeconds ?? HOOK_REREAD_TRIGGER_DEFAULT_COALESCING_WINDOW_SECONDS;\n const nextWindowStart = new Date((Math.floor(receivedAt.getTime() / (windowSeconds * 1_000)) + 1) * windowSeconds * 1_000);\n await this.admit(handler, { ...delivery, providerDeliveryId: reReadTriggerDeliveryId(reference, nextWindowStart, windowSeconds) }, base, reject, undefined, undefined, undefined, {\n ...admission,\n notBefore: nextWindowStart,\n });\n }\n return REREAD_TRIGGER_ANSWER;\n }\n\n /**\n * Counts one request against the endpoint's limit, all senders together (#2909). `false` when it is over the limit, and\n * when the limiter cannot answer: an unverified notification is never worth admitting unmetered, and polling covers\n * whatever a dropped one named.\n */\n private async admittedByReReadTriggerRate(providerRef: string, endpointKey: string, trigger: NonNullable<Hook_Endpoint['reReadTrigger']>): Promise<boolean> {\n if (!this.rateLimits) {\n this.logLimiterFailureAtMostPerMinute('A re-read trigger notification was dropped: no rate limiter is bound', providerRef, endpointKey);\n return false;\n }\n const limit = trigger.rateLimit ?? HOOK_REREAD_TRIGGER_DEFAULT_RATE_LIMIT;\n try {\n await this.rateLimits.checkPolicyForSubject(\n { customWindows: [{ requestsPerWindow: limit.maxRequests, windowSeconds: limit.windowSeconds }] },\n 'inbound-reread-trigger',\n `${providerRef}:${endpointKey}`,\n );\n return true;\n } catch (error) {\n if (!(isWildoBackendError(error) && error.type === ErrorType.RATE_LIMIT)) {\n this.logLimiterFailureAtMostPerMinute('A re-read trigger notification was dropped: its rate limit could not be checked', providerRef, endpointKey, projectCaughtErrorLogFields(error));\n }\n return false;\n }\n }\n\n /** When each endpoint's limiter failure was last logged: unauthenticated requests must not write one line each (review F10). */\n private readonly reReadTriggerLimiterLoggedAt = new Map<string, number>();\n\n private logLimiterFailureAtMostPerMinute(message: string, providerRef: string, endpointKey: string, fields: Record<string, unknown> = {}): void {\n const key = `${providerRef}:${endpointKey}`;\n const now = this.clock().getTime();\n const last = this.reReadTriggerLimiterLoggedAt.get(key);\n if (last !== undefined && now - last < 60_000) return;\n this.reReadTriggerLimiterLoggedAt.set(key, now);\n this.logger.error(message, { providerRef, endpointKey, ...fields });\n }\n\n /**\n * Answers a chat search in the request (#2666 S7 step 6): routed by the handler's own payload schema and scope resolver,\n * exactly as an event would be, then answered by the chat search lane and written by the endpoint's `answerChatSearch`.\n * Nothing is stored, enqueued, or audited as a delivery: a search is a query, sent per keystroke. Its row, when it has\n * one, is the command door's (`CHAT_COMMAND_RUN`, for each outcome or refusal decided for a known member).\n *\n * Every failure here is answered with a sentence, never with \"retry later\": a 500 would show the person an error for a\n * keystroke, and the next keystroke is the retry.\n */\n private async answerChatSearch(\n providerRef: string,\n endpoint: Hook_Endpoint,\n handler: AnyInboundHandlerDefinition,\n verified: Extract<ProviderInboundRequest, { kind: ProviderInboundRequestKind.CHAT_SEARCH }>,\n request: InboundRawRequest,\n sourceKey: string,\n receivedAt: Date,\n ): Promise<InboundReceiveAnswer> {\n let answer: Hook_ChatSearchAnswer;\n if (!this.chatSearchLane) {\n this.logger.error('A chat search arrived, but no chat search lane is bound in this process', { sourceKey });\n // No lane, no words: the sentence's key, visibly unworded, rather than an answer the vendor shows as an error.\n answer = { kind: Hook_ChatSearchAnswerKind.MESSAGE, text: chatCommandLabelKey(CHAT_COMMAND_TRY_AGAIN_LABEL_REF) };\n } else {\n const route = await this.routeUnstoredRequest(handler, verified.body, verified.search.vendorRequestId, verified.verifiedAudience, request, sourceKey, receivedAt, 'chat search');\n answer = await this.chatSearchLane.answer({ route, connectionRef: providerRef, sourceKey, search: verified.search, receivedAt });\n }\n try {\n return acknowledgedBy(ANSWER.received, endpoint.answerChatSearch!(answer));\n } catch (error) {\n this.logger.error('Webhook endpoint function \\'answerChatSearch\\' threw; the search is answered with the engine\\'s plain acknowledgement', {\n providerRef, sourceKey, ...projectCaughtErrorLogFields(error),\n });\n return ANSWER.received;\n }\n }\n\n /**\n * Opens a chat command's form while the person waits (#2770), through the chat command form lane: `true` when it\n * opened (the request is answered and nothing is stored), `false` when it declined, and the command is stored and run as\n * typed. The lane routes the command as a stored one would be routed, by the handler's own schema and resolver.\n */\n private async openedChatCommandForm(\n providerRef: string,\n endpoint: Hook_Endpoint,\n handler: AnyInboundHandlerDefinition,\n verified: Extract<ProviderInboundRequest, { kind: ProviderInboundRequestKind.EVENT }>,\n request: InboundRawRequest,\n contentType: Hook_ContentType,\n sourceKey: string,\n receivedAt: Date,\n ): Promise<boolean> {\n if (!this.chatCommandFormLane || !verified.chatCommand || !request.rawBody) return false;\n const outcome = await this.chatCommandFormLane.open({\n providerRef,\n endpointKey: endpoint.key,\n command: verified.chatCommand,\n request: { rawBody: new Uint8Array(request.rawBody), headers: request.headers, contentType, body: verified.body },\n receivedAt,\n route: async () => {\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a chat command's form is opened only in the organization the endpoint's own resolver routes it to.\n const route = await this.routeUnstoredRequest(handler, verified.body, verified.eventId, verified.verifiedAudience, request, sourceKey, receivedAt, 'chat command form');\n return route.kind === ChatSearchRouteKind.ORGANIZATION ? { organizationId: route.organizationId } : undefined;\n },\n });\n return outcome === ChatCommandFormLaneOutcome.OPENED;\n }\n\n /**\n * Where a request answered in its own request reads (a chat search, #2666 S7; a chat command's form, #2770): the\n * organization the handler's payload schema and scope resolver route it to, exactly as an event's, or nowhere. A\n * failure on OUR side (the handler's schema refusing what the module read, a resolver that threw) is FAILED, not\n * UNROUTABLE: the person is asked to try again, never told the team is not connected.\n */\n private async routeUnstoredRequest(\n handler: AnyInboundHandlerDefinition,\n body: unknown,\n vendorRequestId: string,\n verifiedAudience: Extract<ProviderInboundRequest, { kind: ProviderInboundRequestKind.EVENT }>['verifiedAudience'],\n request: InboundRawRequest,\n sourceKey: string,\n receivedAt: Date,\n what: string,\n ): Promise<ChatSearchRoute> {\n try {\n // A delivery body is JSON (#3478): a date in the handler's payload schema reads from its RFC 3339 form.\n const payload = jsonParsingSchemaOf(handler.payloadSchema).safeParse(body);\n if (!payload.success) {\n this.logger.error(`A ${what} was refused by its handler's payload schema, so it could not be routed`, { sourceKey, handlerRef: handler.ref });\n return { kind: ChatSearchRouteKind.FAILED };\n }\n const delivery: VerifiedInboundDelivery = {\n sourceKind: InboundSourceKind.PROVIDER_ENDPOINT,\n sourceKey,\n // The vendor's id for the request: the only name it has, for a resolver that keys on one. Never stored.\n providerDeliveryId: vendorRequestId,\n receivedAt,\n rawBody: request.rawBody!,\n headers: providerEndpointKeptHeaders(request.headers),\n json: body,\n ...(verifiedAudience === undefined ? {} : { verifiedAudience }),\n };\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a request answered in place reads only in the organization the endpoint's own resolver routes it to.\n const scope = await this.resolveScope(handler, delivery, payload.data);\n return scope.kind === InboundResolvedScopeKind.ORGANIZATION\n ? { kind: ChatSearchRouteKind.ORGANIZATION, organizationId: scope.organizationId }\n : { kind: ChatSearchRouteKind.UNROUTABLE };\n } catch (error) {\n this.logger.error(`A ${what} could not be routed: a handler function threw`, { sourceKey, handlerRef: handler.ref, ...projectCaughtErrorLogFields(error) });\n return { kind: ChatSearchRouteKind.FAILED };\n }\n }\n\n /** Whether the handler's endpoint carries the messages people write to the application's bot (#2665 S6). */\n private isChatConversationEndpoint(handler: AnyInboundHandlerDefinition): boolean {\n return handler.source.kind === InboundSourceKind.PROVIDER_ENDPOINT\n && this.registry.chatMessageEndpoint(handler.source.providerRef, handler.source.endpointKey) !== undefined;\n }\n\n /** Whether the handler's endpoint is one whose requests may carry a chat command a person sent (#2666 S7). */\n private isChatCommandEndpoint(handler: AnyInboundHandlerDefinition): boolean {\n return handler.source.kind === InboundSourceKind.PROVIDER_ENDPOINT\n && this.registry.chatCommandEndpoint(handler.source.providerRef, handler.source.endpointKey) !== undefined;\n }\n\n private async admit(\n handler: AnyInboundHandlerDefinition,\n delivery: VerifiedInboundDelivery,\n base: { sourceKind: InboundSourceKind; sourceKey: string },\n reject: (reason: InboundDeliveryRejectionReason, answer: InboundReceiveAnswer) => Promise<InboundReceiveAnswer>,\n /** The sender's personal conversation with the bot, when the verifier found one (#2664 S5b). */\n personalConversation?: Hook_InboundPersonalConversation,\n /** The message a person wrote to the bot, when the verified request carries one (#2665 S6). */\n chatMessage?: Hook_InboundChatMessage,\n /** The chat command a person sent, when the verified request carries one (#2666 S7). */\n chatCommand?: Hook_InboundChatCommand,\n /**\n * A re-read trigger's delivery (#2909): ordered by its reference, and DROPPED, not stored as unroutable, when the\n * handler's resolver finds no record it names.\n */\n reReadTrigger?: { readonly orderingKey: string; readonly dropUnknown: () => Promise<InboundReceiveAnswer>; readonly notBefore?: Date },\n ): Promise<InboundReceiveAnswer> {\n // A delivery body is JSON (#3478): a date in the handler's payload schema reads from its RFC 3339 form. The dispatch\n // reads the stored body through the same schema, so the value checked here is the value the handler runs on.\n const payload = jsonParsingSchemaOf(handler.payloadSchema).safeParse(delivery.json);\n if (!payload.success) return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n\n let dedupKey: string | undefined;\n let orderingKey: string | null;\n let subjectKeys: readonly string[] | undefined;\n let resolvedScope: InboundDeliveryResolvedScope;\n try {\n dedupKey = handler.dedupKey ? handler.dedupKey(delivery) : delivery.providerDeliveryId;\n orderingKey = handler.orderingKey ? handler.orderingKey(delivery, payload.data) : null;\n // #1642: the people the payload names, as the handler declares them. Keys that cannot be stored refuse the delivery\n // like a dedup key that cannot: stored without them, the person it names could never be found in it.\n subjectKeys = normalizeInboundSubjectKeys(handler.subjectKeys ? handler.subjectKeys(delivery, payload.data) : undefined);\n // A key the store cannot hold is the SENDER's malformed delivery, answered 400 and audited — not a\n // 500 the sender would retry forever with nothing recorded.\n if (!isStorableInboundKey(dedupKey) || (orderingKey !== null && !isStorableInboundKey(orderingKey)) || subjectKeys === undefined) {\n return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n }\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a delivery runs only in the scope its handler admits; nothing falls back to the application scope (I3).\n resolvedScope = await this.resolveScope(handler, delivery, payload.data);\n if (reReadTrigger) {\n // The known-record check (#2909): an unverified notification is kept only for a record this application holds.\n if (resolvedScope.kind === InboundResolvedScopeKind.UNROUTABLE) return reReadTrigger.dropUnknown();\n orderingKey = reReadTrigger.orderingKey;\n }\n // #2665 S6 (plans B6, V9): a chat message is ordered by the ENGINE, after routing, because its organization is part of\n // the key: per organization, connection, vendor conversation and sender. So two people writing in one thread never\n // wait on each other, and two organizations sharing a vendor channel never block each other. A message that routes\n // to no organization orders with nothing. The registry refused a handler key on such an endpoint.\n // #2666 S7 review L5: a request a module read as both is a command, and a command is never ordered behind a\n // conversation's turns: it runs once, by its own compare-and-swap.\n if (chatMessage && !chatCommand && handler.source.kind === InboundSourceKind.PROVIDER_ENDPOINT) {\n orderingKey = resolvedScope.kind === InboundResolvedScopeKind.ORGANIZATION\n ? chatConversationOrderingKeyOf({ organizationId: resolvedScope.organizationId, connectionRef: handler.source.providerRef, message: chatMessage })\n : null;\n }\n } catch (error) {\n this.logger.error('Inbound delivery could not be admitted: a handler function threw before the delivery was stored', {\n handlerRef: handler.ref, sourceKey: base.sourceKey, ...projectCaughtErrorLogFields(error),\n });\n return ANSWER.retryLater;\n }\n\n let inserted;\n try {\n // assurance-control: WILDO.OPERATIONS.EXECUTION_INTEGRITY — one event, one stored delivery, at most one run (I2).\n const applicationId = await this.applicationIdentity.getCanonicalApplicationId();\n inserted = await this.store.insert({\n sourceKind: base.sourceKind,\n sourceKey: base.sourceKey,\n handlerRef: handler.ref,\n dedupKey,\n orderingKey,\n ...(delivery.providerDeliveryId !== undefined ? { providerDeliveryId: delivery.providerDeliveryId } : {}),\n ...(delivery.signedAt !== undefined ? { signedAt: delivery.signedAt } : {}),\n receivedAt: delivery.receivedAt,\n rawBody: delivery.rawBody,\n headers: { ...delivery.headers },\n ...(subjectKeys.length > 0 ? { subjectKeys } : {}),\n resolvedScope,\n // #2909: an unsigned notification is recorded as what it is, and a trailing one waits for its window.\n ...(reReadTrigger ? {\n senderAssurance: InboundSenderAssurance.UNVERIFIED,\n ...(reReadTrigger.notBefore ? { notBefore: reReadTrigger.notBefore } : {}),\n } : {}),\n // #2665 S6 (plan V4), #2666 S7: stored, so READ withholds the body and the PROCESSED settle empties it, whatever the\n // handler registry later holds. A COMMAND is decided by the verified request, which is what it is, never by the\n // live list of verbs. Anything else is marked per ENDPOINT, not per request: a chat-conversation endpoint's other\n // events (an edit, a file share) carry what a person wrote just the same, and so does a request to a command\n // endpoint whose command the module could not read (review M5: unmarked, its text would never be emptied).\n ...(chatCommand\n ? { chatInput: InboundChatInputKind.COMMAND }\n : this.isChatConversationEndpoint(handler) ? { chatInput: InboundChatInputKind.CONVERSATION_MESSAGE }\n : this.isChatCommandEndpoint(handler) ? { chatInput: InboundChatInputKind.COMMAND } : {}),\n }, applicationId);\n } catch (error) {\n this.logger.error('Inbound delivery could not be stored', { handlerRef: handler.ref, sourceKey: base.sourceKey, ...projectCaughtErrorLogFields(error) });\n return ANSWER.retryLater;\n }\n\n if (inserted.outcome === InboundDeliveryInsertOutcome.DUPLICATE) return ANSWER.duplicate;\n if (inserted.row.resolvedScope.kind === InboundResolvedScopeKind.UNROUTABLE) {\n await this.audit.unroutable(inserted.row);\n return ANSWER.received;\n }\n await this.audit.accepted(inserted.row);\n await this.rememberPersonalConversation(handler, inserted.row.resolvedScope, delivery, personalConversation);\n // A failed enqueue leaves the row RECEIVED and due; the sweep picks it up. The sender is not told\n // to retry — the delivery IS stored, and a retry would only be deduplicated.\n const delayMs = reReadTrigger?.notBefore ? Math.max(0, reReadTrigger.notBefore.getTime() - this.clock().getTime()) : 0;\n await enqueueInboundDeliveryDispatch(this.queue, inserted.location, this.logger, delayMs);\n return ANSWER.received;\n }\n\n /**\n * Records the sender's personal conversation with the bot on their chat identity link (#2664 S5b), so the application\n * can post to them later without their writing first (a decision card). Every fact comes from the verified request\n * and its routing, none from a handler:\n *\n * - the organization is the one this delivery was routed to, and only an ORGANIZATION delivery has links;\n * - the connection is the delivery's provider, which every account it names belongs to;\n * - the bot is the one the verified token was for. An organization's own bot is admitted only for that organization,\n * so its conversation is recorded only in that organization's links; the application's bot reaches whichever\n * organization claimed the tenant.\n *\n * A person not linked there gets nothing recorded, and a failure is logged: the delivery is stored and runs either way.\n */\n private async rememberPersonalConversation(\n handler: AnyInboundHandlerDefinition,\n scope: InboundDeliveryResolvedScope,\n delivery: VerifiedInboundDelivery,\n conversation: Hook_InboundPersonalConversation | undefined,\n ): Promise<void> {\n const audience = delivery.verifiedAudience;\n if (!conversation || !audience || !this.chatLinks) return;\n if (handler.source.kind !== InboundSourceKind.PROVIDER_ENDPOINT || scope.kind !== InboundResolvedScopeKind.ORGANIZATION) return;\n if (audience.organizationId !== undefined && audience.organizationId !== scope.organizationId) return;\n try {\n await this.chatLinks.rememberPersonalConversation({\n organizationId: scope.organizationId,\n connectionRef: handler.source.providerRef,\n account: { workspaceRef: conversation.workspaceRef, chatUserId: conversation.chatUserId },\n botOwnerScope: audience.organizationId === undefined ? ChatBotOwnerScope.APPLICATION : ChatBotOwnerScope.ORGANIZATION,\n conversation: { conversationId: conversation.conversationId, serviceUrl: conversation.serviceUrl },\n });\n } catch (error) {\n this.logger.warn('A verified personal conversation could not be recorded on its chat identity link; the delivery runs regardless', {\n handlerRef: handler.ref, sourceKey: delivery.sourceKey, ...projectCaughtErrorLogFields(error),\n });\n }\n }\n\n /**\n * I3: the handler's declared mode decides what may be admitted. There is no fallback — a scope the\n * handler is not admitted to, and an organization or person that does not exist or confers no authority,\n * is `UNROUTABLE` and never runs.\n *\n * An ENGINE handler recording a third party's facts (billing, #1629) may run regardless of the scope's\n * STANDING — see `InboundScopeStandingPolicy`. A scope that does not exist is unroutable for every handler.\n */\n private async resolveScope(handler: AnyInboundHandlerDefinition, delivery: VerifiedInboundDelivery, payload: unknown): Promise<InboundDeliveryResolvedScope> {\n if (handler.scopeMode === InboundHandlerScopeMode.APPLICATION) return { kind: InboundResolvedScopeKind.APPLICATION };\n const resolved: InboundResolvedScope = await handler.resolveScope!(delivery, payload, this.lookups);\n const unroutable = (reason: InboundDeliveryUnroutableReason): InboundDeliveryResolvedScope => ({ kind: InboundResolvedScopeKind.UNROUTABLE, reason });\n const admitted = scopesAdmittedByHandler(handler);\n const regardlessOfStanding = inboundScopeStandingPolicyOf(handler) === InboundScopeStandingPolicy.RECORD_REGARDLESS_OF_STANDING;\n\n switch (resolved.kind) {\n case InboundResolvedScopeKind.UNROUTABLE:\n return unroutable(handler.scopeMode === InboundHandlerScopeMode.ORGANIZATION_REQUIRED\n ? InboundDeliveryUnroutableReason.NO_ORGANIZATION_RESOLVED\n : InboundDeliveryUnroutableReason.RESOLVER_DECLARED_UNROUTABLE);\n case InboundResolvedScopeKind.APPLICATION:\n return admitted.includes(InboundResolvedScopeKind.APPLICATION)\n ? { kind: InboundResolvedScopeKind.APPLICATION }\n : unroutable(InboundDeliveryUnroutableReason.SCOPE_NOT_ADMITTED_BY_HANDLER);\n case InboundResolvedScopeKind.ORGANIZATION: {\n if (!admitted.includes(InboundResolvedScopeKind.ORGANIZATION)) return unroutable(InboundDeliveryUnroutableReason.SCOPE_NOT_ADMITTED_BY_HANDLER);\n if (!resolved.organizationId) return unroutable(InboundDeliveryUnroutableReason.NO_ORGANIZATION_RESOLVED);\n const organization = await this.readOrganizationForRouting(resolved.organizationId);\n if (!organization) return unroutable(InboundDeliveryUnroutableReason.ORGANIZATION_NOT_FOUND);\n if (!regardlessOfStanding && !isAuthorityConferringOrganizationStatus(organization.status)) return unroutable(InboundDeliveryUnroutableReason.ORGANIZATION_WITHOUT_AUTHORITY);\n return { kind: InboundResolvedScopeKind.ORGANIZATION, organizationId: resolved.organizationId };\n }\n case InboundResolvedScopeKind.USER: {\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a person's own data is reached only by a handler that declared roles for that scope, and only for a person who exists (#1629).\n if (!admitted.includes(InboundResolvedScopeKind.USER)) return unroutable(InboundDeliveryUnroutableReason.SCOPE_NOT_ADMITTED_BY_HANDLER);\n if (!resolved.userId) return unroutable(InboundDeliveryUnroutableReason.USER_NOT_FOUND);\n const user = await this.readUserForRouting(resolved.userId);\n if (!user) return unroutable(InboundDeliveryUnroutableReason.USER_NOT_FOUND);\n if (!regardlessOfStanding && !isAuthorityConferringUserStatus(user.status)) return unroutable(InboundDeliveryUnroutableReason.USER_WITHOUT_AUTHORITY);\n return { kind: InboundResolvedScopeKind.USER, userId: resolved.userId };\n }\n default: {\n const unhandled: never = resolved;\n return unhandled;\n }\n }\n }\n\n /** The person a resolver named; an id the store cannot cast names no one. */\n private async readUserForRouting(userId: string): Promise<{ _id: string; status?: UserStatus } | null> {\n try {\n return await this.repositoriesRegistry.readUnscopedByKey<{ _id: string; status?: UserStatus }>(CoreResourceType.USERS, { _id: userId });\n } catch (error) {\n if (isMalformedIdLookupError(error)) return null;\n throw error;\n }\n }\n\n /**\n * The organization a resolver named. An id the store cannot cast names no organization, so it is NOT_FOUND\n * rather than a 500 the sender would retry forever.\n */\n private async readOrganizationForRouting(organizationId: string): Promise<{ _id: string; status?: OrganizationStatus } | null> {\n try {\n return await this.repositoriesRegistry.readUnscopedByKey<{ _id: string; status?: OrganizationStatus }>(CoreResourceType.ORGANIZATIONS, { _id: organizationId });\n } catch (error) {\n if (isMalformedIdLookupError(error)) return null;\n throw error;\n }\n }\n\n /**\n * Routing lookups for a resolver. They run on the infrastructure tier — BEFORE any handler authority\n * exists, under the engine's own routing authority — and answer only an organization id.\n */\n private readonly lookups: InboundScopeLookups = {\n findOrganizationIdByField: (resourceType: ResourceType, field: string, value: string) =>\n this.findScopeOwnerByField(resourceType, ResourcePrimaryScope.ORGANIZATIONS, 'organizationId', field, value),\n findUserIdByField: (resourceType: ResourceType, field: string, value: string) =>\n this.findScopeOwnerByField(resourceType, ResourcePrimaryScope.USER_SELF, 'userId', field, value),\n findOrganizationIdByConnectionFact: (connectionRef: string, factName: string, value: string) =>\n this.findOrganizationIdByConnectionFact(connectionRef, factName, value),\n };\n\n /**\n * See {@link InboundScopeLookups.findOrganizationIdByConnectionFact}. The fact name is a declared identifier\n * (`workspaceId`, `tenantId`), never caller text that could become a path operator, so anything else is refused.\n */\n private async findOrganizationIdByConnectionFact(connectionRef: string, factName: string, value: string): Promise<string | null> {\n if (!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(factName)) {\n throw new Error(`findOrganizationIdByConnectionFact: '${factName}' is not a fact name (a letter, then letters, digits or underscores)`);\n }\n if (typeof connectionRef !== 'string' || connectionRef.length === 0 || typeof value !== 'string' || value.length === 0) return null;\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a chat workspace or bot routes only to the organization its VENDOR reported or accepted, never on a typed value (#2660, #2663).\n // One lookup per trusted provenance, and the answer is an organization only when exactly one holds the value across\n // all of them: a value one organization's vendor reported and another's vendor accepted names no single organization.\n const owners = new Set<string>();\n for (const provenance of PROVIDER_CONNECTION_ROUTING_FACT_PROVENANCES) {\n const outcome = await this.findScopeOwnerOutcome(CoreResourceType.ORG_PROVIDER_CREDENTIALS, ResourcePrimaryScope.ORGANIZATIONS, 'organizationId', {\n connectionRef,\n enabled: true,\n [`connectionFacts.${factName}.value`]: value,\n [`connectionFacts.${factName}.provenance`]: provenance,\n }, 'findOrganizationIdByConnectionFact');\n if (outcome.kind === ScopeOwnerOutcome.AMBIGUOUS) return null;\n if (outcome.kind === ScopeOwnerOutcome.ONE) owners.add(outcome.owner);\n }\n return owners.size === 1 ? [...owners][0]! : null;\n }\n\n /**\n * The scope owner (`organizationId` or `userId`) of the row of `resourceType` whose `field` equals `value`, or\n * `null` — one implementation for both scopes, so the cross-owner refusal and the malformed-id rule cannot\n * be applied to one and forgotten on the other.\n */\n private async findScopeOwnerByField(\n resourceType: ResourceType,\n requiredScope: ResourcePrimaryScope.ORGANIZATIONS | ResourcePrimaryScope.USER_SELF,\n ownerField: 'organizationId' | 'userId',\n field: string,\n value: string,\n ): Promise<string | null> {\n const lookup = ownerField === 'organizationId' ? 'findOrganizationIdByField' : 'findUserIdByField';\n // Only a plain value is looked up: a payload schema permissive enough to pass an object here would\n // otherwise hand the store an operator (`{ $ne: null }`) that matches every row.\n if (typeof value !== 'string' || value.length === 0) {\n this.assertScopedResource(resourceType, requiredScope, ownerField, lookup);\n return null;\n }\n return this.findScopeOwner(resourceType, requiredScope, ownerField, { [field]: value }, lookup);\n }\n\n private assertScopedResource(resourceType: ResourceType, requiredScope: ResourcePrimaryScope, ownerField: 'organizationId' | 'userId', lookup: string): void {\n const configuration = this.resourcesRegistry.getResourceConfiguration(resourceType) as { resourcePrimaryScope?: ResourcePrimaryScope } | undefined;\n if (configuration?.resourcePrimaryScope !== requiredScope) {\n throw new Error(`${lookup}: '${resourceType}' is not a ${requiredScope}-scoped resource, so its rows name no ${ownerField === 'organizationId' ? 'organization' : 'person'}`);\n }\n }\n\n /**\n * The one owner whose rows of `resourceType` match `filter`, shared by every lookup so the cross-owner refusal and\n * the malformed-id rule cannot be applied to one and forgotten on another. Every value in `filter` is a plain value\n * its caller checked.\n */\n private async findScopeOwner(\n resourceType: ResourceType,\n requiredScope: ResourcePrimaryScope.ORGANIZATIONS | ResourcePrimaryScope.USER_SELF,\n ownerField: 'organizationId' | 'userId',\n filter: Record<string, unknown>,\n lookup: string,\n ): Promise<string | null> {\n const outcome = await this.findScopeOwnerOutcome(resourceType, requiredScope, ownerField, filter, lookup);\n return outcome.kind === ScopeOwnerOutcome.ONE ? outcome.owner : null;\n }\n\n /**\n * {@link findScopeOwner}, saying WHY there is no owner: no matching row, or rows of two different owners. A lookup\n * that combines several filters needs the difference, because two filters each naming one owner may name two.\n */\n private async findScopeOwnerOutcome(\n resourceType: ResourceType,\n requiredScope: ResourcePrimaryScope.ORGANIZATIONS | ResourcePrimaryScope.USER_SELF,\n ownerField: 'organizationId' | 'userId',\n filter: Record<string, unknown>,\n lookup: string,\n ): Promise<{ readonly kind: ScopeOwnerOutcome.ONE; readonly owner: string } | { readonly kind: ScopeOwnerOutcome.NONE | ScopeOwnerOutcome.AMBIGUOUS }> {\n this.assertScopedResource(resourceType, requiredScope, ownerField, lookup);\n const page = { sort: [{ field: '_id', order: SortOrder.ASC }], limit: 1 };\n try {\n const [first] = await this.repositoriesRegistry.findManyForInfrastructure<Record<string, unknown>>(resourceType, filter, undefined, undefined, page);\n const owner = first?.[ownerField];\n if (typeof owner !== 'string') return { kind: ScopeOwnerOutcome.NONE };\n // A value unique per owner but not across owners must not route to whichever owner's row sorts first:\n // a matching row belonging to ANY other owner makes the delivery unroutable.\n const [other] = await this.repositoriesRegistry.findManyForInfrastructure<Record<string, unknown>>(\n resourceType, { ...filter, [ownerField]: { $ne: owner } }, undefined, undefined, page,\n );\n return other ? { kind: ScopeOwnerOutcome.AMBIGUOUS } : { kind: ScopeOwnerOutcome.ONE, owner };\n } catch (error) {\n // The sender wrote the value, and the payload schema cannot know the store's id format (an ObjectId on\n // MongoDB, something else on PostgreSQL). A value the store cannot cast matches no row: unroutable, never\n // a 500 that tells the sender to retry the same malformed request forever.\n if (isMalformedIdLookupError(error)) return { kind: ScopeOwnerOutcome.NONE };\n throw error;\n }\n }\n\n\n private keptHeaders(headers: InboundRawRequest['headers'], names: readonly string[]): Record<string, string> {\n const kept: Record<string, string> = {};\n for (const name of names) {\n const value = headerString(headers, name.toLowerCase());\n if (value !== undefined) kept[name.toLowerCase()] = value;\n }\n return kept;\n }\n}\n"]}
1
+ {"version":3,"file":"inbound-delivery-receiver.backend.service.js","sourceRoot":"","sources":["../../../../src/inbound/services/inbound-delivery-receiver.backend.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAg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AC,6BAA6B,CAAC,CAAA;IACxD,WAAA,MAAM,CAAC,kBAAkB,CAAC,2BAA2B,CAAC,CAAA;IACtD,WAAA,MAAM,CAAC,kBAAkB,CAAC,kCAAkC,CAAC,CAAA;IAC7D,WAAA,MAAM,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA;IAOlD,WAAA,MAAM,CAAC,kBAAkB,CAAC,0BAA0B,CAAC,CAAA;IACrD,WAAA,MAAM,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;IAAE,WAAA,QAAQ,EAAE,CAAA;IAC1D,WAAA,MAAM,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;IAAE,WAAA,QAAQ,EAAE,CAAA;IACvD,WAAA,MAAM,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,CAAA;IAAE,WAAA,QAAQ,EAAE,CAAA;IAE5D,WAAA,MAAM,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA;IAAE,WAAA,QAAQ,EAAE,CAAA;IAE9D,YAAA,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAA;IAAE,YAAA,QAAQ,EAAE,CAAA;IAErD,YAAA,MAAM,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA;IAAE,YAAA,QAAQ,EAAE,CAAA;IAE9D,YAAA,MAAM,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;IAAE,YAAA,QAAQ,EAAE,CAAA;IAK1D,YAAA,MAAM,CAAC,kBAAkB,CAAC,gCAAgC,CAAC,CAAA;IAAE,YAAA,QAAQ,EAAE,CAAA;;GA/B/D,qCAAqC,CAs0BjD","sourcesContent":["/**\n * The inbound receiver (#1596): from raw request to a stored, deduplicated, scope-resolved delivery —\n * and an HTTP answer the sender can act on.\n *\n * ```\n * size / media type ─► secret ─► verify ─► parse ─► select handler ─► payload schema\n * ─► dedup key ─► resolve scope (no fallback) ─► insert once ─► enqueue ─► 200\n * ```\n *\n * The answers are chosen for what they tell a SENDER to do:\n *\n * | answer | when | sender's reading |\n * |---|---|---|\n * | 200 | stored, duplicate, unroutable, or an event no handler takes | done; do not retry |\n * | 400 | verified but not what the handler declared | a retry will not help |\n * | 401 | signature, timestamp or secret refused | not accepted |\n * | 413 / 415 | too large / not JSON | a retry will not help |\n * | 500 | something on OUR side failed before the row existed | retry later |\n *\n * Handler execution never happens here: an agent-backed handler outlasts any provider's delivery\n * timeout, and a handler failure is the worker's to retry, not the sender's.\n *\n * A provider endpoint may replace the 200's body with the answer its own contract requires (#2659): a Slack\n * `url_verification` handshake is answered with its challenge and stored nowhere; every other accepted request\n * gets the endpoint's `acknowledge` answer (an empty 200 for Slack, an invoke response for a Teams card action).\n * The answer is a pure function of the verified request, so it is due in milliseconds whatever the handler does.\n *\n * A chat SEARCH (#2666 S7, a Teams message-extension search) is the one request answered with what it asked for: it is\n * routed by the endpoint's own resolver, answered by the chat search lane within the vendor's deadline, written through\n * the endpoint's `answerChatSearch`, and stored nowhere.\n */\nimport { inject, injectable, optional } from 'inversify';\nimport {\n InboundChatInputKind,\n ChatBotOwnerScope,\n CoreResourceType,\n ErrorType,\n deriveInboundEndpointSecretEnvVarName,\n INBOUND_DELIVERY_MAX_BODY_BYTES,\n INBOUND_DELIVERY_MAX_STORED_BODY_BYTES,\n InboundDeliveryRejectionReason,\n InboundDeliveryUnroutableReason,\n InboundHandlerScopeMode,\n InboundResolvedScopeKind,\n InboundSenderAssurance,\n InboundSourceKind,\n isAuthorityConferringOrganizationStatus,\n PROVIDER_CONNECTION_ROUTING_FACT_PROVENANCES,\n isAuthorityConferringUserStatus,\n isWildoBackendError,\n jsonParsingSchemaOf,\n ResourcePrimaryScope,\n SortOrder,\n type InboundDeliveryResolvedScope,\n type OrganizationStatus,\n type ResourceType,\n type UserStatus,\n} from '@wildo-ai/saas-models';\nimport {\n HOOK_REREAD_TRIGGER_DEFAULT_COALESCING_WINDOW_SECONDS,\n HOOK_REREAD_TRIGGER_DEFAULT_RATE_LIMIT,\n Hook_ContentType,\n isReReadTriggerEndpoint,\n type Hook_Acknowledgement,\n type Hook_Endpoint,\n type Hook_InboundChatCommand,\n type Hook_InboundChatMessage,\n type Hook_InboundPersonalConversation,\n Hook_ChatSearchAnswerKind,\n type Hook_ChatSearchAnswer,\n} from '@wildo-ai/external-connectors-models';\nimport { chatConversationOrderingKeyOf } from '~wildo-backend-lib/flows-actors/services/chat-conversation-store.backend.service';\n\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { LoggerService } from '~wildo-backend-lib/monitoring/logger/services/logger.service';\nimport type { RepositoriesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport type { ResourcesRegistryBackendService } from '~wildo-backend-lib/resources/services/resources-registry.backend.service';\nimport type { ApplicationIdentityBackendService } from '~wildo-backend-lib/applications/services/application-identity.backend.service';\nimport type { AuditLogsBackendService } from '~wildo-backend-lib/compliance/audit-trails/services/audit-logs.backend.service';\nimport type { QueueBackendService } from '~wildo-backend-lib/queue/queue.backend.service';\nimport { ProviderInboundRequestKind, type ProviderInboundRequest, type WebhookHandlerBackendService } from '~wildo-backend-lib/notifications/webhooks/services/webhook-handler.backend.service';\nimport { decodeInboundBody, inboundContentTypeOf, providerEndpointKeptHeaders, storedInboundContentType } from '~wildo-backend-lib/inbound/models/inbound-body-decoding.backend';\nimport type { RateLimitBackendService } from '~wildo-backend-lib/errors/services/rate-limit.backend.service';\nimport { projectCaughtErrorLogFields } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { isMalformedIdLookupError } from '~wildo-backend-lib/base-classes/services/repositories/resource-write-integrity.backend';\nimport {\n inboundSourceKey,\n normalizeInboundSubjectKeys,\n scopesAdmittedByHandler,\n type AnyInboundHandlerDefinition,\n type InboundResolvedScope,\n type InboundScopeLookups,\n type VerifiedInboundDelivery,\n} from '~wildo-backend-lib/inbound/models/inbound-handler.backend.definitions';\nimport { InboundScopeStandingPolicy, inboundScopeStandingPolicyOf } from '~wildo-backend-lib/inbound/models/inbound-engine-handler.backend';\nimport { headersKeptForScheme, verifyInboundDelivery } from '~wildo-backend-lib/inbound/verification/inbound-verification-schemes.backend';\nimport type { InboundApplicationEndpoint, InboundHandlerRegistryBackendService } from './inbound-handler-registry.backend.service';\nimport { InboundDeliveryInsertOutcome, inboundDeliveryIdFor, inboundDeliveryResourceTypeFor, type InboundDeliveryStoreBackendService } from './inbound-delivery-store.backend.service';\nimport { storedBodyFileIdOf, type InboundDeliveryStoredBodyBackendService, type StoredInboundBody } from './inbound-delivery-stored-body.backend.service';\nimport { InboundDeliveryAudit } from './inbound-delivery-audit.backend';\nimport { enqueueInboundDeliveryDispatch } from './inbound-delivery-dispatch-queue.backend';\nimport type { ChatIdentityLinkBackendService } from './chat-identity-link.backend.service';\nimport { ChatSearchRouteKind, type ChatSearchLaneBackendService, type ChatSearchRoute } from '~wildo-backend-lib/inbound/chat-commands/chat-search-lane.backend.service';\nimport { CHAT_COMMAND_TRY_AGAIN_LABEL_REF, chatCommandLabelKey } from '~wildo-backend-lib/inbound/chat-commands/chat-command-words.backend.utils';\nimport { ChatCommandFormLaneOutcome, type ChatCommandFormLaneBackendService } from '~wildo-backend-lib/inbound/chat-commands/chat-command-form-lane.backend.service';\n\n/** The request, as the route hands it over. Header names lower-cased. */\nexport interface InboundRawRequest {\n /** The exact bytes received, or `undefined` when the body parser kept none. */\n readonly rawBody: Buffer | undefined;\n readonly headers: Readonly<Record<string, string | string[] | undefined>>;\n /** The body parser refused the body for its size before any bytes were kept (the parser's own ceiling). */\n readonly bodyTooLarge?: boolean;\n /**\n * The path and query string the request arrived on, exactly as received (`req.originalUrl`). Read only by a scheme\n * that signs the URL it was sent to (Twilio's, #3394); never stored.\n */\n readonly requestTarget?: string;\n}\n\nexport interface InboundReceiveAnswer {\n readonly status: number;\n readonly body: Readonly<Record<string, unknown>>;\n /**\n * The provider endpoint's own answer (#2659), written INSTEAD of `body` with a 200. Present only on a request the\n * engine accepted; a refusal always carries the engine's answer.\n */\n readonly acknowledgement?: Hook_Acknowledgement;\n}\n\n/** The engine's 200 answer, carrying the endpoint's acknowledgement when it declares one. Never replaces a refusal. */\nfunction acknowledgedBy(answer: InboundReceiveAnswer, acknowledgement: Hook_Acknowledgement | undefined): InboundReceiveAnswer {\n return acknowledgement && answer.status === 200 ? { ...answer, acknowledgement } : answer;\n}\n\nconst ANSWER = {\n received: { status: 200, body: { received: true } },\n duplicate: { status: 200, body: { received: true, duplicate: true } },\n ignored: { status: 200, body: { received: true, ignored: true } },\n unauthorized: { status: 401, body: { error: 'Invalid signature' } },\n malformed: { status: 400, body: { error: 'Malformed delivery' } },\n tooLarge: { status: 413, body: { error: 'Payload too large' } },\n unsupported: { status: 415, body: { error: 'Unsupported media type' } },\n retryLater: { status: 500, body: { error: 'Processing failed' } },\n} as const satisfies Record<string, InboundReceiveAnswer>;\n\n/** The longest dedup or ordering key the ledger stores (the schema's bound). */\nexport const INBOUND_KEY_MAX_LENGTH = 512;\n\nfunction isStorableInboundKey(key: string | undefined): key is string {\n return typeof key === 'string' && key.length > 0 && key.length <= INBOUND_KEY_MAX_LENGTH;\n}\n\n/**\n * What EVERY request to a re-read trigger endpoint is answered (#2909): known or unknown reference, rate-limited,\n * malformed, stored or not. Its sender is unverified, so no answer may tell it anything, least of all which references\n * exist (a store failure answered 500 would say that one did).\n */\nexport const REREAD_TRIGGER_ANSWER: InboundReceiveAnswer = { status: 202, body: { received: true } };\n/** The largest notification a re-read trigger endpoint reads when its provider declares no `maxBodyBytes`. */\nexport const REREAD_TRIGGER_DEFAULT_MAX_BODY_BYTES = 16 * 1024;\n/** The longest reference kept: the delivery id appends the window's instant to it, within the ledger's key bound. */\nexport const REREAD_TRIGGER_MAX_REFERENCE_LENGTH = INBOUND_KEY_MAX_LENGTH - 32;\n\n/**\n * A re-read trigger's delivery id (#2909): the reference and the start of the coalescing window the notification arrived\n * in. Two notifications for one reference inside one window are one delivery, so a reference is re-read at most once per\n * window, whatever a sender sends.\n */\nexport function reReadTriggerDeliveryId(reference: string, receivedAt: Date, coalescingWindowSeconds: number): string {\n const windowMs = coalescingWindowSeconds * 1_000;\n return `${reference}@${new Date(Math.floor(receivedAt.getTime() / windowMs) * windowMs).toISOString()}`;\n}\n\nfunction headerString(headers: InboundRawRequest['headers'], name: string): string | undefined {\n const value = headers[name];\n return Array.isArray(value) ? value[0] : value;\n}\n\nfunction readPath(value: unknown, dotPath: string): unknown {\n return dotPath.split('.').reduce<unknown>((current, key) => (current && typeof current === 'object' ? (current as Record<string, unknown>)[key] : undefined), value);\n}\n\n/** What a routing lookup found: one owner, none, or rows of two different owners (which names none). */\nenum ScopeOwnerOutcome {\n ONE = 'one',\n NONE = 'none',\n AMBIGUOUS = 'ambiguous',\n}\n\n@injectable()\nexport class InboundDeliveryReceiverBackendService {\n private readonly audit: InboundDeliveryAudit;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.InboundHandlerRegistryService) private readonly registry: InboundHandlerRegistryBackendService,\n @inject(SAAS_SERVICE_TYPES.InboundDeliveryStoreService) private readonly store: InboundDeliveryStoreBackendService,\n @inject(SAAS_SERVICE_TYPES.RepositoriesRegistryHandlerService) private readonly repositoriesRegistry: Pick<RepositoriesRegistryHandlerBackendService, 'findManyForInfrastructure' | 'readUnscopedByKey'>,\n @inject(SAAS_SERVICE_TYPES.ResourceRegistryService) private readonly resourcesRegistry: Pick<ResourcesRegistryBackendService, 'getResourceConfiguration'>,\n /**\n * The APPLICATION RECORD's id, stamped into an application-variant row's `applicationId` scope\n * column. Never `AppConfigurationService.applicationId`: that is the PLATFORM's id for this\n * process, and a row stamped with it is invisible to the application-scope list that filters by\n * the record id (see `platform-application-id-readers.guard.test.ts`).\n */\n @inject(SAAS_SERVICE_TYPES.ApplicationIdentityService) private readonly applicationIdentity: Pick<ApplicationIdentityBackendService, 'getCanonicalApplicationId'>,\n @inject(SAAS_SERVICE_TYPES.QueueBackendService) @optional() private readonly queue?: Pick<QueueBackendService, 'enqueueCustomBatch'>,\n @inject(SAAS_SERVICE_TYPES.AuditLogsService) @optional() auditLogs?: AuditLogsBackendService,\n @inject(SAAS_SERVICE_TYPES.WebhookHandlerService) @optional() private readonly webhookHandler?: WebhookHandlerBackendService,\n /** #2664 S5b: where a verified personal conversation is recorded, on the sender's chat identity link. */\n @inject(SAAS_SERVICE_TYPES.ChatIdentityLinkService) @optional() private readonly chatLinks?: Pick<ChatIdentityLinkBackendService, 'rememberPersonalConversation'>,\n /** #2666 S7: where a chat search is answered, in the request. Optional: without it a search is answered \"try again\". */\n @inject(SAAS_SERVICE_TYPES.ChatSearchLane) @optional() private readonly chatSearchLane?: Pick<ChatSearchLaneBackendService, 'answer'>,\n /** #2909: the per-endpoint limit of a re-read trigger. Absent, every such notification is dropped (fail closed). */\n @inject(SAAS_SERVICE_TYPES.RateLimitBackendService) @optional() private readonly rateLimits?: Pick<RateLimitBackendService, 'checkPolicyForSubject'>,\n /** #2770: where a chat command's form is opened while the person waits. Optional: without it every command runs as typed. */\n @inject(SAAS_SERVICE_TYPES.ChatCommandFormLane) @optional() private readonly chatCommandFormLane?: Pick<ChatCommandFormLaneBackendService, 'open'>,\n /**\n * #3395: where a body larger than a delivery row is written. Optional: without it such a body is refused 413, as it\n * was before bodies could be stored outside the row.\n */\n @inject(SAAS_SERVICE_TYPES.InboundDeliveryStoredBodyService) @optional() private readonly storedBodies?: Pick<InboundDeliveryStoredBodyBackendService, 'write' | 'discard'>,\n ) {\n this.audit = new InboundDeliveryAudit(auditLogs);\n }\n\n /** The clock; a property so tests can pin time without DI trying to inject it. */\n clock: () => Date = () => new Date();\n\n // ─────────────────────────────────────────────────────────────────────────\n // Application endpoints: POST /webhooks/app/{endpointKey}\n // ─────────────────────────────────────────────────────────────────────────\n\n async receiveApplicationEndpoint(endpoint: InboundApplicationEndpoint, request: InboundRawRequest): Promise<InboundReceiveAnswer> {\n const base = { sourceKind: InboundSourceKind.APPLICATION_ENDPOINT, sourceKey: endpoint.sourceKey };\n const reject = async (reason: InboundDeliveryRejectionReason, answer: InboundReceiveAnswer): Promise<InboundReceiveAnswer> => {\n await this.audit.rejected({ ...base, reason });\n return answer;\n };\n\n // Media type first: only JSON keeps its raw bytes, and a scheme cannot verify what was not kept.\n const contentType = (headerString(request.headers, 'content-type') ?? '').split(';')[0]!.trim().toLowerCase();\n if (contentType !== 'application/json') return reject(InboundDeliveryRejectionReason.UNSUPPORTED_MEDIA_TYPE, ANSWER.unsupported);\n\n const declaredLength = Number(headerString(request.headers, 'content-length'));\n if (request.bodyTooLarge || (Number.isFinite(declaredLength) && declaredLength > endpoint.maxBodyBytes) || (request.rawBody && request.rawBody.length > endpoint.maxBodyBytes)) {\n return reject(InboundDeliveryRejectionReason.BODY_TOO_LARGE, ANSWER.tooLarge);\n }\n // No re-serialization fallback: a JSON.stringify of the parsed body does not byte-match what the\n // sender signed, so \"verifying\" it would verify our own bytes.\n if (!request.rawBody) {\n this.logger.error('Inbound delivery refused: the raw request body was not kept, so it cannot be verified', { sourceKey: endpoint.sourceKey });\n return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n }\n\n // I1 at request time: a secret can be removed after mount, and an empty secret is never a key.\n const secretEnvVar = deriveInboundEndpointSecretEnvVarName(endpoint.endpointKey);\n const secret = process.env[secretEnvVar] ?? '';\n if (!secret) {\n this.logger.error('Inbound delivery refused: the endpoint has no verification secret', { sourceKey: endpoint.sourceKey, secretEnvVar });\n return reject(InboundDeliveryRejectionReason.SECRET_NOT_CONFIGURED, ANSWER.unauthorized);\n }\n const receivedAt = this.clock();\n // assurance-control: WILDO.SECURITY.FAIL_CLOSED — no dispatch without a verified signature (I1).\n const verification = verifyInboundDelivery(endpoint.source.verification, { rawBody: request.rawBody, headers: request.headers, secret, now: receivedAt });\n if (verification.ok === false) return reject(verification.reason, ANSWER.unauthorized);\n\n let json: unknown;\n try {\n json = JSON.parse(request.rawBody.toString('utf8'));\n } catch {\n return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n }\n const eventTypeValue = readPath(json, endpoint.eventTypePath);\n const eventType = typeof eventTypeValue === 'string' ? eventTypeValue : undefined;\n const handler = this.registry.selectApplicationEndpointHandler(endpoint, eventType);\n if (!handler) {\n // An event no handler declared is not ours to store; acknowledging stops the sender retrying it.\n return ANSWER.ignored;\n }\n\n const delivery: VerifiedInboundDelivery = {\n sourceKind: InboundSourceKind.APPLICATION_ENDPOINT,\n sourceKey: endpoint.sourceKey,\n ...(verification.deliveryId !== undefined ? { providerDeliveryId: verification.deliveryId } : {}),\n ...(verification.signedAt !== undefined ? { signedAt: verification.signedAt } : {}),\n receivedAt,\n rawBody: request.rawBody,\n headers: this.keptHeaders(request.headers, headersKeptForScheme(endpoint.source.verification)),\n ...(eventType !== undefined ? { eventType } : {}),\n json,\n };\n return this.admit(handler, delivery, base, reject);\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // Provider endpoints bound to a handler: POST /webhooks/{providerRef}/{endpointKey}\n // ─────────────────────────────────────────────────────────────────────────\n\n /**\n * A provider-declared endpoint whose events a handler takes. Verification is the provider's registered adapter\n * (Stripe's SDK `constructEvent`, for one) or, for an engine-verified scheme (Svix, Slack v0, the Bot Framework\n * token), engine code; both refuse an empty secret at request time. Everything after it is the durable path.\n */\n async receiveProviderEndpoint(providerRef: string, endpoint: Hook_Endpoint, handler: AnyInboundHandlerDefinition, request: InboundRawRequest): Promise<InboundReceiveAnswer> {\n const sourceKey = inboundSourceKey(handler.source);\n const base = { sourceKind: InboundSourceKind.PROVIDER_ENDPOINT, sourceKey };\n // The receipt instant, taken before verification: a chat search's deadline is spent from it, verification included.\n const receivedAt = this.clock();\n const reject = async (reason: InboundDeliveryRejectionReason, answer: InboundReceiveAnswer): Promise<InboundReceiveAnswer> => {\n await this.audit.rejected({ ...base, reason });\n return answer;\n };\n // An unsigned notification that only triggers a re-read (#2909): handled by the engine, verified by nothing.\n if (isReReadTriggerEndpoint(endpoint)) return this.receiveReReadTrigger(providerRef, endpoint, handler, request, base, receivedAt, reject);\n if (!this.webhookHandler) return ANSWER.retryLater;\n // The media types the endpoint declares (#2659), JSON when it declares none. Checked FIRST, like the application\n // endpoint's: a body the engine would not decode is refused without being interpreted, and a type neither global\n // parser reads (so no raw bytes were kept) is answered 415, not a misleading 400.\n const contentType = inboundContentTypeOf(request.headers['content-type']);\n if (!contentType || !(endpoint.contentTypes ?? [Hook_ContentType.JSON]).includes(contentType)) {\n return reject(InboundDeliveryRejectionReason.UNSUPPORTED_MEDIA_TYPE, ANSWER.unsupported);\n }\n // Over the body parser's own limit (#3395): refused before anything was read into the request.\n if (request.bodyTooLarge) return reject(InboundDeliveryRejectionReason.BODY_TOO_LARGE, ANSWER.tooLarge);\n if (!request.rawBody) return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n // The endpoint's own cap, when its provider declares one, and never past the most any delivery may hold (#3395): a\n // body over the row's size is stored outside it, but the whole body is verified in memory first.\n if ((endpoint.maxBodyBytes !== undefined && request.rawBody.length > endpoint.maxBodyBytes) || request.rawBody.length > INBOUND_DELIVERY_MAX_BODY_BYTES) {\n return reject(InboundDeliveryRejectionReason.BODY_TOO_LARGE, ANSWER.tooLarge);\n }\n\n let verified: ProviderInboundRequest;\n // assurance-control: WILDO.SECURITY.FAIL_CLOSED — a provider event (billing's, since #1629; Slack's and Teams', #2659) is stored and dispatched only after its signature or token verified (I1).\n try {\n verified = await this.webhookHandler.verifyAndParseForInboundHandler({\n providerRef,\n endpointKey: endpoint.key,\n endpoint,\n rawBody: request.rawBody,\n headers: request.headers as Record<string, string>,\n contentType,\n // An organization's own bot routes by the connection reporting it, through the same lookup a resolver uses (#2663).\n findOrganizationIdByConnectionFact: this.lookups.findOrganizationIdByConnectionFact,\n ...(request.requestTarget === undefined ? {} : { requestTarget: request.requestTarget }),\n });\n } catch (error) {\n if (isWildoBackendError(error) && error.type === ErrorType.AUTHORIZATION) {\n const refusal = error.context as { secretConfigured?: boolean; reason?: InboundDeliveryRejectionReason } | undefined;\n // An engine-verified endpoint (#1600) names its refusal; an adapter-verified one only says whether a secret existed.\n const reason = refusal?.secretConfigured === false\n ? InboundDeliveryRejectionReason.SECRET_NOT_CONFIGURED\n : refusal?.reason === InboundDeliveryRejectionReason.TIMESTAMP_OUT_OF_WINDOW\n ? InboundDeliveryRejectionReason.TIMESTAMP_OUT_OF_WINDOW\n : InboundDeliveryRejectionReason.SIGNATURE_INVALID;\n return reject(reason, ANSWER.unauthorized);\n }\n // Ours, not the sender's: a key set that could not be fetched, an endpoint function that threw.\n this.logger.error('Inbound provider delivery could not be verified or read', { sourceKey, ...projectCaughtErrorLogFields(error) });\n return ANSWER.retryLater;\n }\n\n switch (verified.kind) {\n case ProviderInboundRequestKind.HANDSHAKE:\n // A reachability check, already verified: answered as the provider requires, and stored nowhere.\n this.logger.info('Inbound provider handshake answered', { sourceKey });\n return acknowledgedBy(ANSWER.received, verified.answer);\n case ProviderInboundRequestKind.MALFORMED:\n return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n case ProviderInboundRequestKind.IGNORED:\n return acknowledgedBy(ANSWER.ignored, verified.acknowledgement);\n case ProviderInboundRequestKind.EVENT: {\n // #2770: a command whose form the vendor must open while the person waits (a Slack modal) is answered here, and\n // stored nowhere: its submission comes back as a command of its own. Declined, it is stored and run as typed.\n if (verified.chatCommand && await this.openedChatCommandForm(providerRef, endpoint, handler, verified, request, contentType, sourceKey, receivedAt)) {\n return acknowledgedBy(ANSWER.received, verified.acknowledgement);\n }\n const delivery: VerifiedInboundDelivery = {\n sourceKind: InboundSourceKind.PROVIDER_ENDPOINT,\n sourceKey,\n providerDeliveryId: verified.eventId,\n receivedAt,\n rawBody: request.rawBody,\n // The media type is kept: the dispatcher decodes the stored bytes as what they were received as.\n headers: providerEndpointKeptHeaders(request.headers),\n eventType: verified.providerEventType,\n json: verified.body,\n ...(verified.verifiedAudience === undefined ? {} : { verifiedAudience: verified.verifiedAudience }),\n };\n return acknowledgedBy(await this.admit(handler, delivery, base, reject, verified.personalConversation, verified.chatMessage, verified.chatCommand), verified.acknowledgement);\n }\n case ProviderInboundRequestKind.CHAT_SEARCH:\n return this.answerChatSearch(providerRef, endpoint, handler, verified, request, sourceKey, receivedAt);\n default: {\n // A shape the receiver does not know is OUR defect (a verifier and a receiver out of step), never something to\n // answer with: throwing reaches the route's error handler as a 500, where returning it would write no status.\n const unhandled: never = verified;\n throw new Error(`Unknown provider inbound request kind: ${JSON.stringify((unhandled as { kind?: unknown } | null)?.kind)}`);\n }\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n\n /**\n * A notification nobody can verify, that only names an object to re-read (#2909, `Hook_TriggerStrategy.WEBHOOK_TRIGGERS_POLL`).\n *\n * Nothing in it is trusted: it is rate-limited per endpoint before anything is read, its reference is looked up by the\n * handler's own resolver (the record must already be this application's, or it is dropped), and only that reference is\n * stored, under an id derived from it and the coalescing window. The handler re-reads the object from the vendor's\n * authenticated API; that answer, never the notification, is what it records. Every outcome is answered 202.\n *\n * What the answer does not hide (review F7, a stated residual): its TIMING. A known reference costs a store write, an\n * audit row and an enqueue; an unknown one a lookup and an aggregated refusal. A sender who already holds a candidate\n * reference (a signer sees theirs) may tell from latency whether this application uses it. It learns nothing it could\n * act on: the notification is never believed, and a known reference only causes a re-read at the vendor it came from.\n *\n * assurance-control: WILDO.SECURITY.FAIL_CLOSED — an unverified notification changes nothing by itself: it is dropped\n * unless it names a known record, and then only triggers an authenticated re-read.\n */\n private async receiveReReadTrigger(\n providerRef: string,\n endpoint: Hook_Endpoint,\n handler: AnyInboundHandlerDefinition,\n request: InboundRawRequest,\n base: { sourceKind: InboundSourceKind; sourceKey: string },\n receivedAt: Date,\n reject: (reason: InboundDeliveryRejectionReason, answer: InboundReceiveAnswer) => Promise<InboundReceiveAnswer>,\n ): Promise<InboundReceiveAnswer> {\n const drop = async (reason: InboundDeliveryRejectionReason): Promise<InboundReceiveAnswer> => {\n await reject(reason, REREAD_TRIGGER_ANSWER);\n return REREAD_TRIGGER_ANSWER;\n };\n // The route gate withholds an endpoint without one, so this is a declaration that changed after mount.\n const trigger = endpoint.reReadTrigger;\n if (!trigger) return drop(InboundDeliveryRejectionReason.MALFORMED);\n\n // The endpoint's rate, FIRST: a flood is counted and dropped before anything of it is read or looked up.\n if (!(await this.admittedByReReadTriggerRate(providerRef, endpoint.key, trigger))) return drop(InboundDeliveryRejectionReason.RATE_LIMITED);\n\n const contentType = inboundContentTypeOf(request.headers['content-type']);\n if (!contentType || !(endpoint.contentTypes ?? [Hook_ContentType.JSON]).includes(contentType)) return drop(InboundDeliveryRejectionReason.UNSUPPORTED_MEDIA_TYPE);\n if (request.bodyTooLarge || (request.rawBody && request.rawBody.length > (endpoint.maxBodyBytes ?? REREAD_TRIGGER_DEFAULT_MAX_BODY_BYTES))) {\n return drop(InboundDeliveryRejectionReason.BODY_TOO_LARGE);\n }\n if (!request.rawBody) return drop(InboundDeliveryRejectionReason.MALFORMED);\n const decoded = decodeInboundBody(request.rawBody, contentType);\n if (!decoded.ok) return drop(InboundDeliveryRejectionReason.MALFORMED);\n\n let reference: string | null;\n try {\n reference = trigger.identifyReference({ rawBody: new Uint8Array(request.rawBody), headers: request.headers, contentType, body: decoded.body });\n } catch {\n reference = null;\n }\n if (typeof reference !== 'string' || reference.length === 0 || reference.length > REREAD_TRIGGER_MAX_REFERENCE_LENGTH) {\n return drop(InboundDeliveryRejectionReason.UNKNOWN_REFERENCE);\n }\n\n // Only the reference is kept: the notification's other bytes are unverified and nothing reads them.\n const json = { reference };\n const delivery: VerifiedInboundDelivery = {\n sourceKind: InboundSourceKind.PROVIDER_ENDPOINT,\n sourceKey: base.sourceKey,\n providerDeliveryId: reReadTriggerDeliveryId(reference, receivedAt, trigger.coalescingWindowSeconds ?? HOOK_REREAD_TRIGGER_DEFAULT_COALESCING_WINDOW_SECONDS),\n receivedAt,\n rawBody: Buffer.from(JSON.stringify(json), 'utf8'),\n headers: { 'content-type': Hook_ContentType.JSON },\n json,\n };\n // One re-read of a reference at a time: its deliveries are ordered by the reference.\n const admission = { orderingKey: reference, dropUnknown: () => drop(InboundDeliveryRejectionReason.UNKNOWN_REFERENCE) };\n const leading = await this.admit(handler, delivery, base, reject, undefined, undefined, undefined, admission);\n if (leading === ANSWER.duplicate) {\n // The TRAILING edge (#2909 review F3): this window's re-read is already stored and may already have run, so a later\n // notification would be lost, and the vendor never retries. One more delivery is kept for the NEXT window, due at\n // its start: the reference is re-read once per window at most, and the last notification of a window is never lost.\n // A third notification in the window finds that one too, and is a duplicate of it.\n const windowSeconds = trigger.coalescingWindowSeconds ?? HOOK_REREAD_TRIGGER_DEFAULT_COALESCING_WINDOW_SECONDS;\n const nextWindowStart = new Date((Math.floor(receivedAt.getTime() / (windowSeconds * 1_000)) + 1) * windowSeconds * 1_000);\n await this.admit(handler, { ...delivery, providerDeliveryId: reReadTriggerDeliveryId(reference, nextWindowStart, windowSeconds) }, base, reject, undefined, undefined, undefined, {\n ...admission,\n notBefore: nextWindowStart,\n });\n }\n return REREAD_TRIGGER_ANSWER;\n }\n\n /**\n * Counts one request against the endpoint's limit, all senders together (#2909). `false` when it is over the limit, and\n * when the limiter cannot answer: an unverified notification is never worth admitting unmetered, and polling covers\n * whatever a dropped one named.\n */\n private async admittedByReReadTriggerRate(providerRef: string, endpointKey: string, trigger: NonNullable<Hook_Endpoint['reReadTrigger']>): Promise<boolean> {\n if (!this.rateLimits) {\n this.logLimiterFailureAtMostPerMinute('A re-read trigger notification was dropped: no rate limiter is bound', providerRef, endpointKey);\n return false;\n }\n const limit = trigger.rateLimit ?? HOOK_REREAD_TRIGGER_DEFAULT_RATE_LIMIT;\n try {\n await this.rateLimits.checkPolicyForSubject(\n { customWindows: [{ requestsPerWindow: limit.maxRequests, windowSeconds: limit.windowSeconds }] },\n 'inbound-reread-trigger',\n `${providerRef}:${endpointKey}`,\n );\n return true;\n } catch (error) {\n if (!(isWildoBackendError(error) && error.type === ErrorType.RATE_LIMIT)) {\n this.logLimiterFailureAtMostPerMinute('A re-read trigger notification was dropped: its rate limit could not be checked', providerRef, endpointKey, projectCaughtErrorLogFields(error));\n }\n return false;\n }\n }\n\n /** When each endpoint's limiter failure was last logged: unauthenticated requests must not write one line each (review F10). */\n private readonly reReadTriggerLimiterLoggedAt = new Map<string, number>();\n\n private logLimiterFailureAtMostPerMinute(message: string, providerRef: string, endpointKey: string, fields: Record<string, unknown> = {}): void {\n const key = `${providerRef}:${endpointKey}`;\n const now = this.clock().getTime();\n const last = this.reReadTriggerLimiterLoggedAt.get(key);\n if (last !== undefined && now - last < 60_000) return;\n this.reReadTriggerLimiterLoggedAt.set(key, now);\n this.logger.error(message, { providerRef, endpointKey, ...fields });\n }\n\n /**\n * Answers a chat search in the request (#2666 S7 step 6): routed by the handler's own payload schema and scope resolver,\n * exactly as an event would be, then answered by the chat search lane and written by the endpoint's `answerChatSearch`.\n * Nothing is stored, enqueued, or audited as a delivery: a search is a query, sent per keystroke. Its row, when it has\n * one, is the command door's (`CHAT_COMMAND_RUN`, for each outcome or refusal decided for a known member).\n *\n * Every failure here is answered with a sentence, never with \"retry later\": a 500 would show the person an error for a\n * keystroke, and the next keystroke is the retry.\n */\n private async answerChatSearch(\n providerRef: string,\n endpoint: Hook_Endpoint,\n handler: AnyInboundHandlerDefinition,\n verified: Extract<ProviderInboundRequest, { kind: ProviderInboundRequestKind.CHAT_SEARCH }>,\n request: InboundRawRequest,\n sourceKey: string,\n receivedAt: Date,\n ): Promise<InboundReceiveAnswer> {\n let answer: Hook_ChatSearchAnswer;\n if (!this.chatSearchLane) {\n this.logger.error('A chat search arrived, but no chat search lane is bound in this process', { sourceKey });\n // No lane, no words: the sentence's key, visibly unworded, rather than an answer the vendor shows as an error.\n answer = { kind: Hook_ChatSearchAnswerKind.MESSAGE, text: chatCommandLabelKey(CHAT_COMMAND_TRY_AGAIN_LABEL_REF) };\n } else {\n const route = await this.routeUnstoredRequest(handler, verified.body, verified.search.vendorRequestId, verified.verifiedAudience, request, sourceKey, receivedAt, 'chat search');\n answer = await this.chatSearchLane.answer({ route, connectionRef: providerRef, sourceKey, search: verified.search, receivedAt });\n }\n try {\n return acknowledgedBy(ANSWER.received, endpoint.answerChatSearch!(answer));\n } catch (error) {\n this.logger.error('Webhook endpoint function \\'answerChatSearch\\' threw; the search is answered with the engine\\'s plain acknowledgement', {\n providerRef, sourceKey, ...projectCaughtErrorLogFields(error),\n });\n return ANSWER.received;\n }\n }\n\n /**\n * Opens a chat command's form while the person waits (#2770), through the chat command form lane: `true` when it\n * opened (the request is answered and nothing is stored), `false` when it declined, and the command is stored and run as\n * typed. The lane routes the command as a stored one would be routed, by the handler's own schema and resolver.\n */\n private async openedChatCommandForm(\n providerRef: string,\n endpoint: Hook_Endpoint,\n handler: AnyInboundHandlerDefinition,\n verified: Extract<ProviderInboundRequest, { kind: ProviderInboundRequestKind.EVENT }>,\n request: InboundRawRequest,\n contentType: Hook_ContentType,\n sourceKey: string,\n receivedAt: Date,\n ): Promise<boolean> {\n if (!this.chatCommandFormLane || !verified.chatCommand || !request.rawBody) return false;\n const outcome = await this.chatCommandFormLane.open({\n providerRef,\n endpointKey: endpoint.key,\n command: verified.chatCommand,\n request: { rawBody: new Uint8Array(request.rawBody), headers: request.headers, contentType, body: verified.body },\n receivedAt,\n route: async () => {\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a chat command's form is opened only in the organization the endpoint's own resolver routes it to.\n const route = await this.routeUnstoredRequest(handler, verified.body, verified.eventId, verified.verifiedAudience, request, sourceKey, receivedAt, 'chat command form');\n return route.kind === ChatSearchRouteKind.ORGANIZATION ? { organizationId: route.organizationId } : undefined;\n },\n });\n return outcome === ChatCommandFormLaneOutcome.OPENED;\n }\n\n /**\n * Where a request answered in its own request reads (a chat search, #2666 S7; a chat command's form, #2770): the\n * organization the handler's payload schema and scope resolver route it to, exactly as an event's, or nowhere. A\n * failure on OUR side (the handler's schema refusing what the module read, a resolver that threw) is FAILED, not\n * UNROUTABLE: the person is asked to try again, never told the team is not connected.\n */\n private async routeUnstoredRequest(\n handler: AnyInboundHandlerDefinition,\n body: unknown,\n vendorRequestId: string,\n verifiedAudience: Extract<ProviderInboundRequest, { kind: ProviderInboundRequestKind.EVENT }>['verifiedAudience'],\n request: InboundRawRequest,\n sourceKey: string,\n receivedAt: Date,\n what: string,\n ): Promise<ChatSearchRoute> {\n try {\n // A delivery body is JSON (#3478): a date in the handler's payload schema reads from its RFC 3339 form.\n const payload = jsonParsingSchemaOf(handler.payloadSchema).safeParse(body);\n if (!payload.success) {\n this.logger.error(`A ${what} was refused by its handler's payload schema, so it could not be routed`, { sourceKey, handlerRef: handler.ref });\n return { kind: ChatSearchRouteKind.FAILED };\n }\n const delivery: VerifiedInboundDelivery = {\n sourceKind: InboundSourceKind.PROVIDER_ENDPOINT,\n sourceKey,\n // The vendor's id for the request: the only name it has, for a resolver that keys on one. Never stored.\n providerDeliveryId: vendorRequestId,\n receivedAt,\n rawBody: request.rawBody!,\n headers: providerEndpointKeptHeaders(request.headers),\n json: body,\n ...(verifiedAudience === undefined ? {} : { verifiedAudience }),\n };\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a request answered in place reads only in the organization the endpoint's own resolver routes it to.\n const scope = await this.resolveScope(handler, delivery, payload.data);\n return scope.kind === InboundResolvedScopeKind.ORGANIZATION\n ? { kind: ChatSearchRouteKind.ORGANIZATION, organizationId: scope.organizationId }\n : { kind: ChatSearchRouteKind.UNROUTABLE };\n } catch (error) {\n this.logger.error(`A ${what} could not be routed: a handler function threw`, { sourceKey, handlerRef: handler.ref, ...projectCaughtErrorLogFields(error) });\n return { kind: ChatSearchRouteKind.FAILED };\n }\n }\n\n /** Whether the handler's endpoint carries the messages people write to the application's bot (#2665 S6). */\n private isChatConversationEndpoint(handler: AnyInboundHandlerDefinition): boolean {\n return handler.source.kind === InboundSourceKind.PROVIDER_ENDPOINT\n && this.registry.chatMessageEndpoint(handler.source.providerRef, handler.source.endpointKey) !== undefined;\n }\n\n /** Whether the handler's endpoint is one whose requests may carry a chat command a person sent (#2666 S7). */\n private isChatCommandEndpoint(handler: AnyInboundHandlerDefinition): boolean {\n return handler.source.kind === InboundSourceKind.PROVIDER_ENDPOINT\n && this.registry.chatCommandEndpoint(handler.source.providerRef, handler.source.endpointKey) !== undefined;\n }\n\n private async admit(\n handler: AnyInboundHandlerDefinition,\n delivery: VerifiedInboundDelivery,\n base: { sourceKind: InboundSourceKind; sourceKey: string },\n reject: (reason: InboundDeliveryRejectionReason, answer: InboundReceiveAnswer) => Promise<InboundReceiveAnswer>,\n /** The sender's personal conversation with the bot, when the verifier found one (#2664 S5b). */\n personalConversation?: Hook_InboundPersonalConversation,\n /** The message a person wrote to the bot, when the verified request carries one (#2665 S6). */\n chatMessage?: Hook_InboundChatMessage,\n /** The chat command a person sent, when the verified request carries one (#2666 S7). */\n chatCommand?: Hook_InboundChatCommand,\n /**\n * A re-read trigger's delivery (#2909): ordered by its reference, and DROPPED, not stored as unroutable, when the\n * handler's resolver finds no record it names.\n */\n reReadTrigger?: { readonly orderingKey: string; readonly dropUnknown: () => Promise<InboundReceiveAnswer>; readonly notBefore?: Date },\n ): Promise<InboundReceiveAnswer> {\n // A delivery body is JSON (#3478): a date in the handler's payload schema reads from its RFC 3339 form. The dispatch\n // reads the stored body through the same schema, so the value checked here is the value the handler runs on.\n const payload = jsonParsingSchemaOf(handler.payloadSchema).safeParse(delivery.json);\n if (!payload.success) return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n\n let dedupKey: string | undefined;\n let orderingKey: string | null;\n let subjectKeys: readonly string[] | undefined;\n let resolvedScope: InboundDeliveryResolvedScope;\n try {\n dedupKey = handler.dedupKey ? handler.dedupKey(delivery) : delivery.providerDeliveryId;\n orderingKey = handler.orderingKey ? handler.orderingKey(delivery, payload.data) : null;\n // #1642: the people the payload names, as the handler declares them. Keys that cannot be stored refuse the delivery\n // like a dedup key that cannot: stored without them, the person it names could never be found in it.\n subjectKeys = normalizeInboundSubjectKeys(handler.subjectKeys ? handler.subjectKeys(delivery, payload.data) : undefined);\n // A key the store cannot hold is the SENDER's malformed delivery, answered 400 and audited — not a\n // 500 the sender would retry forever with nothing recorded.\n if (!isStorableInboundKey(dedupKey) || (orderingKey !== null && !isStorableInboundKey(orderingKey)) || subjectKeys === undefined) {\n return reject(InboundDeliveryRejectionReason.MALFORMED, ANSWER.malformed);\n }\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a delivery runs only in the scope its handler admits; nothing falls back to the application scope (I3).\n resolvedScope = await this.resolveScope(handler, delivery, payload.data);\n if (reReadTrigger) {\n // The known-record check (#2909): an unverified notification is kept only for a record this application holds.\n if (resolvedScope.kind === InboundResolvedScopeKind.UNROUTABLE) return reReadTrigger.dropUnknown();\n orderingKey = reReadTrigger.orderingKey;\n }\n // #2665 S6 (plans B6, V9): a chat message is ordered by the ENGINE, after routing, because its organization is part of\n // the key: per organization, connection, vendor conversation and sender. So two people writing in one thread never\n // wait on each other, and two organizations sharing a vendor channel never block each other. A message that routes\n // to no organization orders with nothing. The registry refused a handler key on such an endpoint.\n // #2666 S7 review L5: a request a module read as both is a command, and a command is never ordered behind a\n // conversation's turns: it runs once, by its own compare-and-swap.\n if (chatMessage && !chatCommand && handler.source.kind === InboundSourceKind.PROVIDER_ENDPOINT) {\n orderingKey = resolvedScope.kind === InboundResolvedScopeKind.ORGANIZATION\n ? chatConversationOrderingKeyOf({ organizationId: resolvedScope.organizationId, connectionRef: handler.source.providerRef, message: chatMessage })\n : null;\n }\n } catch (error) {\n this.logger.error('Inbound delivery could not be admitted: a handler function threw before the delivery was stored', {\n handlerRef: handler.ref, sourceKey: base.sourceKey, ...projectCaughtErrorLogFields(error),\n });\n return ANSWER.retryLater;\n }\n\n // #2665 S6 (plan V4), #2666 S7: stored, so READ withholds the body and the PROCESSED settle empties it, whatever the\n // handler registry later holds. A COMMAND is decided by the verified request, which is what it is, never by the\n // live list of verbs. Anything else is marked per ENDPOINT, not per request: a chat-conversation endpoint's other\n // events (an edit, a file share) carry what a person wrote just the same, and so does a request to a command\n // endpoint whose command the module could not read (review M5: unmarked, its text would never be emptied).\n const chatInput = chatCommand\n ? InboundChatInputKind.COMMAND\n : this.isChatConversationEndpoint(handler) ? InboundChatInputKind.CONVERSATION_MESSAGE\n : this.isChatCommandEndpoint(handler) ? InboundChatInputKind.COMMAND : undefined;\n\n let applicationId: string;\n let storedBody: StoredInboundBody | undefined;\n try {\n applicationId = await this.applicationIdentity.getCanonicalApplicationId();\n if (delivery.rawBody.length > INBOUND_DELIVERY_MAX_STORED_BODY_BYTES) {\n // #3395: what a person wrote to the bot is never larger than a row, and its readers read it from the row; a body\n // too large for the row is written outside it only where a backend can, and refused otherwise.\n if (chatInput !== undefined || !this.storedBodies) return reject(InboundDeliveryRejectionReason.BODY_TOO_LARGE, ANSWER.tooLarge);\n // A retried copy of an event already stored writes nothing: the ledger answers it without the upload.\n if (await this.store.locate(inboundDeliveryIdFor(base.sourceKey, dedupKey))) return ANSWER.duplicate;\n storedBody = await this.storedBodies.write({\n resourceType: inboundDeliveryResourceTypeFor(resolvedScope),\n deliveryId: inboundDeliveryIdFor(base.sourceKey, dedupKey),\n bytes: delivery.rawBody,\n mimeType: storedInboundContentType(delivery.headers),\n ownerRow: resolvedScope.kind === InboundResolvedScopeKind.ORGANIZATION ? { organizationId: resolvedScope.organizationId } : { applicationId },\n });\n }\n } catch (error) {\n this.logger.error('Inbound delivery body could not be stored', { handlerRef: handler.ref, sourceKey: base.sourceKey, ...projectCaughtErrorLogFields(error) });\n return ANSWER.retryLater;\n }\n\n let inserted;\n try {\n // assurance-control: WILDO.OPERATIONS.EXECUTION_INTEGRITY — one event, one stored delivery, at most one run (I2).\n inserted = await this.store.insert({\n sourceKind: base.sourceKind,\n sourceKey: base.sourceKey,\n handlerRef: handler.ref,\n dedupKey,\n orderingKey,\n ...(delivery.providerDeliveryId !== undefined ? { providerDeliveryId: delivery.providerDeliveryId } : {}),\n ...(delivery.signedAt !== undefined ? { signedAt: delivery.signedAt } : {}),\n receivedAt: delivery.receivedAt,\n rawBody: delivery.rawBody,\n ...(storedBody ? { storedBody } : {}),\n headers: { ...delivery.headers },\n ...(subjectKeys.length > 0 ? { subjectKeys } : {}),\n resolvedScope,\n // #2909: an unsigned notification is recorded as what it is, and a trailing one waits for its window.\n ...(reReadTrigger ? {\n senderAssurance: InboundSenderAssurance.UNVERIFIED,\n ...(reReadTrigger.notBefore ? { notBefore: reReadTrigger.notBefore } : {}),\n } : {}),\n ...(chatInput !== undefined ? { chatInput } : {}),\n }, applicationId);\n } catch (error) {\n this.logger.error('Inbound delivery could not be stored', { handlerRef: handler.ref, sourceKey: base.sourceKey, ...projectCaughtErrorLogFields(error) });\n if (storedBody) await this.storedBodies!.discard(storedBody.fileId, 'insert_failed');\n return ANSWER.retryLater;\n }\n\n // A body written for a row that was not stored (a concurrent copy won the key) or that does not name it is deleted.\n if (storedBody && (inserted.outcome === InboundDeliveryInsertOutcome.DUPLICATE || storedBodyFileIdOf(inserted.row) !== storedBody.fileId)) {\n await this.storedBodies!.discard(storedBody.fileId, 'not_stored');\n }\n if (inserted.outcome === InboundDeliveryInsertOutcome.DUPLICATE) return ANSWER.duplicate;\n if (inserted.row.resolvedScope.kind === InboundResolvedScopeKind.UNROUTABLE) {\n await this.audit.unroutable(inserted.row);\n return ANSWER.received;\n }\n await this.audit.accepted(inserted.row);\n await this.rememberPersonalConversation(handler, inserted.row.resolvedScope, delivery, personalConversation);\n // A failed enqueue leaves the row RECEIVED and due; the sweep picks it up. The sender is not told\n // to retry — the delivery IS stored, and a retry would only be deduplicated.\n const delayMs = reReadTrigger?.notBefore ? Math.max(0, reReadTrigger.notBefore.getTime() - this.clock().getTime()) : 0;\n await enqueueInboundDeliveryDispatch(this.queue, inserted.location, this.logger, delayMs);\n return ANSWER.received;\n }\n\n /**\n * Records the sender's personal conversation with the bot on their chat identity link (#2664 S5b), so the application\n * can post to them later without their writing first (a decision card). Every fact comes from the verified request\n * and its routing, none from a handler:\n *\n * - the organization is the one this delivery was routed to, and only an ORGANIZATION delivery has links;\n * - the connection is the delivery's provider, which every account it names belongs to;\n * - the bot is the one the verified token was for. An organization's own bot is admitted only for that organization,\n * so its conversation is recorded only in that organization's links; the application's bot reaches whichever\n * organization claimed the tenant.\n *\n * A person not linked there gets nothing recorded, and a failure is logged: the delivery is stored and runs either way.\n */\n private async rememberPersonalConversation(\n handler: AnyInboundHandlerDefinition,\n scope: InboundDeliveryResolvedScope,\n delivery: VerifiedInboundDelivery,\n conversation: Hook_InboundPersonalConversation | undefined,\n ): Promise<void> {\n const audience = delivery.verifiedAudience;\n if (!conversation || !audience || !this.chatLinks) return;\n if (handler.source.kind !== InboundSourceKind.PROVIDER_ENDPOINT || scope.kind !== InboundResolvedScopeKind.ORGANIZATION) return;\n if (audience.organizationId !== undefined && audience.organizationId !== scope.organizationId) return;\n try {\n await this.chatLinks.rememberPersonalConversation({\n organizationId: scope.organizationId,\n connectionRef: handler.source.providerRef,\n account: { workspaceRef: conversation.workspaceRef, chatUserId: conversation.chatUserId },\n botOwnerScope: audience.organizationId === undefined ? ChatBotOwnerScope.APPLICATION : ChatBotOwnerScope.ORGANIZATION,\n conversation: { conversationId: conversation.conversationId, serviceUrl: conversation.serviceUrl },\n });\n } catch (error) {\n this.logger.warn('A verified personal conversation could not be recorded on its chat identity link; the delivery runs regardless', {\n handlerRef: handler.ref, sourceKey: delivery.sourceKey, ...projectCaughtErrorLogFields(error),\n });\n }\n }\n\n /**\n * I3: the handler's declared mode decides what may be admitted. There is no fallback — a scope the\n * handler is not admitted to, and an organization or person that does not exist or confers no authority,\n * is `UNROUTABLE` and never runs.\n *\n * An ENGINE handler recording a third party's facts (billing, #1629) may run regardless of the scope's\n * STANDING — see `InboundScopeStandingPolicy`. A scope that does not exist is unroutable for every handler.\n */\n private async resolveScope(handler: AnyInboundHandlerDefinition, delivery: VerifiedInboundDelivery, payload: unknown): Promise<InboundDeliveryResolvedScope> {\n if (handler.scopeMode === InboundHandlerScopeMode.APPLICATION) return { kind: InboundResolvedScopeKind.APPLICATION };\n const resolved: InboundResolvedScope = await handler.resolveScope!(delivery, payload, this.lookups);\n const unroutable = (reason: InboundDeliveryUnroutableReason): InboundDeliveryResolvedScope => ({ kind: InboundResolvedScopeKind.UNROUTABLE, reason });\n const admitted = scopesAdmittedByHandler(handler);\n const regardlessOfStanding = inboundScopeStandingPolicyOf(handler) === InboundScopeStandingPolicy.RECORD_REGARDLESS_OF_STANDING;\n\n switch (resolved.kind) {\n case InboundResolvedScopeKind.UNROUTABLE:\n return unroutable(handler.scopeMode === InboundHandlerScopeMode.ORGANIZATION_REQUIRED\n ? InboundDeliveryUnroutableReason.NO_ORGANIZATION_RESOLVED\n : InboundDeliveryUnroutableReason.RESOLVER_DECLARED_UNROUTABLE);\n case InboundResolvedScopeKind.APPLICATION:\n return admitted.includes(InboundResolvedScopeKind.APPLICATION)\n ? { kind: InboundResolvedScopeKind.APPLICATION }\n : unroutable(InboundDeliveryUnroutableReason.SCOPE_NOT_ADMITTED_BY_HANDLER);\n case InboundResolvedScopeKind.ORGANIZATION: {\n if (!admitted.includes(InboundResolvedScopeKind.ORGANIZATION)) return unroutable(InboundDeliveryUnroutableReason.SCOPE_NOT_ADMITTED_BY_HANDLER);\n if (!resolved.organizationId) return unroutable(InboundDeliveryUnroutableReason.NO_ORGANIZATION_RESOLVED);\n const organization = await this.readOrganizationForRouting(resolved.organizationId);\n if (!organization) return unroutable(InboundDeliveryUnroutableReason.ORGANIZATION_NOT_FOUND);\n if (!regardlessOfStanding && !isAuthorityConferringOrganizationStatus(organization.status)) return unroutable(InboundDeliveryUnroutableReason.ORGANIZATION_WITHOUT_AUTHORITY);\n return { kind: InboundResolvedScopeKind.ORGANIZATION, organizationId: resolved.organizationId };\n }\n case InboundResolvedScopeKind.USER: {\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a person's own data is reached only by a handler that declared roles for that scope, and only for a person who exists (#1629).\n if (!admitted.includes(InboundResolvedScopeKind.USER)) return unroutable(InboundDeliveryUnroutableReason.SCOPE_NOT_ADMITTED_BY_HANDLER);\n if (!resolved.userId) return unroutable(InboundDeliveryUnroutableReason.USER_NOT_FOUND);\n const user = await this.readUserForRouting(resolved.userId);\n if (!user) return unroutable(InboundDeliveryUnroutableReason.USER_NOT_FOUND);\n if (!regardlessOfStanding && !isAuthorityConferringUserStatus(user.status)) return unroutable(InboundDeliveryUnroutableReason.USER_WITHOUT_AUTHORITY);\n return { kind: InboundResolvedScopeKind.USER, userId: resolved.userId };\n }\n default: {\n const unhandled: never = resolved;\n return unhandled;\n }\n }\n }\n\n /** The person a resolver named; an id the store cannot cast names no one. */\n private async readUserForRouting(userId: string): Promise<{ _id: string; status?: UserStatus } | null> {\n try {\n return await this.repositoriesRegistry.readUnscopedByKey<{ _id: string; status?: UserStatus }>(CoreResourceType.USERS, { _id: userId });\n } catch (error) {\n if (isMalformedIdLookupError(error)) return null;\n throw error;\n }\n }\n\n /**\n * The organization a resolver named. An id the store cannot cast names no organization, so it is NOT_FOUND\n * rather than a 500 the sender would retry forever.\n */\n private async readOrganizationForRouting(organizationId: string): Promise<{ _id: string; status?: OrganizationStatus } | null> {\n try {\n return await this.repositoriesRegistry.readUnscopedByKey<{ _id: string; status?: OrganizationStatus }>(CoreResourceType.ORGANIZATIONS, { _id: organizationId });\n } catch (error) {\n if (isMalformedIdLookupError(error)) return null;\n throw error;\n }\n }\n\n /**\n * Routing lookups for a resolver. They run on the infrastructure tier — BEFORE any handler authority\n * exists, under the engine's own routing authority — and answer only an organization id.\n */\n private readonly lookups: InboundScopeLookups = {\n findOrganizationIdByField: (resourceType: ResourceType, field: string, value: string) =>\n this.findScopeOwnerByField(resourceType, ResourcePrimaryScope.ORGANIZATIONS, 'organizationId', field, value),\n findUserIdByField: (resourceType: ResourceType, field: string, value: string) =>\n this.findScopeOwnerByField(resourceType, ResourcePrimaryScope.USER_SELF, 'userId', field, value),\n findOrganizationIdByConnectionFact: (connectionRef: string, factName: string, value: string) =>\n this.findOrganizationIdByConnectionFact(connectionRef, factName, value),\n };\n\n /**\n * See {@link InboundScopeLookups.findOrganizationIdByConnectionFact}. The fact name is a declared identifier\n * (`workspaceId`, `tenantId`), never caller text that could become a path operator, so anything else is refused.\n */\n private async findOrganizationIdByConnectionFact(connectionRef: string, factName: string, value: string): Promise<string | null> {\n if (!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(factName)) {\n throw new Error(`findOrganizationIdByConnectionFact: '${factName}' is not a fact name (a letter, then letters, digits or underscores)`);\n }\n if (typeof connectionRef !== 'string' || connectionRef.length === 0 || typeof value !== 'string' || value.length === 0) return null;\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a chat workspace or bot routes only to the organization its VENDOR reported or accepted, never on a typed value (#2660, #2663).\n // One lookup per trusted provenance, and the answer is an organization only when exactly one holds the value across\n // all of them: a value one organization's vendor reported and another's vendor accepted names no single organization.\n const owners = new Set<string>();\n for (const provenance of PROVIDER_CONNECTION_ROUTING_FACT_PROVENANCES) {\n const outcome = await this.findScopeOwnerOutcome(CoreResourceType.ORG_PROVIDER_CREDENTIALS, ResourcePrimaryScope.ORGANIZATIONS, 'organizationId', {\n connectionRef,\n enabled: true,\n [`connectionFacts.${factName}.value`]: value,\n [`connectionFacts.${factName}.provenance`]: provenance,\n }, 'findOrganizationIdByConnectionFact');\n if (outcome.kind === ScopeOwnerOutcome.AMBIGUOUS) return null;\n if (outcome.kind === ScopeOwnerOutcome.ONE) owners.add(outcome.owner);\n }\n return owners.size === 1 ? [...owners][0]! : null;\n }\n\n /**\n * The scope owner (`organizationId` or `userId`) of the row of `resourceType` whose `field` equals `value`, or\n * `null` — one implementation for both scopes, so the cross-owner refusal and the malformed-id rule cannot\n * be applied to one and forgotten on the other.\n */\n private async findScopeOwnerByField(\n resourceType: ResourceType,\n requiredScope: ResourcePrimaryScope.ORGANIZATIONS | ResourcePrimaryScope.USER_SELF,\n ownerField: 'organizationId' | 'userId',\n field: string,\n value: string,\n ): Promise<string | null> {\n const lookup = ownerField === 'organizationId' ? 'findOrganizationIdByField' : 'findUserIdByField';\n // Only a plain value is looked up: a payload schema permissive enough to pass an object here would\n // otherwise hand the store an operator (`{ $ne: null }`) that matches every row.\n if (typeof value !== 'string' || value.length === 0) {\n this.assertScopedResource(resourceType, requiredScope, ownerField, lookup);\n return null;\n }\n return this.findScopeOwner(resourceType, requiredScope, ownerField, { [field]: value }, lookup);\n }\n\n private assertScopedResource(resourceType: ResourceType, requiredScope: ResourcePrimaryScope, ownerField: 'organizationId' | 'userId', lookup: string): void {\n const configuration = this.resourcesRegistry.getResourceConfiguration(resourceType) as { resourcePrimaryScope?: ResourcePrimaryScope } | undefined;\n if (configuration?.resourcePrimaryScope !== requiredScope) {\n throw new Error(`${lookup}: '${resourceType}' is not a ${requiredScope}-scoped resource, so its rows name no ${ownerField === 'organizationId' ? 'organization' : 'person'}`);\n }\n }\n\n /**\n * The one owner whose rows of `resourceType` match `filter`, shared by every lookup so the cross-owner refusal and\n * the malformed-id rule cannot be applied to one and forgotten on another. Every value in `filter` is a plain value\n * its caller checked.\n */\n private async findScopeOwner(\n resourceType: ResourceType,\n requiredScope: ResourcePrimaryScope.ORGANIZATIONS | ResourcePrimaryScope.USER_SELF,\n ownerField: 'organizationId' | 'userId',\n filter: Record<string, unknown>,\n lookup: string,\n ): Promise<string | null> {\n const outcome = await this.findScopeOwnerOutcome(resourceType, requiredScope, ownerField, filter, lookup);\n return outcome.kind === ScopeOwnerOutcome.ONE ? outcome.owner : null;\n }\n\n /**\n * {@link findScopeOwner}, saying WHY there is no owner: no matching row, or rows of two different owners. A lookup\n * that combines several filters needs the difference, because two filters each naming one owner may name two.\n */\n private async findScopeOwnerOutcome(\n resourceType: ResourceType,\n requiredScope: ResourcePrimaryScope.ORGANIZATIONS | ResourcePrimaryScope.USER_SELF,\n ownerField: 'organizationId' | 'userId',\n filter: Record<string, unknown>,\n lookup: string,\n ): Promise<{ readonly kind: ScopeOwnerOutcome.ONE; readonly owner: string } | { readonly kind: ScopeOwnerOutcome.NONE | ScopeOwnerOutcome.AMBIGUOUS }> {\n this.assertScopedResource(resourceType, requiredScope, ownerField, lookup);\n const page = { sort: [{ field: '_id', order: SortOrder.ASC }], limit: 1 };\n try {\n const [first] = await this.repositoriesRegistry.findManyForInfrastructure<Record<string, unknown>>(resourceType, filter, undefined, undefined, page);\n const owner = first?.[ownerField];\n if (typeof owner !== 'string') return { kind: ScopeOwnerOutcome.NONE };\n // A value unique per owner but not across owners must not route to whichever owner's row sorts first:\n // a matching row belonging to ANY other owner makes the delivery unroutable.\n const [other] = await this.repositoriesRegistry.findManyForInfrastructure<Record<string, unknown>>(\n resourceType, { ...filter, [ownerField]: { $ne: owner } }, undefined, undefined, page,\n );\n return other ? { kind: ScopeOwnerOutcome.AMBIGUOUS } : { kind: ScopeOwnerOutcome.ONE, owner };\n } catch (error) {\n // The sender wrote the value, and the payload schema cannot know the store's id format (an ObjectId on\n // MongoDB, something else on PostgreSQL). A value the store cannot cast matches no row: unroutable, never\n // a 500 that tells the sender to retry the same malformed request forever.\n if (isMalformedIdLookupError(error)) return { kind: ScopeOwnerOutcome.NONE };\n throw error;\n }\n }\n\n\n private keptHeaders(headers: InboundRawRequest['headers'], names: readonly string[]): Record<string, string> {\n const kept: Record<string, string> = {};\n for (const name of names) {\n const value = headerString(headers, name.toLowerCase());\n if (value !== undefined) kept[name.toLowerCase()] = value;\n }\n return kept;\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { InboundChatInputKind, InboundChannelKind, InboundSenderAssurance, InboundDeliveryUnroutableReason, type InboundChatCommandRunResult, type InboundDeliveryBase, type InboundDeliveryBodyHolder, type InboundDeliveryResolvedScope, type ResourceType } from '@wildo-ai/saas-models';
2
2
  import type { RepositoriesRegistryHandlerBackendService } from '../../base-classes/services/repositories/repositories-registry-handler.backend.service';
3
3
  import { InboundScopeStandingPolicy } from '../../inbound/models/inbound-engine-handler.backend';
4
+ import { type InboundDeliveryStoredBodyBackendService, type StoredInboundBody } from './inbound-delivery-stored-body.backend.service';
4
5
  /** A stored delivery as the store returns it: the base row plus its variant's scope FK. */
5
6
  /** A delivery a wake made due: where it is, and when it is due, which a trailing re-read holds to its window (#2909). */
6
7
  export interface InboundDeliveryWakeup extends InboundDeliveryLocation {
@@ -39,6 +40,11 @@ export interface NewInboundDelivery {
39
40
  readonly signedAt?: Date;
40
41
  readonly receivedAt: Date;
41
42
  readonly rawBody: Buffer;
43
+ /**
44
+ * The body as written outside the row (#3395), when it is larger than the row holds: the receiver wrote and linked the
45
+ * file, and the row keeps its id, SHA-256 and length with an empty `rawBody`. Omitted: the body is kept in the row.
46
+ */
47
+ readonly storedBody?: StoredInboundBody;
42
48
  readonly headers: Record<string, string>;
43
49
  /** The people the payload names, as the handler declared them and the receiver normalized them (#1642). Omitted: none. */
44
50
  readonly subjectKeys?: readonly string[];
@@ -89,9 +95,19 @@ export declare function inboundDeliveryIdFor(sourceKey: string, dedupKey: string
89
95
  export declare function inboundDeliveryResourceTypeFor(scope: InboundDeliveryResolvedScope): ResourceType;
90
96
  export declare class InboundDeliveryStoreBackendService {
91
97
  private readonly repositoriesRegistry;
98
+ /**
99
+ * Deletes a body stored outside its row once a redaction released it (#3395). Bound in every backend; optional only for
100
+ * a store that never holds one (a unit test's). What it cannot delete now stays DELETED and the files cleanup removes it.
101
+ */
102
+ private readonly storedBodies?;
92
103
  /** The store's clock. A property rather than a constructor argument so DI never tries to inject it; tests replace it. */
93
104
  clock: () => Date;
94
- constructor(repositoriesRegistry: Pick<RepositoriesRegistryHandlerBackendService, 'readUnscopedByKey' | 'insertDocumentForInfrastructure' | 'atomicGuardedMutation' | 'findManyForInfrastructure'>);
105
+ constructor(repositoriesRegistry: Pick<RepositoriesRegistryHandlerBackendService, 'readUnscopedByKey' | 'insertDocumentForInfrastructure' | 'atomicGuardedMutation' | 'findManyForInfrastructure'>,
106
+ /**
107
+ * Deletes a body stored outside its row once a redaction released it (#3395). Bound in every backend; optional only for
108
+ * a store that never holds one (a unit test's). What it cannot delete now stays DELETED and the files cleanup removes it.
109
+ */
110
+ storedBodies?: Pick<InboundDeliveryStoredBodyBackendService, 'discard'>);
95
111
  /** Read one row where it lives. */
96
112
  read(location: InboundDeliveryLocation): Promise<InboundDeliveryRow | null>;
97
113
  /** Find a delivery by id in either variant. */
@@ -232,6 +248,11 @@ export declare class InboundDeliveryStoreBackendService {
232
248
  * is nothing left to act on. WITHOUT_AUTHORITY refuses unless the handler records regardless of standing.
233
249
  */
234
250
  scopeStandingRefusal(row: Pick<InboundDeliveryRow, 'resolvedScope'>, policy: InboundScopeStandingPolicy): Promise<InboundDeliveryUnroutableReason | null>;
251
+ /**
252
+ * A redaction won its compare-and-swap (#3395): the body the row named outside itself is deleted now, as its in-row copy
253
+ * just was. The row no longer names the file, so whatever this cannot delete is swept by the files cleanup.
254
+ */
255
+ private discardStoredBodyOf;
235
256
  private settle;
236
257
  }
237
258
  //# sourceMappingURL=inbound-delivery-store.backend.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inbound-delivery-store.backend.service.d.ts","sourceRoot":"","sources":["../../../../src/inbound/services/inbound-delivery-store.backend.service.ts"],"names":[],"mappings":"AAkCA,OAAO,EACL,oBAAoB,EAIpB,kBAAkB,EAIlB,sBAAsB,EACtB,+BAA+B,EAM/B,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAE9B,KAAK,4BAA4B,EACjC,KAAK,YAAY,EAElB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,qGAAqG,CAAC;AACrK,OAAO,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AAG9G,2FAA2F;AAC3F,yHAAyH;AACzH,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB;IACpE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;CACtB;AAED,MAAM,MAAM,kBAAkB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CAAC;IAqBlI;;;;;;;;OAQG;IACG,yBAAyB,CAAC,YAAY,EAAE,uBAAuB,CAAC,cAAc,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAoBlJ;;;;OAIG;IACG,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAQtF;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAMtE;;;OAGG;IACG,oBAAoB,CAAC,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,+BAA+B,GAAG,IAAI,CAAC;YAgBjJ,MAAM;CAQrB"}
1
+ {"version":3,"file":"inbound-delivery-store.backend.service.d.ts","sourceRoot":"","sources":["../../../../src/inbound/services/inbound-delivery-store.backend.service.ts"],"names":[],"mappings":"AAkCA,OAAO,EACL,oBAAoB,EAIpB,kBAAkB,EAIlB,sBAAsB,EACtB,+BAA+B,EAM/B,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAE9B,KAAK,4BAA4B,EACjC,KAAK,YAAY,EAElB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,qGAAqG,CAAC;AACrK,OAAO,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AAE9G,OAAO,EAAsB,KAAK,uCAAuC,EAAE,KAAK,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAE1J,2FAA2F;AAC3F,yHAAyH;AACzH,MAAM,WAAW,qBAAsB,SAAQ,uBAAuB;IACpE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;CACtB;AAED,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG;IACrD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAC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