@wildo-ai/saas-backend-lib 1.1.1 → 1.1.3

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 (972) hide show
  1. package/dist/esm/applications/services/worker-remote-client-factory.backend.service.d.ts.map +1 -1
  2. package/dist/esm/applications/services/worker-remote-client-factory.backend.service.js +19 -1
  3. package/dist/esm/applications/services/worker-remote-client-factory.backend.service.js.map +1 -1
  4. package/dist/esm/base-classes/models/manual-controllers.backend.definition.d.ts.map +1 -1
  5. package/dist/esm/base-classes/models/manual-controllers.backend.definition.js +4 -0
  6. package/dist/esm/base-classes/models/manual-controllers.backend.definition.js.map +1 -1
  7. package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.d.ts +35 -0
  8. package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.d.ts.map +1 -0
  9. package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.js +111 -0
  10. package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.js.map +1 -0
  11. package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.d.ts +50 -0
  12. package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.d.ts.map +1 -0
  13. package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.js +199 -0
  14. package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.js.map +1 -0
  15. package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.d.ts +111 -0
  16. package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.d.ts.map +1 -1
  17. package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.js +140 -0
  18. package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.js.map +1 -1
  19. package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.d.ts +14 -3
  20. package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.d.ts.map +1 -1
  21. package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.js +138 -24
  22. package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.js.map +1 -1
  23. package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.d.ts +3 -1
  24. package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.d.ts.map +1 -1
  25. package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.js +8 -3
  26. package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.js.map +1 -1
  27. package/dist/esm/base-classes/services/repositories/field-clearing-partition.backend.d.ts +11 -0
  28. package/dist/esm/base-classes/services/repositories/field-clearing-partition.backend.d.ts.map +1 -1
  29. package/dist/esm/base-classes/services/repositories/field-clearing-partition.backend.js +11 -2
  30. package/dist/esm/base-classes/services/repositories/field-clearing-partition.backend.js.map +1 -1
  31. package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.d.ts +124 -13
  32. package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.d.ts.map +1 -1
  33. package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.js +207 -21
  34. package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.js.map +1 -1
  35. package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.d.ts +60 -8
  36. package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.d.ts.map +1 -1
  37. package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.js +174 -26
  38. package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.js.map +1 -1
  39. package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.d.ts +48 -4
  40. package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.d.ts.map +1 -1
  41. package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.js +102 -30
  42. package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.js.map +1 -1
  43. package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.d.ts +55 -0
  44. package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.d.ts.map +1 -0
  45. package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.js +114 -0
  46. package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.js.map +1 -0
  47. package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.d.ts +89 -14
  48. package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.d.ts.map +1 -1
  49. package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.js +84 -11
  50. package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.js.map +1 -1
  51. package/dist/esm/base-classes/services/repositories/http-api/odata-query-compiler.backend.d.ts.map +1 -1
  52. package/dist/esm/base-classes/services/repositories/http-api/odata-query-compiler.backend.js +16 -0
  53. package/dist/esm/base-classes/services/repositories/http-api/odata-query-compiler.backend.js.map +1 -1
  54. package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.d.ts +20 -6
  55. package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.d.ts.map +1 -1
  56. package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.js +96 -32
  57. package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.js.map +1 -1
  58. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-repository.backend.service.d.ts +3 -1
  59. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-repository.backend.service.d.ts.map +1 -1
  60. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-repository.backend.service.js +32 -7
  61. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-repository.backend.service.js.map +1 -1
  62. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-source.backend.port.d.ts +8 -5
  63. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-source.backend.port.d.ts.map +1 -1
  64. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-source.backend.port.js.map +1 -1
  65. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.d.ts +80 -0
  66. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.d.ts.map +1 -1
  67. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.js +298 -23
  68. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.js.map +1 -1
  69. package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.d.ts +71 -1
  70. package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.d.ts.map +1 -1
  71. package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.js +85 -5
  72. package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.js.map +1 -1
  73. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.d.ts +21 -0
  74. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.d.ts.map +1 -1
  75. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.js +146 -4
  76. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.js.map +1 -1
  77. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-base.backend.service.d.ts +22 -0
  78. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-base.backend.service.d.ts.map +1 -1
  79. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-base.backend.service.js.map +1 -1
  80. package/dist/esm/base-classes/services/services/resource-operation-implementation-coverage.backend.utils.d.ts +3 -26
  81. package/dist/esm/base-classes/services/services/resource-operation-implementation-coverage.backend.utils.d.ts.map +1 -1
  82. package/dist/esm/base-classes/services/services/resource-operation-implementation-coverage.backend.utils.js +3 -68
  83. package/dist/esm/base-classes/services/services/resource-operation-implementation-coverage.backend.utils.js.map +1 -1
  84. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.d.ts.map +1 -1
  85. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js +4 -1
  86. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js.map +1 -1
  87. package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.d.ts +11 -0
  88. package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.d.ts.map +1 -1
  89. package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.js +39 -5
  90. package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.js.map +1 -1
  91. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts +181 -2
  92. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts.map +1 -1
  93. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js +533 -43
  94. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js.map +1 -1
  95. package/dist/esm/base-classes/services/services/system-access.backend.service.d.ts +36 -3
  96. package/dist/esm/base-classes/services/services/system-access.backend.service.d.ts.map +1 -1
  97. package/dist/esm/base-classes/services/services/system-access.backend.service.js +70 -8
  98. package/dist/esm/base-classes/services/services/system-access.backend.service.js.map +1 -1
  99. package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.d.ts +28 -0
  100. package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.d.ts.map +1 -0
  101. package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.js +90 -0
  102. package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.js.map +1 -0
  103. package/dist/esm/billing/batches/usage-flush.batch.backend.service.d.ts +44 -0
  104. package/dist/esm/billing/batches/usage-flush.batch.backend.service.d.ts.map +1 -0
  105. package/dist/esm/billing/batches/usage-flush.batch.backend.service.js +99 -0
  106. package/dist/esm/billing/batches/usage-flush.batch.backend.service.js.map +1 -0
  107. package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.d.ts +91 -0
  108. package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.d.ts.map +1 -0
  109. package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.js +152 -0
  110. package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.js.map +1 -0
  111. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.d.ts +186 -0
  112. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.d.ts.map +1 -0
  113. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.js +474 -0
  114. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.js.map +1 -0
  115. package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.d.ts +100 -0
  116. package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.d.ts.map +1 -1
  117. package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.js +209 -6
  118. package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.js.map +1 -1
  119. package/dist/esm/billing/services/back-office/usage-metering.backend.service.d.ts +200 -4
  120. package/dist/esm/billing/services/back-office/usage-metering.backend.service.d.ts.map +1 -1
  121. package/dist/esm/billing/services/back-office/usage-metering.backend.service.js +593 -64
  122. package/dist/esm/billing/services/back-office/usage-metering.backend.service.js.map +1 -1
  123. package/dist/esm/billing/services/billing-adapter-registry.backend.d.ts +36 -0
  124. package/dist/esm/billing/services/billing-adapter-registry.backend.d.ts.map +1 -0
  125. package/dist/esm/billing/services/billing-adapter-registry.backend.js +83 -0
  126. package/dist/esm/billing/services/billing-adapter-registry.backend.js.map +1 -0
  127. package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.d.ts +9 -0
  128. package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.d.ts.map +1 -1
  129. package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.js +11 -1
  130. package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.js.map +1 -1
  131. package/dist/esm/billing/services/custom-impl/billing-account.mutations.custom-impl.backend.service.d.ts.map +1 -1
  132. package/dist/esm/billing/services/custom-impl/billing-account.mutations.custom-impl.backend.service.js +54 -13
  133. package/dist/esm/billing/services/custom-impl/billing-account.mutations.custom-impl.backend.service.js.map +1 -1
  134. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.d.ts +38 -1
  135. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.d.ts.map +1 -1
  136. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.js +67 -2
  137. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.js.map +1 -1
  138. package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.d.ts +30 -1
  139. package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.d.ts.map +1 -1
  140. package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.js +43 -1
  141. package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.js.map +1 -1
  142. package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.d.ts +11 -3
  143. package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.d.ts.map +1 -1
  144. package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.js +30 -16
  145. package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.js.map +1 -1
  146. package/dist/esm/billing/services/custom-impl/subscription.mutations.custom-impl.backend.service.d.ts.map +1 -1
  147. package/dist/esm/billing/services/custom-impl/subscription.mutations.custom-impl.backend.service.js +104 -25
  148. package/dist/esm/billing/services/custom-impl/subscription.mutations.custom-impl.backend.service.js.map +1 -1
  149. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.d.ts +18 -1
  150. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.d.ts.map +1 -1
  151. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.js +106 -2
  152. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.js.map +1 -1
  153. package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.d.ts +52 -0
  154. package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.d.ts.map +1 -0
  155. package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.js +74 -0
  156. package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.js.map +1 -0
  157. package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.d.ts +104 -11
  158. package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.d.ts.map +1 -1
  159. package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.js +260 -26
  160. package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.js.map +1 -1
  161. package/dist/esm/billing/testing/mock-billing-provider.d.ts +30 -1
  162. package/dist/esm/billing/testing/mock-billing-provider.d.ts.map +1 -1
  163. package/dist/esm/billing/testing/mock-billing-provider.js +25 -0
  164. package/dist/esm/billing/testing/mock-billing-provider.js.map +1 -1
  165. package/dist/esm/compliance/audit-trails/batches/audit-logs-archive.batch.backend.service.js +11 -4
  166. package/dist/esm/compliance/audit-trails/batches/audit-logs-archive.batch.backend.service.js.map +1 -1
  167. package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.d.ts +263 -13
  168. package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.d.ts.map +1 -1
  169. package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.js +376 -58
  170. package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.js.map +1 -1
  171. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.d.ts +264 -7
  172. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.d.ts.map +1 -1
  173. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.js +414 -5
  174. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.js.map +1 -1
  175. package/dist/esm/compliance/audit-trails/services/composite-audit-log-sink.backend.d.ts.map +1 -1
  176. package/dist/esm/compliance/audit-trails/services/composite-audit-log-sink.backend.js +7 -1
  177. package/dist/esm/compliance/audit-trails/services/composite-audit-log-sink.backend.js.map +1 -1
  178. package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.d.ts +16 -0
  179. package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.d.ts.map +1 -0
  180. package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.js +140 -0
  181. package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.js.map +1 -0
  182. package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.d.ts +42 -0
  183. package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.d.ts.map +1 -1
  184. package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.js +65 -6
  185. package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.js.map +1 -1
  186. package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.d.ts +110 -0
  187. package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.d.ts.map +1 -0
  188. package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.js +192 -0
  189. package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.js.map +1 -0
  190. package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.d.ts.map +1 -1
  191. package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.js +45 -0
  192. package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.js.map +1 -1
  193. package/dist/esm/config/bootstrap/application-runtime-profile.backend.d.ts +5 -0
  194. package/dist/esm/config/bootstrap/application-runtime-profile.backend.d.ts.map +1 -1
  195. package/dist/esm/config/bootstrap/application-runtime-profile.backend.js +6 -0
  196. package/dist/esm/config/bootstrap/application-runtime-profile.backend.js.map +1 -1
  197. package/dist/esm/config/custom/application-config-controller.backend.service.d.ts.map +1 -1
  198. package/dist/esm/config/custom/application-config-controller.backend.service.js +7 -1
  199. package/dist/esm/config/custom/application-config-controller.backend.service.js.map +1 -1
  200. package/dist/esm/config/models/app-config.backend.schemas.d.ts +146 -46
  201. package/dist/esm/config/models/app-config.backend.schemas.d.ts.map +1 -1
  202. package/dist/esm/config/models/app-config.backend.schemas.js +121 -12
  203. package/dist/esm/config/models/app-config.backend.schemas.js.map +1 -1
  204. package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.d.ts +38 -15
  205. package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.d.ts.map +1 -1
  206. package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.js +17 -2
  207. package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.js.map +1 -1
  208. package/dist/esm/config/services/app-configuration-loader.backend.service.d.ts +0 -1
  209. package/dist/esm/config/services/app-configuration-loader.backend.service.d.ts.map +1 -1
  210. package/dist/esm/config/services/app-configuration-loader.backend.service.js +68 -76
  211. package/dist/esm/config/services/app-configuration-loader.backend.service.js.map +1 -1
  212. package/dist/esm/config/services/app-configuration.backend.service.d.ts.map +1 -1
  213. package/dist/esm/config/services/app-configuration.backend.service.js +23 -1
  214. package/dist/esm/config/services/app-configuration.backend.service.js.map +1 -1
  215. package/dist/esm/config/services/app-configuration.backend.utils.d.ts +43 -1
  216. package/dist/esm/config/services/app-configuration.backend.utils.d.ts.map +1 -1
  217. package/dist/esm/config/services/app-configuration.backend.utils.js +52 -3
  218. package/dist/esm/config/services/app-configuration.backend.utils.js.map +1 -1
  219. package/dist/esm/config/services/application-startup-config-validator.backend.service.d.ts +25 -0
  220. package/dist/esm/config/services/application-startup-config-validator.backend.service.d.ts.map +1 -1
  221. package/dist/esm/config/services/application-startup-config-validator.backend.service.js +41 -1
  222. package/dist/esm/config/services/application-startup-config-validator.backend.service.js.map +1 -1
  223. package/dist/esm/data-seeding/services/shared/data-seed-scope-iteration.shared.utils.d.ts +2 -2
  224. package/dist/esm/data-seeding/services/shared/data-seed-scope-iteration.shared.utils.js +2 -2
  225. package/dist/esm/data-seeding/services/shared/data-seed-scope-iteration.shared.utils.js.map +1 -1
  226. package/dist/esm/databases/models/filter.backend.schemas.js +2 -2
  227. package/dist/esm/databases/models/filter.backend.schemas.js.map +1 -1
  228. package/dist/esm/databases/services/aggregation/aggregation-authorization.backend.service.d.ts.map +1 -1
  229. package/dist/esm/databases/services/aggregation/aggregation-authorization.backend.service.js +20 -1
  230. package/dist/esm/databases/services/aggregation/aggregation-authorization.backend.service.js.map +1 -1
  231. package/dist/esm/databases/services/postgresql-schema-plan-diff.backend.d.ts.map +1 -1
  232. package/dist/esm/databases/services/postgresql-schema-plan-diff.backend.js +48 -0
  233. package/dist/esm/databases/services/postgresql-schema-plan-diff.backend.js.map +1 -1
  234. package/dist/esm/databases/services/redis.service.d.ts +27 -0
  235. package/dist/esm/databases/services/redis.service.d.ts.map +1 -1
  236. package/dist/esm/databases/services/redis.service.js +29 -0
  237. package/dist/esm/databases/services/redis.service.js.map +1 -1
  238. package/dist/esm/errors/services/error-builder.backend.service.d.ts +13 -1
  239. package/dist/esm/errors/services/error-builder.backend.service.d.ts.map +1 -1
  240. package/dist/esm/errors/services/error-builder.backend.service.js +13 -1
  241. package/dist/esm/errors/services/error-builder.backend.service.js.map +1 -1
  242. package/dist/esm/errors/services/error-handler.backend.service.d.ts +70 -7
  243. package/dist/esm/errors/services/error-handler.backend.service.d.ts.map +1 -1
  244. package/dist/esm/errors/services/error-handler.backend.service.js +134 -8
  245. package/dist/esm/errors/services/error-handler.backend.service.js.map +1 -1
  246. package/dist/esm/errors/services/rate-limit.backend.service.d.ts +66 -0
  247. package/dist/esm/errors/services/rate-limit.backend.service.d.ts.map +1 -1
  248. package/dist/esm/errors/services/rate-limit.backend.service.js +102 -25
  249. package/dist/esm/errors/services/rate-limit.backend.service.js.map +1 -1
  250. package/dist/esm/errors/utils/error-log-level-classification.backend.utils.d.ts +5 -0
  251. package/dist/esm/errors/utils/error-log-level-classification.backend.utils.d.ts.map +1 -1
  252. package/dist/esm/errors/utils/error-log-level-classification.backend.utils.js +25 -0
  253. package/dist/esm/errors/utils/error-log-level-classification.backend.utils.js.map +1 -1
  254. package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.d.ts +33 -0
  255. package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.d.ts.map +1 -1
  256. package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.js +40 -0
  257. package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.js.map +1 -1
  258. package/dist/esm/external-data/controllers/external-data-admin.backend.contracts.d.ts +41 -0
  259. package/dist/esm/external-data/controllers/external-data-admin.backend.contracts.d.ts.map +1 -0
  260. package/dist/esm/external-data/controllers/external-data-admin.backend.contracts.js +40 -0
  261. package/dist/esm/external-data/controllers/external-data-admin.backend.contracts.js.map +1 -0
  262. package/dist/esm/external-data/controllers/external-data-admin.backend.controller.d.ts +64 -0
  263. package/dist/esm/external-data/controllers/external-data-admin.backend.controller.d.ts.map +1 -0
  264. package/dist/esm/external-data/controllers/external-data-admin.backend.controller.js +193 -0
  265. package/dist/esm/external-data/controllers/external-data-admin.backend.controller.js.map +1 -0
  266. package/dist/esm/external-data/external-data-pipeline-run.backend.service.d.ts +72 -4
  267. package/dist/esm/external-data/external-data-pipeline-run.backend.service.d.ts.map +1 -1
  268. package/dist/esm/external-data/external-data-pipeline-run.backend.service.js +60 -19
  269. package/dist/esm/external-data/external-data-pipeline-run.backend.service.js.map +1 -1
  270. package/dist/esm/external-data/external-data-transform.backend.d.ts.map +1 -1
  271. package/dist/esm/external-data/external-data-transform.backend.js +7 -1
  272. package/dist/esm/external-data/external-data-transform.backend.js.map +1 -1
  273. package/dist/esm/external-data/models/external-data-pipeline-state.backend.schemas.d.ts +2 -0
  274. package/dist/esm/external-data/models/external-data-pipeline-state.backend.schemas.d.ts.map +1 -1
  275. package/dist/esm/external-data/models/external-data-pipeline-state.backend.schemas.js +13 -0
  276. package/dist/esm/external-data/models/external-data-pipeline-state.backend.schemas.js.map +1 -1
  277. package/dist/esm/external-providers/models/provider-selection-resolution-evidence.backend.definitions.d.ts +4 -2
  278. package/dist/esm/external-providers/models/provider-selection-resolution-evidence.backend.definitions.d.ts.map +1 -1
  279. package/dist/esm/external-providers/models/provider-selection-resolution-evidence.backend.definitions.js.map +1 -1
  280. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.d.ts +256 -0
  281. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.d.ts.map +1 -0
  282. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.js +333 -0
  283. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.js.map +1 -0
  284. package/dist/esm/external-providers/operations/provider-operation-request.backend.d.ts +56 -0
  285. package/dist/esm/external-providers/operations/provider-operation-request.backend.d.ts.map +1 -0
  286. package/dist/esm/external-providers/operations/provider-operation-request.backend.js +211 -0
  287. package/dist/esm/external-providers/operations/provider-operation-request.backend.js.map +1 -0
  288. package/dist/esm/external-providers/operations/provider-request-signing.backend.d.ts +45 -0
  289. package/dist/esm/external-providers/operations/provider-request-signing.backend.d.ts.map +1 -0
  290. package/dist/esm/external-providers/operations/provider-request-signing.backend.js +216 -0
  291. package/dist/esm/external-providers/operations/provider-request-signing.backend.js.map +1 -0
  292. package/dist/esm/external-providers/operations/provider-rest-call-client.backend.d.ts +56 -0
  293. package/dist/esm/external-providers/operations/provider-rest-call-client.backend.d.ts.map +1 -0
  294. package/dist/esm/external-providers/operations/provider-rest-call-client.backend.js +78 -0
  295. package/dist/esm/external-providers/operations/provider-rest-call-client.backend.js.map +1 -0
  296. package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.d.ts +1 -1
  297. package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.d.ts.map +1 -1
  298. package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.js +2 -2
  299. package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.js.map +1 -1
  300. package/dist/esm/external-providers/services/backend-provider-loader.backend.service.d.ts +89 -0
  301. package/dist/esm/external-providers/services/backend-provider-loader.backend.service.d.ts.map +1 -0
  302. package/dist/esm/external-providers/services/backend-provider-loader.backend.service.js +164 -0
  303. package/dist/esm/external-providers/services/backend-provider-loader.backend.service.js.map +1 -0
  304. package/dist/esm/external-providers/services/backend-provider-registry.backend.service.d.ts +26 -27
  305. package/dist/esm/external-providers/services/backend-provider-registry.backend.service.d.ts.map +1 -1
  306. package/dist/esm/external-providers/services/backend-provider-registry.backend.service.js +50 -64
  307. package/dist/esm/external-providers/services/backend-provider-registry.backend.service.js.map +1 -1
  308. package/dist/esm/external-providers/services/document-extraction.backend.service.d.ts.map +1 -1
  309. package/dist/esm/external-providers/services/document-extraction.backend.service.js +3 -3
  310. package/dist/esm/external-providers/services/document-extraction.backend.service.js.map +1 -1
  311. package/dist/esm/external-providers/services/embeddings.backend.service.d.ts.map +1 -1
  312. package/dist/esm/external-providers/services/embeddings.backend.service.js +4 -4
  313. package/dist/esm/external-providers/services/embeddings.backend.service.js.map +1 -1
  314. package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts +306 -7
  315. package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts.map +1 -1
  316. package/dist/esm/external-providers/services/external-providers-registry.backend.service.js +539 -45
  317. package/dist/esm/external-providers/services/external-providers-registry.backend.service.js.map +1 -1
  318. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.d.ts.map +1 -1
  319. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.js +25 -2
  320. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.js.map +1 -1
  321. package/dist/esm/files/controllers/file.controller.d.ts +24 -1
  322. package/dist/esm/files/controllers/file.controller.d.ts.map +1 -1
  323. package/dist/esm/files/controllers/file.controller.js +83 -11
  324. package/dist/esm/files/controllers/file.controller.js.map +1 -1
  325. package/dist/esm/files/handlers/file-upload-route-locals.backend.types.d.ts +17 -0
  326. package/dist/esm/files/handlers/file-upload-route-locals.backend.types.d.ts.map +1 -0
  327. package/dist/esm/files/handlers/file-upload-route-locals.backend.types.js +1 -0
  328. package/dist/esm/files/handlers/file-upload-route-locals.backend.types.js.map +1 -0
  329. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.d.ts +5 -1
  330. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.d.ts.map +1 -1
  331. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.js +76 -13
  332. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.js.map +1 -1
  333. package/dist/esm/files/services/file-operation-handler.backend.service.d.ts +18 -0
  334. package/dist/esm/files/services/file-operation-handler.backend.service.d.ts.map +1 -1
  335. package/dist/esm/files/services/file-operation-handler.backend.service.js +36 -28
  336. package/dist/esm/files/services/file-operation-handler.backend.service.js.map +1 -1
  337. package/dist/esm/files/services/file-scanning.backend.service.d.ts +94 -9
  338. package/dist/esm/files/services/file-scanning.backend.service.d.ts.map +1 -1
  339. package/dist/esm/files/services/file-scanning.backend.service.js +197 -17
  340. package/dist/esm/files/services/file-scanning.backend.service.js.map +1 -1
  341. package/dist/esm/files/services/file-text-extraction.backend.service.d.ts +60 -1
  342. package/dist/esm/files/services/file-text-extraction.backend.service.d.ts.map +1 -1
  343. package/dist/esm/files/services/file-text-extraction.backend.service.js +167 -8
  344. package/dist/esm/files/services/file-text-extraction.backend.service.js.map +1 -1
  345. package/dist/esm/files/services/file-upload-grant.backend.service.d.ts +214 -0
  346. package/dist/esm/files/services/file-upload-grant.backend.service.d.ts.map +1 -0
  347. package/dist/esm/files/services/file-upload-grant.backend.service.js +566 -0
  348. package/dist/esm/files/services/file-upload-grant.backend.service.js.map +1 -0
  349. package/dist/esm/files/services/files.backend.service.d.ts +87 -0
  350. package/dist/esm/files/services/files.backend.service.d.ts.map +1 -1
  351. package/dist/esm/files/services/files.backend.service.js +252 -19
  352. package/dist/esm/files/services/files.backend.service.js.map +1 -1
  353. package/dist/esm/files/storage/application-storage-key.backend.utils.d.ts +109 -0
  354. package/dist/esm/files/storage/application-storage-key.backend.utils.d.ts.map +1 -0
  355. package/dist/esm/files/storage/application-storage-key.backend.utils.js +123 -0
  356. package/dist/esm/files/storage/application-storage-key.backend.utils.js.map +1 -0
  357. package/dist/esm/files/storage/file-storage-provider.types.d.ts +16 -10
  358. package/dist/esm/files/storage/file-storage-provider.types.d.ts.map +1 -1
  359. package/dist/esm/files/storage/file-storage-provider.types.js.map +1 -1
  360. package/dist/esm/files/storage/local-directory-storage-provider.backend.service.d.ts +67 -8
  361. package/dist/esm/files/storage/local-directory-storage-provider.backend.service.d.ts.map +1 -1
  362. package/dist/esm/files/storage/local-directory-storage-provider.backend.service.js +101 -28
  363. package/dist/esm/files/storage/local-directory-storage-provider.backend.service.js.map +1 -1
  364. package/dist/esm/files/storage/wildo-managed-storage-provider.backend.service.d.ts.map +1 -1
  365. package/dist/esm/files/storage/wildo-managed-storage-provider.backend.service.js +8 -55
  366. package/dist/esm/files/storage/wildo-managed-storage-provider.backend.service.js.map +1 -1
  367. package/dist/esm/files/utils/file-field-schema-path.backend.utils.d.ts.map +1 -1
  368. package/dist/esm/files/utils/file-field-schema-path.backend.utils.js +20 -0
  369. package/dist/esm/files/utils/file-field-schema-path.backend.utils.js.map +1 -1
  370. package/dist/esm/files/utils/file-uploader.utils.d.ts.map +1 -1
  371. package/dist/esm/files/utils/file-uploader.utils.js +12 -0
  372. package/dist/esm/files/utils/file-uploader.utils.js.map +1 -1
  373. package/dist/esm/files/utils/office-document-text-extraction.backend.utils.d.ts +86 -0
  374. package/dist/esm/files/utils/office-document-text-extraction.backend.utils.d.ts.map +1 -0
  375. package/dist/esm/files/utils/office-document-text-extraction.backend.utils.js +288 -0
  376. package/dist/esm/files/utils/office-document-text-extraction.backend.utils.js.map +1 -0
  377. package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.d.ts +15 -0
  378. package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.d.ts.map +1 -1
  379. package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.js +76 -5
  380. package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.js.map +1 -1
  381. package/dist/esm/flows-actors/a2a/controllers/a2a.controller.d.ts.map +1 -1
  382. package/dist/esm/flows-actors/a2a/controllers/a2a.controller.js +6 -1
  383. package/dist/esm/flows-actors/a2a/controllers/a2a.controller.js.map +1 -1
  384. package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.d.ts +60 -0
  385. package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.d.ts.map +1 -1
  386. package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.js +63 -0
  387. package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.js.map +1 -1
  388. package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.d.ts +74 -0
  389. package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.d.ts.map +1 -1
  390. package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.js +200 -44
  391. package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.js.map +1 -1
  392. package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.d.ts +7 -1
  393. package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.d.ts.map +1 -1
  394. package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.js +53 -1
  395. package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.js.map +1 -1
  396. package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.d.ts +18 -0
  397. package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.d.ts.map +1 -1
  398. package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.js +18 -0
  399. package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.js.map +1 -1
  400. package/dist/esm/flows-actors/a2a/services/a2a.backend.service.d.ts +12 -7
  401. package/dist/esm/flows-actors/a2a/services/a2a.backend.service.d.ts.map +1 -1
  402. package/dist/esm/flows-actors/a2a/services/a2a.backend.service.js.map +1 -1
  403. package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.d.ts +0 -13
  404. package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.d.ts.map +1 -1
  405. package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.js +14 -22
  406. package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.js.map +1 -1
  407. package/dist/esm/flows-actors/models/core-facets.backend.definitions.d.ts +8 -3
  408. package/dist/esm/flows-actors/models/core-facets.backend.definitions.d.ts.map +1 -1
  409. package/dist/esm/flows-actors/models/core-facets.backend.definitions.js +25 -15
  410. package/dist/esm/flows-actors/models/core-facets.backend.definitions.js.map +1 -1
  411. package/dist/esm/flows-actors/models/flows-actors.backend.schemas.d.ts +13 -1
  412. package/dist/esm/flows-actors/models/flows-actors.backend.schemas.d.ts.map +1 -1
  413. package/dist/esm/flows-actors/models/flows-actors.backend.schemas.js.map +1 -1
  414. package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts +88 -8
  415. package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts.map +1 -1
  416. package/dist/esm/flows-actors/models/function-tools.backend.definitions.js +333 -31
  417. package/dist/esm/flows-actors/models/function-tools.backend.definitions.js.map +1 -1
  418. package/dist/esm/flows-actors/models/market-generation.actors-system.backend.definitions.d.ts.map +1 -1
  419. package/dist/esm/flows-actors/models/market-generation.actors-system.backend.definitions.js +4 -2
  420. package/dist/esm/flows-actors/models/market-generation.actors-system.backend.definitions.js.map +1 -1
  421. package/dist/esm/flows-actors/models/mcp-client.backend.definitions.d.ts +113 -0
  422. package/dist/esm/flows-actors/models/mcp-client.backend.definitions.d.ts.map +1 -0
  423. package/dist/esm/flows-actors/models/mcp-client.backend.definitions.js +62 -0
  424. package/dist/esm/flows-actors/models/mcp-client.backend.definitions.js.map +1 -0
  425. package/dist/esm/flows-actors/services/actors-system.backend.service.d.ts.map +1 -1
  426. package/dist/esm/flows-actors/services/actors-system.backend.service.js +0 -2
  427. package/dist/esm/flows-actors/services/actors-system.backend.service.js.map +1 -1
  428. package/dist/esm/flows-actors/services/agents.backend.service.d.ts +107 -1
  429. package/dist/esm/flows-actors/services/agents.backend.service.d.ts.map +1 -1
  430. package/dist/esm/flows-actors/services/agents.backend.service.js +519 -56
  431. package/dist/esm/flows-actors/services/agents.backend.service.js.map +1 -1
  432. package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts +5 -1
  433. package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts.map +1 -1
  434. package/dist/esm/flows-actors/services/conversational-execution.backend.service.js +79 -16
  435. package/dist/esm/flows-actors/services/conversational-execution.backend.service.js.map +1 -1
  436. package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts +34 -5
  437. package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts.map +1 -1
  438. package/dist/esm/flows-actors/services/flows-actors-registry.service.js +154 -20
  439. package/dist/esm/flows-actors/services/flows-actors-registry.service.js.map +1 -1
  440. package/dist/esm/flows-actors/services/flows.backend.services.d.ts.map +1 -1
  441. package/dist/esm/flows-actors/services/flows.backend.services.js +27 -23
  442. package/dist/esm/flows-actors/services/flows.backend.services.js.map +1 -1
  443. package/dist/esm/flows-actors/services/llm-observability-agent-call-trace-sink.backend.d.ts.map +1 -1
  444. package/dist/esm/flows-actors/services/llm-observability-agent-call-trace-sink.backend.js +7 -1
  445. package/dist/esm/flows-actors/services/llm-observability-agent-call-trace-sink.backend.js.map +1 -1
  446. package/dist/esm/flows-actors/services/mcp-client.backend.service.d.ts +90 -0
  447. package/dist/esm/flows-actors/services/mcp-client.backend.service.d.ts.map +1 -0
  448. package/dist/esm/flows-actors/services/mcp-client.backend.service.js +368 -0
  449. package/dist/esm/flows-actors/services/mcp-client.backend.service.js.map +1 -0
  450. package/dist/esm/flows-actors/services/prompt-compiler.backend.service.d.ts +9 -5
  451. package/dist/esm/flows-actors/services/prompt-compiler.backend.service.d.ts.map +1 -1
  452. package/dist/esm/flows-actors/services/prompt-compiler.backend.service.js +12 -17
  453. package/dist/esm/flows-actors/services/prompt-compiler.backend.service.js.map +1 -1
  454. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts +151 -41
  455. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts.map +1 -1
  456. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js +308 -143
  457. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js.map +1 -1
  458. package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.d.ts +0 -207
  459. package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.d.ts.map +1 -1
  460. package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.js +8 -243
  461. package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.js.map +1 -1
  462. package/dist/esm/flows-actors/utils/meta-workflow-structured-generation-plan.backend.utils.d.ts.map +1 -1
  463. package/dist/esm/flows-actors/utils/meta-workflow-structured-generation-plan.backend.utils.js.map +1 -1
  464. package/dist/esm/guidance/services/milestone-evaluator.backend.service.d.ts +9 -14
  465. package/dist/esm/guidance/services/milestone-evaluator.backend.service.d.ts.map +1 -1
  466. package/dist/esm/guidance/services/milestone-evaluator.backend.service.js +18 -89
  467. package/dist/esm/guidance/services/milestone-evaluator.backend.service.js.map +1 -1
  468. package/dist/esm/guidance/services/progression-state-store.backend.service.d.ts +86 -0
  469. package/dist/esm/guidance/services/progression-state-store.backend.service.d.ts.map +1 -0
  470. package/dist/esm/guidance/services/progression-state-store.backend.service.js +155 -0
  471. package/dist/esm/guidance/services/progression-state-store.backend.service.js.map +1 -0
  472. package/dist/esm/i18n/controllers/i18n-controller.backend.service.d.ts +10 -0
  473. package/dist/esm/i18n/controllers/i18n-controller.backend.service.d.ts.map +1 -1
  474. package/dist/esm/i18n/controllers/i18n-controller.backend.service.js +55 -5
  475. package/dist/esm/i18n/controllers/i18n-controller.backend.service.js.map +1 -1
  476. package/dist/esm/index.d.ts +15 -5
  477. package/dist/esm/index.d.ts.map +1 -1
  478. package/dist/esm/index.js +45 -5
  479. package/dist/esm/index.js.map +1 -1
  480. package/dist/esm/inject/models/container.d.ts.map +1 -1
  481. package/dist/esm/inject/models/container.js +82 -10
  482. package/dist/esm/inject/models/container.js.map +1 -1
  483. package/dist/esm/inject/models/service-types.d.ts +20 -3
  484. package/dist/esm/inject/models/service-types.d.ts.map +1 -1
  485. package/dist/esm/inject/models/service-types.js +21 -3
  486. package/dist/esm/inject/models/service-types.js.map +1 -1
  487. package/dist/esm/mcp/controllers/mcp.controller.d.ts.map +1 -1
  488. package/dist/esm/mcp/controllers/mcp.controller.js +32 -4
  489. package/dist/esm/mcp/controllers/mcp.controller.js.map +1 -1
  490. package/dist/esm/mcp/models/mcp-tool.backend.schemas.d.ts +34 -0
  491. package/dist/esm/mcp/models/mcp-tool.backend.schemas.d.ts.map +1 -1
  492. package/dist/esm/mcp/models/mcp-tool.backend.schemas.js +42 -0
  493. package/dist/esm/mcp/models/mcp-tool.backend.schemas.js.map +1 -1
  494. package/dist/esm/mcp/services/mcp-server.backend.service.d.ts +84 -1
  495. package/dist/esm/mcp/services/mcp-server.backend.service.d.ts.map +1 -1
  496. package/dist/esm/mcp/services/mcp-server.backend.service.js +235 -11
  497. package/dist/esm/mcp/services/mcp-server.backend.service.js.map +1 -1
  498. package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.d.ts +64 -2
  499. package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.d.ts.map +1 -1
  500. package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.js +152 -6
  501. package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.js.map +1 -1
  502. package/dist/esm/monitoring/analytics/controllers/analytics.backend.controller.d.ts.map +1 -1
  503. package/dist/esm/monitoring/analytics/controllers/analytics.backend.controller.js +49 -4
  504. package/dist/esm/monitoring/analytics/controllers/analytics.backend.controller.js.map +1 -1
  505. package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.d.ts +66 -0
  506. package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.d.ts.map +1 -0
  507. package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.js +199 -0
  508. package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.js.map +1 -0
  509. package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.d.ts +149 -13
  510. package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.d.ts.map +1 -1
  511. package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.js +411 -19
  512. package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.js.map +1 -1
  513. package/dist/esm/monitoring/analytics/services/value-moment-handler-registry.backend.service.d.ts +11 -2
  514. package/dist/esm/monitoring/analytics/services/value-moment-handler-registry.backend.service.d.ts.map +1 -1
  515. package/dist/esm/monitoring/analytics/services/value-moment-handler-registry.backend.service.js.map +1 -1
  516. package/dist/esm/monitoring/logger/models/logger.backend.schemas.d.ts +28 -9
  517. package/dist/esm/monitoring/logger/models/logger.backend.schemas.d.ts.map +1 -1
  518. package/dist/esm/monitoring/logger/models/logger.backend.schemas.js +30 -10
  519. package/dist/esm/monitoring/logger/models/logger.backend.schemas.js.map +1 -1
  520. package/dist/esm/monitoring/logger/services/logger.service.d.ts +12 -0
  521. package/dist/esm/monitoring/logger/services/logger.service.d.ts.map +1 -1
  522. package/dist/esm/monitoring/logger/services/logger.service.js +52 -11
  523. package/dist/esm/monitoring/logger/services/logger.service.js.map +1 -1
  524. package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.d.ts +62 -0
  525. package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.d.ts.map +1 -0
  526. package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.js +78 -0
  527. package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.js.map +1 -0
  528. package/dist/esm/monitoring/observability/audit-observation-emission.backend.d.ts +309 -0
  529. package/dist/esm/monitoring/observability/audit-observation-emission.backend.d.ts.map +1 -0
  530. package/dist/esm/monitoring/observability/audit-observation-emission.backend.js +385 -0
  531. package/dist/esm/monitoring/observability/audit-observation-emission.backend.js.map +1 -0
  532. package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts +1 -0
  533. package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts.map +1 -1
  534. package/dist/esm/monitoring/observability/models/observability.backend.schemas.js.map +1 -1
  535. package/dist/esm/monitoring/observability/services/metrics.service.d.ts +21 -0
  536. package/dist/esm/monitoring/observability/services/metrics.service.d.ts.map +1 -1
  537. package/dist/esm/monitoring/observability/services/metrics.service.js +38 -0
  538. package/dist/esm/monitoring/observability/services/metrics.service.js.map +1 -1
  539. package/dist/esm/notifications/email/models/email-context-provider.interface.d.ts +0 -80
  540. package/dist/esm/notifications/email/models/email-context-provider.interface.d.ts.map +0 -1
  541. package/dist/esm/notifications/email/models/email-context-provider.interface.js +0 -25
  542. package/dist/esm/notifications/email/models/email-context-provider.interface.js.map +0 -1
  543. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.d.ts +0 -49
  544. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.d.ts.map +0 -1
  545. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.js +0 -141
  546. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.js.map +0 -1
  547. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.d.ts +0 -37
  548. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.d.ts.map +0 -1
  549. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.js +0 -121
  550. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.js.map +0 -1
  551. package/dist/esm/notifications/email/services/email-template-registry.backend.service.d.ts +66 -1
  552. package/dist/esm/notifications/email/services/email-template-registry.backend.service.d.ts.map +1 -1
  553. package/dist/esm/notifications/email/services/email-template-registry.backend.service.js +105 -10
  554. package/dist/esm/notifications/email/services/email-template-registry.backend.service.js.map +1 -1
  555. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.d.ts +0 -58
  556. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.d.ts.map +0 -1
  557. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.js +0 -223
  558. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.js.map +0 -1
  559. package/dist/esm/notifications/email/services/email-template-validator.backend.service.d.ts.map +1 -1
  560. package/dist/esm/notifications/email/services/email-template-validator.backend.service.js +10 -1
  561. package/dist/esm/notifications/email/services/email-template-validator.backend.service.js.map +1 -1
  562. package/dist/esm/notifications/email/services/email.backend.service.d.ts +60 -4
  563. package/dist/esm/notifications/email/services/email.backend.service.d.ts.map +1 -1
  564. package/dist/esm/notifications/email/services/email.backend.service.js +145 -43
  565. package/dist/esm/notifications/email/services/email.backend.service.js.map +1 -1
  566. package/dist/esm/notifications/email/utils/color-conversion.utils.d.ts +0 -1
  567. package/dist/esm/notifications/email/utils/color-conversion.utils.d.ts.map +1 -1
  568. package/dist/esm/notifications/email/utils/color-conversion.utils.js.map +1 -1
  569. package/dist/esm/notifications/services/notification-badge.backend.service.d.ts +142 -21
  570. package/dist/esm/notifications/services/notification-badge.backend.service.d.ts.map +1 -1
  571. package/dist/esm/notifications/services/notification-badge.backend.service.js +283 -58
  572. package/dist/esm/notifications/services/notification-badge.backend.service.js.map +1 -1
  573. package/dist/esm/notifications/services/notifications-dispatcher.backend.service.d.ts +108 -13
  574. package/dist/esm/notifications/services/notifications-dispatcher.backend.service.d.ts.map +1 -1
  575. package/dist/esm/notifications/services/notifications-dispatcher.backend.service.js +432 -101
  576. package/dist/esm/notifications/services/notifications-dispatcher.backend.service.js.map +1 -1
  577. package/dist/esm/notifications/sms/services/sms.backend.service.d.ts +2 -2
  578. package/dist/esm/notifications/sms/services/sms.backend.service.d.ts.map +1 -1
  579. package/dist/esm/notifications/sms/services/sms.backend.service.js +5 -5
  580. package/dist/esm/notifications/sms/services/sms.backend.service.js.map +1 -1
  581. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts +117 -5
  582. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts.map +1 -1
  583. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js +164 -6
  584. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js.map +1 -1
  585. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.d.ts +0 -6
  586. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.d.ts.map +1 -1
  587. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.js +54 -7
  588. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.js.map +1 -1
  589. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.utils.d.ts +5 -5
  590. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.utils.d.ts.map +1 -1
  591. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.utils.js +14 -13
  592. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.utils.js.map +1 -1
  593. package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.d.ts +2 -1
  594. package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.d.ts.map +1 -1
  595. package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.js +18 -8
  596. package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.js.map +1 -1
  597. package/dist/esm/notifications/webhooks/outbound/services/webhook-config-test-endpoint.custom-impl.backend.service.d.ts.map +1 -1
  598. package/dist/esm/notifications/webhooks/outbound/services/webhook-config-test-endpoint.custom-impl.backend.service.js +20 -18
  599. package/dist/esm/notifications/webhooks/outbound/services/webhook-config-test-endpoint.custom-impl.backend.service.js.map +1 -1
  600. package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.d.ts +16 -0
  601. package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.d.ts.map +1 -1
  602. package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.js +18 -0
  603. package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.js.map +1 -1
  604. package/dist/esm/organizations/batches/organization-purge.batch.backend.service.d.ts +2 -2
  605. package/dist/esm/organizations/batches/organization-purge.batch.backend.service.js +2 -2
  606. package/dist/esm/organizations/batches/organization-purge.batch.backend.service.js.map +1 -1
  607. package/dist/esm/organizations/services/organization-custom-implementation.backend.service.d.ts.map +1 -1
  608. package/dist/esm/organizations/services/organization-custom-implementation.backend.service.js +63 -2
  609. package/dist/esm/organizations/services/organization-custom-implementation.backend.service.js.map +1 -1
  610. package/dist/esm/organizations/services/organization-unit-custom-implementation.backend.service.d.ts.map +1 -1
  611. package/dist/esm/organizations/services/organization-unit-custom-implementation.backend.service.js +4 -1
  612. package/dist/esm/organizations/services/organization-unit-custom-implementation.backend.service.js.map +1 -1
  613. package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.d.ts +66 -0
  614. package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.d.ts.map +1 -0
  615. package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.js +257 -0
  616. package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.js.map +1 -0
  617. package/dist/esm/queue/adapters/queue-adapter.backend.binding.d.ts +12 -0
  618. package/dist/esm/queue/adapters/queue-adapter.backend.binding.d.ts.map +1 -0
  619. package/dist/esm/queue/adapters/queue-adapter.backend.binding.js +47 -0
  620. package/dist/esm/queue/adapters/queue-adapter.backend.binding.js.map +1 -0
  621. package/dist/esm/queue/adapters/queue-adapter.backend.interface.d.ts +87 -0
  622. package/dist/esm/queue/adapters/queue-adapter.backend.interface.d.ts.map +1 -0
  623. package/dist/esm/queue/adapters/queue-adapter.backend.interface.js +1 -0
  624. package/dist/esm/queue/adapters/queue-adapter.backend.interface.js.map +1 -0
  625. package/dist/esm/queue/adapters/queue-adapter.backend.options.d.ts +31 -0
  626. package/dist/esm/queue/adapters/queue-adapter.backend.options.d.ts.map +1 -0
  627. package/dist/esm/queue/adapters/queue-adapter.backend.options.js +13 -0
  628. package/dist/esm/queue/adapters/queue-adapter.backend.options.js.map +1 -0
  629. package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.d.ts +19 -25
  630. package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.d.ts.map +1 -1
  631. package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.js +33 -0
  632. package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.js.map +1 -1
  633. package/dist/esm/queue/domain-queue-consumer.backend.service.d.ts +2 -2
  634. package/dist/esm/queue/domain-queue-consumer.backend.service.d.ts.map +1 -1
  635. package/dist/esm/queue/domain-queue-consumer.backend.service.js +1 -4
  636. package/dist/esm/queue/domain-queue-consumer.backend.service.js.map +1 -1
  637. package/dist/esm/queue/job-consumer.backend.service.d.ts +2 -2
  638. package/dist/esm/queue/job-consumer.backend.service.d.ts.map +1 -1
  639. package/dist/esm/queue/job-consumer.backend.service.js +1 -4
  640. package/dist/esm/queue/job-consumer.backend.service.js.map +1 -1
  641. package/dist/esm/queue/job-executor.backend.service.d.ts +2 -2
  642. package/dist/esm/queue/job-executor.backend.service.d.ts.map +1 -1
  643. package/dist/esm/queue/job-executor.backend.service.js +1 -4
  644. package/dist/esm/queue/job-executor.backend.service.js.map +1 -1
  645. package/dist/esm/queue/queue-monitoring.backend.service.d.ts +8 -4
  646. package/dist/esm/queue/queue-monitoring.backend.service.d.ts.map +1 -1
  647. package/dist/esm/queue/queue-monitoring.backend.service.js +25 -17
  648. package/dist/esm/queue/queue-monitoring.backend.service.js.map +1 -1
  649. package/dist/esm/queue/queue-worker-initializer.backend.service.d.ts +16 -1
  650. package/dist/esm/queue/queue-worker-initializer.backend.service.d.ts.map +1 -1
  651. package/dist/esm/queue/queue-worker-initializer.backend.service.js +16 -1
  652. package/dist/esm/queue/queue-worker-initializer.backend.service.js.map +1 -1
  653. package/dist/esm/queue/queue.backend.service.d.ts +3 -3
  654. package/dist/esm/queue/queue.backend.service.d.ts.map +1 -1
  655. package/dist/esm/queue/queue.backend.service.js +26 -4
  656. package/dist/esm/queue/queue.backend.service.js.map +1 -1
  657. package/dist/esm/queue/worker-shutdown-manager.backend.service.d.ts +2 -2
  658. package/dist/esm/queue/worker-shutdown-manager.backend.service.d.ts.map +1 -1
  659. package/dist/esm/queue/worker-shutdown-manager.backend.service.js +18 -3
  660. package/dist/esm/queue/worker-shutdown-manager.backend.service.js.map +1 -1
  661. package/dist/esm/rag/utils/rag-chunking.backend.utils.d.ts +50 -25
  662. package/dist/esm/rag/utils/rag-chunking.backend.utils.d.ts.map +1 -1
  663. package/dist/esm/rag/utils/rag-chunking.backend.utils.js +147 -39
  664. package/dist/esm/rag/utils/rag-chunking.backend.utils.js.map +1 -1
  665. package/dist/esm/rag/utils/rag-context-assembly.backend.utils.d.ts +12 -3
  666. package/dist/esm/rag/utils/rag-context-assembly.backend.utils.d.ts.map +1 -1
  667. package/dist/esm/rag/utils/rag-context-assembly.backend.utils.js +12 -3
  668. package/dist/esm/rag/utils/rag-context-assembly.backend.utils.js.map +1 -1
  669. package/dist/esm/requests/service/websocket.service.d.ts +9 -0
  670. package/dist/esm/requests/service/websocket.service.d.ts.map +1 -1
  671. package/dist/esm/requests/service/websocket.service.js +88 -15
  672. package/dist/esm/requests/service/websocket.service.js.map +1 -1
  673. package/dist/esm/resources/models/custom-service-implementations.backend.definition.d.ts.map +1 -1
  674. package/dist/esm/resources/models/custom-service-implementations.backend.definition.js +16 -2
  675. package/dist/esm/resources/models/custom-service-implementations.backend.definition.js.map +1 -1
  676. package/dist/esm/resources/models/resources-operations.backend.definitions.d.ts.map +1 -1
  677. package/dist/esm/resources/models/resources-operations.backend.definitions.js +2 -0
  678. package/dist/esm/resources/models/resources-operations.backend.definitions.js.map +1 -1
  679. package/dist/esm/resources/models/resources-relationships.backend.definitions.d.ts.map +1 -1
  680. package/dist/esm/resources/models/resources-relationships.backend.definitions.js +14 -0
  681. package/dist/esm/resources/models/resources-relationships.backend.definitions.js.map +1 -1
  682. package/dist/esm/resources/models/resources-types.backend.schemas.d.ts +2 -1
  683. package/dist/esm/resources/models/resources-types.backend.schemas.d.ts.map +1 -1
  684. package/dist/esm/resources/models/resources-types.backend.schemas.js +8 -0
  685. package/dist/esm/resources/models/resources-types.backend.schemas.js.map +1 -1
  686. package/dist/esm/resources/services/resource-id.backend.service.js +3 -3
  687. package/dist/esm/resources/services/resource-id.backend.service.js.map +1 -1
  688. package/dist/esm/resources/services/resources-registry.backend.service.d.ts +60 -5
  689. package/dist/esm/resources/services/resources-registry.backend.service.d.ts.map +1 -1
  690. package/dist/esm/resources/services/resources-registry.backend.service.js +91 -7
  691. package/dist/esm/resources/services/resources-registry.backend.service.js.map +1 -1
  692. package/dist/esm/runtime/controllers/health-controller.backend.service.d.ts +36 -3
  693. package/dist/esm/runtime/controllers/health-controller.backend.service.d.ts.map +1 -1
  694. package/dist/esm/runtime/controllers/health-controller.backend.service.js +32 -10
  695. package/dist/esm/runtime/controllers/health-controller.backend.service.js.map +1 -1
  696. package/dist/esm/runtime/domain-module.backend.definitions.d.ts +24 -0
  697. package/dist/esm/runtime/domain-module.backend.definitions.d.ts.map +1 -1
  698. package/dist/esm/runtime/domain-module.backend.definitions.js +24 -0
  699. package/dist/esm/runtime/domain-module.backend.definitions.js.map +1 -1
  700. package/dist/esm/runtime/services/execution-context-creator.backend.service.d.ts.map +1 -1
  701. package/dist/esm/runtime/services/execution-context-creator.backend.service.js +13 -7
  702. package/dist/esm/runtime/services/execution-context-creator.backend.service.js.map +1 -1
  703. package/dist/esm/runtime/services/health-readiness-contributor.backend.interface.d.ts +51 -0
  704. package/dist/esm/runtime/services/health-readiness-contributor.backend.interface.d.ts.map +1 -1
  705. package/dist/esm/runtime/services/health-readiness-contributor.backend.interface.js.map +1 -1
  706. package/dist/esm/runtime/services/http-server.backend.service.d.ts +26 -0
  707. package/dist/esm/runtime/services/http-server.backend.service.d.ts.map +1 -1
  708. package/dist/esm/runtime/services/http-server.backend.service.js +181 -1
  709. package/dist/esm/runtime/services/http-server.backend.service.js.map +1 -1
  710. package/dist/esm/runtime/services/start-application.backend.service.d.ts +47 -1
  711. package/dist/esm/runtime/services/start-application.backend.service.d.ts.map +1 -1
  712. package/dist/esm/runtime/services/start-application.backend.service.js +343 -77
  713. package/dist/esm/runtime/services/start-application.backend.service.js.map +1 -1
  714. package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.d.ts +15 -0
  715. package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.d.ts.map +1 -1
  716. package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.js +28 -0
  717. package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.js.map +1 -1
  718. package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.d.ts +5 -1
  719. package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.d.ts.map +1 -1
  720. package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.js +24 -4
  721. package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.js.map +1 -1
  722. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.d.ts.map +1 -1
  723. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.js +29 -4
  724. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.js.map +1 -1
  725. package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.d.ts +114 -0
  726. package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.d.ts.map +1 -1
  727. package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.js +354 -3
  728. package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.js.map +1 -1
  729. package/dist/esm/security/authentications/models/cimd.backend.schemas.d.ts +1 -0
  730. package/dist/esm/security/authentications/models/cimd.backend.schemas.d.ts.map +1 -1
  731. package/dist/esm/security/authentications/models/cimd.backend.schemas.js +22 -0
  732. package/dist/esm/security/authentications/models/cimd.backend.schemas.js.map +1 -1
  733. package/dist/esm/security/authentications/models/jwt.backend.schemas.d.ts +3 -23
  734. package/dist/esm/security/authentications/models/jwt.backend.schemas.d.ts.map +1 -1
  735. package/dist/esm/security/authentications/models/jwt.backend.schemas.js +20 -45
  736. package/dist/esm/security/authentications/models/jwt.backend.schemas.js.map +1 -1
  737. package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.d.ts +15 -0
  738. package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.d.ts.map +1 -1
  739. package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.js.map +1 -1
  740. package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.d.ts +0 -2
  741. package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.d.ts.map +1 -1
  742. package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.js +23 -14
  743. package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.js.map +1 -1
  744. package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.d.ts +0 -1
  745. package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.d.ts.map +1 -1
  746. package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.js +15 -12
  747. package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.js.map +1 -1
  748. package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.d.ts +113 -3
  749. package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.d.ts.map +1 -1
  750. package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.js +207 -30
  751. package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.js.map +1 -1
  752. package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.d.ts +95 -2
  753. package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.d.ts.map +1 -1
  754. package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.js +153 -9
  755. package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.js.map +1 -1
  756. package/dist/esm/security/authentications/services/anonymous-session.backend.service.d.ts +190 -0
  757. package/dist/esm/security/authentications/services/anonymous-session.backend.service.d.ts.map +1 -1
  758. package/dist/esm/security/authentications/services/anonymous-session.backend.service.js +377 -53
  759. package/dist/esm/security/authentications/services/anonymous-session.backend.service.js.map +1 -1
  760. package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.d.ts +9 -1
  761. package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.d.ts.map +1 -1
  762. package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.js +77 -2
  763. package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.js.map +1 -1
  764. package/dist/esm/security/authentications/services/auth-methods/auth-mfa.backend.service.d.ts.map +1 -1
  765. package/dist/esm/security/authentications/services/auth-methods/auth-mfa.backend.service.js +5 -3
  766. package/dist/esm/security/authentications/services/auth-methods/auth-mfa.backend.service.js.map +1 -1
  767. package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.d.ts +41 -0
  768. package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.d.ts.map +1 -1
  769. package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.js +202 -23
  770. package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.js.map +1 -1
  771. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.d.ts.map +1 -1
  772. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.js +42 -1
  773. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.js.map +1 -1
  774. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.d.ts.map +1 -1
  775. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.js +34 -4
  776. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.js.map +1 -1
  777. package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.d.ts +29 -5
  778. package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.d.ts.map +1 -1
  779. package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.js +77 -5
  780. package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.js.map +1 -1
  781. package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.d.ts +41 -1
  782. package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.d.ts.map +1 -1
  783. package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.js +87 -4
  784. package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.js.map +1 -1
  785. package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.d.ts +43 -1
  786. package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.d.ts.map +1 -1
  787. package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.js +277 -97
  788. package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.js.map +1 -1
  789. package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.d.ts +28 -5
  790. package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.d.ts.map +1 -1
  791. package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.js +72 -12
  792. package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.js.map +1 -1
  793. package/dist/esm/security/authentications/services/custom-impls/auth-custom-implementations.backend.d.ts.map +1 -1
  794. package/dist/esm/security/authentications/services/custom-impls/auth-custom-implementations.backend.js +3 -0
  795. package/dist/esm/security/authentications/services/custom-impls/auth-custom-implementations.backend.js.map +1 -1
  796. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.d.ts +28 -0
  797. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.d.ts.map +1 -0
  798. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js +283 -0
  799. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js.map +1 -0
  800. package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.d.ts +4 -3
  801. package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.d.ts.map +1 -1
  802. package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.js +4 -3
  803. package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.js.map +1 -1
  804. package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.d.ts +35 -0
  805. package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.d.ts.map +1 -1
  806. package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.js +111 -21
  807. package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.js.map +1 -1
  808. package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.d.ts +14 -1
  809. package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.d.ts.map +1 -1
  810. package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.js +49 -8
  811. package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.js.map +1 -1
  812. package/dist/esm/security/authentications/services/utils/auth-policy-resolution.backend.utils.d.ts.map +1 -1
  813. package/dist/esm/security/authentications/services/utils/auth-policy-resolution.backend.utils.js +4 -0
  814. package/dist/esm/security/authentications/services/utils/auth-policy-resolution.backend.utils.js.map +1 -1
  815. package/dist/esm/security/authentications/services/utils/auth-user-lookup.backend.service.d.ts.map +1 -1
  816. package/dist/esm/security/authentications/services/utils/auth-user-lookup.backend.service.js +6 -0
  817. package/dist/esm/security/authentications/services/utils/auth-user-lookup.backend.service.js.map +1 -1
  818. package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.d.ts +37 -1
  819. package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.d.ts.map +1 -1
  820. package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.js +51 -0
  821. package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.js.map +1 -1
  822. package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.d.ts +41 -0
  823. package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.d.ts.map +1 -1
  824. package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.js +45 -0
  825. package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.js.map +1 -1
  826. package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.d.ts +116 -0
  827. package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.d.ts.map +1 -0
  828. package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.js +162 -0
  829. package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.js.map +1 -0
  830. package/dist/esm/security/authorizations/initiator-organization-confinement.backend.d.ts.map +1 -1
  831. package/dist/esm/security/authorizations/initiator-organization-confinement.backend.js +24 -1
  832. package/dist/esm/security/authorizations/initiator-organization-confinement.backend.js.map +1 -1
  833. package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.d.ts +20 -20
  834. package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.d.ts.map +1 -1
  835. package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.js +27 -28
  836. package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.js.map +1 -1
  837. package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.d.ts.map +1 -1
  838. package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.js +77 -3
  839. package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.js.map +1 -1
  840. package/dist/esm/security/authorizations/privileged-access-review.backend.utils.d.ts +117 -0
  841. package/dist/esm/security/authorizations/privileged-access-review.backend.utils.d.ts.map +1 -0
  842. package/dist/esm/security/authorizations/privileged-access-review.backend.utils.js +104 -0
  843. package/dist/esm/security/authorizations/privileged-access-review.backend.utils.js.map +1 -0
  844. package/dist/esm/security/authorizations/role-ceiling.backend.utils.d.ts +4 -0
  845. package/dist/esm/security/authorizations/role-ceiling.backend.utils.d.ts.map +1 -1
  846. package/dist/esm/security/authorizations/role-ceiling.backend.utils.js +4 -0
  847. package/dist/esm/security/authorizations/role-ceiling.backend.utils.js.map +1 -1
  848. package/dist/esm/security/authorizations/role-conferral.backend.utils.d.ts +93 -0
  849. package/dist/esm/security/authorizations/role-conferral.backend.utils.d.ts.map +1 -0
  850. package/dist/esm/security/authorizations/role-conferral.backend.utils.js +95 -0
  851. package/dist/esm/security/authorizations/role-conferral.backend.utils.js.map +1 -0
  852. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.d.ts +124 -1
  853. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.d.ts.map +1 -1
  854. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.js +142 -5
  855. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.js.map +1 -1
  856. package/dist/esm/security/authorizations/services/authorizations.backend.service.d.ts +175 -14
  857. package/dist/esm/security/authorizations/services/authorizations.backend.service.d.ts.map +1 -1
  858. package/dist/esm/security/authorizations/services/authorizations.backend.service.js +385 -49
  859. package/dist/esm/security/authorizations/services/authorizations.backend.service.js.map +1 -1
  860. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts +6 -14
  861. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts.map +1 -1
  862. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js +13 -22
  863. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js.map +1 -1
  864. package/dist/esm/security/connected-accounts/connection-target-authorization.backend.d.ts +60 -0
  865. package/dist/esm/security/connected-accounts/connection-target-authorization.backend.d.ts.map +1 -0
  866. package/dist/esm/security/connected-accounts/connection-target-authorization.backend.js +79 -0
  867. package/dist/esm/security/connected-accounts/connection-target-authorization.backend.js.map +1 -0
  868. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.d.ts +161 -0
  869. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.d.ts.map +1 -0
  870. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.js +512 -0
  871. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.js.map +1 -0
  872. package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.d.ts +59 -0
  873. package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.d.ts.map +1 -0
  874. package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.js +22 -0
  875. package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.js.map +1 -0
  876. package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.d.ts +44 -0
  877. package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.d.ts.map +1 -0
  878. package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.js +20 -0
  879. package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.js.map +1 -0
  880. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.d.ts +191 -0
  881. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.d.ts.map +1 -0
  882. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.js +385 -0
  883. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.js.map +1 -0
  884. package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.d.ts +41 -0
  885. package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.d.ts.map +1 -0
  886. package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.js +358 -0
  887. package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.js.map +1 -0
  888. package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.d.ts +160 -0
  889. package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.d.ts.map +1 -0
  890. package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.js +266 -0
  891. package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.js.map +1 -0
  892. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.d.ts +111 -0
  893. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.d.ts.map +1 -0
  894. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.js +107 -0
  895. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.js.map +1 -0
  896. package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.d.ts +54 -0
  897. package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.d.ts.map +1 -0
  898. package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.js +153 -0
  899. package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.js.map +1 -0
  900. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.d.ts +195 -0
  901. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.d.ts.map +1 -0
  902. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.js +387 -0
  903. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.js.map +1 -0
  904. package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.d.ts +45 -0
  905. package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.d.ts.map +1 -0
  906. package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.js +291 -0
  907. package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.js.map +1 -0
  908. package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.d.ts +62 -0
  909. package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.d.ts.map +1 -0
  910. package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.js +29 -0
  911. package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.js.map +1 -0
  912. package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.d.ts +127 -0
  913. package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.d.ts.map +1 -0
  914. package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.js +277 -0
  915. package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.js.map +1 -0
  916. package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.d.ts +66 -0
  917. package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.d.ts.map +1 -0
  918. package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.js +75 -0
  919. package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.js.map +1 -0
  920. package/dist/esm/security/consumable-tokens/batches/consumable-tokens-cleanup.batch.backend.service.d.ts +18 -1
  921. package/dist/esm/security/consumable-tokens/batches/consumable-tokens-cleanup.batch.backend.service.d.ts.map +1 -1
  922. package/dist/esm/security/consumable-tokens/batches/consumable-tokens-cleanup.batch.backend.service.js +110 -74
  923. package/dist/esm/security/consumable-tokens/batches/consumable-tokens-cleanup.batch.backend.service.js.map +1 -1
  924. package/dist/esm/security/consumable-tokens/consumable-token-models.exports.d.ts +22 -0
  925. package/dist/esm/security/consumable-tokens/consumable-token-models.exports.d.ts.map +1 -0
  926. package/dist/esm/security/consumable-tokens/consumable-token-models.exports.js +22 -0
  927. package/dist/esm/security/consumable-tokens/consumable-token-models.exports.js.map +1 -0
  928. package/dist/esm/security/consumable-tokens/models/consumable-tokens.backend.resources-config.schemas.d.ts +17 -3
  929. package/dist/esm/security/consumable-tokens/models/consumable-tokens.backend.resources-config.schemas.d.ts.map +1 -1
  930. package/dist/esm/security/consumable-tokens/models/consumable-tokens.backend.resources-config.schemas.js +12 -0
  931. package/dist/esm/security/consumable-tokens/models/consumable-tokens.backend.resources-config.schemas.js.map +1 -1
  932. package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.d.ts +41 -3
  933. package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.d.ts.map +1 -1
  934. package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.js +83 -20
  935. package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.js.map +1 -1
  936. package/dist/esm/security/credential-rotation-grace.backend.utils.d.ts +9 -4
  937. package/dist/esm/security/credential-rotation-grace.backend.utils.d.ts.map +1 -1
  938. package/dist/esm/security/credential-rotation-grace.backend.utils.js +9 -4
  939. package/dist/esm/security/credential-rotation-grace.backend.utils.js.map +1 -1
  940. package/dist/esm/security/jwt/services/jwt.backend.service.d.ts.map +1 -1
  941. package/dist/esm/security/jwt/services/jwt.backend.service.js +1 -18
  942. package/dist/esm/security/jwt/services/jwt.backend.service.js.map +1 -1
  943. package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.d.ts +26 -0
  944. package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.d.ts.map +1 -1
  945. package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.js +43 -0
  946. package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.js.map +1 -1
  947. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts +8 -1
  948. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts.map +1 -1
  949. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js +49 -0
  950. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js.map +1 -1
  951. package/dist/esm/security/scim/controllers/scim.backend.controller.d.ts.map +1 -1
  952. package/dist/esm/security/scim/controllers/scim.backend.controller.js +17 -5
  953. package/dist/esm/security/scim/controllers/scim.backend.controller.js.map +1 -1
  954. package/dist/esm/security/scim/models/scim-protocol.backend.schemas.d.ts +67 -29
  955. package/dist/esm/security/scim/models/scim-protocol.backend.schemas.d.ts.map +1 -1
  956. package/dist/esm/security/scim/models/scim-protocol.backend.schemas.js +47 -25
  957. package/dist/esm/security/scim/models/scim-protocol.backend.schemas.js.map +1 -1
  958. package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.d.ts +10 -2
  959. package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.d.ts.map +1 -1
  960. package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.js +10 -2
  961. package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.js.map +1 -1
  962. package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.d.ts +143 -0
  963. package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.d.ts.map +1 -0
  964. package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.js +258 -0
  965. package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.js.map +1 -0
  966. package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.d.ts +39 -0
  967. package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.d.ts.map +1 -0
  968. package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.js +159 -0
  969. package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.js.map +1 -0
  970. package/dist/tsconfig.build.tsbuildinfo +1 -1
  971. package/package.json +17 -9
  972. package/dist/esm/.builder.pid +0 -9
