@wildo-ai/saas-backend-lib 1.1.12 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/base-classes/models/manual-controllers.backend.definition.d.ts.map +1 -1
- package/dist/esm/base-classes/models/manual-controllers.backend.definition.js +2 -0
- package/dist/esm/base-classes/models/manual-controllers.backend.definition.js.map +1 -1
- package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.d.ts +4 -0
- package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.d.ts.map +1 -1
- package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.js +20 -5
- package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.js.map +1 -1
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.d.ts +3 -0
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.js +10 -1
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.d.ts +22 -0
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.js +25 -1
- package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.js.map +1 -1
- package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.d.ts +38 -3
- package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.js +68 -5
- package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.js.map +1 -1
- package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.d.ts +2 -2
- package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js +6 -3
- package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts +83 -0
- package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts.map +1 -1
- package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js +217 -14
- package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js.map +1 -1
- package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.d.ts +32 -0
- package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.d.ts.map +1 -0
- package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.js +36 -0
- package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.js.map +1 -0
- package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.d.ts +38 -0
- package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.d.ts.map +1 -0
- package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.js +83 -0
- package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.js.map +1 -0
- package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.d.ts +36 -0
- package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.d.ts.map +1 -0
- package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.js +51 -0
- package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.js.map +1 -0
- package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.d.ts +46 -0
- package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.d.ts.map +1 -1
- package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.js +68 -0
- package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.js.map +1 -1
- package/dist/esm/compliance/approval-seals/approval-seal-store.backend.d.ts +27 -0
- package/dist/esm/compliance/approval-seals/approval-seal-store.backend.d.ts.map +1 -1
- package/dist/esm/compliance/approval-seals/approval-seal-store.backend.js +42 -3
- package/dist/esm/compliance/approval-seals/approval-seal-store.backend.js.map +1 -1
- package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.d.ts +26 -1
- package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.d.ts.map +1 -1
- package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.js +10 -0
- package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.js.map +1 -1
- package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.d.ts +10 -1
- package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.d.ts.map +1 -1
- package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.js +60 -28
- package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.js.map +1 -1
- package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.d.ts +90 -0
- package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.d.ts.map +1 -0
- package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.js +373 -0
- package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.js.map +1 -0
- package/dist/esm/compliance/approval-seals/decision-presentation.backend.d.ts +29 -2
- package/dist/esm/compliance/approval-seals/decision-presentation.backend.d.ts.map +1 -1
- package/dist/esm/compliance/approval-seals/decision-presentation.backend.js +40 -3
- package/dist/esm/compliance/approval-seals/decision-presentation.backend.js.map +1 -1
- package/dist/esm/compliance/electronic-signatures/pdf-signature-structure.backend.d.ts.map +1 -1
- package/dist/esm/compliance/electronic-signatures/pdf-signature-structure.backend.js +34 -6
- package/dist/esm/compliance/electronic-signatures/pdf-signature-structure.backend.js.map +1 -1
- package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.d.ts +30 -6
- package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.d.ts.map +1 -1
- package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.js +67 -22
- package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.js.map +1 -1
- package/dist/esm/compliance/electronic-signatures/signature-request-poll.batch.backend.service.d.ts.map +1 -1
- package/dist/esm/compliance/electronic-signatures/signature-request-poll.batch.backend.service.js +18 -1
- package/dist/esm/compliance/electronic-signatures/signature-request-poll.batch.backend.service.js.map +1 -1
- package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.d.ts +66 -1
- package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.d.ts.map +1 -1
- package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.js +161 -14
- package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.js.map +1 -1
- package/dist/esm/compliance/electronic-signatures/signed-document-validation.backend.d.ts +47 -0
- package/dist/esm/compliance/electronic-signatures/signed-document-validation.backend.d.ts.map +1 -1
- package/dist/esm/compliance/electronic-signatures/signed-document-validation.backend.js.map +1 -1
- package/dist/esm/external-providers/services/content-safety.backend.service.d.ts +27 -2
- package/dist/esm/external-providers/services/content-safety.backend.service.d.ts.map +1 -1
- package/dist/esm/external-providers/services/content-safety.backend.service.js +46 -1
- package/dist/esm/external-providers/services/content-safety.backend.service.js.map +1 -1
- package/dist/esm/external-providers/services/embeddings.backend.service.d.ts.map +1 -1
- package/dist/esm/external-providers/services/embeddings.backend.service.js +2 -0
- package/dist/esm/external-providers/services/embeddings.backend.service.js.map +1 -1
- package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts +11 -0
- package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts.map +1 -1
- package/dist/esm/external-providers/services/external-providers-registry.backend.service.js +23 -0
- package/dist/esm/external-providers/services/external-providers-registry.backend.service.js.map +1 -1
- package/dist/esm/external-providers/services/provider-service-account-token.backend.d.ts +19 -1
- package/dist/esm/external-providers/services/provider-service-account-token.backend.d.ts.map +1 -1
- package/dist/esm/external-providers/services/provider-service-account-token.backend.js +41 -1
- package/dist/esm/external-providers/services/provider-service-account-token.backend.js.map +1 -1
- package/dist/esm/files/utils/file-parent-read-context.backend.d.ts +27 -2
- package/dist/esm/files/utils/file-parent-read-context.backend.d.ts.map +1 -1
- package/dist/esm/files/utils/file-parent-read-context.backend.js +23 -4
- package/dist/esm/files/utils/file-parent-read-context.backend.js.map +1 -1
- package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.d.ts +26 -0
- package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.d.ts.map +1 -1
- package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.js +100 -8
- package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.js.map +1 -1
- package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.d.ts +3 -1
- package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.d.ts.map +1 -1
- package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.js +8 -2
- package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.js.map +1 -1
- package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts +43 -0
- package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts.map +1 -1
- package/dist/esm/flows-actors/models/function-tools.backend.definitions.js +37 -0
- package/dist/esm/flows-actors/models/function-tools.backend.definitions.js.map +1 -1
- package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.d.ts +7 -0
- package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.js +8 -3
- package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/services/agents.backend.service.d.ts +31 -6
- package/dist/esm/flows-actors/services/agents.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/agents.backend.service.js +78 -30
- package/dist/esm/flows-actors/services/agents.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/services/autonomous-agent-turn.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/autonomous-agent-turn.backend.service.js +4 -0
- package/dist/esm/flows-actors/services/autonomous-agent-turn.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts +28 -2
- package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/conversational-execution.backend.service.js +132 -22
- package/dist/esm/flows-actors/services/conversational-execution.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/services/flow-actor-executions.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/flow-actor-executions.custom-impl.backend.service.js +12 -8
- package/dist/esm/flows-actors/services/flow-actor-executions.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts +5 -0
- package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts.map +1 -1
- package/dist/esm/flows-actors/services/flows-actors-registry.service.js +18 -2
- package/dist/esm/flows-actors/services/flows-actors-registry.service.js.map +1 -1
- package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts +33 -0
- package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts.map +1 -1
- package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js +58 -0
- package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js.map +1 -1
- package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.d.ts +12 -1
- package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.d.ts.map +1 -1
- package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.js +23 -4
- package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.js.map +1 -1
- package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.d.ts +12 -1
- package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.d.ts.map +1 -1
- package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.js +55 -17
- package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.js.map +1 -1
- package/dist/esm/inbound/services/inbound-delivery-store.backend.service.d.ts +22 -1
- package/dist/esm/inbound/services/inbound-delivery-store.backend.service.d.ts.map +1 -1
- package/dist/esm/inbound/services/inbound-delivery-store.backend.service.js +52 -9
- package/dist/esm/inbound/services/inbound-delivery-store.backend.service.js.map +1 -1
- package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.d.ts +79 -0
- package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.d.ts.map +1 -0
- package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.js +211 -0
- package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.js.map +1 -0
- package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.d.ts +2 -2
- package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.d.ts.map +1 -1
- package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.js +9 -1
- package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/inject/models/container.d.ts.map +1 -1
- package/dist/esm/inject/models/container.js +6 -0
- package/dist/esm/inject/models/container.js.map +1 -1
- package/dist/esm/inject/models/service-types.d.ts +5 -0
- package/dist/esm/inject/models/service-types.d.ts.map +1 -1
- package/dist/esm/inject/models/service-types.js +3 -0
- package/dist/esm/inject/models/service-types.js.map +1 -1
- package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts +5 -0
- package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts.map +1 -1
- package/dist/esm/monitoring/observability/models/observability.backend.schemas.js.map +1 -1
- package/dist/esm/monitoring/observability/services/metrics.service.d.ts +34 -1
- package/dist/esm/monitoring/observability/services/metrics.service.d.ts.map +1 -1
- package/dist/esm/monitoring/observability/services/metrics.service.js +49 -0
- package/dist/esm/monitoring/observability/services/metrics.service.js.map +1 -1
- package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts +6 -1
- package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js +15 -4
- package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js.map +1 -1
- package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.js +3 -1
- package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/runtime/services/http-server.backend.service.d.ts +3 -1
- package/dist/esm/runtime/services/http-server.backend.service.d.ts.map +1 -1
- package/dist/esm/runtime/services/http-server.backend.service.js +11 -3
- package/dist/esm/runtime/services/http-server.backend.service.js.map +1 -1
- package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.d.ts +22 -0
- package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.d.ts.map +1 -1
- package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.js +54 -0
- package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.js.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.d.ts +51 -0
- package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.js +87 -15
- package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.js +5 -2
- package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js +65 -24
- package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts +64 -1
- package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts.map +1 -1
- package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js +84 -2
- package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts +14 -0
- package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js +13 -5
- package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/users/services/anonymous-consent.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/users/services/anonymous-consent.custom-impl.backend.service.js +6 -2
- package/dist/esm/users/services/anonymous-consent.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.d.ts +7 -0
- package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.js +65 -20
- package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.js +11 -4
- package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.js.map +1 -1
- package/dist/esm/users/services/user-self-custom-implementations.backend.d.ts.map +1 -1
- package/dist/esm/users/services/user-self-custom-implementations.backend.js +4 -2
- package/dist/esm/users/services/user-self-custom-implementations.backend.js.map +1 -1
- package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.d.ts.map +1 -1
- package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.js +16 -0
- package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-requests.backend.service.js","sourceRoot":"","sources":["../../../../src/compliance/electronic-signatures/signature-requests.backend.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,2BAA2B,EAC3B,SAAS,EACT,qBAAqB,EACrB,mCAAmC,EACnC,sBAAsB,EACtB,4BAA4B,EAC5B,sBAAsB,EACtB,kCAAkC,EAClC,iCAAiC,EACjC,SAAS,EACT,UAAU,EACV,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uCAAuC,EACvC,uCAAuC,GAExC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAOpF,OAAO,EAAE,8BAA8B,EAAE,MAAM,qFAAqF,CAAC;AACrI,OAAO,EAAE,mBAAmB,EAAE,MAAM,8EAA8E,CAAC;AACnH,OAAO,EAAE,0BAA0B,EAAE,MAAM,8EAA8E,CAAC;AAE1H,OAAO,EAAE,qBAAqB,EAA6D,MAAM,sCAAsC,CAAC;AACxI,OAAO,EAAE,6BAA6B,EAAsC,MAAM,4CAA4C,CAAC;AAE/H,sCAAsC;AACtC,MAAM,CAAN,IAAY,2BAmBX;AAnBD,WAAY,2BAA2B;IACrC,gEA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Q,CAAC,QAAQ,CAAC,uCAAuC,CAAC,SAAS,CAAC;QAAE,OAAO,sBAAsB,CAAC,SAAS,CAAC;IAClH,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,uCAAuC,CAAC,SAAS,CAAC;QAAE,OAAO,sBAAsB,CAAC,yBAAyB,CAAC;IAC7K,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,uCAAuC,CAAC,gBAAgB,IAAI,MAAM,KAAK,uCAAuC,CAAC,SAAS,CAAC,EAAE,CAAC;QACnK,OAAO,sBAAsB,CAAC,6BAA6B,CAAC;IAC9D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/**\n * # Sending a deliverable for its signers' electronic signatures (#2293)\n *\n * The send path of level 2: a deliverable a person approved (its approval SEALED, its file bound by hash, #2904) is sent\n * to the electronic-signature vendor with the people who must sign it, and recorded as a `signatureRequests` row with one\n * `signatureRequestSigners` row per signer.\n *\n * ## What it refuses, before anything leaves\n *\n * - **The approval is not sealed, or did not approve.** A request follows a sealed approval (#2293: \"the request is created\n * only once the approval is sealed\"), and a refusal or a pending seal approves nothing to sign.\n * - **The seal binds no file.** Only a file deliverable whose bytes the approver approved (`deliverableFileId`, #2904) can\n * be sent: what is signed must be what was approved.\n * - **The bytes changed.** The file is read and hashed again, and must match the hash it recorded (#2900): the vendor is\n * sent exactly the frozen original, and the request keeps that hash to compare the signed revision with.\n * - **A signer cannot be invited**: unknown, not ACTIVE, or with no email or name to address them by.\n * - **An open request already exists for this approval.** One deliverable approval, one open request.\n *\n * ## Order of writes, and what a failure leaves\n *\n * The vendor is asked FIRST and the rows are written once it answers SENT: the state machine starts at SENT, and a row\n * written before the vendor answered would claim a sending that may never happen. The row and signer ids are minted\n * before sending, because the vendor maps its signers to the engine's references. If the rows cannot be written after\n * the vendor accepted, the request is cancelled at the vendor (and deleted there where the provider deletes on removal),\n * so no signer is invited to sign a document the application does not track.\n *\n * Stated residual: the \"one open request per approval\" check is a read before the write, not a constraint, so two\n * concurrent sends of one approval can both reach the vendor. The second is a duplicate the operator can cancel; a\n * unique slot is owed when a caller can race (the send trigger, #2925).\n */\nimport { createHash, randomBytes } from 'node:crypto';\nimport { injectable, inject, optional } from 'inversify';\nimport {\n ApprovalSealStatus,\n CoreAuditableEventType,\n CoreResourceType,\n ErrorCustomMessageReference,\n ErrorType,\n HumanDecision_Outcome,\n SignatureRequest_CancellationReason,\n SignatureRequest_Event,\n SignatureRequest_RereadCause,\n SignatureRequest_State,\n SignatureRequest_TransitionOutcome,\n SIGNATURE_REQUEST_TERMINAL_STATES,\n SortOrder,\n UserStatus,\n advanceSignatureRequestState,\n} from '@wildo-ai/saas-models';\nimport {\n ElectronicSignature_CancellationOutcome,\n ElectronicSignature_VendorRequestStatus,\n type ElectronicSignature_Level,\n} from '@wildo-ai/external-connectors-models';\n\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { LoggerService } from '~wildo-backend-lib/monitoring/logger/services/logger.service';\nimport type { ErrorBuilderBackendService } from '~wildo-backend-lib/errors/services/error-builder.backend.service';\nimport type { RepositoriesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport type { ExecutionContextCreatorBackendService } from '~wildo-backend-lib/runtime/services/execution-context-creator.backend.service';\nimport type { FilesBackendService } from '~wildo-backend-lib/files/services/files.backend.service';\nimport type { ElectronicSignatureBackendService } from '~wildo-backend-lib/external-providers/services/electronic-signature.backend.service';\nimport { ElectronicSignatureSendOutcome } from '~wildo-backend-lib/external-providers/services/electronic-signature.backend.service';\nimport { describeCaughtError } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { isUniqueConstraintConflict } from '~wildo-backend-lib/errors/utils/unique-conflict-classification.backend.utils';\nimport type { AuditLogsBackendService } from '~wildo-backend-lib/compliance/audit-trails/services/audit-logs.backend.service';\nimport { SignedDocumentVerdict, type SignedDocumentEvidence, type SignedDocumentValidator } from './signed-document-validation.backend';\nimport { SignatureRequestEvidenceField, type SignatureRequestEvidenceFiles } from './signature-request-evidence-files.backend';\n\n/** Why a deliverable was not sent. */\nexport enum SignatureRequestSendRefusal {\n SEAL_NOT_FOUND = 'seal_not_found',\n /** The seal is still PENDING or IN_FLIGHT, or DEAD: there is no sealed approval yet. */\n SEAL_NOT_SEALED = 'seal_not_sealed',\n /** The sealed decision refused what was proposed: nothing was approved to sign. */\n DECISION_NOT_APPROVED = 'decision_not_approved',\n /** The seal binds no file deliverable by its hash. */\n NO_BOUND_DELIVERABLE = 'no_bound_deliverable',\n DELIVERABLE_UNREADABLE = 'deliverable_unreadable',\n /** The file's bytes no longer match the hash it recorded. */\n DELIVERABLE_CHANGED = 'deliverable_changed',\n /** A signer is unknown, not active, or has no email or name to be invited by. */\n SIGNER_NOT_INVITABLE = 'signer_not_invitable',\n /** An open request already exists for this approval. */\n ALREADY_OPEN = 'already_open',\n /** The vendor (or the provider, or the absence of one) refused the sending. */\n VENDOR_REFUSED = 'vendor_refused',\n /** The vendor accepted the request and the record could not be written; the request was cancelled at the vendor. */\n RECORD_NOT_WRITTEN = 'record_not_written',\n}\n\nexport interface SendForSignatureInput {\n readonly approvalSealId: string;\n /** The signers in signing order: the first signs first. Name a `signingOrder` to have several sign in parallel. */\n readonly signers: ReadonlyArray<{ readonly userId: string; readonly signingOrder?: number }>;\n readonly requiredLevel: ElectronicSignature_Level;\n /**\n * The request's id, when the caller derives it (the trigger derives it from the approval seal, so two concurrent sends\n * of one approval cannot both be recorded: the second write fails and its vendor request is cancelled). Minted otherwise.\n */\n readonly requestId?: string;\n}\n\nexport type SendForSignatureResult =\n | { readonly sent: true; readonly signatureRequestId: string; readonly signerRowIds: readonly string[] }\n | { readonly sent: false; readonly refusal: SignatureRequestSendRefusal; readonly reason: string; readonly retryable: boolean; readonly signatureRequestId?: string };\n\n/** What the send path reads and writes through. Structural, so a test hands in what it holds. */\nexport type SignatureRequestsRepositories = Pick<RepositoriesRegistryHandlerBackendService, 'findManyForInfrastructure' | 'insertDocumentForInfrastructure' | 'deleteManyForInfrastructure' | 'atomicGuardedMutation'>;\nexport type SignatureRequestsFiles = Pick<FilesBackendService, 'getFile' | 'ensureContentHash' | 'readFileBytes'>;\nexport type SignatureRequestsTransport = Pick<ElectronicSignatureBackendService, 'send' | 'cancel' | 'read' | 'downloadSignedDocument'>\n & Partial<Pick<ElectronicSignatureBackendService, 'vendorEnvironmentOf' | 'evidencePolicyOf'>>;\n\n/** Why a re-read did not reach the transition function, or did and could not write. */\nexport enum SignatureRequestRefreshStop {\n /** No such request. */\n NOT_FOUND = 'not_found',\n /** The vendor could not be read, or answered unusably: the request is left as it was. */\n NOT_READ = 'not_read',\n /** Another re-read moved the request first (the state write is guarded on the state read). */\n LOST_RACE = 'lost_race',\n}\n\n/** What one re-read of a request did. */\nexport interface SignatureRequestRefreshResult {\n readonly signatureRequestId: string;\n readonly outcome: SignatureRequest_TransitionOutcome | SignatureRequestRefreshStop;\n readonly state?: SignatureRequest_State;\n readonly event?: SignatureRequest_Event;\n /** Why the vendor's answer, or the evidence, left the request where it was. */\n readonly reason?: string;\n}\n\n/** The bounds of one poll (#2293): per run, per tenant and per provider, so one tenant or one vendor cannot use the run up. */\nexport interface SignatureRequestPollBounds {\n readonly maxRequests: number;\n readonly maxPerOrganization: number;\n readonly maxPerProvider: number;\n}\n\nexport const DEFAULT_SIGNATURE_REQUEST_POLL_BOUNDS: SignatureRequestPollBounds = Object.freeze({ maxRequests: 100, maxPerOrganization: 20, maxPerProvider: 50 });\n\n/** What a poll run did, for its batch output. */\nexport interface SignatureRequestPollReport {\n readonly examined: number;\n readonly moved: number;\n readonly unchanged: number;\n readonly notRead: number;\n readonly lostRace: number;\n /** Open requests left for a later run by the per-tenant or per-provider bound. */\n readonly deferredByBudget: number;\n}\n\n/** A new row id: 24 hex characters, the shape every adapter stores a string id in. */\nfunction newRowId(): string {\n return randomBytes(12).toString('hex');\n}\n\n@injectable()\nexport class SignatureRequestsBackendService {\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.RepositoriesRegistryHandlerService) private readonly repositories: SignatureRequestsRepositories,\n @inject(SAAS_SERVICE_TYPES.ExecutionContextCreatorBackendService) private readonly executionContextCreator: Pick<ExecutionContextCreatorBackendService, 'createForInternalSystemOperation'>,\n @inject(SAAS_SERVICE_TYPES.ElectronicSignatureService) private readonly transport: SignatureRequestsTransport,\n @inject(SAAS_SERVICE_TYPES.FilesBackendService) @optional() private readonly files?: SignatureRequestsFiles,\n @inject(SAAS_SERVICE_TYPES.SignedDocumentValidator) @optional() private readonly validator?: SignedDocumentValidator,\n @inject(SAAS_SERVICE_TYPES.ErrorBuilderService) @optional() private readonly errorBuilder?: Pick<ErrorBuilderBackendService, 'buildError'>,\n /** Where a SIGNED request keeps its signed document and its validation's evidence. Absent, nothing becomes SIGNED. */\n @inject(SAAS_SERVICE_TYPES.SignatureRequestEvidenceFiles) @optional() private readonly evidenceFiles?: SignatureRequestEvidenceFiles,\n @inject(SAAS_SERVICE_TYPES.AuditLogsService) @optional() private readonly auditLogs?: Pick<AuditLogsBackendService, 'logSignatureRequestEvent'>,\n ) {}\n\n /**\n * The removal effect of `signatureRequests` (#2293), registered at startup with the evidence teardown: before the rows of\n * requests whose record goes are destroyed, every OPEN one is cancelled at its vendor, and deleted there where its\n * provider deletes what it no longer needs. A request already final at the vendor needs nothing. A cancellation that\n * fails THROWS, which refuses the removal: the record stays, and its removal is retried, rather than a signer still being\n * invited to sign a document whose record is gone. Never called for a held request: the teardown keeps held evidence.\n */\n public async cancelOpenRequestsAtVendor(rows: ReadonlyArray<Record<string, unknown>>): Promise<void> {\n const failures: string[] = [];\n for (const row of rows) {\n if (SIGNATURE_REQUEST_TERMINAL_STATES.has(row.state as SignatureRequest_State)) continue;\n const providerRef = String(row.providerRef);\n const references = Array.isArray(row.vendorReferences) ? (row.vendorReferences as unknown[]).filter((reference): reference is string => typeof reference === 'string') : [];\n for (const reference of references) {\n const result = await this.transport.cancel(providerRef, reference, { deleteAfterCancel: true });\n if (result.outcome === ElectronicSignature_CancellationOutcome.FAILED) {\n failures.push(`${String(row._id)}: ${result.reason ?? 'the vendor did not confirm the cancellation'}`);\n continue;\n }\n this.logger.info('[signature-requests] An open signature request was cancelled at its vendor because its record went', {\n signatureRequestId: String(row._id), providerRef, outcome: result.outcome, deletedAtVendor: result.deletedAtVendor,\n });\n // The row is destroyed next: this is the record that it was cancelled, why, and whether the vendor deleted it.\n await this.record({\n eventType: CoreAuditableEventType.SIGNATURE_REQUEST_CANCELLED_AT_VENDOR, ...signatureRequestEventFieldsOf(row), vendorReference: reference,\n outcome: result.outcome as ElectronicSignature_CancellationOutcome.CANCELLED | ElectronicSignature_CancellationOutcome.ALREADY_FINAL,\n ...(result.deletedAtVendor === undefined ? {} : { deletedAtVendor: result.deletedAtVendor }),\n cancellationReason: SignatureRequest_CancellationReason.SUBJECT_REMOVED,\n }, reference);\n }\n }\n if (failures.length === 0) return;\n const message = `${failures.length} open signature request(s) could not be cancelled at the vendor, so the record was not removed: ${failures.join('; ')}`;\n throw this.errorBuilder\n ? this.errorBuilder.buildError(ErrorType.EXTERNAL_SERVICE, undefined, { customMessageReference: ErrorCustomMessageReference.SIGNATURE_REQUEST_VENDOR_CANCELLATION_FAILED, context: { message } })\n : new Error(message);\n }\n\n /**\n * Send the file deliverable of a sealed approval to the selected vendor, for `input.signers` to sign at\n * `input.requiredLevel`, and record the request. Never throws for a refusal; it answers why.\n *\n * assurance-control: WILDO.AI.HUMAN_OVERSIGHT, WILDO.AUDIT.EVIDENCE_INTEGRITY — a deliverable reaches its signers only after\n * a person's approval of exactly its bytes was sealed, and the bytes sent are re-hashed against what was approved.\n * (#2293 named `WILDO.DOCUMENTS.APPROVAL_BEFORE_PRESENTATION`; that objective is about governed documents, as #2903 found\n * for the seal's bind check, so the sealed-deliverable gate is marked as that check is.)\n */\n public async sendForSignature(input: SendForSignatureInput): Promise<SendForSignatureResult> {\n const refuse = (refusal: SignatureRequestSendRefusal, reason: string, retryable = false, signatureRequestId?: string): SendForSignatureResult =>\n ({ sent: false, refusal, reason, retryable, ...(signatureRequestId ? { signatureRequestId } : {}) });\n const context = await this.executionContextCreator.createForInternalSystemOperation();\n\n // 1. The sealed approval, and the file it binds.\n const [seal] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.APPROVAL_SEALS, { _id: input.approvalSealId }, context);\n if (!seal) return refuse(SignatureRequestSendRefusal.SEAL_NOT_FOUND, `No approval seal \"${input.approvalSealId}\".`);\n if (seal.status !== ApprovalSealStatus.SEALED) {\n return refuse(SignatureRequestSendRefusal.SEAL_NOT_SEALED, `The approval seal is ${String(seal.status)}, not sealed.`, seal.status !== ApprovalSealStatus.DEAD);\n }\n if (seal.outcome !== HumanDecision_Outcome.ACCEPTED && seal.outcome !== HumanDecision_Outcome.ACCEPTED_WITH_MODIFICATIONS) {\n return refuse(SignatureRequestSendRefusal.DECISION_NOT_APPROVED, 'The sealed decision did not approve the deliverable.');\n }\n const fileId = typeof seal.deliverableFileId === 'string' ? seal.deliverableFileId : undefined;\n if (!fileId) return refuse(SignatureRequestSendRefusal.NO_BOUND_DELIVERABLE, 'The sealed approval binds no file deliverable by its hash.');\n\n // 2. One open request per approval.\n const existing = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.SIGNATURE_REQUESTS, { approvalSealId: input.approvalSealId }, context);\n const open = existing.find((row) => !SIGNATURE_REQUEST_TERMINAL_STATES.has(row.state as SignatureRequest_State));\n if (open) return refuse(SignatureRequestSendRefusal.ALREADY_OPEN, 'An open signature request already exists for this approval.', false, String(open._id));\n\n // 3. The frozen original: its recorded hash, and its bytes, which must still match it.\n if (!this.files) return refuse(SignatureRequestSendRefusal.DELIVERABLE_UNREADABLE, 'No file service is bound in this runtime.');\n let document: Buffer;\n let contentSha256: string | undefined;\n let documentName: string;\n let mimeType: string;\n try {\n const file = await this.files.getFile(fileId, context) as unknown as { originalName?: string; fileName?: string; name?: string; mimeType?: string; contentType?: string } | null;\n if (!file) return refuse(SignatureRequestSendRefusal.DELIVERABLE_UNREADABLE, `The deliverable file \"${fileId}\" is gone.`);\n contentSha256 = await this.files.ensureContentHash(fileId, context);\n document = await this.files.readFileBytes(file as never, context);\n documentName = file.originalName ?? file.fileName ?? file.name ?? `${fileId}.pdf`;\n mimeType = file.mimeType ?? file.contentType ?? 'application/pdf';\n } catch (error) {\n return refuse(SignatureRequestSendRefusal.DELIVERABLE_UNREADABLE, `The deliverable file could not be read: ${describeCaughtError(error)}`, true);\n }\n if (!contentSha256 || createHash('sha256').update(document).digest('hex') !== contentSha256) {\n return refuse(SignatureRequestSendRefusal.DELIVERABLE_CHANGED, 'The deliverable\\'s bytes do not match the hash it recorded; what would be signed is not what was approved.');\n }\n\n // 4. The signers, each invitable.\n if (input.signers.length === 0) return refuse(SignatureRequestSendRefusal.SIGNER_NOT_INVITABLE, 'A request names at least one signer.');\n const signerRows: Array<{ _id: string; userId: string; signingOrder: number; firstName: string; lastName: string; email: string }> = [];\n for (const [index, signer] of input.signers.entries()) {\n const [user] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.USERS, { _id: signer.userId }, context);\n const [profile] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.USER_PROFILES, { userId: signer.userId }, context);\n const email = typeof user?.email === 'string' ? user.email : '';\n const firstName = typeof profile?.firstName === 'string' ? profile.firstName : '';\n const lastName = typeof profile?.lastName === 'string' ? profile.lastName : '';\n if (!user || user.status !== UserStatus.ACTIVE || !email || !firstName || !lastName) {\n return refuse(SignatureRequestSendRefusal.SIGNER_NOT_INVITABLE, `Signer \"${signer.userId}\" is unknown, not active, or has no email or name to be invited by.`);\n }\n signerRows.push({ _id: newRowId(), userId: signer.userId, signingOrder: signer.signingOrder ?? index, firstName, lastName, email });\n }\n\n // 5. The vendor first: the record starts at SENT.\n const sent = await this.transport.send({\n document: new Uint8Array(document), documentName, mimeType, contentSha256, level: input.requiredLevel,\n signers: signerRows.map((row) => ({ signerRef: row._id, signingOrder: row.signingOrder, firstName: row.firstName, lastName: row.lastName, email: row.email })),\n });\n if (sent.outcome !== ElectronicSignatureSendOutcome.SENT) return refuse(SignatureRequestSendRefusal.VENDOR_REFUSED, sent.reason, sent.retryable);\n\n // 6. The record, and the vendor's request cancelled when it cannot be written.\n const now = new Date();\n const requestId = input.requestId ?? newRowId();\n const organizationId = typeof seal.organizationId === 'string' ? { organizationId: seal.organizationId } : {};\n const subject = { linkedResourceType: String(seal.linkedResourceType), linkedResourceId: String(seal.linkedResourceId) };\n // What THIS call wrote, so a failure removes only its own rows: with a derived id, a concurrent sending of the same\n // approval may own the request row this insert collided with, and deleting by id would remove the winner's record.\n let requestWritten = false;\n const signerRowsWritten: string[] = [];\n try {\n await this.repositories.insertDocumentForInfrastructure(CoreResourceType.SIGNATURE_REQUESTS, {\n _id: requestId, applicationId: String(seal.applicationId), ...organizationId, ...subject,\n originalFileId: fileId, originalContentSha256: contentSha256, approvalSealId: input.approvalSealId,\n requiredLevel: input.requiredLevel, providerRef: sent.providerRef, vendorReferences: [...sent.vendorReferences],\n primaryVendorReference: sent.vendorReferences[0],\n state: SignatureRequest_State.SENT, stateChangedAt: now, createdAt: now, updatedAt: now,\n }, context);\n requestWritten = true;\n for (const row of signerRows) {\n await this.repositories.insertDocumentForInfrastructure(CoreResourceType.SIGNATURE_REQUEST_SIGNERS, {\n _id: row._id, applicationId: String(seal.applicationId), ...organizationId, ...subject, signatureRequestId: requestId,\n signerUserId: row.userId, signingOrder: row.signingOrder, vendorSignerReference: sent.vendorSignerReferences[row._id],\n createdAt: now, updatedAt: now,\n }, context);\n signerRowsWritten.push(row._id);\n }\n } catch (error) {\n for (const signerRowId of signerRowsWritten) {\n await this.repositories.deleteManyForInfrastructure(CoreResourceType.SIGNATURE_REQUEST_SIGNERS, { _id: signerRowId }, context).catch(() => 0);\n }\n if (requestWritten) await this.repositories.deleteManyForInfrastructure(CoreResourceType.SIGNATURE_REQUESTS, { _id: requestId }, context).catch(() => 0);\n const cancellations = await Promise.all(sent.vendorReferences.map((reference) => this.transport.cancel(sent.providerRef, reference, { deleteAfterCancel: true })));\n const uncancelled = cancellations.filter((result) => result.outcome !== ElectronicSignature_CancellationOutcome.CANCELLED).length;\n this.logger.error('[signature-requests] The vendor accepted a request the application could not record; it was cancelled at the vendor', {\n providerRef: sent.providerRef, vendorReferenceCount: sent.vendorReferences.length, uncancelled, error: describeCaughtError(error),\n });\n // A collision with another sending of this approval: that one is recorded, and its vendor request is the live one.\n if (!requestWritten && input.requestId && isUniqueConstraintConflict(error)) {\n return refuse(SignatureRequestSendRefusal.ALREADY_OPEN, 'Another sending of this approval recorded its request first; this one was cancelled at the vendor.', false, requestId);\n }\n return refuse(SignatureRequestSendRefusal.RECORD_NOT_WRITTEN,\n `The request could not be recorded (${describeCaughtError(error)}); it was cancelled at the vendor${uncancelled > 0 ? `, ${uncancelled} reference(s) not confirmed cancelled` : ''}.`, true);\n }\n await this.record({\n eventType: CoreAuditableEventType.SIGNATURE_REQUEST_SENT,\n signatureRequestId: requestId, approvalSealId: input.approvalSealId, ...organizationId, ...subject, providerRef: sent.providerRef,\n requiredLevel: input.requiredLevel, originalContentSha256: contentSha256,\n signerUserIds: signerRows.map((row) => row.userId), vendorReferenceCount: sent.vendorReferences.length,\n }, 'sent');\n return { sent: true, signatureRequestId: requestId, signerRowIds: signerRows.map((row) => row._id) };\n }\n\n /**\n * Re-read one request at its vendor, through the provider it was sent through, and move it as its one transition\n * function says. Used by the poll and by a vendor notification's re-read trigger (#2909): a notification is never\n * trusted, it only causes this re-read.\n *\n * A request already final answers `ignored_after_terminal` and is not read: a late event changes nothing, and the caller\n * records that it was ignored. A vendor reporting the request complete moves nothing by itself: the signed document is\n * downloaded and handed to the validator, and only {@link SignedDocumentVerdict.VALID} for every document makes it\n * SIGNED. The state is written with a guard on the state read, so two re-reads never both move it.\n */\n public async refreshRequest(signatureRequestId: string, cause: SignatureRequest_RereadCause = SignatureRequest_RereadCause.POLL): Promise<SignatureRequestRefreshResult> {\n const context = await this.executionContextCreator.createForInternalSystemOperation();\n const [row] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.SIGNATURE_REQUESTS, { _id: signatureRequestId }, context);\n if (!row) return { signatureRequestId, outcome: SignatureRequestRefreshStop.NOT_FOUND };\n return this.refreshRow(row, context, cause);\n }\n\n /**\n * The request a vendor's notification names (#2909), through the provider it came from, or `undefined`: what the\n * notification handler's resolver and its run look the request up by. A notification is never believed; it only causes\n * {@link refreshRequest}.\n */\n public async findByVendorReference(providerRef: string, vendorReference: string): Promise<Record<string, unknown> | undefined> {\n const context = await this.executionContextCreator.createForInternalSystemOperation();\n const [row] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(\n CoreResourceType.SIGNATURE_REQUESTS, { providerRef, primaryVendorReference: vendorReference }, context,\n );\n return row;\n }\n\n /**\n * Re-read the open requests, oldest move first, within `bounds`: at most `maxRequests` in the run, `maxPerOrganization`\n * of one tenant and `maxPerProvider` of one provider. A request left out by a bound is the next run's. Never throws for\n * one request: each is reported.\n */\n public async pollOpenRequests(bounds: SignatureRequestPollBounds = DEFAULT_SIGNATURE_REQUEST_POLL_BOUNDS): Promise<SignatureRequestPollReport> {\n const context = await this.executionContextCreator.createForInternalSystemOperation();\n const open = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(\n CoreResourceType.SIGNATURE_REQUESTS,\n { state: { $in: [SignatureRequest_State.SENT, SignatureRequest_State.PARTIALLY_SIGNED] } },\n context,\n undefined,\n { sort: [{ field: 'stateChangedAt', order: SortOrder.ASC }, { field: '_id', order: SortOrder.ASC }], limit: Math.max(1, bounds.maxRequests * 4) },\n );\n const perOrganization = new Map<string, number>();\n const perProvider = new Map<string, number>();\n const selected: Record<string, unknown>[] = [];\n let deferredByBudget = 0;\n for (const row of open) {\n if (selected.length >= bounds.maxRequests) { deferredByBudget += 1; continue; }\n const organization = typeof row.organizationId === 'string' ? row.organizationId : '';\n const provider = String(row.providerRef);\n if ((perOrganization.get(organization) ?? 0) >= bounds.maxPerOrganization || (perProvider.get(provider) ?? 0) >= bounds.maxPerProvider) {\n deferredByBudget += 1;\n continue;\n }\n perOrganization.set(organization, (perOrganization.get(organization) ?? 0) + 1);\n perProvider.set(provider, (perProvider.get(provider) ?? 0) + 1);\n selected.push(row);\n }\n const report = { examined: selected.length, moved: 0, unchanged: 0, notRead: 0, lostRace: 0, deferredByBudget };\n for (const row of selected) {\n let result: SignatureRequestRefreshResult;\n try {\n result = await this.refreshRow(row, context, SignatureRequest_RereadCause.POLL);\n } catch (error) {\n this.logger.warn('[signature-requests] A request could not be re-read', { signatureRequestId: String(row._id), error: describeCaughtError(error) });\n report.notRead += 1;\n continue;\n }\n if (result.outcome === SignatureRequest_TransitionOutcome.MOVED) report.moved += 1;\n else if (result.outcome === SignatureRequestRefreshStop.NOT_READ) report.notRead += 1;\n else if (result.outcome === SignatureRequestRefreshStop.LOST_RACE) report.lostRace += 1;\n else report.unchanged += 1;\n }\n return report;\n }\n\n private async refreshRow(\n row: Record<string, unknown>,\n context: Awaited<ReturnType<ExecutionContextCreatorBackendService['createForInternalSystemOperation']>>,\n cause: SignatureRequest_RereadCause,\n ): Promise<SignatureRequestRefreshResult> {\n const signatureRequestId = String(row._id);\n const current = row.state as SignatureRequest_State;\n if (SIGNATURE_REQUEST_TERMINAL_STATES.has(current)) {\n // A vendor event for a final request changes nothing. One that a notification brought is recorded: the poll never\n // re-reads a final request, so only a notification can be late.\n if (cause === SignatureRequest_RereadCause.NOTIFICATION) {\n await this.record({\n eventType: CoreAuditableEventType.SIGNATURE_REQUEST_LATE_EVENT_IGNORED, ...signatureRequestEventFieldsOf(row), state: current, cause,\n }, `${cause}|${Math.floor(Date.now() / 60_000)}`);\n }\n return { signatureRequestId, outcome: SignatureRequest_TransitionOutcome.IGNORED_AFTER_TERMINAL, state: current };\n }\n const providerRef = String(row.providerRef);\n const references = Array.isArray(row.vendorReferences) ? (row.vendorReferences as unknown[]).filter((reference): reference is string => typeof reference === 'string') : [];\n if (references.length === 0) return { signatureRequestId, outcome: SignatureRequestRefreshStop.NOT_READ, reason: 'The request holds no vendor reference.' };\n\n const statuses: ElectronicSignature_VendorRequestStatus[] = [];\n for (const reference of references) {\n const read = await this.transport.read(providerRef, reference);\n if (read.read === false) return { signatureRequestId, outcome: SignatureRequestRefreshStop.NOT_READ, reason: read.reason };\n statuses.push(read.reading.status);\n }\n let event = eventOfVendorStatuses(statuses);\n let reason: string | undefined;\n let validated: ValidatedSignedDocument | undefined;\n if (event === SignatureRequest_Event.VENDOR_REPORTED_COMPLETED) {\n const evidence = await this.validateEvidence(row, context);\n event = evidence.event;\n reason = evidence.reason;\n validated = evidence.validated;\n }\n if (event === undefined) return { signatureRequestId, outcome: SignatureRequest_TransitionOutcome.UNCHANGED, state: current, reason };\n const transition = advanceSignatureRequestState(current, event);\n if (transition.outcome !== SignatureRequest_TransitionOutcome.MOVED) return { signatureRequestId, outcome: transition.outcome, state: transition.state, event, reason };\n\n // SIGNED names its evidence in the same write: the files first (unlinked), then the move, then the links.\n let kept: KeptEvidence | undefined;\n if (transition.state === SignatureRequest_State.SIGNED) {\n const keeping = await this.keepEvidence(row, validated);\n if ('reason' in keeping) return { signatureRequestId, outcome: SignatureRequest_TransitionOutcome.UNCHANGED, state: current, event, reason: keeping.reason };\n kept = keeping;\n }\n const now = new Date();\n const written = await this.repositories.atomicGuardedMutation(\n CoreResourceType.SIGNATURE_REQUESTS,\n { _id: row._id, state: current },\n {\n set: {\n state: transition.state, stateChangedAt: now, updatedAt: now,\n ...(kept ? {\n signedDocument: { fileId: kept.signedDocumentFileId, updatedAt: now },\n validationEvidence: { fileId: kept.validationEvidenceFileId, updatedAt: now },\n validatedAt: now,\n } : {}),\n },\n },\n context,\n );\n if (!written) {\n if (kept) {\n await this.evidenceFiles?.discard(kept.signedDocumentFileId);\n await this.evidenceFiles?.discard(kept.validationEvidenceFileId);\n }\n return { signatureRequestId, outcome: SignatureRequestRefreshStop.LOST_RACE, reason: 'Another re-read moved the request first.' };\n }\n if (kept) {\n await this.evidenceFiles?.link(kept.signedDocumentFileId, row, SignatureRequestEvidenceField.SIGNED_DOCUMENT);\n await this.evidenceFiles?.link(kept.validationEvidenceFileId, row, SignatureRequestEvidenceField.VALIDATION_EVIDENCE);\n }\n this.logger.info('[signature-requests] A signature request moved', { signatureRequestId, from: current, to: transition.state, event });\n await this.record({\n eventType: CoreAuditableEventType.SIGNATURE_REQUEST_MOVED, ...signatureRequestEventFieldsOf(row), from: current, to: transition.state, event,\n ...(reason ? { reason } : {}),\n ...(kept ? {\n signedContentSha256: kept.evidence.signedContentSha256,\n signedDocumentFileId: kept.signedDocumentFileId,\n validationEvidenceFileId: kept.validationEvidenceFileId,\n signerUserIds: [...kept.signerUserIds],\n } : {}),\n }, `${current}->${transition.state}`);\n return { signatureRequestId, outcome: SignatureRequest_TransitionOutcome.MOVED, state: transition.state, event, reason };\n }\n\n /**\n * The evidence of a request the vendor reports complete: its signed document downloaded and validated. VALID is\n * EVIDENCE_VALIDATED (with the document and its evidence, kept on the move); MISMATCHED is EVIDENCE_MISMATCHED; anything\n * else (no validator, a download that failed, a document that did not validate) is EVIDENCE_REJECTED, which leaves the\n * request open.\n *\n * One signed document per request: the engine sends one deliverable per request, so a request a vendor split into\n * several references cannot keep its evidence in the request's own fields and is left open (stated, never guessed).\n */\n private async validateEvidence(\n row: Record<string, unknown>,\n context: Awaited<ReturnType<ExecutionContextCreatorBackendService['createForInternalSystemOperation']>>,\n ): Promise<{ event: SignatureRequest_Event; reason?: string; validated?: ValidatedSignedDocument }> {\n if (!this.validator) {\n return { event: SignatureRequest_Event.EVIDENCE_REJECTED, reason: 'The vendor reports the request complete and no signed-document validator is bound: it stays open.' };\n }\n const providerRef = String(row.providerRef);\n const references = row.vendorReferences as string[];\n if (references.length !== 1) {\n return { event: SignatureRequest_Event.EVIDENCE_REJECTED, reason: `The vendor split the request into ${references.length} documents; one signed document per request is kept, so it stays open.` };\n }\n const evidencePolicy = this.transport.evidencePolicyOf?.(providerRef);\n if (!evidencePolicy) return { event: SignatureRequest_Event.EVIDENCE_REJECTED, reason: `Provider \"${providerRef}\" declares no evidence policy (trust anchors): it stays open.` };\n const signers = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.SIGNATURE_REQUEST_SIGNERS, { signatureRequestId: row._id }, context);\n const expectedSigners: Array<{ signerUserId: string; email: string; vendorSignerReference?: string }> = [];\n for (const signer of signers) {\n const userId = String(signer.signerUserId);\n const [user] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.USERS, { _id: userId }, context);\n expectedSigners.push({\n signerUserId: userId,\n // The address the person is known by now: one they changed since they were invited does not match their certificate.\n email: typeof user?.email === 'string' ? user.email : '',\n ...(typeof signer.vendorSignerReference === 'string' ? { vendorSignerReference: signer.vendorSignerReference } : {}),\n });\n }\n const download = await this.transport.downloadSignedDocument(providerRef, references[0]!);\n if (download.downloaded === false) return { event: SignatureRequest_Event.EVIDENCE_REJECTED, reason: download.reason };\n const verdict = await this.validator.validate({\n signedDocument: download.bytes, originalContentSha256: String(row.originalContentSha256), requiredLevel: row.requiredLevel as ElectronicSignature_Level,\n providerRef, vendorEnvironment: this.transport.vendorEnvironmentOf?.(providerRef), evidencePolicy,\n requestSentAt: row.createdAt instanceof Date ? row.createdAt : new Date(String(row.createdAt ?? row.stateChangedAt)),\n expectedSigners,\n });\n if (verdict.verdict === SignedDocumentVerdict.MISMATCHED) return { event: SignatureRequest_Event.EVIDENCE_MISMATCHED, reason: verdict.reason };\n if (verdict.verdict !== SignedDocumentVerdict.VALID) return { event: SignatureRequest_Event.EVIDENCE_REJECTED, reason: verdict.reason };\n // The signers the evidence PROVED: those a validated certificate names. At SIMPLE a vendor's own seal names nobody.\n const provedEmails = new Set(verdict.evidence.signatures.flatMap((signature) => (signature.signerEmail ? [signature.signerEmail] : [])));\n return {\n event: SignatureRequest_Event.EVIDENCE_VALIDATED,\n validated: {\n bytes: download.bytes, evidence: verdict.evidence,\n signerUserIds: expectedSigners.filter((signer) => provedEmails.has(signer.email.trim().toLowerCase())).map((signer) => signer.signerUserId),\n },\n };\n }\n\n /** Write the request's two evidence files, unlinked. A reason when they cannot be kept: the request then stays open. */\n private async keepEvidence(row: Record<string, unknown>, validated: ValidatedSignedDocument | undefined): Promise<KeptEvidence | { reason: string }> {\n if (!validated) return { reason: 'The signed document validated and its evidence was not returned: it stays open.' };\n if (!this.evidenceFiles) return { reason: 'No evidence store is bound, so the validated document cannot be kept: it stays open.' };\n const id = String(row._id);\n let signedDocumentFileId: string | undefined;\n try {\n signedDocumentFileId = await this.evidenceFiles.write({\n request: row, field: SignatureRequestEvidenceField.SIGNED_DOCUMENT, bytes: validated.bytes, mimeType: 'application/pdf', filename: `signature-request-${id}-signed.pdf`,\n });\n const validationEvidenceFileId = await this.evidenceFiles.write({\n request: row, field: SignatureRequestEvidenceField.VALIDATION_EVIDENCE,\n bytes: new TextEncoder().encode(JSON.stringify(validated.evidence, null, 2)), mimeType: 'application/json', filename: `signature-request-${id}-validation.json`,\n });\n return { signedDocumentFileId, validationEvidenceFileId, evidence: validated.evidence, signerUserIds: validated.signerUserIds };\n } catch (error) {\n if (signedDocumentFileId) await this.evidenceFiles.discard(signedDocumentFileId);\n this.logger.warn('[signature-requests] A validated signed document could not be kept; the request stays open and is read again', {\n signatureRequestId: id, error: describeCaughtError(error),\n });\n return { reason: `The validated document could not be kept: ${describeCaughtError(error)}` };\n }\n }\n\n /** One request event on the trail. Never throws: the request's state is the record, the trail observes it. */\n private async record(event: Parameters<AuditLogsBackendService['logSignatureRequestEvent']>[0], occurrenceKey: string): Promise<void> {\n if (!this.auditLogs) return;\n await this.auditLogs.logSignatureRequestEvent(event, occurrenceKey).catch((error: unknown) => this.logger.warn('[signature-requests] A signature request event could not be recorded', {\n signatureRequestId: event.signatureRequestId, eventType: event.eventType, error: describeCaughtError(error),\n }));\n }\n}\n\n/** A signed document that validated, with what the validation proved. */\ninterface ValidatedSignedDocument {\n readonly bytes: Uint8Array;\n readonly evidence: SignedDocumentEvidence;\n readonly signerUserIds: readonly string[];\n}\n\n/** The evidence files a SIGNED request names. */\ninterface KeptEvidence {\n readonly signedDocumentFileId: string;\n readonly validationEvidenceFileId: string;\n readonly evidence: SignedDocumentEvidence;\n readonly signerUserIds: readonly string[];\n}\n\n/** The fields every signature request event names, read from the request row. */\nexport function signatureRequestEventFieldsOf(row: Record<string, unknown>) {\n return {\n signatureRequestId: String(row._id),\n approvalSealId: String(row.approvalSealId),\n ...(typeof row.organizationId === 'string' ? { organizationId: row.organizationId } : {}),\n linkedResourceType: String(row.linkedResourceType),\n linkedResourceId: String(row.linkedResourceId),\n providerRef: String(row.providerRef),\n requiredLevel: row.requiredLevel as ElectronicSignature_Level,\n originalContentSha256: String(row.originalContentSha256),\n };\n}\n\n/**\n * The one event the vendor's statuses of a request's references mean. Final vendor statuses win (a decline or an expiry\n * of any document ends the request; a cancellation at the vendor ends it), then completion of EVERY document, then any\n * progress. `undefined` when nothing moved.\n */\nexport function eventOfVendorStatuses(statuses: readonly ElectronicSignature_VendorRequestStatus[]): SignatureRequest_Event | undefined {\n if (statuses.includes(ElectronicSignature_VendorRequestStatus.DECLINED)) return SignatureRequest_Event.VENDOR_REPORTED_DECLINED;\n if (statuses.includes(ElectronicSignature_VendorRequestStatus.EXPIRED)) return SignatureRequest_Event.VENDOR_REPORTED_EXPIRED;\n if (statuses.includes(ElectronicSignature_VendorRequestStatus.CANCELLED)) return SignatureRequest_Event.CANCELLED;\n if (statuses.length > 0 && statuses.every((status) => status === ElectronicSignature_VendorRequestStatus.COMPLETED)) return SignatureRequest_Event.VENDOR_REPORTED_COMPLETED;\n if (statuses.some((status) => status === ElectronicSignature_VendorRequestStatus.PARTIALLY_SIGNED || status === ElectronicSignature_VendorRequestStatus.COMPLETED)) {\n return SignatureRequest_Event.VENDOR_REPORTED_SIGNER_SIGNED;\n }\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"signature-requests.backend.service.js","sourceRoot":"","sources":["../../../../src/compliance/electronic-signatures/signature-requests.backend.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,2BAA2B,EAC3B,SAAS,EACT,qBAAqB,EACrB,mCAAmC,EACnC,sBAAsB,EACtB,4BAA4B,EAC5B,sBAAsB,EACtB,kCAAkC,EAClC,iCAAiC,EACjC,SAAS,EACT,UAAU,EACV,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uCAAuC,EACvC,uCAAuC,GAExC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAOpF,OAAO,EAAE,8BAA8B,EAAE,MAAM,qFAAqF,CAAC;AACrI,OAAO,EAAE,mBAAmB,EAAE,MAAM,8EAA8E,CAAC;AACnH,OAAO,EAAE,0BAA0B,EAAE,MAAM,8EAA8E,CAAC;AAE1H,OAAO,EAAE,qBAAqB,EAA6D,MAAM,sCAAsC,CAAC;AACxI,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,EAC7B,mCAAmC,GAEpC,MAAM,4CAA4C,CAAC;AAGpD,sCAAsC;AACtC,MAAM,CAAN,IAAY,2BAmBX;AAnBD,WAAY,2BAA2B;IACrC,gEAAiC,CAAA;IACjC,wFAAwF;IACxF,kEAAmC,CAAA;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AC,uBAAuB,CAAC;IAC9H,IAAI,QAAQ,CAAC,QAAQ,CAAC,uCAAuC,CAAC,SAAS,CAAC;QAAE,OAAO,sBAAsB,CAAC,SAAS,CAAC;IAClH,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,uCAAuC,CAAC,SAAS,CAAC;QAAE,OAAO,sBAAsB,CAAC,yBAAyB,CAAC;IAC7K,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,uCAAuC,CAAC,gBAAgB,IAAI,MAAM,KAAK,uCAAuC,CAAC,SAAS,CAAC,EAAE,CAAC;QACnK,OAAO,sBAAsB,CAAC,6BAA6B,CAAC;IAC9D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/**\n * # Sending a deliverable for its signers' electronic signatures (#2293)\n *\n * The send path of level 2: a deliverable a person approved (its approval SEALED, its file bound by hash, #2904) is sent\n * to the electronic-signature vendor with the people who must sign it, and recorded as a `signatureRequests` row with one\n * `signatureRequestSigners` row per signer.\n *\n * ## What it refuses, before anything leaves\n *\n * - **The approval is not sealed, or did not approve.** A request follows a sealed approval (#2293: \"the request is created\n * only once the approval is sealed\"), and a refusal or a pending seal approves nothing to sign.\n * - **The seal binds no file.** Only a file deliverable whose bytes the approver approved (`deliverableFileId`, #2904) can\n * be sent: what is signed must be what was approved.\n * - **The bytes changed.** The file is read and hashed again, and must match the hash it recorded (#2900): the vendor is\n * sent exactly the frozen original, and the request keeps that hash to compare the signed revision with.\n * - **A signer cannot be invited**: unknown, not ACTIVE, or with no email or name to address them by.\n * - **An open request already exists for this approval.** One deliverable approval, one open request.\n *\n * ## Order of writes, and what a failure leaves\n *\n * The vendor is asked FIRST and the rows are written once it answers SENT: the state machine starts at SENT, and a row\n * written before the vendor answered would claim a sending that may never happen. The row and signer ids are minted\n * before sending, because the vendor maps its signers to the engine's references. If the rows cannot be written after\n * the vendor accepted, the request is cancelled at the vendor (and deleted there where the provider deletes on removal),\n * so no signer is invited to sign a document the application does not track.\n *\n * Stated residual: the \"one open request per approval\" check is a read before the write, not a constraint, so two\n * concurrent sends of one approval can both reach the vendor. The second is a duplicate the operator can cancel; a\n * unique slot is owed when a caller can race (the send trigger, #2925).\n */\nimport { createHash, randomBytes } from 'node:crypto';\nimport { injectable, inject, optional, unmanaged } from 'inversify';\nimport {\n ApprovalSealStatus,\n CoreAuditableEventType,\n CoreResourceType,\n ErrorCustomMessageReference,\n ErrorType,\n HumanDecision_Outcome,\n SignatureRequest_CancellationReason,\n SignatureRequest_Event,\n SignatureRequest_RereadCause,\n SignatureRequest_State,\n SignatureRequest_TransitionOutcome,\n SIGNATURE_REQUEST_TERMINAL_STATES,\n SortOrder,\n UserStatus,\n advanceSignatureRequestState,\n} from '@wildo-ai/saas-models';\nimport {\n ElectronicSignature_CancellationOutcome,\n ElectronicSignature_VendorRequestStatus,\n type ElectronicSignature_Level,\n} from '@wildo-ai/external-connectors-models';\n\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport type { LoggerService } from '~wildo-backend-lib/monitoring/logger/services/logger.service';\nimport type { ErrorBuilderBackendService } from '~wildo-backend-lib/errors/services/error-builder.backend.service';\nimport type { RepositoriesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/repositories/repositories-registry-handler.backend.service';\nimport type { ExecutionContextCreatorBackendService } from '~wildo-backend-lib/runtime/services/execution-context-creator.backend.service';\nimport type { FilesBackendService } from '~wildo-backend-lib/files/services/files.backend.service';\nimport type { ElectronicSignatureBackendService } from '~wildo-backend-lib/external-providers/services/electronic-signature.backend.service';\nimport { ElectronicSignatureSendOutcome } from '~wildo-backend-lib/external-providers/services/electronic-signature.backend.service';\nimport { describeCaughtError } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport { isUniqueConstraintConflict } from '~wildo-backend-lib/errors/utils/unique-conflict-classification.backend.utils';\nimport type { AuditLogsBackendService } from '~wildo-backend-lib/compliance/audit-trails/services/audit-logs.backend.service';\nimport { SignedDocumentVerdict, type SignedDocumentEvidence, type SignedDocumentValidator } from './signed-document-validation.backend';\nimport {\n SIGNATURE_EVIDENCE_LINK_RETRIED,\n SignatureRequestEvidenceField,\n SignatureRequestEvidenceLinkOutcome,\n type SignatureRequestEvidenceFiles,\n} from './signature-request-evidence-files.backend';\nimport type { MetricsService } from '~wildo-backend-lib/monitoring/observability/services/metrics.service';\n\n/** Why a deliverable was not sent. */\nexport enum SignatureRequestSendRefusal {\n SEAL_NOT_FOUND = 'seal_not_found',\n /** The seal is still PENDING or IN_FLIGHT, or DEAD: there is no sealed approval yet. */\n SEAL_NOT_SEALED = 'seal_not_sealed',\n /** The sealed decision refused what was proposed: nothing was approved to sign. */\n DECISION_NOT_APPROVED = 'decision_not_approved',\n /** The seal binds no file deliverable by its hash. */\n NO_BOUND_DELIVERABLE = 'no_bound_deliverable',\n DELIVERABLE_UNREADABLE = 'deliverable_unreadable',\n /** The file's bytes no longer match the hash it recorded. */\n DELIVERABLE_CHANGED = 'deliverable_changed',\n /** A signer is unknown, not active, or has no email or name to be invited by. */\n SIGNER_NOT_INVITABLE = 'signer_not_invitable',\n /** An open request already exists for this approval. */\n ALREADY_OPEN = 'already_open',\n /** The vendor (or the provider, or the absence of one) refused the sending. */\n VENDOR_REFUSED = 'vendor_refused',\n /** The vendor accepted the request and the record could not be written; the request was cancelled at the vendor. */\n RECORD_NOT_WRITTEN = 'record_not_written',\n}\n\nexport interface SendForSignatureInput {\n readonly approvalSealId: string;\n /** The signers in signing order: the first signs first. Name a `signingOrder` to have several sign in parallel. */\n readonly signers: ReadonlyArray<{ readonly userId: string; readonly signingOrder?: number }>;\n readonly requiredLevel: ElectronicSignature_Level;\n /**\n * The request's id, when the caller derives it (the trigger derives it from the approval seal, so two concurrent sends\n * of one approval cannot both be recorded: the second write fails and its vendor request is cancelled). Minted otherwise.\n */\n readonly requestId?: string;\n}\n\nexport type SendForSignatureResult =\n | { readonly sent: true; readonly signatureRequestId: string; readonly signerRowIds: readonly string[] }\n | { readonly sent: false; readonly refusal: SignatureRequestSendRefusal; readonly reason: string; readonly retryable: boolean; readonly signatureRequestId?: string };\n\n/**\n * Why a request the vendor reported complete was not made SIGNED by its evidence: the label of\n * `signature_request_evidence_refused_total`, and what the re-read's reason explains in words.\n */\nexport enum SignatureRequestEvidenceFailure {\n /** No signed-document validator is bound in this runtime. */\n NO_VALIDATOR = 'no_validator',\n /** The vendor split the request into several documents; one signed document per request is kept. */\n SPLIT_REQUEST = 'split_request',\n /** The provider declares no evidence policy (trust anchors). */\n NO_EVIDENCE_POLICY = 'no_evidence_policy',\n /** The signed document could not be downloaded. */\n DOWNLOAD_FAILED = 'download_failed',\n /** The document did not validate (tampered, updated after signing, untrusted chain, refused algorithm, revocation). */\n REJECTED = 'rejected',\n /** The document validated and proves another signer or a lower level than required: the request FAILS. */\n MISMATCHED = 'mismatched',\n /** The document validated and its evidence could not be written: the request stays open and is read again. */\n NOT_KEPT = 'not_kept',\n}\n\n/**\n * How long after a request became SIGNED the poll keeps linking its evidence files (#2293). Longer than the files\n * cleanup waits before it removes an unlinked file (a day after its scan ended, its default `unlinkedThresholdMs`), so a\n * scan that ends late is still linked; a file the cleanup removed first is reported lost.\n */\nexport const SIGNATURE_EVIDENCE_LINK_WINDOW_MS = 48 * 3_600_000;\n/** The SIGNED requests one poll reads, a page at a time, to link their evidence. */\nconst SIGNATURE_EVIDENCE_LINK_SCAN_LIMIT = 2_000;\nconst SIGNATURE_EVIDENCE_LINK_SCAN_PAGE = 100;\n\n/** What one evidence-link pass of the poll did. */\nexport interface SignatureEvidenceLinkReport {\n /** SIGNED requests of the window whose evidence was looked at. */\n readonly examined: number;\n /** Evidence files linked by this pass. */\n readonly linked: number;\n /** Evidence files still not linkable (their scan has not ended) or whose link failed for now: the next pass tries again. */\n readonly pending: number;\n /** Evidence files that can never be linked: the request names evidence nothing keeps. Each is logged once. */\n readonly lost: number;\n}\n\n/** What the send path reads and writes through. Structural, so a test hands in what it holds. */\nexport type SignatureRequestsRepositories = Pick<RepositoriesRegistryHandlerBackendService, 'findManyForInfrastructure' | 'insertDocumentForInfrastructure' | 'deleteManyForInfrastructure' | 'atomicGuardedMutation'>;\nexport type SignatureRequestsFiles = Pick<FilesBackendService, 'getFile' | 'ensureContentHash' | 'readFileBytes'>;\nexport type SignatureRequestsTransport = Pick<ElectronicSignatureBackendService, 'send' | 'cancel' | 'read' | 'downloadSignedDocument'>\n & Partial<Pick<ElectronicSignatureBackendService, 'vendorEnvironmentOf' | 'evidencePolicyOf'>>;\n\n/** Why a re-read did not reach the transition function, or did and could not write. */\nexport enum SignatureRequestRefreshStop {\n /** No such request. */\n NOT_FOUND = 'not_found',\n /** The vendor could not be read, or answered unusably: the request is left as it was. */\n NOT_READ = 'not_read',\n /** Another re-read moved the request first (the state write is guarded on the state read). */\n LOST_RACE = 'lost_race',\n}\n\n/** What one re-read of a request did. */\nexport interface SignatureRequestRefreshResult {\n readonly signatureRequestId: string;\n readonly outcome: SignatureRequest_TransitionOutcome | SignatureRequestRefreshStop;\n readonly state?: SignatureRequest_State;\n readonly event?: SignatureRequest_Event;\n /** Why the vendor's answer, or the evidence, left the request where it was. */\n readonly reason?: string;\n}\n\n/** The bounds of one poll (#2293): per run, per tenant and per provider, so one tenant or one vendor cannot use the run up. */\nexport interface SignatureRequestPollBounds {\n readonly maxRequests: number;\n readonly maxPerOrganization: number;\n readonly maxPerProvider: number;\n}\n\nexport const DEFAULT_SIGNATURE_REQUEST_POLL_BOUNDS: SignatureRequestPollBounds = Object.freeze({ maxRequests: 100, maxPerOrganization: 20, maxPerProvider: 50 });\n\n/** What a poll run did, for its batch output. */\nexport interface SignatureRequestPollReport {\n readonly examined: number;\n readonly moved: number;\n readonly unchanged: number;\n readonly notRead: number;\n readonly lostRace: number;\n /** Open requests left for a later run by the per-tenant or per-provider bound. */\n readonly deferredByBudget: number;\n}\n\n/** A new row id: 24 hex characters, the shape every adapter stores a string id in. */\nfunction newRowId(): string {\n return randomBytes(12).toString('hex');\n}\n\n@injectable()\nexport class SignatureRequestsBackendService {\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.RepositoriesRegistryHandlerService) private readonly repositories: SignatureRequestsRepositories,\n @inject(SAAS_SERVICE_TYPES.ExecutionContextCreatorBackendService) private readonly executionContextCreator: Pick<ExecutionContextCreatorBackendService, 'createForInternalSystemOperation'>,\n @inject(SAAS_SERVICE_TYPES.ElectronicSignatureService) private readonly transport: SignatureRequestsTransport,\n @inject(SAAS_SERVICE_TYPES.FilesBackendService) @optional() private readonly files?: SignatureRequestsFiles,\n @inject(SAAS_SERVICE_TYPES.SignedDocumentValidator) @optional() private readonly validator?: SignedDocumentValidator,\n @inject(SAAS_SERVICE_TYPES.ErrorBuilderService) @optional() private readonly errorBuilder?: Pick<ErrorBuilderBackendService, 'buildError'>,\n /** Where a SIGNED request keeps its signed document and its validation's evidence. Absent, nothing becomes SIGNED. */\n @inject(SAAS_SERVICE_TYPES.SignatureRequestEvidenceFiles) @optional() private readonly evidenceFiles?: SignatureRequestEvidenceFiles,\n @inject(SAAS_SERVICE_TYPES.AuditLogsService) @optional() private readonly auditLogs?: Pick<AuditLogsBackendService, 'logSignatureRequestEvent'>,\n @inject(SAAS_SERVICE_TYPES.MetricsService) @optional() private readonly metrics?: Pick<MetricsService,\n 'recordSignatureRequestSent' | 'recordSignatureRequestMoved' | 'recordSignatureRequestEvidenceRefused' | 'recordSignatureRequestVendorNotRead' | 'recordSignatureRequestEvidenceLink'>,\n /** A test seam, `@unmanaged()`: the container's instance reads the system clock (Inversify counts every parameter). */\n @unmanaged() clock?: () => Date,\n ) {\n this.clock = clock ?? (() => new Date());\n }\n\n private readonly clock: () => Date;\n /** Evidence files already reported lost by this process, so a lost file is logged once rather than every poll. */\n private readonly reportedLostEvidence = new Set<string>();\n\n /**\n * The removal effect of `signatureRequests` (#2293), registered at startup with the evidence teardown: before the rows of\n * requests whose record goes are destroyed, every OPEN one is cancelled at its vendor, and deleted there where its\n * provider deletes what it no longer needs. A request already final at the vendor needs nothing. A cancellation that\n * fails THROWS, which refuses the removal: the record stays, and its removal is retried, rather than a signer still being\n * invited to sign a document whose record is gone. Never called for a held request: the teardown keeps held evidence.\n */\n public async cancelOpenRequestsAtVendor(rows: ReadonlyArray<Record<string, unknown>>): Promise<void> {\n const failures: string[] = [];\n for (const row of rows) {\n if (SIGNATURE_REQUEST_TERMINAL_STATES.has(row.state as SignatureRequest_State)) continue;\n const providerRef = String(row.providerRef);\n const references = Array.isArray(row.vendorReferences) ? (row.vendorReferences as unknown[]).filter((reference): reference is string => typeof reference === 'string') : [];\n for (const reference of references) {\n const result = await this.transport.cancel(providerRef, reference, { deleteAfterCancel: true });\n if (result.outcome === ElectronicSignature_CancellationOutcome.FAILED) {\n failures.push(`${String(row._id)}: ${result.reason ?? 'the vendor did not confirm the cancellation'}`);\n continue;\n }\n this.logger.info('[signature-requests] An open signature request was cancelled at its vendor because its record went', {\n signatureRequestId: String(row._id), providerRef, outcome: result.outcome, deletedAtVendor: result.deletedAtVendor,\n });\n // The row is destroyed next: this is the record that it was cancelled, why, and whether the vendor deleted it.\n await this.record({\n eventType: CoreAuditableEventType.SIGNATURE_REQUEST_CANCELLED_AT_VENDOR, ...signatureRequestEventFieldsOf(row), vendorReference: reference,\n outcome: result.outcome as ElectronicSignature_CancellationOutcome.CANCELLED | ElectronicSignature_CancellationOutcome.ALREADY_FINAL,\n ...(result.deletedAtVendor === undefined ? {} : { deletedAtVendor: result.deletedAtVendor }),\n cancellationReason: SignatureRequest_CancellationReason.SUBJECT_REMOVED,\n }, reference);\n }\n }\n if (failures.length === 0) return;\n const message = `${failures.length} open signature request(s) could not be cancelled at the vendor, so the record was not removed: ${failures.join('; ')}`;\n throw this.errorBuilder\n ? this.errorBuilder.buildError(ErrorType.EXTERNAL_SERVICE, undefined, { customMessageReference: ErrorCustomMessageReference.SIGNATURE_REQUEST_VENDOR_CANCELLATION_FAILED, context: { message } })\n : new Error(message);\n }\n\n /**\n * Send the file deliverable of a sealed approval to the selected vendor, for `input.signers` to sign at\n * `input.requiredLevel`, and record the request. Never throws for a refusal; it answers why.\n *\n * assurance-control: WILDO.AI.HUMAN_OVERSIGHT, WILDO.AUDIT.EVIDENCE_INTEGRITY — a deliverable reaches its signers only after\n * a person's approval of exactly its bytes was sealed, and the bytes sent are re-hashed against what was approved.\n * (#2293 named `WILDO.DOCUMENTS.APPROVAL_BEFORE_PRESENTATION`; that objective is about governed documents, as #2903 found\n * for the seal's bind check, so the sealed-deliverable gate is marked as that check is.)\n */\n public async sendForSignature(input: SendForSignatureInput): Promise<SendForSignatureResult> {\n const result = await this.sendOnce(input);\n this.metrics?.recordSignatureRequestSent({ outcome: 'refusal' in result ? result.refusal : ElectronicSignatureSendOutcome.SENT, requiredLevel: input.requiredLevel });\n return result;\n }\n\n private async sendOnce(input: SendForSignatureInput): Promise<SendForSignatureResult> {\n const refuse = (refusal: SignatureRequestSendRefusal, reason: string, retryable = false, signatureRequestId?: string): SendForSignatureResult =>\n ({ sent: false, refusal, reason, retryable, ...(signatureRequestId ? { signatureRequestId } : {}) });\n const context = await this.executionContextCreator.createForInternalSystemOperation();\n\n // 1. The sealed approval, and the file it binds.\n const [seal] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.APPROVAL_SEALS, { _id: input.approvalSealId }, context);\n if (!seal) return refuse(SignatureRequestSendRefusal.SEAL_NOT_FOUND, `No approval seal \"${input.approvalSealId}\".`);\n if (seal.status !== ApprovalSealStatus.SEALED) {\n return refuse(SignatureRequestSendRefusal.SEAL_NOT_SEALED, `The approval seal is ${String(seal.status)}, not sealed.`, seal.status !== ApprovalSealStatus.DEAD);\n }\n if (seal.outcome !== HumanDecision_Outcome.ACCEPTED && seal.outcome !== HumanDecision_Outcome.ACCEPTED_WITH_MODIFICATIONS) {\n return refuse(SignatureRequestSendRefusal.DECISION_NOT_APPROVED, 'The sealed decision did not approve the deliverable.');\n }\n const fileId = typeof seal.deliverableFileId === 'string' ? seal.deliverableFileId : undefined;\n if (!fileId) return refuse(SignatureRequestSendRefusal.NO_BOUND_DELIVERABLE, 'The sealed approval binds no file deliverable by its hash.');\n\n // 2. One open request per approval.\n const existing = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.SIGNATURE_REQUESTS, { approvalSealId: input.approvalSealId }, context);\n const open = existing.find((row) => !SIGNATURE_REQUEST_TERMINAL_STATES.has(row.state as SignatureRequest_State));\n if (open) return refuse(SignatureRequestSendRefusal.ALREADY_OPEN, 'An open signature request already exists for this approval.', false, String(open._id));\n\n // 3. The frozen original: its recorded hash, and its bytes, which must still match it.\n if (!this.files) return refuse(SignatureRequestSendRefusal.DELIVERABLE_UNREADABLE, 'No file service is bound in this runtime.');\n let document: Buffer;\n let contentSha256: string | undefined;\n let documentName: string;\n let mimeType: string;\n try {\n const file = await this.files.getFile(fileId, context) as unknown as { originalName?: string; fileName?: string; name?: string; mimeType?: string; contentType?: string } | null;\n if (!file) return refuse(SignatureRequestSendRefusal.DELIVERABLE_UNREADABLE, `The deliverable file \"${fileId}\" is gone.`);\n contentSha256 = await this.files.ensureContentHash(fileId, context);\n document = await this.files.readFileBytes(file as never, context);\n documentName = file.originalName ?? file.fileName ?? file.name ?? `${fileId}.pdf`;\n mimeType = file.mimeType ?? file.contentType ?? 'application/pdf';\n } catch (error) {\n return refuse(SignatureRequestSendRefusal.DELIVERABLE_UNREADABLE, `The deliverable file could not be read: ${describeCaughtError(error)}`, true);\n }\n if (!contentSha256 || createHash('sha256').update(document).digest('hex') !== contentSha256) {\n return refuse(SignatureRequestSendRefusal.DELIVERABLE_CHANGED, 'The deliverable\\'s bytes do not match the hash it recorded; what would be signed is not what was approved.');\n }\n\n // 4. The signers, each invitable.\n if (input.signers.length === 0) return refuse(SignatureRequestSendRefusal.SIGNER_NOT_INVITABLE, 'A request names at least one signer.');\n const signerRows: Array<{ _id: string; userId: string; signingOrder: number; firstName: string; lastName: string; email: string }> = [];\n for (const [index, signer] of input.signers.entries()) {\n const [user] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.USERS, { _id: signer.userId }, context);\n const [profile] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.USER_PROFILES, { userId: signer.userId }, context);\n const email = typeof user?.email === 'string' ? user.email : '';\n const firstName = typeof profile?.firstName === 'string' ? profile.firstName : '';\n const lastName = typeof profile?.lastName === 'string' ? profile.lastName : '';\n if (!user || user.status !== UserStatus.ACTIVE || !email || !firstName || !lastName) {\n return refuse(SignatureRequestSendRefusal.SIGNER_NOT_INVITABLE, `Signer \"${signer.userId}\" is unknown, not active, or has no email or name to be invited by.`);\n }\n signerRows.push({ _id: newRowId(), userId: signer.userId, signingOrder: signer.signingOrder ?? index, firstName, lastName, email });\n }\n\n // 5. The vendor first: the record starts at SENT.\n const sent = await this.transport.send({\n document: new Uint8Array(document), documentName, mimeType, contentSha256, level: input.requiredLevel,\n signers: signerRows.map((row) => ({ signerRef: row._id, signingOrder: row.signingOrder, firstName: row.firstName, lastName: row.lastName, email: row.email })),\n });\n if (sent.outcome !== ElectronicSignatureSendOutcome.SENT) return refuse(SignatureRequestSendRefusal.VENDOR_REFUSED, sent.reason, sent.retryable);\n\n // 6. The record, and the vendor's request cancelled when it cannot be written.\n const now = new Date();\n const requestId = input.requestId ?? newRowId();\n const organizationId = typeof seal.organizationId === 'string' ? { organizationId: seal.organizationId } : {};\n const subject = { linkedResourceType: String(seal.linkedResourceType), linkedResourceId: String(seal.linkedResourceId) };\n // What THIS call wrote, so a failure removes only its own rows: with a derived id, a concurrent sending of the same\n // approval may own the request row this insert collided with, and deleting by id would remove the winner's record.\n let requestWritten = false;\n const signerRowsWritten: string[] = [];\n try {\n await this.repositories.insertDocumentForInfrastructure(CoreResourceType.SIGNATURE_REQUESTS, {\n _id: requestId, applicationId: String(seal.applicationId), ...organizationId, ...subject,\n originalFileId: fileId, originalContentSha256: contentSha256, approvalSealId: input.approvalSealId,\n requiredLevel: input.requiredLevel, providerRef: sent.providerRef, vendorReferences: [...sent.vendorReferences],\n primaryVendorReference: sent.vendorReferences[0],\n state: SignatureRequest_State.SENT, stateChangedAt: now, createdAt: now, updatedAt: now,\n }, context);\n requestWritten = true;\n for (const row of signerRows) {\n await this.repositories.insertDocumentForInfrastructure(CoreResourceType.SIGNATURE_REQUEST_SIGNERS, {\n _id: row._id, applicationId: String(seal.applicationId), ...organizationId, ...subject, signatureRequestId: requestId,\n signerUserId: row.userId, signingOrder: row.signingOrder, vendorSignerReference: sent.vendorSignerReferences[row._id],\n createdAt: now, updatedAt: now,\n }, context);\n signerRowsWritten.push(row._id);\n }\n } catch (error) {\n for (const signerRowId of signerRowsWritten) {\n await this.repositories.deleteManyForInfrastructure(CoreResourceType.SIGNATURE_REQUEST_SIGNERS, { _id: signerRowId }, context).catch(() => 0);\n }\n if (requestWritten) await this.repositories.deleteManyForInfrastructure(CoreResourceType.SIGNATURE_REQUESTS, { _id: requestId }, context).catch(() => 0);\n const cancellations = await Promise.all(sent.vendorReferences.map((reference) => this.transport.cancel(sent.providerRef, reference, { deleteAfterCancel: true })));\n const uncancelled = cancellations.filter((result) => result.outcome !== ElectronicSignature_CancellationOutcome.CANCELLED).length;\n this.logger.error('[signature-requests] The vendor accepted a request the application could not record; it was cancelled at the vendor', {\n providerRef: sent.providerRef, vendorReferenceCount: sent.vendorReferences.length, uncancelled, error: describeCaughtError(error),\n });\n // A collision with another sending of this approval: that one is recorded, and its vendor request is the live one.\n if (!requestWritten && input.requestId && isUniqueConstraintConflict(error)) {\n return refuse(SignatureRequestSendRefusal.ALREADY_OPEN, 'Another sending of this approval recorded its request first; this one was cancelled at the vendor.', false, requestId);\n }\n return refuse(SignatureRequestSendRefusal.RECORD_NOT_WRITTEN,\n `The request could not be recorded (${describeCaughtError(error)}); it was cancelled at the vendor${uncancelled > 0 ? `, ${uncancelled} reference(s) not confirmed cancelled` : ''}.`, true);\n }\n await this.record({\n eventType: CoreAuditableEventType.SIGNATURE_REQUEST_SENT,\n signatureRequestId: requestId, approvalSealId: input.approvalSealId, ...organizationId, ...subject, providerRef: sent.providerRef,\n requiredLevel: input.requiredLevel, originalContentSha256: contentSha256,\n signerUserIds: signerRows.map((row) => row.userId), vendorReferenceCount: sent.vendorReferences.length,\n }, 'sent');\n return { sent: true, signatureRequestId: requestId, signerRowIds: signerRows.map((row) => row._id) };\n }\n\n /**\n * Re-read one request at its vendor, through the provider it was sent through, and move it as its one transition\n * function says. Used by the poll and by a vendor notification's re-read trigger (#2909): a notification is never\n * trusted, it only causes this re-read.\n *\n * A request already final answers `ignored_after_terminal` and is not read: a late event changes nothing, and the caller\n * records that it was ignored. A vendor reporting the request complete moves nothing by itself: the signed document is\n * downloaded and handed to the validator, and only {@link SignedDocumentVerdict.VALID} for every document makes it\n * SIGNED. The state is written with a guard on the state read, so two re-reads never both move it.\n */\n public async refreshRequest(signatureRequestId: string, cause: SignatureRequest_RereadCause = SignatureRequest_RereadCause.POLL): Promise<SignatureRequestRefreshResult> {\n const context = await this.executionContextCreator.createForInternalSystemOperation();\n const [row] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.SIGNATURE_REQUESTS, { _id: signatureRequestId }, context);\n if (!row) return { signatureRequestId, outcome: SignatureRequestRefreshStop.NOT_FOUND };\n return this.refreshRow(row, context, cause);\n }\n\n /**\n * The request a vendor's notification names (#2909), through the provider it came from, or `undefined`: what the\n * notification handler's resolver and its run look the request up by. A notification is never believed; it only causes\n * {@link refreshRequest}.\n */\n public async findByVendorReference(providerRef: string, vendorReference: string): Promise<Record<string, unknown> | undefined> {\n const context = await this.executionContextCreator.createForInternalSystemOperation();\n const [row] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(\n CoreResourceType.SIGNATURE_REQUESTS, { providerRef, primaryVendorReference: vendorReference }, context,\n );\n return row;\n }\n\n /**\n * Re-read the open requests, oldest move first, within `bounds`: at most `maxRequests` in the run, `maxPerOrganization`\n * of one tenant and `maxPerProvider` of one provider. A request left out by a bound is the next run's. Never throws for\n * one request: each is reported.\n */\n public async pollOpenRequests(bounds: SignatureRequestPollBounds = DEFAULT_SIGNATURE_REQUEST_POLL_BOUNDS): Promise<SignatureRequestPollReport> {\n const context = await this.executionContextCreator.createForInternalSystemOperation();\n const open = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(\n CoreResourceType.SIGNATURE_REQUESTS,\n { state: { $in: [SignatureRequest_State.SENT, SignatureRequest_State.PARTIALLY_SIGNED] } },\n context,\n undefined,\n { sort: [{ field: 'stateChangedAt', order: SortOrder.ASC }, { field: '_id', order: SortOrder.ASC }], limit: Math.max(1, bounds.maxRequests * 4) },\n );\n const perOrganization = new Map<string, number>();\n const perProvider = new Map<string, number>();\n const selected: Record<string, unknown>[] = [];\n let deferredByBudget = 0;\n for (const row of open) {\n if (selected.length >= bounds.maxRequests) { deferredByBudget += 1; continue; }\n const organization = typeof row.organizationId === 'string' ? row.organizationId : '';\n const provider = String(row.providerRef);\n if ((perOrganization.get(organization) ?? 0) >= bounds.maxPerOrganization || (perProvider.get(provider) ?? 0) >= bounds.maxPerProvider) {\n deferredByBudget += 1;\n continue;\n }\n perOrganization.set(organization, (perOrganization.get(organization) ?? 0) + 1);\n perProvider.set(provider, (perProvider.get(provider) ?? 0) + 1);\n selected.push(row);\n }\n const report = { examined: selected.length, moved: 0, unchanged: 0, notRead: 0, lostRace: 0, deferredByBudget };\n for (const row of selected) {\n let result: SignatureRequestRefreshResult;\n try {\n result = await this.refreshRow(row, context, SignatureRequest_RereadCause.POLL);\n } catch (error) {\n this.logger.warn('[signature-requests] A request could not be re-read', { signatureRequestId: String(row._id), error: describeCaughtError(error) });\n report.notRead += 1;\n continue;\n }\n if (result.outcome === SignatureRequest_TransitionOutcome.MOVED) report.moved += 1;\n else if (result.outcome === SignatureRequestRefreshStop.NOT_READ) report.notRead += 1;\n else if (result.outcome === SignatureRequestRefreshStop.LOST_RACE) report.lostRace += 1;\n else report.unchanged += 1;\n }\n return report;\n }\n\n private async refreshRow(\n row: Record<string, unknown>,\n context: Awaited<ReturnType<ExecutionContextCreatorBackendService['createForInternalSystemOperation']>>,\n cause: SignatureRequest_RereadCause,\n ): Promise<SignatureRequestRefreshResult> {\n const signatureRequestId = String(row._id);\n const current = row.state as SignatureRequest_State;\n if (SIGNATURE_REQUEST_TERMINAL_STATES.has(current)) {\n // A vendor event for a final request changes nothing. One that a notification brought is recorded: the poll never\n // re-reads a final request, so only a notification can be late.\n if (cause === SignatureRequest_RereadCause.NOTIFICATION) {\n await this.record({\n eventType: CoreAuditableEventType.SIGNATURE_REQUEST_LATE_EVENT_IGNORED, ...signatureRequestEventFieldsOf(row), state: current, cause,\n }, `${cause}|${Math.floor(Date.now() / 60_000)}`);\n }\n return { signatureRequestId, outcome: SignatureRequest_TransitionOutcome.IGNORED_AFTER_TERMINAL, state: current };\n }\n const providerRef = String(row.providerRef);\n const references = Array.isArray(row.vendorReferences) ? (row.vendorReferences as unknown[]).filter((reference): reference is string => typeof reference === 'string') : [];\n if (references.length === 0) return { signatureRequestId, outcome: SignatureRequestRefreshStop.NOT_READ, reason: 'The request holds no vendor reference.' };\n\n const statuses: ElectronicSignature_VendorRequestStatus[] = [];\n for (const reference of references) {\n const read = await this.transport.read(providerRef, reference);\n if (read.read === false) {\n this.metrics?.recordSignatureRequestVendorNotRead({ providerRef });\n return { signatureRequestId, outcome: SignatureRequestRefreshStop.NOT_READ, reason: read.reason };\n }\n statuses.push(read.reading.status);\n }\n let event = eventOfVendorStatuses(statuses);\n let reason: string | undefined;\n let validated: ValidatedSignedDocument | undefined;\n if (event === SignatureRequest_Event.VENDOR_REPORTED_COMPLETED) {\n const evidence = await this.validateEvidence(row, context);\n event = evidence.event;\n reason = evidence.reason;\n validated = evidence.validated;\n if (evidence.failure) this.metrics?.recordSignatureRequestEvidenceRefused({ providerRef, failure: evidence.failure });\n }\n if (event === undefined) return { signatureRequestId, outcome: SignatureRequest_TransitionOutcome.UNCHANGED, state: current, reason };\n const transition = advanceSignatureRequestState(current, event);\n if (transition.outcome !== SignatureRequest_TransitionOutcome.MOVED) return { signatureRequestId, outcome: transition.outcome, state: transition.state, event, reason };\n\n // SIGNED names its evidence in the same write: the files first (unlinked), then the move, then the links.\n let kept: KeptEvidence | undefined;\n if (transition.state === SignatureRequest_State.SIGNED) {\n const keeping = await this.keepEvidence(row, validated);\n if ('reason' in keeping) {\n this.metrics?.recordSignatureRequestEvidenceRefused({ providerRef, failure: SignatureRequestEvidenceFailure.NOT_KEPT });\n return { signatureRequestId, outcome: SignatureRequest_TransitionOutcome.UNCHANGED, state: current, event, reason: keeping.reason };\n }\n kept = keeping;\n }\n const now = new Date();\n const written = await this.repositories.atomicGuardedMutation(\n CoreResourceType.SIGNATURE_REQUESTS,\n { _id: row._id, state: current },\n {\n set: {\n state: transition.state, stateChangedAt: now, updatedAt: now,\n ...(kept ? {\n signedDocument: { fileId: kept.signedDocumentFileId, updatedAt: now },\n validationEvidence: { fileId: kept.validationEvidenceFileId, updatedAt: now },\n validatedAt: now,\n } : {}),\n },\n },\n context,\n );\n if (!written) {\n if (kept) {\n await this.evidenceFiles?.discard(kept.signedDocumentFileId);\n await this.evidenceFiles?.discard(kept.validationEvidenceFileId);\n }\n return { signatureRequestId, outcome: SignatureRequestRefreshStop.LOST_RACE, reason: 'Another re-read moved the request first.' };\n }\n if (kept) {\n // A file not linkable yet (its scan is in flight) is linked by a later poll (`linkPendingEvidence`), never dropped.\n await this.linkEvidenceFile(kept.signedDocumentFileId, row, SignatureRequestEvidenceField.SIGNED_DOCUMENT);\n await this.linkEvidenceFile(kept.validationEvidenceFileId, row, SignatureRequestEvidenceField.VALIDATION_EVIDENCE);\n }\n this.logger.info('[signature-requests] A signature request moved', { signatureRequestId, from: current, to: transition.state, event });\n this.metrics?.recordSignatureRequestMoved({ providerRef, to: transition.state });\n await this.record({\n eventType: CoreAuditableEventType.SIGNATURE_REQUEST_MOVED, ...signatureRequestEventFieldsOf(row), from: current, to: transition.state, event,\n ...(reason ? { reason } : {}),\n ...(kept ? {\n signedContentSha256: kept.evidence.signedContentSha256,\n signedDocumentFileId: kept.signedDocumentFileId,\n validationEvidenceFileId: kept.validationEvidenceFileId,\n signerUserIds: [...kept.signerUserIds],\n } : {}),\n }, `${current}->${transition.state}`);\n return { signatureRequestId, outcome: SignatureRequest_TransitionOutcome.MOVED, state: transition.state, event, reason };\n }\n\n /**\n * The evidence of a request the vendor reports complete: its signed document downloaded and validated. VALID is\n * EVIDENCE_VALIDATED (with the document and its evidence, kept on the move); MISMATCHED is EVIDENCE_MISMATCHED; anything\n * else (no validator, a download that failed, a document that did not validate) is EVIDENCE_REJECTED, which leaves the\n * request open.\n *\n * One signed document per request: the engine sends one deliverable per request, so a request a vendor split into\n * several references cannot keep its evidence in the request's own fields and is left open (stated, never guessed).\n */\n private async validateEvidence(\n row: Record<string, unknown>,\n context: Awaited<ReturnType<ExecutionContextCreatorBackendService['createForInternalSystemOperation']>>,\n ): Promise<{ event: SignatureRequest_Event; reason?: string; validated?: ValidatedSignedDocument; failure?: SignatureRequestEvidenceFailure }> {\n const F = SignatureRequestEvidenceFailure;\n if (!this.validator) {\n return { event: SignatureRequest_Event.EVIDENCE_REJECTED, failure: F.NO_VALIDATOR, reason: 'The vendor reports the request complete and no signed-document validator is bound: it stays open.' };\n }\n const providerRef = String(row.providerRef);\n const references = row.vendorReferences as string[];\n if (references.length !== 1) {\n return { event: SignatureRequest_Event.EVIDENCE_REJECTED, failure: F.SPLIT_REQUEST, reason: `The vendor split the request into ${references.length} documents; one signed document per request is kept, so it stays open.` };\n }\n const evidencePolicy = this.transport.evidencePolicyOf?.(providerRef);\n if (!evidencePolicy) return { event: SignatureRequest_Event.EVIDENCE_REJECTED, failure: F.NO_EVIDENCE_POLICY, reason: `Provider \"${providerRef}\" declares no evidence policy (trust anchors): it stays open.` };\n const signers = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.SIGNATURE_REQUEST_SIGNERS, { signatureRequestId: row._id }, context);\n const expectedSigners: Array<{ signerUserId: string; email: string; vendorSignerReference?: string }> = [];\n for (const signer of signers) {\n const userId = String(signer.signerUserId);\n const [user] = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(CoreResourceType.USERS, { _id: userId }, context);\n expectedSigners.push({\n signerUserId: userId,\n // The address the person is known by now: one they changed since they were invited does not match their certificate.\n email: typeof user?.email === 'string' ? user.email : '',\n ...(typeof signer.vendorSignerReference === 'string' ? { vendorSignerReference: signer.vendorSignerReference } : {}),\n });\n }\n const download = await this.transport.downloadSignedDocument(providerRef, references[0]!);\n if (download.downloaded === false) return { event: SignatureRequest_Event.EVIDENCE_REJECTED, failure: F.DOWNLOAD_FAILED, reason: download.reason };\n const verdict = await this.validator.validate({\n signedDocument: download.bytes, originalContentSha256: String(row.originalContentSha256), requiredLevel: row.requiredLevel as ElectronicSignature_Level,\n providerRef, vendorEnvironment: this.transport.vendorEnvironmentOf?.(providerRef), evidencePolicy,\n requestSentAt: row.createdAt instanceof Date ? row.createdAt : new Date(String(row.createdAt ?? row.stateChangedAt)),\n expectedSigners,\n });\n if (verdict.verdict === SignedDocumentVerdict.MISMATCHED) return { event: SignatureRequest_Event.EVIDENCE_MISMATCHED, failure: F.MISMATCHED, reason: verdict.reason };\n if (verdict.verdict !== SignedDocumentVerdict.VALID) return { event: SignatureRequest_Event.EVIDENCE_REJECTED, failure: F.REJECTED, reason: verdict.reason };\n // The signers the evidence PROVED: those a validated certificate names. At SIMPLE a vendor's own seal names nobody.\n const provedEmails = new Set(verdict.evidence.signatures.flatMap((signature) => (signature.signerEmail ? [signature.signerEmail] : [])));\n return {\n event: SignatureRequest_Event.EVIDENCE_VALIDATED,\n validated: {\n bytes: download.bytes, evidence: verdict.evidence,\n signerUserIds: expectedSigners.filter((signer) => provedEmails.has(signer.email.trim().toLowerCase())).map((signer) => signer.signerUserId),\n },\n };\n }\n\n /**\n * Link the evidence files of the requests that became SIGNED in the last {@link SIGNATURE_EVIDENCE_LINK_WINDOW_MS} and\n * are not linked yet (#2293). Run by the poll. A file whose scan has not ended is linked by a later run; one that can\n * never be linked is reported lost, once. Without this, a signed document scanned on write was never linked (its link\n * is refused while it is SCANNING) and the files cleanup removed it a day later. Never throws for one request.\n *\n * Read cost, stated: each run reads every SIGNED request of the window and each of its two files once, a primary-key read\n * per file, up to {@link SIGNATURE_EVIDENCE_LINK_SCAN_LIMIT} requests.\n */\n public async linkPendingEvidence(): Promise<SignatureEvidenceLinkReport> {\n const report = { examined: 0, linked: 0, pending: 0, lost: 0 };\n if (!this.evidenceFiles) return report;\n const context = await this.executionContextCreator.createForInternalSystemOperation();\n for await (const row of this.signedInLinkWindow(context)) {\n report.examined += 1;\n for (const field of [SignatureRequestEvidenceField.SIGNED_DOCUMENT, SignatureRequestEvidenceField.VALIDATION_EVIDENCE]) {\n const fileId = (row[field] as { fileId?: unknown } | undefined)?.fileId;\n if (typeof fileId !== 'string') continue;\n let outcome: SignatureRequestEvidenceLinkOutcome;\n try {\n outcome = await this.linkEvidenceFile(fileId, row, field);\n } catch (error) {\n this.logger.warn('[signature-requests] An evidence file could not be linked; the next poll tries again', { signatureRequestId: String(row._id), fileId, error: describeCaughtError(error) });\n report.pending += 1;\n continue;\n }\n if (outcome === SignatureRequestEvidenceLinkOutcome.LINKED) report.linked += 1;\n else if (SIGNATURE_EVIDENCE_LINK_RETRIED.has(outcome)) report.pending += 1;\n else if (outcome === SignatureRequestEvidenceLinkOutcome.LOST) report.lost += 1;\n }\n }\n return report;\n }\n\n /**\n * Link one evidence file and say what happened: a lost file at error (once per process, with its metric), a link left\n * for a later poll at info. Never throws; the port never does.\n */\n private async linkEvidenceFile(fileId: string, row: Record<string, unknown>, field: SignatureRequestEvidenceField): Promise<SignatureRequestEvidenceLinkOutcome> {\n if (!this.evidenceFiles) return SignatureRequestEvidenceLinkOutcome.FAILED;\n const outcome = await this.evidenceFiles.link(fileId, row, field);\n if (outcome === SignatureRequestEvidenceLinkOutcome.ALREADY_LINKED) return outcome;\n if (outcome === SignatureRequestEvidenceLinkOutcome.LOST) {\n if (this.reportedLostEvidence.has(fileId)) return outcome;\n if (this.reportedLostEvidence.size < 10_000) this.reportedLostEvidence.add(fileId);\n this.logger.error('[signature-requests] A SIGNED request names an evidence file that can never be linked to it (gone, infected, quarantined, failed, or linked elsewhere); its evidence is not kept', {\n signatureRequestId: String(row._id), fileId, field,\n });\n } else if (SIGNATURE_EVIDENCE_LINK_RETRIED.has(outcome)) {\n this.logger.info('[signature-requests] An evidence file is not linkable yet (its scan has not ended, or the store did not answer); the poll links it later', {\n signatureRequestId: String(row._id), fileId, field, outcome,\n });\n }\n this.metrics?.recordSignatureRequestEvidenceLink({ outcome });\n return outcome;\n }\n\n /**\n * The SIGNED requests validated in the link window, oldest first, a page at a time. Pages advance on `validatedAt`, ids\n * already seen skipped, so requests validated in the same instant are not lost between pages (the trigger's paging).\n */\n private async *signedInLinkWindow(context: Awaited<ReturnType<ExecutionContextCreatorBackendService['createForInternalSystemOperation']>>): AsyncGenerator<Record<string, unknown>> {\n let from = new Date(this.clock().getTime() - SIGNATURE_EVIDENCE_LINK_WINDOW_MS);\n const seen = new Set<string>();\n let pageSize = SIGNATURE_EVIDENCE_LINK_SCAN_PAGE;\n for (let scanned = 0; scanned < SIGNATURE_EVIDENCE_LINK_SCAN_LIMIT;) {\n const page = await this.repositories.findManyForInfrastructure<Record<string, unknown>>(\n CoreResourceType.SIGNATURE_REQUESTS,\n { state: SignatureRequest_State.SIGNED, validatedAt: { $gte: from } },\n context,\n undefined,\n { sort: [{ field: 'validatedAt', order: SortOrder.ASC }, { field: '_id', order: SortOrder.ASC }], limit: pageSize },\n );\n const fresh = page.filter((row) => !seen.has(String(row._id)));\n if (fresh.length === 0) {\n if (page.length < pageSize || pageSize >= SIGNATURE_EVIDENCE_LINK_SCAN_LIMIT) return;\n pageSize = Math.min(pageSize * 2, SIGNATURE_EVIDENCE_LINK_SCAN_LIMIT);\n continue;\n }\n for (const row of fresh) {\n seen.add(String(row._id));\n scanned += 1;\n yield row;\n }\n if (page.length < pageSize) return;\n const last = page[page.length - 1]!.validatedAt;\n from = last instanceof Date ? last : new Date(String(last));\n }\n }\n\n /** Write the request's two evidence files, unlinked. A reason when they cannot be kept: the request then stays open. */\n private async keepEvidence(row: Record<string, unknown>, validated: ValidatedSignedDocument | undefined): Promise<KeptEvidence | { reason: string }> {\n if (!validated) return { reason: 'The signed document validated and its evidence was not returned: it stays open.' };\n if (!this.evidenceFiles) return { reason: 'No evidence store is bound, so the validated document cannot be kept: it stays open.' };\n const id = String(row._id);\n let signedDocumentFileId: string | undefined;\n try {\n signedDocumentFileId = await this.evidenceFiles.write({\n request: row, field: SignatureRequestEvidenceField.SIGNED_DOCUMENT, bytes: validated.bytes, mimeType: 'application/pdf', filename: `signature-request-${id}-signed.pdf`,\n });\n const validationEvidenceFileId = await this.evidenceFiles.write({\n request: row, field: SignatureRequestEvidenceField.VALIDATION_EVIDENCE,\n bytes: new TextEncoder().encode(JSON.stringify(validated.evidence, null, 2)), mimeType: 'application/json', filename: `signature-request-${id}-validation.json`,\n });\n return { signedDocumentFileId, validationEvidenceFileId, evidence: validated.evidence, signerUserIds: validated.signerUserIds };\n } catch (error) {\n if (signedDocumentFileId) await this.evidenceFiles.discard(signedDocumentFileId);\n this.logger.warn('[signature-requests] A validated signed document could not be kept; the request stays open and is read again', {\n signatureRequestId: id, error: describeCaughtError(error),\n });\n return { reason: `The validated document could not be kept: ${describeCaughtError(error)}` };\n }\n }\n\n /** One request event on the trail. Never throws: the request's state is the record, the trail observes it. */\n private async record(event: Parameters<AuditLogsBackendService['logSignatureRequestEvent']>[0], occurrenceKey: string): Promise<void> {\n if (!this.auditLogs) return;\n await this.auditLogs.logSignatureRequestEvent(event, occurrenceKey).catch((error: unknown) => this.logger.warn('[signature-requests] A signature request event could not be recorded', {\n signatureRequestId: event.signatureRequestId, eventType: event.eventType, error: describeCaughtError(error),\n }));\n }\n}\n\n/** A signed document that validated, with what the validation proved. */\ninterface ValidatedSignedDocument {\n readonly bytes: Uint8Array;\n readonly evidence: SignedDocumentEvidence;\n readonly signerUserIds: readonly string[];\n}\n\n/** The evidence files a SIGNED request names. */\ninterface KeptEvidence {\n readonly signedDocumentFileId: string;\n readonly validationEvidenceFileId: string;\n readonly evidence: SignedDocumentEvidence;\n readonly signerUserIds: readonly string[];\n}\n\n/** The fields every signature request event names, read from the request row. */\nexport function signatureRequestEventFieldsOf(row: Record<string, unknown>) {\n return {\n signatureRequestId: String(row._id),\n approvalSealId: String(row.approvalSealId),\n ...(typeof row.organizationId === 'string' ? { organizationId: row.organizationId } : {}),\n linkedResourceType: String(row.linkedResourceType),\n linkedResourceId: String(row.linkedResourceId),\n providerRef: String(row.providerRef),\n requiredLevel: row.requiredLevel as ElectronicSignature_Level,\n originalContentSha256: String(row.originalContentSha256),\n };\n}\n\n/**\n * The one event the vendor's statuses of a request's references mean. Final vendor statuses win (a decline or an expiry\n * of any document ends the request; a cancellation at the vendor ends it), then completion of EVERY document, then any\n * progress. `undefined` when nothing moved.\n */\nexport function eventOfVendorStatuses(statuses: readonly ElectronicSignature_VendorRequestStatus[]): SignatureRequest_Event | undefined {\n if (statuses.includes(ElectronicSignature_VendorRequestStatus.DECLINED)) return SignatureRequest_Event.VENDOR_REPORTED_DECLINED;\n if (statuses.includes(ElectronicSignature_VendorRequestStatus.EXPIRED)) return SignatureRequest_Event.VENDOR_REPORTED_EXPIRED;\n if (statuses.includes(ElectronicSignature_VendorRequestStatus.CANCELLED)) return SignatureRequest_Event.CANCELLED;\n if (statuses.length > 0 && statuses.every((status) => status === ElectronicSignature_VendorRequestStatus.COMPLETED)) return SignatureRequest_Event.VENDOR_REPORTED_COMPLETED;\n if (statuses.some((status) => status === ElectronicSignature_VendorRequestStatus.PARTIALLY_SIGNED || status === ElectronicSignature_VendorRequestStatus.COMPLETED)) {\n return SignatureRequest_Event.VENDOR_REPORTED_SIGNER_SIGNED;\n }\n return undefined;\n}\n"]}
|
|
@@ -8,6 +8,53 @@
|
|
|
8
8
|
* The answer carries the EVIDENCE of a valid document: what was checked, against which chain, at which date, with which
|
|
9
9
|
* revocation data. The service keeps it as a file beside the signed document, so a request says "validated at T with this
|
|
10
10
|
* revocation data" for as long as its record lives.
|
|
11
|
+
*
|
|
12
|
+
* ## Identity proofing that does not rely on the operator's contact data: DESIGNED, not built (#2293, 2026-11-12)
|
|
13
|
+
*
|
|
14
|
+
* **The gap.** Today a signer is proved by the e-mail address their certificate carries, compared with the address on
|
|
15
|
+
* their user record (`expectedSigners[].email`), and the vendor invites them at that address. Both are the OPERATOR's
|
|
16
|
+
* data: a person who can write the users table can change a signer's address to their own, receive the invitation, and
|
|
17
|
+
* complete an advanced signature that this validator accepts as the signer's.
|
|
18
|
+
*
|
|
19
|
+
* **What the field does, which settles the approach.** An advanced signature must be "capable of identifying the
|
|
20
|
+
* signatory" (eIDAS Art. 26(b)). Who the signatory is gets established by IDENTITY PROOFING, which ETSI TS 119 461
|
|
21
|
+
* V2.1.1 specifies for trust services at two levels, Baseline LoIP (substantial) and Extended LoIP (high) (§3.1), through
|
|
22
|
+
* a fixed set of use cases: an identity document with physical presence, attended remote or unattended remote; eID means;
|
|
23
|
+
* an existing signature with certificate (§9.2.1–§9.2.5). An identity proofing provider conforming to it may name its
|
|
24
|
+
* policy with 0.4.0.19461.1.1 (baseline) or 0.4.0.19461.1.2 (extended) (§4.6). Vendors expose it as a per-signer option
|
|
25
|
+
* chosen when the request is sent (DocuSign's recipient `identityVerification` names an account's ID-verification
|
|
26
|
+
* workflow), and the identity it established reaches the SIGNED DOCUMENT as the signer's certificate, issued after that
|
|
27
|
+
* proofing under a certificate policy the vendor publishes.
|
|
28
|
+
* spec-cite: Regulation (EU) No 910/2014 Art. 26 (point b), retained text at legislation.gov.uk/eur/2014/910/article/26;
|
|
29
|
+
* ETSI TS 119 461 V2.1.1 (2025-02) §3.1 (Baseline LoIP, extended LoIP), §4.6 (the two OIDs), §9.2 (use cases).
|
|
30
|
+
*
|
|
31
|
+
* **The design.**
|
|
32
|
+
* 1. A requirement `ElectronicSignature_IdentityProofing` (`CONTACT_CHANNEL`, today's and the default; `BASELINE_LOIP`;
|
|
33
|
+
* `EXTENDED_LOIP`, which also meets baseline) beside the level, in `@wildo-ai/external-connectors-models`, declared on a
|
|
34
|
+
* tool's `electronicSignature` and RECORDED on the request (`requiredIdentityProofing`: a field, so a migration on the
|
|
35
|
+
* five surfaces), because a request is validated against what it was sent with, not against today's tool.
|
|
36
|
+
* 2. The provider contract declares `supportedIdentityProofing` (startup refuses a requirement it cannot meet, as for
|
|
37
|
+
* levels) and, in `evidence`, `identityProofingCertificatePolicies`: per level, the certificate-policy OIDs of the
|
|
38
|
+
* certificates the vendor issues only after proofing at that level. The send input carries the requirement per signer.
|
|
39
|
+
* 3. This validator proves it from the document, never from the vendor's API: each expected signer's signature must chain
|
|
40
|
+
* to a pinned anchor (as today) AND its certificate must carry a declared OID of the required level or a higher one,
|
|
41
|
+
* else MISMATCHED. The evidence records the achieved proofing level and the certificate's verified name.
|
|
42
|
+
* 4. The verified name is bound to a name the operator could not rewrite afterwards: the approver's name as SEALED in the
|
|
43
|
+
* approval (the approver disclosure, committed to by the custodian's signature, #2903), not their current profile.
|
|
44
|
+
* The comparison is on name tokens (NFKD, marks removed, case-folded, order ignored) of the certificate's
|
|
45
|
+
* `givenName` + `surname`, else its `commonName`; a difference is MISMATCHED. An approver whose sealed name was erased
|
|
46
|
+
* leaves the request open. The vendor is sent that sealed name, so its own proofing checks the same identity.
|
|
47
|
+
*
|
|
48
|
+
* **Why it is not built yet.** Every step needs a vendor that offers ID-verified signing and publishes the policy its
|
|
49
|
+
* certificates carry, and none is integrated: IgniSign (#2912) and the simulator (#2911) are where it is proven. Without
|
|
50
|
+
* them the requirement would be refused at startup by every provider, so nothing could use it.
|
|
51
|
+
*
|
|
52
|
+
* **Rejected.** The vendor's identity-evidence API (an ID-verification result read over HTTP) as the proof: it is the
|
|
53
|
+
* vendor's word, unsigned and outside the document, which is exactly what "the vendor's API is not the authority" rules
|
|
54
|
+
* out. Comparing the certificate's name with the user's CURRENT profile name: that is operator data again, the threat
|
|
55
|
+
* itself.
|
|
56
|
+
* **What would remain.** A person who changed the approver's name and address BEFORE the approval was sealed, and also
|
|
57
|
+
* holds an identity document in that name.
|
|
11
58
|
*/
|
|
12
59
|
import type { ElectronicSignature_Level, ElectronicSignature_VendorEnvironment } from '@wildo-ai/external-connectors-models';
|
|
13
60
|
/**
|
package/dist/esm/compliance/electronic-signatures/signed-document-validation.backend.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signed-document-validation.backend.d.ts","sourceRoot":"","sources":["../../../../src/compliance/electronic-signatures/signed-document-validation.backend.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"signed-document-validation.backend.d.ts","sourceRoot":"","sources":["../../../../src/compliance/electronic-signatures/signed-document-validation.backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,OAAO,KAAK,EAAE,yBAAyB,EAAE,qCAAqC,EAAE,MAAM,sCAAsC,CAAC;AAE7H;;;GAGG;AACH,oBAAY,qBAAqB;IAC/B;iHAC6G;IAC7G,KAAK,UAAU;IACf;sEACkE;IAClE,QAAQ,aAAa;IACrB,0HAA0H;IAC1H,UAAU,eAAe;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,yCAAyC;IACzC,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,qCAAqC,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9G,qFAAqF;IACrF,QAAQ,CAAC,oCAAoC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClE;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AC;AAErH,iEAAiE;AACjE,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signed-document-validation.backend.js","sourceRoot":"","sources":["../../../../src/compliance/electronic-signatures/signed-document-validation.backend.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,MAAM,CAAN,IAAY,qBASX;AATD,WAAY,qBAAqB;IAC/B;iHAC6G;IAC7G,wCAAe,CAAA;IACf;sEACkE;IAClE,8CAAqB,CAAA;IACrB,0HAA0H;IAC1H,kDAAyB,CAAA;AAC3B,CAAC,EATW,qBAAqB,KAArB,qBAAqB,QAShC;AA+BD,0CAA0C;AAC1C,MAAM,CAAN,IAAY,4BAKX;AALD,WAAY,4BAA4B;IACtC,sGAAsG;IACtG,2CAAW,CAAA;IACX,6GAA6G;IAC7G,6CAAa,CAAA;AACf,CAAC,EALW,4BAA4B,KAA5B,4BAA4B,QAKvC;AAED,kDAAkD;AAClD,MAAM,CAAN,IAAY,8BAKX;AALD,WAAY,8BAA8B;IACxC,6GAA6G;IAC7G,uDAAqB,CAAA;IACrB,wEAAwE;IACxE,qDAAmB,CAAA;AACrB,CAAC,EALW,8BAA8B,KAA9B,8BAA8B,QAKzC","sourcesContent":["/**\n * # The signed-document validator port (#2293)\n *\n * What the signature-request service asks of the validator, and what the validator answers. A port, so the request's life\n * does not depend on the implementation: the engine binds `PadesSignedDocumentValidator`; with none bound, a request the\n * vendor reports complete stays open (it is never SIGNED on the vendor's word).\n *\n * The answer carries the EVIDENCE of a valid document: what was checked, against which chain, at which date, with which\n * revocation data. The service keeps it as a file beside the signed document, so a request says \"validated at T with this\n * revocation data\" for as long as its record lives.\n */\nimport type { ElectronicSignature_Level, ElectronicSignature_VendorEnvironment } from '@wildo-ai/external-connectors-models';\n\n/**\n * What the validator concluded about one signed document. The engine never takes the vendor's word: a request becomes\n * SIGNED only on {@link SignedDocumentVerdict.VALID} for every document of the request.\n */\nexport enum SignedDocumentVerdict {\n /** The document validated (byte range, signed revision equal to the bytes sent, chain to a pinned anchor, revocation\n * data fetched and stored, no refused algorithm) and proves every expected signer at the required level. */\n VALID = 'valid',\n /** The document did not validate: tampered, updated after the signature, an untrusted or development chain, a refused\n * algorithm. The request stays open for a document that does. */\n REJECTED = 'rejected',\n /** The document validated and proves another signer, or a lower level, than required: the request can never be SIGNED. */\n MISMATCHED = 'mismatched',\n}\n\n/**\n * The provider's declaration of what its evidence must chain to (from its contract's `evidence`). Anchors are declared\n * PER VENDOR ENVIRONMENT, and the validator reads only the set of the environment the contract reaches: production pins\n * production anchors only.\n */\nexport interface SignedDocumentEvidencePolicy {\n /** PEM certificates, per environment. */\n readonly trustAnchorsPem: Readonly<Partial<Record<ElectronicSignature_VendorEnvironment, readonly string[]>>>;\n /** The certificate-policy OIDs of the vendor's advanced signatures' certificates. */\n readonly advancedSignatureCertificatePolicies: readonly string[];\n}\n\nexport interface SignedDocumentValidationInput {\n readonly signedDocument: Uint8Array;\n /** The SHA-256 of the bytes sent: the signed revision must start with exactly these bytes. */\n readonly originalContentSha256: string;\n readonly requiredLevel: ElectronicSignature_Level;\n readonly providerRef: string;\n readonly vendorEnvironment: ElectronicSignature_VendorEnvironment | undefined;\n readonly evidencePolicy: SignedDocumentEvidencePolicy;\n /** When the request was sent: no signature can predate it. */\n readonly requestSentAt: Date;\n /**\n * The signers the request invited, each with the e-mail address on their record NOW (an address changed since the\n * invitation does not match their certificate; an empty one cannot be compared, and leaves the request open).\n */\n readonly expectedSigners: ReadonlyArray<{ readonly signerUserId: string; readonly email: string; readonly vendorSignerReference?: string }>;\n}\n\n/** What a piece of revocation data is. */\nexport enum SignedDocumentRevocationKind {\n /** A certificate revocation list (RFC 5280 §5), signed by the issuer of the certificates it lists. */\n CRL = 'crl',\n /** An OCSP response (RFC 6960) about one certificate. Read when the signature carries one; never fetched. */\n OCSP = 'ocsp',\n}\n\n/** Where a piece of revocation data came from. */\nexport enum SignedDocumentRevocationSource {\n /** Carried by the signature itself (its CMS `crls`, or Adobe's revocation-information archive attribute). */\n EMBEDDED = 'embedded',\n /** Fetched at receipt from the certificate's CRL distribution point. */\n FETCHED = 'fetched',\n}\n\n/** One piece of revocation data a validation used, kept with the evidence. */\nexport interface SignedDocumentRevocationData {\n readonly kind: SignedDocumentRevocationKind;\n readonly source: SignedDocumentRevocationSource;\n readonly url?: string;\n readonly fetchedAt?: string;\n readonly derBase64: string;\n}\n\n/** What one signature of a valid document proved. */\nexport interface SignedDocumentSignatureEvidence {\n readonly index: number;\n readonly subFilter: string;\n readonly byteRange: readonly number[];\n readonly signerSubject: string;\n readonly signerEmail?: string;\n readonly signerCertificateSerialHex: string;\n readonly certificatePolicies: readonly string[];\n readonly achievedLevel: ElectronicSignature_Level;\n /** The signing time the signature dictionary CLAIMS: the vendor's word, never proof. */\n readonly claimedSigningTime?: string;\n /** The date the chain and revocation were checked at. */\n readonly checkDate: string;\n /** The validated chain, signer first, anchor last, as DER in base64. */\n readonly chainDerBase64: readonly string[];\n}\n\n/** The evidence of a valid document, kept as a JSON file beside it. */\nexport interface SignedDocumentEvidence {\n readonly validatorVersion: 1;\n readonly checkedAt: string;\n readonly originalContentSha256: string;\n readonly signedContentSha256: string;\n readonly originalLength: number;\n readonly vendorEnvironment: ElectronicSignature_VendorEnvironment;\n readonly signatures: readonly SignedDocumentSignatureEvidence[];\n readonly revocation: readonly SignedDocumentRevocationData[];\n}\n\nexport type SignedDocumentValidation =\n | { readonly verdict: SignedDocumentVerdict.VALID; readonly evidence: SignedDocumentEvidence }\n | { readonly verdict: SignedDocumentVerdict.REJECTED | SignedDocumentVerdict.MISMATCHED; readonly reason: string };\n\n/** The validator of a signed document. See the module header. */\nexport interface SignedDocumentValidator {\n validate(input: SignedDocumentValidationInput): Promise<SignedDocumentValidation>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"signed-document-validation.backend.js","sourceRoot":"","sources":["../../../../src/compliance/electronic-signatures/signed-document-validation.backend.ts"],"names":[],"mappings":"AA4DA;;;GAGG;AACH,MAAM,CAAN,IAAY,qBASX;AATD,WAAY,qBAAqB;IAC/B;iHAC6G;IAC7G,wCAAe,CAAA;IACf;sEACkE;IAClE,8CAAqB,CAAA;IACrB,0HAA0H;IAC1H,kDAAyB,CAAA;AAC3B,CAAC,EATW,qBAAqB,KAArB,qBAAqB,QAShC;AA+BD,0CAA0C;AAC1C,MAAM,CAAN,IAAY,4BAKX;AALD,WAAY,4BAA4B;IACtC,sGAAsG;IACtG,2CAAW,CAAA;IACX,6GAA6G;IAC7G,6CAAa,CAAA;AACf,CAAC,EALW,4BAA4B,KAA5B,4BAA4B,QAKvC;AAED,kDAAkD;AAClD,MAAM,CAAN,IAAY,8BAKX;AALD,WAAY,8BAA8B;IACxC,6GAA6G;IAC7G,uDAAqB,CAAA;IACrB,wEAAwE;IACxE,qDAAmB,CAAA;AACrB,CAAC,EALW,8BAA8B,KAA9B,8BAA8B,QAKzC","sourcesContent":["/**\n * # The signed-document validator port (#2293)\n *\n * What the signature-request service asks of the validator, and what the validator answers. A port, so the request's life\n * does not depend on the implementation: the engine binds `PadesSignedDocumentValidator`; with none bound, a request the\n * vendor reports complete stays open (it is never SIGNED on the vendor's word).\n *\n * The answer carries the EVIDENCE of a valid document: what was checked, against which chain, at which date, with which\n * revocation data. The service keeps it as a file beside the signed document, so a request says \"validated at T with this\n * revocation data\" for as long as its record lives.\n *\n * ## Identity proofing that does not rely on the operator's contact data: DESIGNED, not built (#2293, 2026-11-12)\n *\n * **The gap.** Today a signer is proved by the e-mail address their certificate carries, compared with the address on\n * their user record (`expectedSigners[].email`), and the vendor invites them at that address. Both are the OPERATOR's\n * data: a person who can write the users table can change a signer's address to their own, receive the invitation, and\n * complete an advanced signature that this validator accepts as the signer's.\n *\n * **What the field does, which settles the approach.** An advanced signature must be \"capable of identifying the\n * signatory\" (eIDAS Art. 26(b)). Who the signatory is gets established by IDENTITY PROOFING, which ETSI TS 119 461\n * V2.1.1 specifies for trust services at two levels, Baseline LoIP (substantial) and Extended LoIP (high) (§3.1), through\n * a fixed set of use cases: an identity document with physical presence, attended remote or unattended remote; eID means;\n * an existing signature with certificate (§9.2.1–§9.2.5). An identity proofing provider conforming to it may name its\n * policy with 0.4.0.19461.1.1 (baseline) or 0.4.0.19461.1.2 (extended) (§4.6). Vendors expose it as a per-signer option\n * chosen when the request is sent (DocuSign's recipient `identityVerification` names an account's ID-verification\n * workflow), and the identity it established reaches the SIGNED DOCUMENT as the signer's certificate, issued after that\n * proofing under a certificate policy the vendor publishes.\n * spec-cite: Regulation (EU) No 910/2014 Art. 26 (point b), retained text at legislation.gov.uk/eur/2014/910/article/26;\n * ETSI TS 119 461 V2.1.1 (2025-02) §3.1 (Baseline LoIP, extended LoIP), §4.6 (the two OIDs), §9.2 (use cases).\n *\n * **The design.**\n * 1. A requirement `ElectronicSignature_IdentityProofing` (`CONTACT_CHANNEL`, today's and the default; `BASELINE_LOIP`;\n * `EXTENDED_LOIP`, which also meets baseline) beside the level, in `@wildo-ai/external-connectors-models`, declared on a\n * tool's `electronicSignature` and RECORDED on the request (`requiredIdentityProofing`: a field, so a migration on the\n * five surfaces), because a request is validated against what it was sent with, not against today's tool.\n * 2. The provider contract declares `supportedIdentityProofing` (startup refuses a requirement it cannot meet, as for\n * levels) and, in `evidence`, `identityProofingCertificatePolicies`: per level, the certificate-policy OIDs of the\n * certificates the vendor issues only after proofing at that level. The send input carries the requirement per signer.\n * 3. This validator proves it from the document, never from the vendor's API: each expected signer's signature must chain\n * to a pinned anchor (as today) AND its certificate must carry a declared OID of the required level or a higher one,\n * else MISMATCHED. The evidence records the achieved proofing level and the certificate's verified name.\n * 4. The verified name is bound to a name the operator could not rewrite afterwards: the approver's name as SEALED in the\n * approval (the approver disclosure, committed to by the custodian's signature, #2903), not their current profile.\n * The comparison is on name tokens (NFKD, marks removed, case-folded, order ignored) of the certificate's\n * `givenName` + `surname`, else its `commonName`; a difference is MISMATCHED. An approver whose sealed name was erased\n * leaves the request open. The vendor is sent that sealed name, so its own proofing checks the same identity.\n *\n * **Why it is not built yet.** Every step needs a vendor that offers ID-verified signing and publishes the policy its\n * certificates carry, and none is integrated: IgniSign (#2912) and the simulator (#2911) are where it is proven. Without\n * them the requirement would be refused at startup by every provider, so nothing could use it.\n *\n * **Rejected.** The vendor's identity-evidence API (an ID-verification result read over HTTP) as the proof: it is the\n * vendor's word, unsigned and outside the document, which is exactly what \"the vendor's API is not the authority\" rules\n * out. Comparing the certificate's name with the user's CURRENT profile name: that is operator data again, the threat\n * itself.\n * **What would remain.** A person who changed the approver's name and address BEFORE the approval was sealed, and also\n * holds an identity document in that name.\n */\nimport type { ElectronicSignature_Level, ElectronicSignature_VendorEnvironment } from '@wildo-ai/external-connectors-models';\n\n/**\n * What the validator concluded about one signed document. The engine never takes the vendor's word: a request becomes\n * SIGNED only on {@link SignedDocumentVerdict.VALID} for every document of the request.\n */\nexport enum SignedDocumentVerdict {\n /** The document validated (byte range, signed revision equal to the bytes sent, chain to a pinned anchor, revocation\n * data fetched and stored, no refused algorithm) and proves every expected signer at the required level. */\n VALID = 'valid',\n /** The document did not validate: tampered, updated after the signature, an untrusted or development chain, a refused\n * algorithm. The request stays open for a document that does. */\n REJECTED = 'rejected',\n /** The document validated and proves another signer, or a lower level, than required: the request can never be SIGNED. */\n MISMATCHED = 'mismatched',\n}\n\n/**\n * The provider's declaration of what its evidence must chain to (from its contract's `evidence`). Anchors are declared\n * PER VENDOR ENVIRONMENT, and the validator reads only the set of the environment the contract reaches: production pins\n * production anchors only.\n */\nexport interface SignedDocumentEvidencePolicy {\n /** PEM certificates, per environment. */\n readonly trustAnchorsPem: Readonly<Partial<Record<ElectronicSignature_VendorEnvironment, readonly string[]>>>;\n /** The certificate-policy OIDs of the vendor's advanced signatures' certificates. */\n readonly advancedSignatureCertificatePolicies: readonly string[];\n}\n\nexport interface SignedDocumentValidationInput {\n readonly signedDocument: Uint8Array;\n /** The SHA-256 of the bytes sent: the signed revision must start with exactly these bytes. */\n readonly originalContentSha256: string;\n readonly requiredLevel: ElectronicSignature_Level;\n readonly providerRef: string;\n readonly vendorEnvironment: ElectronicSignature_VendorEnvironment | undefined;\n readonly evidencePolicy: SignedDocumentEvidencePolicy;\n /** When the request was sent: no signature can predate it. */\n readonly requestSentAt: Date;\n /**\n * The signers the request invited, each with the e-mail address on their record NOW (an address changed since the\n * invitation does not match their certificate; an empty one cannot be compared, and leaves the request open).\n */\n readonly expectedSigners: ReadonlyArray<{ readonly signerUserId: string; readonly email: string; readonly vendorSignerReference?: string }>;\n}\n\n/** What a piece of revocation data is. */\nexport enum SignedDocumentRevocationKind {\n /** A certificate revocation list (RFC 5280 §5), signed by the issuer of the certificates it lists. */\n CRL = 'crl',\n /** An OCSP response (RFC 6960) about one certificate. Read when the signature carries one; never fetched. */\n OCSP = 'ocsp',\n}\n\n/** Where a piece of revocation data came from. */\nexport enum SignedDocumentRevocationSource {\n /** Carried by the signature itself (its CMS `crls`, or Adobe's revocation-information archive attribute). */\n EMBEDDED = 'embedded',\n /** Fetched at receipt from the certificate's CRL distribution point. */\n FETCHED = 'fetched',\n}\n\n/** One piece of revocation data a validation used, kept with the evidence. */\nexport interface SignedDocumentRevocationData {\n readonly kind: SignedDocumentRevocationKind;\n readonly source: SignedDocumentRevocationSource;\n readonly url?: string;\n readonly fetchedAt?: string;\n readonly derBase64: string;\n}\n\n/** What one signature of a valid document proved. */\nexport interface SignedDocumentSignatureEvidence {\n readonly index: number;\n readonly subFilter: string;\n readonly byteRange: readonly number[];\n readonly signerSubject: string;\n readonly signerEmail?: string;\n readonly signerCertificateSerialHex: string;\n readonly certificatePolicies: readonly string[];\n readonly achievedLevel: ElectronicSignature_Level;\n /** The signing time the signature dictionary CLAIMS: the vendor's word, never proof. */\n readonly claimedSigningTime?: string;\n /** The date the chain and revocation were checked at. */\n readonly checkDate: string;\n /** The validated chain, signer first, anchor last, as DER in base64. */\n readonly chainDerBase64: readonly string[];\n}\n\n/** The evidence of a valid document, kept as a JSON file beside it. */\nexport interface SignedDocumentEvidence {\n readonly validatorVersion: 1;\n readonly checkedAt: string;\n readonly originalContentSha256: string;\n readonly signedContentSha256: string;\n readonly originalLength: number;\n readonly vendorEnvironment: ElectronicSignature_VendorEnvironment;\n readonly signatures: readonly SignedDocumentSignatureEvidence[];\n readonly revocation: readonly SignedDocumentRevocationData[];\n}\n\nexport type SignedDocumentValidation =\n | { readonly verdict: SignedDocumentVerdict.VALID; readonly evidence: SignedDocumentEvidence }\n | { readonly verdict: SignedDocumentVerdict.REJECTED | SignedDocumentVerdict.MISMATCHED; readonly reason: string };\n\n/** The validator of a signed document. See the module header. */\nexport interface SignedDocumentValidator {\n validate(input: SignedDocumentValidationInput): Promise<SignedDocumentValidation>;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type AgentCallTraceSink, type AgentTraceabilityPolicy, A2ATokenBudgetDenialReason, type TokenSpendCeiling } from '@wildo-ai/saas-models';
|
|
2
|
-
import { ContentSafety_HarmCategory, type ContentSafety_HarmCategoryVerdict, type ContentSafety_PromptInjectionLimits, ContentSafetyModerationOutcome, ContentSafetyScreeningOutcome } from '@wildo-ai/external-connectors-models';
|
|
1
|
+
import { type AgentCallTraceSink, type AgentTraceabilityPolicy, A2ATokenBudgetDenialReason, type EnvironmentAgentContentGuardrailsReading, type TokenSpendCeiling } from '@wildo-ai/saas-models';
|
|
2
|
+
import { ContentSafetyProvider_OperationKey, ContentSafety_HarmCategory, type ContentSafety_HarmCategoryVerdict, type ContentSafety_PromptInjectionLimits, ContentSafetyModerationOutcome, ContentSafetyScreeningOutcome } from '@wildo-ai/external-connectors-models';
|
|
3
3
|
import type { LoggerService } from '../../monitoring/logger/services/logger.service';
|
|
4
4
|
import type { ErrorBuilderBackendService } from '../../errors/services/error-builder.backend.service';
|
|
5
5
|
import type { ExternalProvidersRegistryBackendService } from '../../external-providers/services/external-providers-registry.backend.service';
|
|
@@ -95,6 +95,31 @@ export declare class ContentSafetyBackendService {
|
|
|
95
95
|
private admitScreening;
|
|
96
96
|
/** #3030: charge the text records a screening or moderation sent (counted once the vendor answered). Never throws. */
|
|
97
97
|
private chargeScreening;
|
|
98
|
+
/**
|
|
99
|
+
* What this environment declared about agents' classifier-backed guardrails where no classifier serves them
|
|
100
|
+
* (`agentContentGuardrails` in `wildo.infra.<env>.config.ts`, projected to `WILDO_AGENT_CONTENT_GUARDRAILS`). Read once,
|
|
101
|
+
* when the service is built: the posture of a running process does not change under it. An unreadable value reads as
|
|
102
|
+
* REFUSE (fail closed), and the startup report says so.
|
|
103
|
+
*/
|
|
104
|
+
private readonly guardrailsWithoutClassifier;
|
|
105
|
+
/** The environment's declaration, as read when the service was built. */
|
|
106
|
+
agentGuardrailsWithoutClassifier(): EnvironmentAgentContentGuardrailsReading;
|
|
107
|
+
/**
|
|
108
|
+
* Whether a classifier for `operation` is PRESENT in this environment, as opposed to absent from it. Absent (`false`)
|
|
109
|
+
* in exactly three cases, each a fact of this environment's configuration:
|
|
110
|
+
*
|
|
111
|
+
* - the configuration declares no provider for `AI_CONTENT_SAFETY`;
|
|
112
|
+
* - the selected provider's contract does not offer `operation` (`openai-moderation` declares no screening);
|
|
113
|
+
* - the selected provider's credentials are not authored HERE: its API key slot, or the host slot it reads its endpoint
|
|
114
|
+
* from, is unset in this environment. The classifier is declared once for the whole application, so this is the one
|
|
115
|
+
* way an environment can be without it while another has it (staging without an Azure key, production with one).
|
|
116
|
+
*
|
|
117
|
+
* Everything else is `true` (present): a declared provider that did not load (a data residency refusal), a malformed
|
|
118
|
+
* host, a category it does not assess, a key that is set and wrong, an outage, and anything this cannot read. An
|
|
119
|
+
* environment that declares it runs agents unguarded where no classifier is present must still refuse, or withhold,
|
|
120
|
+
* when one is there and broken, because that is a failure, not the absence the environment declared.
|
|
121
|
+
*/
|
|
122
|
+
classifierPresentFor(operation: ContentSafetyProvider_OperationKey): boolean;
|
|
98
123
|
/**
|
|
99
124
|
* Whether this process records the screenings it makes (a provider-call recorder is bound). An agent that declares
|
|
100
125
|
* screening refuses to run where it does not: a screening nobody can show happened is the gap R7 exists to close.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-safety.backend.service.d.ts","sourceRoot":"","sources":["../../../../src/external-providers/services/content-safety.backend.service.ts"],"names":[],"mappings":"AAiDA,OAAO,EAUL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,0BAA0B,
|
|
1
|
+
{"version":3,"file":"content-safety.backend.service.d.ts","sourceRoot":"","sources":["../../../../src/external-providers/services/content-safety.backend.service.ts"],"names":[],"mappings":"AAiDA,OAAO,EAUL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,0BAA0B,EAI1B,KAAK,wCAAwC,EAC7C,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kCAAkC,EAClC,0BAA0B,EAK1B,KAAK,iCAAiC,EAEtC,KAAK,mCAAmC,EAGxC,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,sCAAsC,CAAC;AAI9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AACnH,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,4FAA4F,CAAC;AAC1J,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,iFAAiF,CAAC;AAI1I,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,+EAA+E,CAAC;AAGrI,0HAA0H;AAC1H,eAAO,MAAM,iCAAiC,QAAS,CAAC;AAExD,4GAA4G;AAC5G,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,6CAA6C,SAAU,CAAC;AAErE,yDAAyD;AACzD,eAAO,MAAM,8BAA8B,0BAA0B,CAAC;AAEtE;;;;GAIG;AACH,MAAM,WAAW,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