@@ -139,20 +139,12 @@ export type SuperAdminConferralResolver = () => string[];
139
139
  * Every APPLICATION-scope role key whose `inheritFrom` chain reaches `APP_ADMIN_SUPER_ADMIN` — i.e.
140
140
  * every role whose holder passes a super-admin gate.
141
141
  *
142
- * Mirrors the authorization layer's own test: `authorize` admits a caller when
143
- * `getRoleHierarchy(heldRole, scope).includes(requiredRole)`. Deriving the set the same way is what
144
- * keeps the floor counting exactly the principals the gates would let through — an independently
145
- * written membership test is how the two would drift.
146
- *
147
- * `APP_ADMIN_SUPER_ADMIN` itself is seeded unconditionally rather than being discovered by the walk.
148
- * If an application's role table somehow omitted the key, `getRoleHierarchy` would return an empty
149
- * chain, the conferring set would be empty, and the floor would then measure a population that is
150
- * empty by construction — refusing every removal forever while protecting nothing. Seeding the
151
- * anchor keeps the primary role counted whatever the table says.
152
- *
153
- * ORGANIZATIONS-scope roles are never consulted: `appRoles` is the APPLICATION authority axis, and
154
- * `getRoleHierarchy` partitions the two tables precisely so an org-scoped role string that happens
155
- * to spell an app role confers nothing.
142
+ * This floor's BINDING of the shared conferral derivation. The derivation itself, and the reasoning
143
+ * that used to be restated here and in the organization-owner floor in two different sets of words,
144
+ * live in {@link resolveRolesConferringAnchor} — including why the anchor is seeded unconditionally
145
+ * and why the SCOPE argument is what makes an org-scoped role string that happens to spell an app
146
+ * role confer nothing. `appRoles` is the APPLICATION authority axis; ORGANIZATIONS-scope roles are
147
+ * never consulted, and that is now one fact in one place rather than two paragraphs that can drift.
156
148
  */
157
149
  export declare function resolveSuperAdminConferringRoles(authorizationsService: Pick<AuthorizationsBackendService, 'getAppRoles' | 'getRoleHierarchy'>): string[];
158
150
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"super-admin-floor.backend.utils.d.ts","sourceRoot":"","sources":["../../../../../src/security/authorizations/super-admin-floor.backend.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,OAAO,EAOL,UAAU,EACV,KAAK,IAAI,EACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAC5G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AACnH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oFAAoF,CAAC;AACvI,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,qGAAqG,CAAC;AAGrK;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,IAAI,CAAC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IAClC,yBAAyB,EAAE,MAAM,EAAE,CAAC;IACpC,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,sCAAsC,CAAC,MAAM,EAAE;IACnE,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,QAAQ,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC;IACpF,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxC,oBAAoB,EAAE,yCAAyC,CAAC;IAChE,YAAY,EAAE,0BAA0B,CAAC;IACzC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,8FAA8F;IAC9F,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,mFAAmF;IACnF,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAChF,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBhB"}
1
+ {"version":3,"file":"super-admin-floor.backend.utils.d.ts","sourceRoot":"","sources":["../../../../../src/security/authorizations/super-admin-floor.backend.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,OAAO,EAOL,UAAU,EACV,KAAK,IAAI,EACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAC5G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AACnH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oFAAoF,CAAC;AACvI,OAAO,KAAK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E,MAAM,EAAE,CAAA;CAAE,CAAC,CAe7F;AAED,iFAAiF;AACjF,MAAM,MAAM,qBAAqB,GAAG;IAClC,yBAAyB,EAAE,MAAM,EAAE,CAAC;IACpC,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,sCAAsC,CAAC,MAAM,EAAE;IACnE,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,QAAQ,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC;IACpF,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxC,oBAAoB,EAAE,yCAAyC,CAAC;IAChE,YAAY,EAAE,0BAA0B,CAAC;IACzC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,8FAA8F;IAC9F,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,mFAAmF;IACnF,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAChF,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBhB"}
@@ -68,6 +68,7 @@
68
68
  */
69
69
  import { AdministrativeContinuityErrorCode, CORE_APP_ROLES, CoreResourceOperation, CoreResourceType, ErrorType, ResourcePrimaryScope, UserStatus, } from '@wildo-ai/saas-models';
70
70
  import { SAAS_SERVICE_TYPES } from '../../inject/models/service-types.js';
71
+ import { resolveRolesConferringAnchor } from '../../security/authorizations/role-conferral.backend.utils.js';
71
72
  /**
72
73
  * The minimum number of administratively usable super-administrators an application must retain.
73
74
  *
@@ -128,30 +129,20 @@ export var SuperAdminFloorReductionCause;
128
129
  * Every APPLICATION-scope role key whose `inheritFrom` chain reaches `APP_ADMIN_SUPER_ADMIN` — i.e.
129
130
  * every role whose holder passes a super-admin gate.
130
131
  *
131
- * Mirrors the authorization layer's own test: `authorize` admits a caller when
132
- * `getRoleHierarchy(heldRole, scope).includes(requiredRole)`. Deriving the set the same way is what
133
- * keeps the floor counting exactly the principals the gates would let through — an independently
134
- * written membership test is how the two would drift.
135
- *
136
- * `APP_ADMIN_SUPER_ADMIN` itself is seeded unconditionally rather than being discovered by the walk.
137
- * If an application's role table somehow omitted the key, `getRoleHierarchy` would return an empty
138
- * chain, the conferring set would be empty, and the floor would then measure a population that is
139
- * empty by construction — refusing every removal forever while protecting nothing. Seeding the
140
- * anchor keeps the primary role counted whatever the table says.
141
- *
142
- * ORGANIZATIONS-scope roles are never consulted: `appRoles` is the APPLICATION authority axis, and
143
- * `getRoleHierarchy` partitions the two tables precisely so an org-scoped role string that happens
144
- * to spell an app role confers nothing.
132
+ * This floor's BINDING of the shared conferral derivation. The derivation itself, and the reasoning
133
+ * that used to be restated here and in the organization-owner floor in two different sets of words,
134
+ * live in {@link resolveRolesConferringAnchor} — including why the anchor is seeded unconditionally
135
+ * and why the SCOPE argument is what makes an org-scoped role string that happens to spell an app
136
+ * role confer nothing. `appRoles` is the APPLICATION authority axis; ORGANIZATIONS-scope roles are
137
+ * never consulted, and that is now one fact in one place rather than two paragraphs that can drift.
145
138
  */
146
139
  export function resolveSuperAdminConferringRoles(authorizationsService) {
147
- const conferringRoles = new Set([CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN]);
148
- for (const roleKey of Object.keys(authorizationsService.getAppRoles() ?? {})) {
149
- const conferred = authorizationsService.getRoleHierarchy(roleKey, ResourcePrimaryScope.APPLICATION);
150
- if (conferred.includes(CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN)) {
151
- conferringRoles.add(roleKey);
152
- }
153
- }
154
- return [...conferringRoles];
140
+ return resolveRolesConferringAnchor({
141
+ anchorRole: CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN,
142
+ scope: ResourcePrimaryScope.APPLICATION,
143
+ declaredRoleKeys: Object.keys(authorizationsService.getAppRoles() ?? {}),
144
+ roleHierarchyResolver: (roleKey, scope) => authorizationsService.getRoleHierarchy(roleKey, scope),
145
+ });
155
146
  }
156
147
  /**
157
148
  * Bind a {@link SuperAdminConferralResolver} to the container's live `AuthorizationsBackendService`.
@@ -1 +1 @@
1
- {"version":3,"file":"super-admin-floor.backend.utils.js","sourceRoot":"","sources":["../../../../../src/security/authorizations/super-admin-floor.backend.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,OAAO,EACL,iCAAiC,EACjC,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EACpB,UAAU,GAEX,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAA0B,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAEhG;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GACnC,yFAAyF,CAAC;AAE5F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,wBAAwB,CAAC;AAEzE;;;;GAIG;AACH,MAAM,CAAN,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC,mEAAmE;IACnE,8DAA6B,CAAA;IAC7B,gEAAgE;IAChE,gEAA+B,CAAA;IAC/B,4CAA4C;IAC5C,sDAAqB,CAAA;IACrB,gEAAgE;IAChE,oDAAmB,CAAA;AACrB,CAAC,EATW,6BAA6B,KAA7B,6BAA6B,QASxC;AAWD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gCAAgC,CAC9C,qBAA6F;IAE7F,MAAM,eAAe,GAAG,IAAI,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AAC;KAC7C,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * THE last-super-administrator floor — one semantic authority, consumed by every reducing path.\n *\n * assurance-control: WILDO.ACCESS.ADMINISTRATIVE_CONTINUITY — an application must\n * retain an accountable administrative principal; losing the last one is simultaneously an access-\n * control failure and an availability failure, with no in-product remedy.\n *\n * ## The invariant, stated once\n *\n * An application always retains at least one **administratively usable super-administrator**. Every\n * write that could reduce that population below {@link SUPER_ADMIN_FLOOR_MINIMUM} is refused.\n *\n * ## Why this cannot be left to the operation gates\n *\n * Every path that can remove application authority is itself gated on `APP_ADMIN_SUPER_ADMIN`, so\n * the gates are satisfied precisely by the principal capable of causing the lockout. And every\n * recovery door — `assign_roles`, the core USERS `UPDATE`, the admin console — carries the same\n * gate, so once the population reaches zero there is no in-product way back. That combination is\n * what makes this a fail-closed invariant rather than a warning: the failure is unrecoverable, and\n * the only moment it can be prevented is before the write.\n *\n * ## \"Administratively usable\" — three independent conditions, all resolved toward the SMALLER count\n *\n * 1. **The roles must actually CONFER super-admin.** Testing for the literal\n * `APP_ADMIN_SUPER_ADMIN` string is wrong: roles are application-configurable\n * (`initializeRolesWithCustom`), and an app may register a role with\n * `inheritFrom: APP_ADMIN_SUPER_ADMIN` whose holder passes every super-admin gate —\n * `authorize` admits any role whose `inheritFrom` chain CONTAINS the required one. The\n * conferring set is therefore resolved from the live role table at call time; see\n * {@link resolveSuperAdminConferringRoles}.\n * 2. **The subject must be able to AUTHENTICATE.** `_enforceUserStatus` admits `UserStatus.ACTIVE`\n * and throws `AUTHENTICATION_ACCOUNT_LOCKED` for every other status. A `SUSPENDED` or\n * `PENDING_INVITATION` super-admin would satisfy a naive count while being unable to log in —\n * the exact lockout this module exists to prevent, arriving through the guard itself. See\n * {@link ADMINISTRATIVELY_USABLE_USER_STATUSES}.\n * 3. **The row must not be retention-hidden.** An erased-but-retained user KEEPS its `appRoles`:\n * the field carries no `.impersonalizeWith()` because it is `.isAuditEvidence()` — what decided\n * authority must survive the scrub. So a retained row still MATCHES a role filter while being\n * invisible and frozen to every ordinary path. This condition needs no code here: the repository\n * chokepoint applies the retention hide to LIST, so an ordinary request execution context cannot\n * see retained rows. It is stated because the absence of an explicit filter is otherwise\n * indistinguishable from having forgotten the case.\n *\n * The direction of every ambiguity is deliberate. **Under-counting refuses a legitimate removal**\n * — recoverable by appointing another administrator. **Over-counting permits the lockout** — not\n * recoverable at all. Anything uncertain therefore resolves toward not counting.\n *\n * ## The floor is a POPULATION rule, not a self-demotion check\n *\n * Nothing here compares the subject to the caller. Two usable administrators → either may be\n * demoted, including by themselves. One → nobody may remove it. The asymmetry that looks like it\n * should matter does not: to reach any of these operations a human caller already satisfies an\n * `APP_ADMIN_SUPER_ADMIN` gate, so demoting SOMEONE ELSE means the caller is themselves a second\n * usable administrator and the floor already holds. In practice the guard fires only on\n * self-demotion — but it is written as a population rule because the system paths it also protects\n * (subject erasure) have no human caller to compare against.\n *\n * ## No system / internal bypass\n *\n * `assertRequestedRolesWithinCallerCeiling` exempts `INTERNALLY_INITIATED_REQUEST` because a system\n * write carries no human ceiling to measure. This module deliberately does NOT copy that exemption:\n * a system write that strips the last administrator produces exactly the same unadministrable\n * application as a human one. The concrete case is subject erasure, and refusing it is the correct\n * compliance answer rather than an obstacle to one — an erasure that leaves the application\n * unadministrable is an availability incident, not a completed data-protection request. The\n * operator appoints a successor and then erases; {@link SUPER_ADMIN_FLOOR_REMEDY} is the text that\n * says so.\n */\n\nimport {\n AdministrativeContinuityErrorCode,\n CORE_APP_ROLES,\n CoreResourceOperation,\n CoreResourceType,\n ErrorType,\n ResourcePrimaryScope,\n UserStatus,\n type User,\n} from '@wildo-ai/saas-models';\nimport type { Container } from 'inversify';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport type { ErrorBuilderBackendService } from '~wildo-backend-lib/errors/services/error-builder.backend.service';\nimport type { AuthorizationsBackendService } from '~wildo-backend-lib/security/authorizations/services/authorizations.backend.service';\nimport type { RepositoriesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\n\n/**\n * The minimum number of administratively usable super-administrators an application must retain.\n *\n * Named rather than inlined as `> 0` so the several call sites state the same rule, and so a\n * product that ever requires two (a four-eyes administrative policy) has one place to change.\n */\nexport const SUPER_ADMIN_FLOOR_MINIMUM = 1;\n\n/**\n * The statuses in which a user can actually authenticate, and therefore the only ones that count\n * toward the floor.\n *\n * Derived from `AuthenticationOrchestrator._enforceUserStatus`, which returns for\n * {@link UserStatus.ACTIVE} and throws `AUTHENTICATION_ACCOUNT_LOCKED` for everything else.\n *\n * `PENDING_VERIFICATION` is deliberately EXCLUDED even though the verification flow can flip it to\n * `ACTIVE`: a recoverable administrator is not a usable one, and admitting it would let the floor\n * be satisfied by an account nobody can currently log into. Same for `PENDING_INVITATION`, whose\n * subject has no credentials at all.\n *\n * Kept as an explicit list rather than `!== ACTIVE` so that adding a member to {@link UserStatus}\n * forces a decision here instead of silently inheriting \"usable\".\n */\nexport const ADMINISTRATIVELY_USABLE_USER_STATUSES: readonly UserStatus[] = [UserStatus.ACTIVE];\n\n/**\n * The remedy every refusal names.\n *\n * A guard that only says \"no\" on an operation an administrator is authorized to perform reads as a\n * defect. Stating the one action that unblocks it — appoint another administrator first — is what\n * makes the refusal actionable, and it is the same remedy for a human demotion and for a subject\n * erasure blocked by the floor.\n */\nexport const SUPER_ADMIN_FLOOR_REMEDY =\n 'Grant an application super-administrator role to another active user first, then retry.';\n\n/**\n * The reason code every floor refusal carries, so one filter finds them across the trail.\n *\n * INTERNAL. Not the wire contract — `sanitizeErrorForClient` strips `reason` from a CONFLICT and\n * allow-lists `code`, which carries {@link AdministrativeContinuityErrorCode}. Keep them distinct:\n * this one is free to stay richer than the client-facing code.\n */\nexport const SUPER_ADMIN_FLOOR_REFUSAL_REASON = 'last_super_admin_floor';\n\n/**\n * Why a subject would stop counting toward the floor. Rides the refusal so an operator reading the\n * error (or the audit trail) knows which axis of {@link ADMINISTRATIVELY_USABLE_USER_STATUSES} /\n * role conferral / row existence the blocked write was about to change.\n */\nexport enum SuperAdminFloorReductionCause {\n /** The subject's `appRoles` would no longer confer super-admin. */\n ROLE_REMOVAL = 'role_removal',\n /** The subject's `status` would leave the authenticable set. */\n STATUS_CHANGE = 'status_change',\n /** The subject's row would be destroyed. */\n DELETION = 'deletion',\n /** The subject's row would be scrubbed and retention-hidden. */\n ERASURE = 'erasure',\n}\n\n/**\n * Resolves the role keys that confer super-admin, from the LIVE application role table.\n *\n * Injected rather than imported for the same reason {@link RoleHierarchyResolver} is: the effective\n * hierarchy is application-configurable, so a statically-derived set would silently disagree with\n * the roles the authorization layer actually honours.\n */\nexport type SuperAdminConferralResolver = () => string[];\n\n/**\n * Every APPLICATION-scope role key whose `inheritFrom` chain reaches `APP_ADMIN_SUPER_ADMIN` — i.e.\n * every role whose holder passes a super-admin gate.\n *\n * Mirrors the authorization layer's own test: `authorize` admits a caller when\n * `getRoleHierarchy(heldRole, scope).includes(requiredRole)`. Deriving the set the same way is what\n * keeps the floor counting exactly the principals the gates would let through — an independently\n * written membership test is how the two would drift.\n *\n * `APP_ADMIN_SUPER_ADMIN` itself is seeded unconditionally rather than being discovered by the walk.\n * If an application's role table somehow omitted the key, `getRoleHierarchy` would return an empty\n * chain, the conferring set would be empty, and the floor would then measure a population that is\n * empty by construction — refusing every removal forever while protecting nothing. Seeding the\n * anchor keeps the primary role counted whatever the table says.\n *\n * ORGANIZATIONS-scope roles are never consulted: `appRoles` is the APPLICATION authority axis, and\n * `getRoleHierarchy` partitions the two tables precisely so an org-scoped role string that happens\n * to spell an app role confers nothing.\n */\nexport function resolveSuperAdminConferringRoles(\n authorizationsService: Pick<AuthorizationsBackendService, 'getAppRoles' | 'getRoleHierarchy'>,\n): string[] {\n const conferringRoles = new Set<string>([CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN]);\n\n for (const roleKey of Object.keys(authorizationsService.getAppRoles() ?? {})) {\n const conferred = authorizationsService.getRoleHierarchy(roleKey as any, ResourcePrimaryScope.APPLICATION);\n if (conferred.includes(CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN)) {\n conferringRoles.add(roleKey);\n }\n }\n\n return [...conferringRoles];\n}\n\n/**\n * Bind a {@link SuperAdminConferralResolver} to the container's live `AuthorizationsBackendService`.\n *\n * Resolution is LAZY then per-call, exactly like `createRoleHierarchyResolver`: custom-implementation\n * factories are constructed during module registration, which can run before the authorization\n * service is bound (an eager `container.get` would turn this into a startup crash), and the role\n * table is mutated in place by `initializeRolesWithCustom`, so the conferring set is recomputed per\n * call rather than memoized. The set is a handful of strings over a table of the same size — the\n * recomputation is far cheaper than the staleness it avoids.\n */\nexport function createSuperAdminConferralResolver(container: Container): SuperAdminConferralResolver {\n let authorizationsService: AuthorizationsBackendService | undefined;\n return () => {\n authorizationsService ??= container.get<AuthorizationsBackendService>(SAAS_SERVICE_TYPES.AuthorizationsService);\n return resolveSuperAdminConferringRoles(authorizationsService);\n };\n}\n\n/**\n * Whether a role array confers super-admin.\n *\n * Defensive on the array itself: this runs on values read from unparsed caller input as well as on\n * persisted rows, and a non-array is treated as conferring nothing — which can only ever make the\n * count smaller, the safe direction (see the module header).\n */\nexport function rolesConferSuperAdmin(roles: unknown, conferringRoles: readonly string[]): boolean {\n if (!Array.isArray(roles)) return false;\n const conferringRoleSet = new Set(conferringRoles);\n return roles.some((role) => typeof role === 'string' && conferringRoleSet.has(role));\n}\n\n/** Whether a status leaves the subject able to authenticate — see {@link ADMINISTRATIVELY_USABLE_USER_STATUSES}. */\nexport function isAdministrativelyUsableStatus(status: unknown): boolean {\n return ADMINISTRATIVELY_USABLE_USER_STATUSES.includes(status as UserStatus);\n}\n\n/** Whether a user row, as it stands, counts as one administratively usable super-administrator. */\nexport function isUsableSuperAdmin(\n user: Pick<User, 'appRoles' | 'status'> | undefined | null,\n conferringRoles: readonly string[],\n): boolean {\n if (!user) return false;\n return rolesConferSuperAdmin(user.appRoles, conferringRoles) && isAdministrativelyUsableStatus(user.status);\n}\n\n/** The narrow row shape the floor count reads. */\ntype SuperAdminFloorCandidateRow = Pick<User, '_id'>;\n\n/**\n * Count the administratively usable super-administrators OTHER than the named subjects.\n *\n * ## Why a LIST and not a `count`\n *\n * `RepositoryResource.count` requires the resource to declare `CoreResourceOperation.COUNT`, and\n * `USERS` does not — it declares READ / LIST / SEARCH / CREATE / UPDATE / UPDATE_MANY / DELETE. A\n * LIST over an indexed (`appRoles` is `.isDBIndexed()`) predicate that selects only application\n * super-administrators returns a population that is inherently tiny, so materialising it costs\n * nothing worth engineering around. Adding a COUNT operation to `USERS` purely to serve this guard\n * would open a new operation surface (and its DTO, its ACL, its route decision) for an internal\n * arithmetic need — a worse trade.\n *\n * ## Why the subjects are excluded in memory rather than in the query\n *\n * A `_id: {$nin: [...]}` fragment would have to agree with the adapter's id representation —\n * MongoDB stores `_id` as an `ObjectId` while every id crossing the service boundary is a string,\n * and a silent cast miss would leave the subject INSIDE the count, satisfying the floor with the\n * very row about to be removed. Comparing `String(row._id)` after the fact cannot fail that way and\n * is exact on both adapters.\n *\n * ## Retention\n *\n * No retention fragment is built here on purpose. `buildContextualFilter` applies the hide at the\n * repository chokepoint for LIST, so retained rows are already absent. Re-stating it here would be\n * a second copy of a rule the retention authority owns — the precise duplication that produced the\n * G-AGG defect it was created to end.\n */\nexport async function countOtherUsableSuperAdmins(params: {\n excludedSubjectIds: readonly string[];\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n operationIdentifier: string;\n}): Promise<number> {\n const { excludedSubjectIds, executionContext, repositoriesRegistry, errorBuilder, conferringRoles, operationIdentifier } = params;\n\n const userRepository = repositoriesRegistry.getRepository(CoreResourceType.USERS);\n\n // Fail closed. Without the repository the population is unknowable, and answering \"0\" would\n // refuse every removal while answering \"many\" would permit the lockout. Neither is a guess worth\n // making on an invariant with no recovery path.\n if (!userRepository) {\n throw errorBuilder.buildError(ErrorType.CONFIGURATION, executionContext, {\n context: {\n message: 'Cannot evaluate the super-administrator floor: the users repository is not registered',\n resourceType: CoreResourceType.USERS,\n operationIdentifier,\n },\n });\n }\n\n const candidates = await userRepository.list<SuperAdminFloorCandidateRow>(executionContext, {\n appRoles: { $in: [...conferringRoles] },\n status: { $in: [...ADMINISTRATIVELY_USABLE_USER_STATUSES] },\n });\n\n const excludedSubjectIdSet = new Set(excludedSubjectIds.map((subjectId) => String(subjectId)));\n const rows: SuperAdminFloorCandidateRow[] = Array.isArray(candidates) ? candidates : [];\n\n return rows.filter((row) => !excludedSubjectIdSet.has(String(row?._id))).length;\n}\n\n/**\n * Refuse a write that would leave the application without an administratively usable\n * super-administrator.\n *\n * Call this ONLY once the caller has established that the named subjects currently count toward the\n * floor and would stop counting — the population query is skipped entirely otherwise, so an\n * ordinary user edit, an additive grant, or the deletion of a non-administrator pays nothing.\n *\n * assurance-control: WILDO.ACCESS.ADMINISTRATIVE_CONTINUITY — refuse the removal of the last\n * accountable administrative principal; the denial is an access-control decision and is recorded as\n * one by the operation's own error path.\n */\nexport async function assertSuperAdminFloorPreserved(params: {\n /** The subjects about to stop counting. Excluded from the population before it is measured. */\n subjectUserIds: readonly string[];\n cause: SuperAdminFloorReductionCause;\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n operationIdentifier: string;\n}): Promise<void> {\n const { subjectUserIds, cause, executionContext, repositoriesRegistry, errorBuilder, conferringRoles, operationIdentifier } = params;\n\n const remainingUsableSuperAdmins = await countOtherUsableSuperAdmins({\n excludedSubjectIds: subjectUserIds,\n executionContext,\n repositoriesRegistry,\n errorBuilder,\n conferringRoles,\n operationIdentifier,\n });\n\n if (remainingUsableSuperAdmins >= SUPER_ADMIN_FLOOR_MINIMUM) return;\n\n // CONFLICT, not AUTHORIZATION and not VALIDATION. The request is well-formed and the caller IS\n // authorized — every one of these operations is gated on the very role being protected. What\n // forbids the write is the current STATE of the application, which is what CONFLICT means. A 403\n // would tell an administrator to acquire authority they already hold (and none exists that lifts\n // this floor); a 400 would tell them to fix a payload that is correct.\n throw errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {\n context: {\n // The WIRE contract — allow-listed by `sanitizeErrorForClient`, so this is what a client\n // switches on. Distinct from `reason` below, which is the internal audit/log filter handle and\n // is deliberately stripped at the boundary; the two must not be conflated.\n code: AdministrativeContinuityErrorCode.LAST_APPLICATION_SUPER_ADMIN,\n reason: SUPER_ADMIN_FLOOR_REFUSAL_REASON,\n message:\n 'Refused: this would leave the application with no usable super-administrator. '\n + SUPER_ADMIN_FLOOR_REMEDY,\n cause,\n operationIdentifier,\n subjectUserIds: [...subjectUserIds],\n remainingUsableSuperAdmins,\n requiredUsableSuperAdmins: SUPER_ADMIN_FLOOR_MINIMUM,\n conferringRoles: [...conferringRoles],\n usableStatuses: [...ADMINISTRATIVELY_USABLE_USER_STATUSES],\n },\n });\n}\n\n/**\n * The floor check for a role/status TRANSITION on a single subject.\n *\n * Encapsulates the short-circuit that keeps the population query off the hot path: the floor can\n * only be threatened when the subject counted BEFORE the write and would not count AFTER it. A\n * subject who was never a usable super-administrator, or who remains one, costs a set membership\n * test and nothing else.\n *\n * That shape is also why the additive `assign_roles` verb can call this unconditionally — a union\n * can never drop conferral, so it always short-circuits — which removes the standing invitation for\n * a future change to the set algebra to bypass the floor unnoticed.\n */\nexport async function assertSuperAdminFloorPreservedForTransition(params: {\n subjectUserId: string;\n previousRoles: unknown;\n previousStatus: unknown;\n nextRoles: unknown;\n nextStatus: unknown;\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n operationIdentifier: string;\n}): Promise<void> {\n const {\n subjectUserId, previousRoles, previousStatus, nextRoles, nextStatus,\n executionContext, repositoriesRegistry, errorBuilder, conferringRoles, operationIdentifier,\n } = params;\n\n const countedBefore = rolesConferSuperAdmin(previousRoles, conferringRoles) && isAdministrativelyUsableStatus(previousStatus);\n if (!countedBefore) return;\n\n const stillConfersRole = rolesConferSuperAdmin(nextRoles, conferringRoles);\n const stillUsableStatus = isAdministrativelyUsableStatus(nextStatus);\n if (stillConfersRole && stillUsableStatus) return;\n\n await assertSuperAdminFloorPreserved({\n subjectUserIds: [subjectUserId],\n // Which axis actually broke it. Role removal is named first when BOTH change in one write: it\n // is the axis the operator authored against the authority field, and the more specific finding.\n cause: !stillConfersRole ? SuperAdminFloorReductionCause.ROLE_REMOVAL : SuperAdminFloorReductionCause.STATUS_CHANGE,\n executionContext,\n repositoriesRegistry,\n errorBuilder,\n conferringRoles,\n operationIdentifier,\n });\n}\n\n/**\n * The floor check for a write that removes the subject's row wholesale — a hard DELETE or a subject\n * erasure (which scrubs the row and retention-hides it, so it stops counting just as decisively).\n *\n * Takes the subjects' CURRENT rows rather than a transition: there is no \"after\" state to compare,\n * the row simply stops counting. Subjects that did not count are filtered out first, so deleting a\n * hundred ordinary users never touches the population query.\n */\nexport async function assertSuperAdminFloorPreservedForRemoval(params: {\n subjects: readonly (Pick<User, '_id' | 'appRoles' | 'status'> | undefined | null)[];\n cause: SuperAdminFloorReductionCause;\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n operationIdentifier: string;\n}): Promise<void> {\n const { subjects, cause, executionContext, repositoriesRegistry, errorBuilder, conferringRoles, operationIdentifier } = params;\n\n const removedUsableSuperAdminIds = subjects\n .filter((subject) => isUsableSuperAdmin(subject, conferringRoles))\n .map((subject) => String(subject!._id));\n\n if (removedUsableSuperAdminIds.length === 0) return;\n\n await assertSuperAdminFloorPreserved({\n subjectUserIds: removedUsableSuperAdminIds,\n cause,\n executionContext,\n repositoriesRegistry,\n errorBuilder,\n conferringRoles,\n operationIdentifier,\n });\n}\n\n/**\n * The resource types whose rows carry the application authority axis, and therefore the subject\n * types whose erasure can breach the floor.\n *\n * `USERS` and `USER_SELF` are two resource configurations over the SAME collection (see\n * `getCollectionNameForResource`), both declaring `RETAIN_AND_IMPERSONALIZE`, so an erasure\n * addressed through either door scrubs and hides the same row.\n */\nexport const SUPER_ADMIN_FLOOR_GOVERNED_SUBJECT_RESOURCE_TYPES: readonly string[] = [\n CoreResourceType.USERS,\n CoreResourceType.USER_SELF,\n];\n\n/** Whether an erasure of this subject resource type can reduce the super-administrator population. */\nexport function isSuperAdminFloorGovernedSubjectResource(resourceType: unknown): boolean {\n return SUPER_ADMIN_FLOOR_GOVERNED_SUBJECT_RESOURCE_TYPES.includes(String(resourceType));\n}\n\n/**\n * Read the subjects an erasure is about to scrub, for the floor check.\n *\n * Reads through the repository so the retention hide applies: a subject ALREADY erased is invisible\n * here, which is correct — it stopped counting at its own erasure, and a re-run must not be refused\n * on account of a row that no longer contributes. A subject that cannot be read is simply absent\n * and contributes nothing, which is the safe direction for a check whose job is to notice the\n * subjects that DO count.\n */\nexport async function readSubjectsForSuperAdminFloor(params: {\n subjectIds: readonly string[];\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n operationIdentifier: string;\n}): Promise<Pick<User, '_id' | 'appRoles' | 'status'>[]> {\n const { subjectIds, executionContext, repositoriesRegistry, errorBuilder, operationIdentifier } = params;\n\n const userRepository = repositoriesRegistry.getRepository(CoreResourceType.USERS);\n\n if (!userRepository) {\n throw errorBuilder.buildError(ErrorType.CONFIGURATION, executionContext, {\n context: {\n message: 'Cannot evaluate the super-administrator floor: the users repository is not registered',\n resourceType: CoreResourceType.USERS,\n operationIdentifier,\n },\n });\n }\n\n const subjects = await userRepository.list<Pick<User, '_id' | 'appRoles' | 'status'>>(\n executionContext,\n [...subjectIds],\n );\n\n return Array.isArray(subjects) ? subjects : [];\n}\n\n/**\n * Measure the floor without refusing anything — the boot-time report.\n *\n * Separate from {@link assertSuperAdminFloorPreserved} because it answers a different question at a\n * moment when refusing is not an option: a fresh application legitimately boots with zero users\n * (the first administrator arrives through seeding or first-run registration), so a startup that\n * failed on this condition would brick every greenfield app. What it CAN do is observe the states\n * no write guard ever saw — a direct database edit, a restore from a backup taken mid-erasure, a\n * seed that authored no administrator, or a role-table reconfiguration that changed which roles\n * confer super-admin out from under an existing population.\n */\nexport async function measureUsableSuperAdminPopulation(params: {\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n}): Promise<{ usableSuperAdminCount: number; meetsFloor: boolean; conferringRoles: string[] }> {\n const usableSuperAdminCount = await countOtherUsableSuperAdmins({\n excludedSubjectIds: [],\n executionContext: params.executionContext,\n repositoriesRegistry: params.repositoriesRegistry,\n errorBuilder: params.errorBuilder,\n conferringRoles: params.conferringRoles,\n operationIdentifier: CoreResourceOperation.LIST,\n });\n\n return {\n usableSuperAdminCount,\n meetsFloor: usableSuperAdminCount >= SUPER_ADMIN_FLOOR_MINIMUM,\n conferringRoles: [...params.conferringRoles],\n };\n}\n\n/** One acknowledged breach of the application floor — reported, never thrown. */\nexport type SuperAdminFloorBreach = {\n erasedUsableSuperAdminIds: string[];\n conferringRoles: string[];\n};\n\n/**\n * The erasure door: refuse by default, defeasible by an explicit controller acknowledgement.\n *\n * The application twin of `assertOrganizationOwnerFloorForSubjectErasure`, and it exists for the same\n * reason that one does — so the POLICY lives in the authority rather than in whichever service\n * happens to call it. A caller that owns the decision must not also own the rule.\n *\n * ## Why this door alone is defeasible\n *\n * See `.claude/rules/administrative-continuity-floors.md`. In short: GDPR Art. 17(3) is a closed list\n * of grounds for refusing an erasure and \"the application would become unadministrable\" is not on it,\n * while Art. 12(3) requires an answer without undue delay. A framework that refuses indefinitely\n * takes that choice away from the application, which is the controller that owes the data subject an\n * answer. Every ADMINISTRATIVE door — `revoke_roles`, core UPDATE, core DELETE — stays unconditional,\n * because nobody holds a right to have their administrative role removed.\n *\n * ## Why the stakes argue FOR the escape, not against it\n *\n * A stranded application is worse than a stranded tenant: there is no scope above it, so there is no\n * higher-tier repair door to reach for, and recovery is necessarily a seed or a direct database\n * write. That is precisely why the escape must be explicit, per-request, non-default and LOUD — the\n * operator's only chance to act is the record this emits, since nobody will discover the state by\n * being denied something later.\n */\nexport async function assertSuperAdminFloorForSubjectErasure(params: {\n subjects: readonly (Pick<User, '_id' | 'appRoles' | 'status'> | undefined | null)[];\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n operationIdentifier: string;\n /** The controller's explicit decision to complete an erasure that strands the application. */\n acknowledgeFloorBreach?: boolean;\n /** Invoked when the breach is acknowledged AND real. Never on the refusal path. */\n onAcknowledgedBreach?: (breach: SuperAdminFloorBreach) => Promise<void> | void;\n}): Promise<void> {\n if (!params.acknowledgeFloorBreach) {\n await assertSuperAdminFloorPreservedForRemoval({\n ...params,\n cause: SuperAdminFloorReductionCause.ERASURE,\n });\n return;\n }\n\n // Acknowledged: nothing is refused, so the only remaining obligation is that the consequence is\n // never silent. The same usability test still runs — an acknowledged erasure that removes no\n // usable administrator must stay quiet, or the alert stops meaning anything.\n const erasedUsableSuperAdminIds = params.subjects\n .filter((subject) => isUsableSuperAdmin(subject, params.conferringRoles))\n .map((subject) => String(subject!._id));\n\n if (erasedUsableSuperAdminIds.length === 0) return;\n\n await params.onAcknowledgedBreach?.({\n erasedUsableSuperAdminIds,\n conferringRoles: [...params.conferringRoles],\n });\n}\n"]}
1
+ {"version":3,"file":"super-admin-floor.backend.utils.js","sourceRoot":"","sources":["../../../../../src/security/authorizations/super-admin-floor.backend.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,GAAG,MAAM,CAAC,eAAe,CAAC;KAC7C,CAAC;AACJ,CAAC;AAQD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAAC,MAW5D;IACC,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACnC,MAAM,wCAAwC,CAAC;YAC7C,GAAG,MAAM;YACT,KAAK,EAAE,6BAA6B,CAAC,OAAO;SAC7C,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,gGAAgG;IAChG,6FAA6F;IAC7F,6EAA6E;IAC7E,MAAM,yBAAyB,GAAG,MAAM,CAAC,QAAQ;SAC9C,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;SACxE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAE1C,IAAI,yBAAyB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEnD,MAAM,MAAM,CAAC,oBAAoB,EAAE,CAAC;QAClC,yBAAyB;QACzB,eAAe,EAAE,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC;KAC7C,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * THE last-super-administrator floor — one semantic authority, consumed by every reducing path.\n *\n * assurance-control: WILDO.ACCESS.ADMINISTRATIVE_CONTINUITY — an application must\n * retain an accountable administrative principal; losing the last one is simultaneously an access-\n * control failure and an availability failure, with no in-product remedy.\n *\n * ## The invariant, stated once\n *\n * An application always retains at least one **administratively usable super-administrator**. Every\n * write that could reduce that population below {@link SUPER_ADMIN_FLOOR_MINIMUM} is refused.\n *\n * ## Why this cannot be left to the operation gates\n *\n * Every path that can remove application authority is itself gated on `APP_ADMIN_SUPER_ADMIN`, so\n * the gates are satisfied precisely by the principal capable of causing the lockout. And every\n * recovery door — `assign_roles`, the core USERS `UPDATE`, the admin console — carries the same\n * gate, so once the population reaches zero there is no in-product way back. That combination is\n * what makes this a fail-closed invariant rather than a warning: the failure is unrecoverable, and\n * the only moment it can be prevented is before the write.\n *\n * ## \"Administratively usable\" — three independent conditions, all resolved toward the SMALLER count\n *\n * 1. **The roles must actually CONFER super-admin.** Testing for the literal\n * `APP_ADMIN_SUPER_ADMIN` string is wrong: roles are application-configurable\n * (`initializeRolesWithCustom`), and an app may register a role with\n * `inheritFrom: APP_ADMIN_SUPER_ADMIN` whose holder passes every super-admin gate —\n * `authorize` admits any role whose `inheritFrom` chain CONTAINS the required one. The\n * conferring set is therefore resolved from the live role table at call time; see\n * {@link resolveSuperAdminConferringRoles}.\n * 2. **The subject must be able to AUTHENTICATE.** `_enforceUserStatus` admits `UserStatus.ACTIVE`\n * and throws `AUTHENTICATION_ACCOUNT_LOCKED` for every other status. A `SUSPENDED` or\n * `PENDING_INVITATION` super-admin would satisfy a naive count while being unable to log in —\n * the exact lockout this module exists to prevent, arriving through the guard itself. See\n * {@link ADMINISTRATIVELY_USABLE_USER_STATUSES}.\n * 3. **The row must not be retention-hidden.** An erased-but-retained user KEEPS its `appRoles`:\n * the field carries no `.impersonalizeWith()` because it is `.isAuditEvidence()` — what decided\n * authority must survive the scrub. So a retained row still MATCHES a role filter while being\n * invisible and frozen to every ordinary path. This condition needs no code here: the repository\n * chokepoint applies the retention hide to LIST, so an ordinary request execution context cannot\n * see retained rows. It is stated because the absence of an explicit filter is otherwise\n * indistinguishable from having forgotten the case.\n *\n * The direction of every ambiguity is deliberate. **Under-counting refuses a legitimate removal**\n * — recoverable by appointing another administrator. **Over-counting permits the lockout** — not\n * recoverable at all. Anything uncertain therefore resolves toward not counting.\n *\n * ## The floor is a POPULATION rule, not a self-demotion check\n *\n * Nothing here compares the subject to the caller. Two usable administrators → either may be\n * demoted, including by themselves. One → nobody may remove it. The asymmetry that looks like it\n * should matter does not: to reach any of these operations a human caller already satisfies an\n * `APP_ADMIN_SUPER_ADMIN` gate, so demoting SOMEONE ELSE means the caller is themselves a second\n * usable administrator and the floor already holds. In practice the guard fires only on\n * self-demotion — but it is written as a population rule because the system paths it also protects\n * (subject erasure) have no human caller to compare against.\n *\n * ## No system / internal bypass\n *\n * `assertRequestedRolesWithinCallerCeiling` exempts `INTERNALLY_INITIATED_REQUEST` because a system\n * write carries no human ceiling to measure. This module deliberately does NOT copy that exemption:\n * a system write that strips the last administrator produces exactly the same unadministrable\n * application as a human one. The concrete case is subject erasure, and refusing it is the correct\n * compliance answer rather than an obstacle to one — an erasure that leaves the application\n * unadministrable is an availability incident, not a completed data-protection request. The\n * operator appoints a successor and then erases; {@link SUPER_ADMIN_FLOOR_REMEDY} is the text that\n * says so.\n */\n\nimport {\n AdministrativeContinuityErrorCode,\n CORE_APP_ROLES,\n CoreResourceOperation,\n CoreResourceType,\n ErrorType,\n ResourcePrimaryScope,\n UserStatus,\n type User,\n} from '@wildo-ai/saas-models';\nimport type { Container } from 'inversify';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport type { ErrorBuilderBackendService } from '~wildo-backend-lib/errors/services/error-builder.backend.service';\nimport type { AuthorizationsBackendService } from '~wildo-backend-lib/security/authorizations/services/authorizations.backend.service';\nimport type { RepositoriesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport { resolveRolesConferringAnchor } from '~wildo-backend-lib/security/authorizations/role-conferral.backend.utils';\n\n/**\n * The minimum number of administratively usable super-administrators an application must retain.\n *\n * Named rather than inlined as `> 0` so the several call sites state the same rule, and so a\n * product that ever requires two (a four-eyes administrative policy) has one place to change.\n */\nexport const SUPER_ADMIN_FLOOR_MINIMUM = 1;\n\n/**\n * The statuses in which a user can actually authenticate, and therefore the only ones that count\n * toward the floor.\n *\n * Derived from `AuthenticationOrchestrator._enforceUserStatus`, which returns for\n * {@link UserStatus.ACTIVE} and throws `AUTHENTICATION_ACCOUNT_LOCKED` for everything else.\n *\n * `PENDING_VERIFICATION` is deliberately EXCLUDED even though the verification flow can flip it to\n * `ACTIVE`: a recoverable administrator is not a usable one, and admitting it would let the floor\n * be satisfied by an account nobody can currently log into. Same for `PENDING_INVITATION`, whose\n * subject has no credentials at all.\n *\n * Kept as an explicit list rather than `!== ACTIVE` so that adding a member to {@link UserStatus}\n * forces a decision here instead of silently inheriting \"usable\".\n */\nexport const ADMINISTRATIVELY_USABLE_USER_STATUSES: readonly UserStatus[] = [UserStatus.ACTIVE];\n\n/**\n * The remedy every refusal names.\n *\n * A guard that only says \"no\" on an operation an administrator is authorized to perform reads as a\n * defect. Stating the one action that unblocks it — appoint another administrator first — is what\n * makes the refusal actionable, and it is the same remedy for a human demotion and for a subject\n * erasure blocked by the floor.\n */\nexport const SUPER_ADMIN_FLOOR_REMEDY =\n 'Grant an application super-administrator role to another active user first, then retry.';\n\n/**\n * The reason code every floor refusal carries, so one filter finds them across the trail.\n *\n * INTERNAL. Not the wire contract — `sanitizeErrorForClient` strips `reason` from a CONFLICT and\n * allow-lists `code`, which carries {@link AdministrativeContinuityErrorCode}. Keep them distinct:\n * this one is free to stay richer than the client-facing code.\n */\nexport const SUPER_ADMIN_FLOOR_REFUSAL_REASON = 'last_super_admin_floor';\n\n/**\n * Why a subject would stop counting toward the floor. Rides the refusal so an operator reading the\n * error (or the audit trail) knows which axis of {@link ADMINISTRATIVELY_USABLE_USER_STATUSES} /\n * role conferral / row existence the blocked write was about to change.\n */\nexport enum SuperAdminFloorReductionCause {\n /** The subject's `appRoles` would no longer confer super-admin. */\n ROLE_REMOVAL = 'role_removal',\n /** The subject's `status` would leave the authenticable set. */\n STATUS_CHANGE = 'status_change',\n /** The subject's row would be destroyed. */\n DELETION = 'deletion',\n /** The subject's row would be scrubbed and retention-hidden. */\n ERASURE = 'erasure',\n}\n\n/**\n * Resolves the role keys that confer super-admin, from the LIVE application role table.\n *\n * Injected rather than imported for the same reason {@link RoleHierarchyResolver} is: the effective\n * hierarchy is application-configurable, so a statically-derived set would silently disagree with\n * the roles the authorization layer actually honours.\n */\nexport type SuperAdminConferralResolver = () => string[];\n\n/**\n * Every APPLICATION-scope role key whose `inheritFrom` chain reaches `APP_ADMIN_SUPER_ADMIN` — i.e.\n * every role whose holder passes a super-admin gate.\n *\n * This floor's BINDING of the shared conferral derivation. The derivation itself, and the reasoning\n * that used to be restated here and in the organization-owner floor in two different sets of words,\n * live in {@link resolveRolesConferringAnchor} — including why the anchor is seeded unconditionally\n * and why the SCOPE argument is what makes an org-scoped role string that happens to spell an app\n * role confer nothing. `appRoles` is the APPLICATION authority axis; ORGANIZATIONS-scope roles are\n * never consulted, and that is now one fact in one place rather than two paragraphs that can drift.\n */\nexport function resolveSuperAdminConferringRoles(\n authorizationsService: Pick<AuthorizationsBackendService, 'getAppRoles' | 'getRoleHierarchy'>,\n): string[] {\n return resolveRolesConferringAnchor({\n anchorRole: CORE_APP_ROLES.APP_ADMIN_SUPER_ADMIN,\n scope: ResourcePrimaryScope.APPLICATION,\n declaredRoleKeys: Object.keys(authorizationsService.getAppRoles() ?? {}),\n roleHierarchyResolver: (roleKey, scope) => authorizationsService.getRoleHierarchy(roleKey as any, scope),\n });\n}\n\n/**\n * Bind a {@link SuperAdminConferralResolver} to the container's live `AuthorizationsBackendService`.\n *\n * Resolution is LAZY then per-call, exactly like `createRoleHierarchyResolver`: custom-implementation\n * factories are constructed during module registration, which can run before the authorization\n * service is bound (an eager `container.get` would turn this into a startup crash), and the role\n * table is mutated in place by `initializeRolesWithCustom`, so the conferring set is recomputed per\n * call rather than memoized. The set is a handful of strings over a table of the same size — the\n * recomputation is far cheaper than the staleness it avoids.\n */\nexport function createSuperAdminConferralResolver(container: Container): SuperAdminConferralResolver {\n let authorizationsService: AuthorizationsBackendService | undefined;\n return () => {\n authorizationsService ??= container.get<AuthorizationsBackendService>(SAAS_SERVICE_TYPES.AuthorizationsService);\n return resolveSuperAdminConferringRoles(authorizationsService);\n };\n}\n\n/**\n * Whether a role array confers super-admin.\n *\n * Defensive on the array itself: this runs on values read from unparsed caller input as well as on\n * persisted rows, and a non-array is treated as conferring nothing — which can only ever make the\n * count smaller, the safe direction (see the module header).\n */\nexport function rolesConferSuperAdmin(roles: unknown, conferringRoles: readonly string[]): boolean {\n if (!Array.isArray(roles)) return false;\n const conferringRoleSet = new Set(conferringRoles);\n return roles.some((role) => typeof role === 'string' && conferringRoleSet.has(role));\n}\n\n/** Whether a status leaves the subject able to authenticate — see {@link ADMINISTRATIVELY_USABLE_USER_STATUSES}. */\nexport function isAdministrativelyUsableStatus(status: unknown): boolean {\n return ADMINISTRATIVELY_USABLE_USER_STATUSES.includes(status as UserStatus);\n}\n\n/** Whether a user row, as it stands, counts as one administratively usable super-administrator. */\nexport function isUsableSuperAdmin(\n user: Pick<User, 'appRoles' | 'status'> | undefined | null,\n conferringRoles: readonly string[],\n): boolean {\n if (!user) return false;\n return rolesConferSuperAdmin(user.appRoles, conferringRoles) && isAdministrativelyUsableStatus(user.status);\n}\n\n/** The narrow row shape the floor count reads. */\ntype SuperAdminFloorCandidateRow = Pick<User, '_id'>;\n\n/**\n * Count the administratively usable super-administrators OTHER than the named subjects.\n *\n * ## Why a LIST and not a `count`\n *\n * `RepositoryResource.count` requires the resource to declare `CoreResourceOperation.COUNT`, and\n * `USERS` does not — it declares READ / LIST / SEARCH / CREATE / UPDATE / UPDATE_MANY / DELETE. A\n * LIST over an indexed (`appRoles` is `.isDBIndexed()`) predicate that selects only application\n * super-administrators returns a population that is inherently tiny, so materialising it costs\n * nothing worth engineering around. Adding a COUNT operation to `USERS` purely to serve this guard\n * would open a new operation surface (and its DTO, its ACL, its route decision) for an internal\n * arithmetic need — a worse trade.\n *\n * ## Why the subjects are excluded in memory rather than in the query\n *\n * A `_id: {$nin: [...]}` fragment would have to agree with the adapter's id representation —\n * MongoDB stores `_id` as an `ObjectId` while every id crossing the service boundary is a string,\n * and a silent cast miss would leave the subject INSIDE the count, satisfying the floor with the\n * very row about to be removed. Comparing `String(row._id)` after the fact cannot fail that way and\n * is exact on both adapters.\n *\n * ## Retention\n *\n * No retention fragment is built here on purpose. `buildContextualFilter` applies the hide at the\n * repository chokepoint for LIST, so retained rows are already absent. Re-stating it here would be\n * a second copy of a rule the retention authority owns — the precise duplication that produced the\n * G-AGG defect it was created to end.\n */\nexport async function countOtherUsableSuperAdmins(params: {\n excludedSubjectIds: readonly string[];\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n operationIdentifier: string;\n}): Promise<number> {\n const { excludedSubjectIds, executionContext, repositoriesRegistry, errorBuilder, conferringRoles, operationIdentifier } = params;\n\n const userRepository = repositoriesRegistry.getRepository(CoreResourceType.USERS);\n\n // Fail closed. Without the repository the population is unknowable, and answering \"0\" would\n // refuse every removal while answering \"many\" would permit the lockout. Neither is a guess worth\n // making on an invariant with no recovery path.\n if (!userRepository) {\n throw errorBuilder.buildError(ErrorType.CONFIGURATION, executionContext, {\n context: {\n message: 'Cannot evaluate the super-administrator floor: the users repository is not registered',\n resourceType: CoreResourceType.USERS,\n operationIdentifier,\n },\n });\n }\n\n const candidates = await userRepository.list<SuperAdminFloorCandidateRow>(executionContext, {\n appRoles: { $in: [...conferringRoles] },\n status: { $in: [...ADMINISTRATIVELY_USABLE_USER_STATUSES] },\n });\n\n const excludedSubjectIdSet = new Set(excludedSubjectIds.map((subjectId) => String(subjectId)));\n const rows: SuperAdminFloorCandidateRow[] = Array.isArray(candidates) ? candidates : [];\n\n return rows.filter((row) => !excludedSubjectIdSet.has(String(row?._id))).length;\n}\n\n/**\n * Refuse a write that would leave the application without an administratively usable\n * super-administrator.\n *\n * Call this ONLY once the caller has established that the named subjects currently count toward the\n * floor and would stop counting — the population query is skipped entirely otherwise, so an\n * ordinary user edit, an additive grant, or the deletion of a non-administrator pays nothing.\n *\n * assurance-control: WILDO.ACCESS.ADMINISTRATIVE_CONTINUITY — refuse the removal of the last\n * accountable administrative principal; the denial is an access-control decision and is recorded as\n * one by the operation's own error path.\n */\nexport async function assertSuperAdminFloorPreserved(params: {\n /** The subjects about to stop counting. Excluded from the population before it is measured. */\n subjectUserIds: readonly string[];\n cause: SuperAdminFloorReductionCause;\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n operationIdentifier: string;\n}): Promise<void> {\n const { subjectUserIds, cause, executionContext, repositoriesRegistry, errorBuilder, conferringRoles, operationIdentifier } = params;\n\n const remainingUsableSuperAdmins = await countOtherUsableSuperAdmins({\n excludedSubjectIds: subjectUserIds,\n executionContext,\n repositoriesRegistry,\n errorBuilder,\n conferringRoles,\n operationIdentifier,\n });\n\n if (remainingUsableSuperAdmins >= SUPER_ADMIN_FLOOR_MINIMUM) return;\n\n // CONFLICT, not AUTHORIZATION and not VALIDATION. The request is well-formed and the caller IS\n // authorized — every one of these operations is gated on the very role being protected. What\n // forbids the write is the current STATE of the application, which is what CONFLICT means. A 403\n // would tell an administrator to acquire authority they already hold (and none exists that lifts\n // this floor); a 400 would tell them to fix a payload that is correct.\n throw errorBuilder.buildError(ErrorType.CONFLICT, executionContext, {\n context: {\n // The WIRE contract — allow-listed by `sanitizeErrorForClient`, so this is what a client\n // switches on. Distinct from `reason` below, which is the internal audit/log filter handle and\n // is deliberately stripped at the boundary; the two must not be conflated.\n code: AdministrativeContinuityErrorCode.LAST_APPLICATION_SUPER_ADMIN,\n reason: SUPER_ADMIN_FLOOR_REFUSAL_REASON,\n message:\n 'Refused: this would leave the application with no usable super-administrator. '\n + SUPER_ADMIN_FLOOR_REMEDY,\n cause,\n operationIdentifier,\n subjectUserIds: [...subjectUserIds],\n remainingUsableSuperAdmins,\n requiredUsableSuperAdmins: SUPER_ADMIN_FLOOR_MINIMUM,\n conferringRoles: [...conferringRoles],\n usableStatuses: [...ADMINISTRATIVELY_USABLE_USER_STATUSES],\n },\n });\n}\n\n/**\n * The floor check for a role/status TRANSITION on a single subject.\n *\n * Encapsulates the short-circuit that keeps the population query off the hot path: the floor can\n * only be threatened when the subject counted BEFORE the write and would not count AFTER it. A\n * subject who was never a usable super-administrator, or who remains one, costs a set membership\n * test and nothing else.\n *\n * That shape is also why the additive `assign_roles` verb can call this unconditionally — a union\n * can never drop conferral, so it always short-circuits — which removes the standing invitation for\n * a future change to the set algebra to bypass the floor unnoticed.\n */\nexport async function assertSuperAdminFloorPreservedForTransition(params: {\n subjectUserId: string;\n previousRoles: unknown;\n previousStatus: unknown;\n nextRoles: unknown;\n nextStatus: unknown;\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n operationIdentifier: string;\n}): Promise<void> {\n const {\n subjectUserId, previousRoles, previousStatus, nextRoles, nextStatus,\n executionContext, repositoriesRegistry, errorBuilder, conferringRoles, operationIdentifier,\n } = params;\n\n const countedBefore = rolesConferSuperAdmin(previousRoles, conferringRoles) && isAdministrativelyUsableStatus(previousStatus);\n if (!countedBefore) return;\n\n const stillConfersRole = rolesConferSuperAdmin(nextRoles, conferringRoles);\n const stillUsableStatus = isAdministrativelyUsableStatus(nextStatus);\n if (stillConfersRole && stillUsableStatus) return;\n\n await assertSuperAdminFloorPreserved({\n subjectUserIds: [subjectUserId],\n // Which axis actually broke it. Role removal is named first when BOTH change in one write: it\n // is the axis the operator authored against the authority field, and the more specific finding.\n cause: !stillConfersRole ? SuperAdminFloorReductionCause.ROLE_REMOVAL : SuperAdminFloorReductionCause.STATUS_CHANGE,\n executionContext,\n repositoriesRegistry,\n errorBuilder,\n conferringRoles,\n operationIdentifier,\n });\n}\n\n/**\n * The floor check for a write that removes the subject's row wholesale — a hard DELETE or a subject\n * erasure (which scrubs the row and retention-hides it, so it stops counting just as decisively).\n *\n * Takes the subjects' CURRENT rows rather than a transition: there is no \"after\" state to compare,\n * the row simply stops counting. Subjects that did not count are filtered out first, so deleting a\n * hundred ordinary users never touches the population query.\n */\nexport async function assertSuperAdminFloorPreservedForRemoval(params: {\n subjects: readonly (Pick<User, '_id' | 'appRoles' | 'status'> | undefined | null)[];\n cause: SuperAdminFloorReductionCause;\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n operationIdentifier: string;\n}): Promise<void> {\n const { subjects, cause, executionContext, repositoriesRegistry, errorBuilder, conferringRoles, operationIdentifier } = params;\n\n const removedUsableSuperAdminIds = subjects\n .filter((subject) => isUsableSuperAdmin(subject, conferringRoles))\n .map((subject) => String(subject!._id));\n\n if (removedUsableSuperAdminIds.length === 0) return;\n\n await assertSuperAdminFloorPreserved({\n subjectUserIds: removedUsableSuperAdminIds,\n cause,\n executionContext,\n repositoriesRegistry,\n errorBuilder,\n conferringRoles,\n operationIdentifier,\n });\n}\n\n/**\n * The resource types whose rows carry the application authority axis, and therefore the subject\n * types whose erasure can breach the floor.\n *\n * `USERS` and `USER_SELF` are two resource configurations over the SAME collection (see\n * `getCollectionNameForResource`), both declaring `RETAIN_AND_IMPERSONALIZE`, so an erasure\n * addressed through either door scrubs and hides the same row.\n */\nexport const SUPER_ADMIN_FLOOR_GOVERNED_SUBJECT_RESOURCE_TYPES: readonly string[] = [\n CoreResourceType.USERS,\n CoreResourceType.USER_SELF,\n];\n\n/** Whether an erasure of this subject resource type can reduce the super-administrator population. */\nexport function isSuperAdminFloorGovernedSubjectResource(resourceType: unknown): boolean {\n return SUPER_ADMIN_FLOOR_GOVERNED_SUBJECT_RESOURCE_TYPES.includes(String(resourceType));\n}\n\n/**\n * Read the subjects an erasure is about to scrub, for the floor check.\n *\n * Reads through the repository so the retention hide applies: a subject ALREADY erased is invisible\n * here, which is correct — it stopped counting at its own erasure, and a re-run must not be refused\n * on account of a row that no longer contributes. A subject that cannot be read is simply absent\n * and contributes nothing, which is the safe direction for a check whose job is to notice the\n * subjects that DO count.\n */\nexport async function readSubjectsForSuperAdminFloor(params: {\n subjectIds: readonly string[];\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n operationIdentifier: string;\n}): Promise<Pick<User, '_id' | 'appRoles' | 'status'>[]> {\n const { subjectIds, executionContext, repositoriesRegistry, errorBuilder, operationIdentifier } = params;\n\n const userRepository = repositoriesRegistry.getRepository(CoreResourceType.USERS);\n\n if (!userRepository) {\n throw errorBuilder.buildError(ErrorType.CONFIGURATION, executionContext, {\n context: {\n message: 'Cannot evaluate the super-administrator floor: the users repository is not registered',\n resourceType: CoreResourceType.USERS,\n operationIdentifier,\n },\n });\n }\n\n const subjects = await userRepository.list<Pick<User, '_id' | 'appRoles' | 'status'>>(\n executionContext,\n [...subjectIds],\n );\n\n return Array.isArray(subjects) ? subjects : [];\n}\n\n/**\n * Measure the floor without refusing anything — the boot-time report.\n *\n * Separate from {@link assertSuperAdminFloorPreserved} because it answers a different question at a\n * moment when refusing is not an option: a fresh application legitimately boots with zero users\n * (the first administrator arrives through seeding or first-run registration), so a startup that\n * failed on this condition would brick every greenfield app. What it CAN do is observe the states\n * no write guard ever saw — a direct database edit, a restore from a backup taken mid-erasure, a\n * seed that authored no administrator, or a role-table reconfiguration that changed which roles\n * confer super-admin out from under an existing population.\n */\nexport async function measureUsableSuperAdminPopulation(params: {\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n}): Promise<{ usableSuperAdminCount: number; meetsFloor: boolean; conferringRoles: string[] }> {\n const usableSuperAdminCount = await countOtherUsableSuperAdmins({\n excludedSubjectIds: [],\n executionContext: params.executionContext,\n repositoriesRegistry: params.repositoriesRegistry,\n errorBuilder: params.errorBuilder,\n conferringRoles: params.conferringRoles,\n operationIdentifier: CoreResourceOperation.LIST,\n });\n\n return {\n usableSuperAdminCount,\n meetsFloor: usableSuperAdminCount >= SUPER_ADMIN_FLOOR_MINIMUM,\n conferringRoles: [...params.conferringRoles],\n };\n}\n\n/** One acknowledged breach of the application floor — reported, never thrown. */\nexport type SuperAdminFloorBreach = {\n erasedUsableSuperAdminIds: string[];\n conferringRoles: string[];\n};\n\n/**\n * The erasure door: refuse by default, defeasible by an explicit controller acknowledgement.\n *\n * The application twin of `assertOrganizationOwnerFloorForSubjectErasure`, and it exists for the same\n * reason that one does — so the POLICY lives in the authority rather than in whichever service\n * happens to call it. A caller that owns the decision must not also own the rule.\n *\n * ## Why this door alone is defeasible\n *\n * See `.claude/rules/administrative-continuity-floors.md`. In short: GDPR Art. 17(3) is a closed list\n * of grounds for refusing an erasure and \"the application would become unadministrable\" is not on it,\n * while Art. 12(3) requires an answer without undue delay. A framework that refuses indefinitely\n * takes that choice away from the application, which is the controller that owes the data subject an\n * answer. Every ADMINISTRATIVE door — `revoke_roles`, core UPDATE, core DELETE — stays unconditional,\n * because nobody holds a right to have their administrative role removed.\n *\n * ## Why the stakes argue FOR the escape, not against it\n *\n * A stranded application is worse than a stranded tenant: there is no scope above it, so there is no\n * higher-tier repair door to reach for, and recovery is necessarily a seed or a direct database\n * write. That is precisely why the escape must be explicit, per-request, non-default and LOUD — the\n * operator's only chance to act is the record this emits, since nobody will discover the state by\n * being denied something later.\n */\nexport async function assertSuperAdminFloorForSubjectErasure(params: {\n subjects: readonly (Pick<User, '_id' | 'appRoles' | 'status'> | undefined | null)[];\n executionContext: ExecutionContext<any>;\n repositoriesRegistry: RepositoriesRegistryHandlerBackendService;\n errorBuilder: ErrorBuilderBackendService;\n conferringRoles: readonly string[];\n operationIdentifier: string;\n /** The controller's explicit decision to complete an erasure that strands the application. */\n acknowledgeFloorBreach?: boolean;\n /** Invoked when the breach is acknowledged AND real. Never on the refusal path. */\n onAcknowledgedBreach?: (breach: SuperAdminFloorBreach) => Promise<void> | void;\n}): Promise<void> {\n if (!params.acknowledgeFloorBreach) {\n await assertSuperAdminFloorPreservedForRemoval({\n ...params,\n cause: SuperAdminFloorReductionCause.ERASURE,\n });\n return;\n }\n\n // Acknowledged: nothing is refused, so the only remaining obligation is that the consequence is\n // never silent. The same usability test still runs — an acknowledged erasure that removes no\n // usable administrator must stay quiet, or the alert stops meaning anything.\n const erasedUsableSuperAdminIds = params.subjects\n .filter((subject) => isUsableSuperAdmin(subject, params.conferringRoles))\n .map((subject) => String(subject!._id));\n\n if (erasedUsableSuperAdminIds.length === 0) return;\n\n await params.onAcknowledgedBreach?.({\n erasedUsableSuperAdminIds,\n conferringRoles: [...params.conferringRoles],\n });\n}\n"]}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * MAY this execution act for THAT owner — the authorization half of a connection target.
3
+ *
4
+ * assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — confines whose third-party account an execution
5
+ * may spend to the tenants the initiator actually belongs to.
6
+ * assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — a unit-scoped grant confers no organization-wide
7
+ * authority here, and a platform operator's administrative reach does not extend to acting as a
8
+ * tenant toward a third party.
9
+ *
10
+ * The call NAMES whose account it spends; this decides whether it may. Keeping the two apart is what
11
+ * lets the target vary within one execution: a single user action pushing a message to every
12
+ * organization that user belongs to issues N calls with N owners and one initiator, so an authority
13
+ * derived from the ambient scope could not answer for more than the first.
14
+ *
15
+ * ## Membership, not current scope — and the difference is the whole point
16
+ *
17
+ * `initiatorIds.organizationId` is the tenant the request is ACTING IN, and it is trustworthy: the
18
+ * execution-context creator validates a requested organization against the caller's memberships and
19
+ * refuses one they do not belong to. It is also singular, so testing against it would refuse the
20
+ * fan-out above — the caller legitimately spends several tenants' accounts under one ambient scope.
21
+ *
22
+ * `initiatorRoles` carries the full set: one entry per organization the initiator belongs to, built
23
+ * at authentication from real memberships and not authorable by a caller. That set is exactly the
24
+ * question this asks, and asking it needs no database read — which matters, because this runs on
25
+ * every outbound provider call.
26
+ *
27
+ * ## Organization-WIDE membership only
28
+ *
29
+ * A unit-scoped role entry is deliberately not enough. Spending a tenant's credential acts as the
30
+ * WHOLE workspace toward the vendor — there is no such thing as sending a Slack message as one
31
+ * department — so admitting a unit-scoped grant would turn "manager of Sales" into "may act as the
32
+ * entire tenant toward every third party it has connected". That is the escalation
33
+ * `isOrganizationWideRoleInfo` exists to prevent, and this asks through it rather than testing the
34
+ * narrowing field by hand.
35
+ *
36
+ * ## What is deliberately REFUSED here, rather than forgotten
37
+ *
38
+ * A platform operator who is not a member cannot spend a tenant's provider credential, even holding
39
+ * `APP_ADMIN_SUPER_ADMIN`. Cross-tenant administrative reach exists and is declared per operation
40
+ * variant, and since the access-grant work it also requires a usable, time-bound grant — but none of
41
+ * that has been extended to mean "may act as this tenant toward a third party", which is a different
42
+ * and larger act than administering its rows: it produces effects in a system Wildo does not own,
43
+ * under the tenant's identity, where no later review can reach them. Admitting it is a decision with
44
+ * its own evidence, not a corollary of an existing door.
45
+ *
46
+ * An unattributed internal call is refused for a mechanical reason on top of that one: an
47
+ * `INTERNALLY_INITIATED_REQUEST` is forbidden from carrying an `organizationId` at all, so a
48
+ * background job that must spend a tenant's account has to run under the originating principal
49
+ * (`createForDeferredAuthorizedEffect`) or an `ORGANIZATION_MACHINE` identity. Falling back to the
50
+ * application's account instead is the substitution this whole subsystem exists to remove.
51
+ */
52
+ import type { ExternalProvider_ConnectionTarget } from '@wildo-ai/external-connectors-models';
53
+ import type { ExecutionContext } from '../../runtime/models/execution-context.backend.schemas';
54
+ import type { ConnectionTargetAuthorizationPort } from '../../base-classes/services/repositories/http-api/http-api-provider-access.backend';
55
+ /** Every organization the initiator belongs to ORGANIZATION-WIDE. */
56
+ export declare function organizationWideMembershipsOf(executionContext: unknown): readonly string[];
57
+ export declare class InitiatorMembershipConnectionTargetAuthorization implements ConnectionTargetAuthorizationPort {
58
+ mayActFor(target: ExternalProvider_ConnectionTarget, executionContext: ExecutionContext<any>): Promise<boolean>;
59
+ }
60
+ //# sourceMappingURL=connection-target-authorization.backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-target-authorization.backend.d.ts","sourceRoot":"","sources":["../../../../../src/security/connected-accounts/connection-target-authorization.backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAIH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,sCAAsC,CAAC;AAE9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAC5G,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,iGAAiG,CAAC;AAazJ,qEAAqE;AACrE,wBAAgB,6BAA6B,CAAC,gBAAgB,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAW1F;AAED,qBAAa,gDAAiD,YAAW,iCAAiC;IAC3F,SAAS,CACpB,MAAM,EAAE,iCAAiC,EACzC,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAC,GACtC,OAAO,CAAC,OAAO,CAAC;CAapB"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * MAY this execution act for THAT owner — the authorization half of a connection target.
3
+ *
4
+ * assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — confines whose third-party account an execution
5
+ * may spend to the tenants the initiator actually belongs to.
6
+ * assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — a unit-scoped grant confers no organization-wide
7
+ * authority here, and a platform operator's administrative reach does not extend to acting as a
8
+ * tenant toward a third party.
9
+ *
10
+ * The call NAMES whose account it spends; this decides whether it may. Keeping the two apart is what
11
+ * lets the target vary within one execution: a single user action pushing a message to every
12
+ * organization that user belongs to issues N calls with N owners and one initiator, so an authority
13
+ * derived from the ambient scope could not answer for more than the first.
14
+ *
15
+ * ## Membership, not current scope — and the difference is the whole point
16
+ *
17
+ * `initiatorIds.organizationId` is the tenant the request is ACTING IN, and it is trustworthy: the
18
+ * execution-context creator validates a requested organization against the caller's memberships and
19
+ * refuses one they do not belong to. It is also singular, so testing against it would refuse the
20
+ * fan-out above — the caller legitimately spends several tenants' accounts under one ambient scope.
21
+ *
22
+ * `initiatorRoles` carries the full set: one entry per organization the initiator belongs to, built
23
+ * at authentication from real memberships and not authorable by a caller. That set is exactly the
24
+ * question this asks, and asking it needs no database read — which matters, because this runs on
25
+ * every outbound provider call.
26
+ *
27
+ * ## Organization-WIDE membership only
28
+ *
29
+ * A unit-scoped role entry is deliberately not enough. Spending a tenant's credential acts as the
30
+ * WHOLE workspace toward the vendor — there is no such thing as sending a Slack message as one
31
+ * department — so admitting a unit-scoped grant would turn "manager of Sales" into "may act as the
32
+ * entire tenant toward every third party it has connected". That is the escalation
33
+ * `isOrganizationWideRoleInfo` exists to prevent, and this asks through it rather than testing the
34
+ * narrowing field by hand.
35
+ *
36
+ * ## What is deliberately REFUSED here, rather than forgotten
37
+ *
38
+ * A platform operator who is not a member cannot spend a tenant's provider credential, even holding
39
+ * `APP_ADMIN_SUPER_ADMIN`. Cross-tenant administrative reach exists and is declared per operation
40
+ * variant, and since the access-grant work it also requires a usable, time-bound grant — but none of
41
+ * that has been extended to mean "may act as this tenant toward a third party", which is a different
42
+ * and larger act than administering its rows: it produces effects in a system Wildo does not own,
43
+ * under the tenant's identity, where no later review can reach them. Admitting it is a decision with
44
+ * its own evidence, not a corollary of an existing door.
45
+ *
46
+ * An unattributed internal call is refused for a mechanical reason on top of that one: an
47
+ * `INTERNALLY_INITIATED_REQUEST` is forbidden from carrying an `organizationId` at all, so a
48
+ * background job that must spend a tenant's account has to run under the originating principal
49
+ * (`createForDeferredAuthorizedEffect`) or an `ORGANIZATION_MACHINE` identity. Falling back to the
50
+ * application's account instead is the substitution this whole subsystem exists to remove.
51
+ */
52
+ import { ResourcePrimaryScope, isOrganizationWideRoleInfo } from '@wildo-ai/saas-models';
53
+ import { ExternalProvider_Connection_OwnerScope } from '@wildo-ai/external-connectors-models';
54
+ /** Every organization the initiator belongs to ORGANIZATION-WIDE. */
55
+ export function organizationWideMembershipsOf(executionContext) {
56
+ const signal = executionContext;
57
+ return [
58
+ ...new Set((signal.initiatorRoles ?? [])
59
+ .filter((roleInfo) => roleInfo.relatedPrimaryScope === ResourcePrimaryScope.ORGANIZATIONS)
60
+ .filter((roleInfo) => isOrganizationWideRoleInfo(roleInfo))
61
+ .map((roleInfo) => roleInfo.relatedResourceId)
62
+ .filter((organizationId) => typeof organizationId === 'string' && organizationId.length > 0)),
63
+ ];
64
+ }
65
+ export class InitiatorMembershipConnectionTargetAuthorization {
66
+ async mayActFor(target, executionContext) {
67
+ if (target.ownerScope === ExternalProvider_Connection_OwnerScope.APPLICATION)
68
+ return true;
69
+ if (target.ownerScope === ExternalProvider_Connection_OwnerScope.USER) {
70
+ // Only the person themselves. A personal key is not something an administrator may spend on
71
+ // the holder's behalf: the vendor would record the act as the holder's, and consent to store
72
+ // a key is not consent for someone else to use it.
73
+ const userId = executionContext.initiatorIds?.userId;
74
+ return typeof userId === 'string' && userId === target.ownerId;
75
+ }
76
+ return organizationWideMembershipsOf(executionContext).includes(target.ownerId ?? '');
77
+ }
78
+ }
79
+ //# sourceMappingURL=connection-target-authorization.backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-target-authorization.backend.js","sourceRoot":"","sources":["../../../../../src/security/connected-accounts/connection-target-authorization.backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EAAE,sCAAsC,EAAE,MAAM,sCAAsC,CAAC;AAiB9F,qEAAqE;AACrE,MAAM,UAAU,6BAA6B,CAAC,gBAAyB;IACrE,MAAM,MAAM,GAAG,gBAAmC,CAAC;IACnD,OAAO;QACL,GAAG,IAAI,GAAG,CACR,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC;aAC1B,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,mBAAmB,KAAK,oBAAoB,CAAC,aAAa,CAAC;aACzF,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,0BAA0B,CAAC,QAAiB,CAAC,CAAC;aACnE,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;aAC7C,MAAM,CAAC,CAAC,cAAc,EAA4B,EAAE,CAAC,OAAO,cAAc,KAAK,QAAQ,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CACzH;KACF,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,gDAAgD;IACpD,KAAK,CAAC,SAAS,CACpB,MAAyC,EACzC,gBAAuC;QAEvC,IAAI,MAAM,CAAC,UAAU,KAAK,sCAAsC,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC;QAE1F,IAAI,MAAM,CAAC,UAAU,KAAK,sCAAsC,CAAC,IAAI,EAAE,CAAC;YACtE,4FAA4F;YAC5F,6FAA6F;YAC7F,mDAAmD;YACnD,MAAM,MAAM,GAAI,gBAAoC,CAAC,YAAY,EAAE,MAAM,CAAC;YAC1E,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,MAAM,CAAC,OAAO,CAAC;QACjE,CAAC;QAED,OAAO,6BAA6B,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IACxF,CAAC;CACF","sourcesContent":["/**\n * MAY this execution act for THAT owner — the authorization half of a connection target.\n *\n * assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — confines whose third-party account an execution\n * may spend to the tenants the initiator actually belongs to.\n * assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — a unit-scoped grant confers no organization-wide\n * authority here, and a platform operator's administrative reach does not extend to acting as a\n * tenant toward a third party.\n *\n * The call NAMES whose account it spends; this decides whether it may. Keeping the two apart is what\n * lets the target vary within one execution: a single user action pushing a message to every\n * organization that user belongs to issues N calls with N owners and one initiator, so an authority\n * derived from the ambient scope could not answer for more than the first.\n *\n * ## Membership, not current scope — and the difference is the whole point\n *\n * `initiatorIds.organizationId` is the tenant the request is ACTING IN, and it is trustworthy: the\n * execution-context creator validates a requested organization against the caller's memberships and\n * refuses one they do not belong to. It is also singular, so testing against it would refuse the\n * fan-out above — the caller legitimately spends several tenants' accounts under one ambient scope.\n *\n * `initiatorRoles` carries the full set: one entry per organization the initiator belongs to, built\n * at authentication from real memberships and not authorable by a caller. That set is exactly the\n * question this asks, and asking it needs no database read — which matters, because this runs on\n * every outbound provider call.\n *\n * ## Organization-WIDE membership only\n *\n * A unit-scoped role entry is deliberately not enough. Spending a tenant's credential acts as the\n * WHOLE workspace toward the vendor — there is no such thing as sending a Slack message as one\n * department — so admitting a unit-scoped grant would turn \"manager of Sales\" into \"may act as the\n * entire tenant toward every third party it has connected\". That is the escalation\n * `isOrganizationWideRoleInfo` exists to prevent, and this asks through it rather than testing the\n * narrowing field by hand.\n *\n * ## What is deliberately REFUSED here, rather than forgotten\n *\n * A platform operator who is not a member cannot spend a tenant's provider credential, even holding\n * `APP_ADMIN_SUPER_ADMIN`. Cross-tenant administrative reach exists and is declared per operation\n * variant, and since the access-grant work it also requires a usable, time-bound grant — but none of\n * that has been extended to mean \"may act as this tenant toward a third party\", which is a different\n * and larger act than administering its rows: it produces effects in a system Wildo does not own,\n * under the tenant's identity, where no later review can reach them. Admitting it is a decision with\n * its own evidence, not a corollary of an existing door.\n *\n * An unattributed internal call is refused for a mechanical reason on top of that one: an\n * `INTERNALLY_INITIATED_REQUEST` is forbidden from carrying an `organizationId` at all, so a\n * background job that must spend a tenant's account has to run under the originating principal\n * (`createForDeferredAuthorizedEffect`) or an `ORGANIZATION_MACHINE` identity. Falling back to the\n * application's account instead is the substitution this whole subsystem exists to remove.\n */\n\nimport { ResourcePrimaryScope, isOrganizationWideRoleInfo } from '@wildo-ai/saas-models';\nimport { ExternalProvider_Connection_OwnerScope } from '@wildo-ai/external-connectors-models';\nimport type { ExternalProvider_ConnectionTarget } from '@wildo-ai/external-connectors-models';\n\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport type { ConnectionTargetAuthorizationPort } from '~wildo-backend-lib/base-classes/services/repositories/http-api/http-api-provider-access.backend';\n\n/** The narrow view this authority needs. Kept minimal so a unit harness need not build a context. */\ninterface InitiatorSignal {\n readonly initiatorIds?: { readonly userId?: string | null } | null;\n readonly initiatorRoles?: readonly {\n readonly relatedPrimaryScope: ResourcePrimaryScope;\n readonly relatedResourceId?: string;\n readonly organizationUnitId?: string;\n readonly roles: readonly string[];\n }[] | null;\n}\n\n/** Every organization the initiator belongs to ORGANIZATION-WIDE. */\nexport function organizationWideMembershipsOf(executionContext: unknown): readonly string[] {\n const signal = executionContext as InitiatorSignal;\n return [\n ...new Set(\n (signal.initiatorRoles ?? [])\n .filter((roleInfo) => roleInfo.relatedPrimaryScope === ResourcePrimaryScope.ORGANIZATIONS)\n .filter((roleInfo) => isOrganizationWideRoleInfo(roleInfo as never))\n .map((roleInfo) => roleInfo.relatedResourceId)\n .filter((organizationId): organizationId is string => typeof organizationId === 'string' && organizationId.length > 0),\n ),\n ];\n}\n\nexport class InitiatorMembershipConnectionTargetAuthorization implements ConnectionTargetAuthorizationPort {\n public async mayActFor(\n target: ExternalProvider_ConnectionTarget,\n executionContext: ExecutionContext<any>,\n ): Promise<boolean> {\n if (target.ownerScope === ExternalProvider_Connection_OwnerScope.APPLICATION) return true;\n\n if (target.ownerScope === ExternalProvider_Connection_OwnerScope.USER) {\n // Only the person themselves. A personal key is not something an administrator may spend on\n // the holder's behalf: the vendor would record the act as the holder's, and consent to store\n // a key is not consent for someone else to use it.\n const userId = (executionContext as InitiatorSignal).initiatorIds?.userId;\n return typeof userId === 'string' && userId === target.ownerId;\n }\n\n return organizationWideMembershipsOf(executionContext).includes(target.ownerId ?? '');\n }\n}\n"]}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Connecting a third-party account — the two HTTP legs of the authorization-code flow.
3
+ *
4
+ * `POST /connections/:providerRef/start` answers with the URL to send somebody to.
5
+ * `GET /connections/callback` receives them back and stores the grant.
6
+ *
7
+ * ## The opposite direction from the OAuth controller next door
8
+ *
9
+ * `oauth-provider-controller` makes this application an OAuth PROVIDER, and
10
+ * `authentication-controller` signs people IN using a vendor as their identity provider. This
11
+ * connects a vendor account so the application can act AS that account. Same RFC, opposite arrow,
12
+ * and nothing is shared but the specification.
13
+ *
14
+ * ## Everything arriving on the callback is attacker-controllable
15
+ *
16
+ * The callback is reached by a redirect through the person's own browser. Its query string is
17
+ * whatever somebody put there. So the callback trusts NOTHING from its own URL except the `state`,
18
+ * which it uses only as a lookup key — the provider, the owner, the PKCE verifier and the redirect
19
+ * URI all come from the record that was written when the redirect went out. A callback that read the
20
+ * owner from a query parameter would let anybody choose whose account a grant is stored against.
21
+ *
22
+ * ## Why the start leg returns a URL instead of redirecting
23
+ *
24
+ * The caller is a fetch from a settings screen, not a browser navigation. A 302 to a vendor would be
25
+ * followed by the fetch, produce an opaque cross-origin response, and never reach the person — the
26
+ * consent screen would render into a response body nobody sees. The screen navigates itself.
27
+ *
28
+ * assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — a principal authorizes this
29
+ * application to act toward a named third party on their behalf.
30
+ */
31
+ import 'reflect-metadata';
32
+ import { AbstractControllerBackendService } from '../../../base-classes/services/controllers/abstract-controller.backend.service';
33
+ import type { LoggerService } from '../../../monitoring/logger/services/logger.service';
34
+ import type { ErrorBuilderBackendService } from '../../../errors/services/error-builder.backend.service';
35
+ import type { ErrorHandlerService } from '../../../errors/services/error-handler.backend.service';
36
+ import type { AuthJwtGuardBackendService } from '../../../security/jwt/services/auth-jwt-guard.backend.service';
37
+ import type { AuthExecutionContextFactoryBackendService } from '../../../security/authentications/services/auth-execution-context-factory.backend.service';
38
+ import type { ExternalProvidersRegistryBackendService } from '../../../external-providers/services/external-providers-registry.backend.service';
39
+ import type { ConnectionTargetAuthorizationPort } from '../../../base-classes/services/repositories/http-api/http-api-provider-access.backend';
40
+ import type { AppConfigurationService } from '../../../config/services/app-configuration.backend.service';
41
+ import type { ProviderOAuth2PendingAuthorizationBackendService } from '../services/provider-oauth2-pending-authorization.backend.service';
42
+ import type { UserProviderCredentialStoreBackendService } from '../services/user-provider-credential-store.backend.service';
43
+ import type { OrganizationProviderCredentialStoreBackendService } from '../services/organization-provider-credential-store.backend.service';
44
+ export declare class ProviderConnectionControllerBackendService extends AbstractControllerBackendService {
45
+ private readonly authJwtGuard;
46
+ private readonly authEcFactory;
47
+ private readonly registry;
48
+ private readonly pending;
49
+ private readonly targetAuthorization;
50
+ private readonly userCredentials;
51
+ private readonly organizationCredentials;
52
+ private readonly appConfig;
53
+ constructor(logger: LoggerService, errorBuilder: ErrorBuilderBackendService, errorHandler: ErrorHandlerService, authJwtGuard: AuthJwtGuardBackendService, authEcFactory: AuthExecutionContextFactoryBackendService, registry: ExternalProvidersRegistryBackendService, pending: ProviderOAuth2PendingAuthorizationBackendService, targetAuthorization: ConnectionTargetAuthorizationPort, userCredentials: UserProviderCredentialStoreBackendService, organizationCredentials: OrganizationProviderCredentialStoreBackendService, appConfig: AppConfigurationService);
54
+ protected setupRoutes(): void;
55
+ /**
56
+ * What can be connected — the question the stored-credential list cannot answer.
57
+ *
58
+ * A settings screen listing somebody's connections shows an empty table on the day they have none,
59
+ * which is precisely the day they need to learn what they might connect. So the CATALOGUE and the
60
+ * ROWS are two reads, deliberately: this one is about the provider, the resource LIST is about the
61
+ * person, and merging them would make "nothing connected" and "nothing connectable" indistinguishable.
62
+ *
63
+ * ## It reports a DECISION, and computes nothing
64
+ *
65
+ * `admissibleConnections` is the recorded decision in the provider's catalogue record — never
66
+ * derived from what a vendor's API happens to support. A vendor with a personal-token endpoint does
67
+ * not thereby become a provider a person may connect individually; somebody decided that, and this
68
+ * route repeats what they decided.
69
+ *
70
+ * ## It answers ADMISSIBILITY, not AUTHORIZATION, and that split is not laziness
71
+ *
72
+ * Whether this caller may act for a given owner depends on the owner's ID, which a catalogue has
73
+ * none of — an organization-scoped shape is admissible for the provider while the caller may be
74
+ * entitled to act for one tenant and not another. So the start leg keeps both gates in the same
75
+ * order every credential path uses, and a screen that renders an owner it cannot act for gets a
76
+ * 403 there rather than a silently missing row here.
77
+ *
78
+ * ## Nothing here is a secret
79
+ *
80
+ * Which vendors an application integrates with is a property of the application, visible on its own
81
+ * marketing pages. No token, no client secret, no env-var VALUE is reported — `connectionParameters`
82
+ * names the placeholders a connection must ANSWER, which is an input to ask a person for.
83
+ */
84
+ private handleCatalogue;
85
+ /**
86
+ * Leg one: decide whether this caller may connect this target, and hand back the URL.
87
+ *
88
+ * The two gates are the SAME pair every credential path goes through, in the same order.
89
+ * ADMISSIBLE — does this provider admit this owner scope at all? AUTHORIZED — may this execution
90
+ * act for that owner? Running them here rather than only at the callback means a person who cannot
91
+ * connect is told so before being sent to a vendor, rather than after granting consent.
92
+ */
93
+ private handleStart;
94
+ /**
95
+ * Leg two: the person comes back with a code.
96
+ *
97
+ * Consuming the record is the first thing that happens, and it is atomic — so a replayed callback
98
+ * finds nothing and there is no window in which two concurrent callbacks both proceed.
99
+ */
100
+ private handleCallback;
101
+ /**
102
+ * End the callback the way a BROWSER expects: a redirect, never a payload.
103
+ *
104
+ * This leg is reached by the vendor redirecting the person's own browser. Whatever it writes is
105
+ * rendered as a page, so answering `res.json(...)` — which this flow did until it was driven —
106
+ * shows somebody who has just granted consent a raw JSON blob on a backend origin, with no way
107
+ * back. Every exit therefore lands them on the settings screen they started from, with the outcome
108
+ * in the query string for that screen to render.
109
+ *
110
+ * The frontend is resolved from the RECORD's `frontendServiceName`, never from a header: the
111
+ * vendor's redirect carries none of Wildo's own headers. When it cannot be resolved — an attempt
112
+ * whose record is exactly what is missing, or a caller that omitted the header at start — the
113
+ * fallback is a minimal HTML page rather than JSON. It says the same thing in the same medium the
114
+ * browser is already rendering.
115
+ *
116
+ * Status is 303, not 302: the callback arrives as a GET and the destination is a different
117
+ * resource to fetch with GET, which is what 303 means.
118
+ * spec-cite: RFC 9110 §15.4.4 (303 See Other).
119
+ */
120
+ private finishInBrowser;
121
+ /**
122
+ * Route the minted grant to the store that owns the owner's table.
123
+ *
124
+ * The target comes from the PENDING RECORD, so the row is written for whoever the authorized
125
+ * attempt named. Reading it from the callback's request instead would let somebody choose whose
126
+ * account a grant lands on — the failure the whole state mechanism exists to prevent.
127
+ *
128
+ * An APPLICATION target has no store: the deployment's own credential lives in the environment,
129
+ * and a connect flow that produced one would be writing a row nobody reads.
130
+ */
131
+ private storeGrantForTarget;
132
+ /**
133
+ * May this caller act for that owner?
134
+ *
135
+ * An APPLICATION target has exactly one instance and the application IS the caller, so there is no
136
+ * second party whose account might be spent. Every other target goes through the same membership
137
+ * port the resolution path uses — one answer to "may this execution act for that owner", not two
138
+ * that can disagree.
139
+ */
140
+ private mayActFor;
141
+ private requireClientId;
142
+ private requireClientSecret;
143
+ /**
144
+ * The redirect URI, built once and then carried in the pending record.
145
+ *
146
+ * Derived from the request's own origin so a deployment needs no extra configuration, and stored
147
+ * rather than rebuilt at the callback: a vendor verifies it byte-for-byte, and a proxy that
148
+ * rewrites the host would make the rebuilt one differ from the authorized one.
149
+ */
150
+ private callbackUrlFor;
151
+ private extractCaller;
152
+ /**
153
+ * One shape for every failure, and never the vendor's response body.
154
+ *
155
+ * A token endpoint's reply carries credentials even when it fails — several vendors echo the
156
+ * submitted client secret back in a validation message — so the message is logged with its detail
157
+ * and answered without it.
158
+ */
159
+ private handleControllerError;
160
+ }
161
+ //# sourceMappingURL=provider-connection.controller.backend.service.d.ts.map