@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":"pdf-signature-structure.backend.js","sourceRoot":"","sources":["../../../../src/compliance/electronic-signatures/pdf-signature-structure.backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8EAA8E,CAAC;AAEnH,8FAA8F;AAC9F,MAAM,CAAN,IAAY,4BAaX;AAbD,WAAY,4BAA4B;IACtC,uEAAuE;IACvE,6DAA6B,CAAA;IAC7B,kHAAkH;IAClH,6EAA6C,CAAA;IAC7C,0EAA0E;IAC1E,2GAA2E,CAAA;IAC3E,0EAA0E;IAC1E,+EAA+C,CAAA;IAC/C,0FAA0F;IAC1F,iFAAiD,CAAA;IACjD,6HAA6H;IAC7H,2EAA2C,CAAA;AAC7C,CAAC,EAbW,4BAA4B,KAA5B,4BAA4B,QAavC;AAgBD,kGAAkG;AAClG,MAAM,CAAC,MAAM,iCAAiC,GAAwB,IAAI,GAAG,CAAC,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAY9H,8GAA8G;AAC9G,MAAM,UAAU,4BAA4B,CAAC,IAAgB,EAAE,qBAA6B;IAC1F,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAA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AC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,iBAAiB;QACvB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAChC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAC;YAC5C,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;gBACvB,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;gBACnB,SAAS;YACX,CAAC;YACD,IAAI,SAAS,KAAK,GAAG;gBAAE,KAAK,IAAI,CAAC,CAAC;YAClC,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;gBACtB,KAAK,IAAI,CAAC,CAAC;gBACX,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;oBAChB,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;oBACnB,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;YACD,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACrB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/**\n * # The structure of a signed PDF (#2293): what the signatures cover, and what was added after the bytes sent\n *\n * The byte-level half of validating a signed deliverable. It reads no cryptography (the signed-document validator does)\n * and answers three questions about the file the vendor returned:\n *\n * 1. **Where are the signatures, and what do they cover?** Each signature dictionary names a `/ByteRange [0 a b c]`: the\n * signed bytes are `[0, a)` and `[b, b + c)`, and the gap `[a, b)` must be exactly the `/Contents` hex string, which holds\n * the CMS signature. A range that does not start at 0, whose gap is not that hex string, or that runs past the file is\n * refused.\n * 2. **Do the signatures extend the bytes that were sent?** An electronic signature is applied as an INCREMENTAL UPDATE:\n * the vendor appends to the file it was given. So the file must start with exactly the bytes the approver approved,\n * ending at one of their `%%EOF` markers, and that prefix must hash to the request's `originalContentSha256`. A vendor\n * that rewrites the file (re-saves it, flattens it) is refused: what was signed is then not provably what was sent.\n * 3. **Is everything appended after those bytes a PERMITTED change?** Signing adds a signature dictionary, a signature\n * field and its widget, an appearance, a form, a page's `/Annots` and the catalog's `/AcroForm`; a validation update\n * adds a `/DSS`. Anything else appended (a new page, changed page content, another kind of annotation over the text, a\n * catalog swapped through the trailer) is refused, and so is anything after the LAST signature that is not a DSS\n * update: nothing signed covers it.\n *\n * ## How the appended bytes are read, and the limits that are stated\n *\n * They are WALKED strictly, the way a reader meets them: indirect objects, each closed by `endobj` and a stream's data\n * delimited by its `/Length`; cross-reference sections (tables, and cross-reference streams decoded with FlateDecode and\n * the PNG predictors); trailers; `startxref`; comments. Any other byte is refused, so no object can hide inside another's\n * bytes. Every cross-reference entry appended must point at an object the walk read, by its number and generation, so a\n * reader cannot be sent to bytes the analysis did not judge; freeing an object of the original is refused. An object\n * whose number the original or an earlier revision defined is a REDEFINITION, whatever type it now claims, and is judged\n * against what it replaces: only the catalog's `/AcroForm` and `/DSS`, a page's `/Annots`, a form's fields, an indirect\n * array a page's `/Annots` or a form's `/Fields` names (which may only grow), the trailer's `/Info` dictionary and an XMP\n * stream that was already one may change. After the last signature only NEW `/DSS` data and the catalog's `/DSS` may\n * appear. A form may not gain `/XFA` or `/NeedAppearances`, and the appended trailers keep the original's catalog and\n * encryption.\n *\n * Refused as unreadable: an appended object stream (its objects cannot be read without decompressing it, and a\n * redefinition hidden in one would pass unseen), a cross-reference entry placing an object in one, and a redefinition\n * whose previous definition the original keeps only in a compressed object stream. Admitted without inspecting what it\n * draws: a new appearance stream (`/Type /XObject /Subtype /Form`), which renders only inside its own widget's\n * rectangle and is what every vendor adds to show a signature. A \"shadow\" drawn in a signature widget is therefore not\n * detected; that is this analysis's stated residual. A vendor whose updates this refuses leaves the request open, never\n * SIGNED.\n *\n * spec-cite: ISO 32000-1:2008 §7.5.6 (incremental updates), §12.8.1 (signature dictionary: `ByteRange`, `Contents`,\n * `SubFilter`, `M`) and ETSI EN 319 142-1 §5.4 (the DSS dictionary); paraphrased from the structure they define, not\n * quoted.\n */\nimport { createHash } from 'node:crypto';\nimport { inflateSync } from 'node:zlib';\n\nimport { describeCaughtError } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\n\n/** Why a signed PDF's structure was refused. Stable codes: a REJECTED verdict carries one. */\nexport enum PdfSignatureStructureRefusal {\n /** No signature dictionary with a well-formed byte range was found. */\n NO_SIGNATURE = 'no_signature',\n /** A byte range does not start at 0, runs past the file, or its gap is not exactly the `/Contents` hex string. */\n MALFORMED_BYTE_RANGE = 'malformed_byte_range',\n /** Bytes follow the last signature and are not a permitted DSS update. */\n UNSIGNED_BYTES_AFTER_LAST_SIGNATURE = 'unsigned_bytes_after_last_signature',\n /** No prefix of the file ending at a `%%EOF` hashes to the bytes sent. */\n ORIGINAL_NOT_A_PREFIX = 'original_not_a_prefix',\n /** The appended bytes change the document beyond what signing and validation data add. */\n NOT_A_PERMITTED_CHANGE = 'not_a_permitted_change',\n /** The appended bytes cannot be analysed (an object stream, a redefinition of a compressed object, an unreadable object). */\n UNANALYSABLE_UPDATE = 'unanalysable_update',\n}\n\n/** One signature found in the file. */\nexport interface PdfSignatureField {\n /** `[0, a, b, c]` as declared. */\n readonly byteRange: readonly [number, number, number, number];\n /** The DER of the CMS signature: the `/Contents` hex decoded, its zero padding left for the CMS parser to end on. */\n readonly contents: Uint8Array;\n /** The signature dictionary's `/SubFilter` name, without the slash. */\n readonly subFilter: string | undefined;\n /** The signing time the dictionary's `/M` CLAIMS. The vendor's word, never proof. */\n readonly claimedSigningTime: Date | undefined;\n /** The offset just past the last byte this signature covers. */\n readonly coveredEnd: number;\n}\n\n/** The SubFilters a PAdES / PDF signature validated here may declare: CMS detached signatures. */\nexport const PDF_ACCEPTED_SIGNATURE_SUBFILTERS: ReadonlySet<string> = new Set(['adbe.pkcs7.detached', 'ETSI.CAdES.detached']);\n\nexport type PdfSignatureStructure =\n | {\n readonly ok: true;\n /** The signatures, in the order they cover the file (the first covers the least). */\n readonly signatures: readonly PdfSignatureField[];\n /** The length of the original bytes the file starts with. */\n readonly originalLength: number;\n }\n | { readonly ok: false; readonly refusal: PdfSignatureStructureRefusal; readonly reason: string };\n\n/** Read a signed PDF's structure against the hash of the bytes sent (see the module header). Never throws. */\nexport function analysePdfSignatureStructure(file: Uint8Array, originalContentSha256: string): PdfSignatureStructure {\n try {\n return analyse(file, originalContentSha256);\n } catch (error) {\n return { ok: false, refusal: PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, reason: `The file could not be read: ${describeCaughtError(error)}` };\n }\n}\n\nfunction refuse(refusal: PdfSignatureStructureRefusal, reason: string): PdfSignatureStructure {\n return { ok: false, refusal, reason };\n}\n\nfunction analyse(file: Uint8Array, originalContentSha256: string): PdfSignatureStructure {\n // latin1: one character per byte, so every string offset is a byte offset.\n const text = Buffer.from(file.buffer, file.byteOffset, file.byteLength).toString('latin1');\n const signatures: PdfSignatureField[] = [];\n const byteRangePattern = /\\/ByteRange\\s*\\[\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s*\\]/g;\n for (let match = byteRangePattern.exec(text); match; match = byteRangePattern.exec(text)) {\n const [start, firstLength, secondStart, secondLength] = match.slice(1, 5).map((value) => Number(value)) as [number, number, number, number];\n if (start !== 0 || firstLength <= 0 || secondStart <= firstLength || secondStart + secondLength > file.byteLength) {\n return refuse(PdfSignatureStructureRefusal.MALFORMED_BYTE_RANGE, `A signature's byte range [${start} ${firstLength} ${secondStart} ${secondLength}] does not cover the file from its start within its length.`);\n }\n const gap = text.slice(firstLength, secondStart);\n if (!/^<[0-9A-Fa-f\\s]*>$/.test(gap)) {\n return refuse(PdfSignatureStructureRefusal.MALFORMED_BYTE_RANGE, `A signature's byte range leaves out bytes ${firstLength}–${secondStart} that are not its /Contents hex string.`);\n }\n // The dictionary the byte range sits in must be the one whose /Contents is the gap.\n const objectStart = text.lastIndexOf(' obj', match.index);\n const objectEnd = text.indexOf('endobj', match.index);\n if (objectStart < 0 || objectEnd < 0 || firstLength < objectStart || secondStart > objectEnd) {\n return refuse(PdfSignatureStructureRefusal.MALFORMED_BYTE_RANGE, 'A signature\\'s byte range does not leave out the /Contents of its own signature dictionary.');\n }\n const dictionary = text.slice(objectStart, firstLength) + text.slice(secondStart, objectEnd);\n const hex = gap.slice(1, -1).replace(/\\s+/g, '');\n signatures.push({\n byteRange: [start, firstLength, secondStart, secondLength],\n contents: new Uint8Array(Buffer.from(hex.length % 2 === 0 ? hex : `${hex}0`, 'hex')),\n subFilter: /\\/SubFilter\\s*\\/([^\\s/<>[\\]()]+)/.exec(dictionary)?.[1],\n claimedSigningTime: parsePdfDate(/\\/M\\s*\\((D:[^)]*)\\)/.exec(dictionary)?.[1]),\n coveredEnd: secondStart + secondLength,\n });\n }\n if (signatures.length === 0) return refuse(PdfSignatureStructureRefusal.NO_SIGNATURE, 'The file carries no signature.');\n signatures.sort((first, second) => first.coveredEnd - second.coveredEnd);\n\n // The bytes sent, as a prefix ending at one of their %%EOF markers.\n const firstSignatureStart = Math.min(...signatures.map((signature) => signature.byteRange[1]));\n const originalLength = originalPrefixLength(file, text, firstSignatureStart, originalContentSha256);\n if (originalLength === undefined) {\n return refuse(PdfSignatureStructureRefusal.ORIGINAL_NOT_A_PREFIX, 'The signed file does not start with the bytes that were sent: the vendor did not sign them as an incremental update.');\n }\n\n const lastCovered = signatures[signatures.length - 1]!.coveredEnd;\n const changes = analyseAppendedRevisions(text, originalLength, signatures, lastCovered);\n if (changes) return changes;\n return { ok: true, signatures, originalLength };\n}\n\n/**\n * The length of the prefix that hashes to the bytes sent: an offset just past a `%%EOF` marker (and its end-of-line, when\n * the original ended with one), before the first signature.\n */\nfunction originalPrefixLength(file: Uint8Array, text: string, before: number, sha256: string): number | undefined {\n for (let index = text.indexOf('%%EOF'); index >= 0 && index < before; index = text.indexOf('%%EOF', index + 1)) {\n const end = index + 5;\n const candidates = [end];\n if (text[end] === '\\r' && text[end + 1] === '\\n') candidates.push(end + 2);\n else if (text[end] === '\\n' || text[end] === '\\r') candidates.push(end + 1);\n for (const length of candidates) {\n if (length > before) continue;\n if (createHash('sha256').update(file.subarray(0, length)).digest('hex') === sha256) return length;\n }\n }\n return undefined;\n}\n\n/** One indirect object as written in the bytes. */\ninterface PdfIndirectObject {\n readonly number: number;\n readonly generation: number;\n /** The offset of the object's number: where a cross-reference entry must point. */\n readonly offset: number;\n /** The object's value up to `stream` or `endobj`: a dictionary, an array, or a simple value. */\n readonly value: string;\n readonly isStream: boolean;\n /** A stream's data, as written (undecoded). */\n readonly streamData?: string;\n}\n\n/** Where a cross-reference entry says an object is (ISO 32000-1 §7.5.4, §7.5.8.3). */\nenum PdfCrossReferenceEntryKind {\n /** In use, its definition at the entry's byte offset. */\n IN_USE = 'in_use',\n /** Free: the object is deleted. */\n FREE = 'free',\n /** Stored inside an object stream (refused: the analysis does not read object streams). */\n COMPRESSED = 'compressed',\n}\n\n/** A cross-reference entry an appended section declares. */\ninterface PdfCrossReferenceEntry {\n readonly number: number;\n readonly generation: number;\n readonly kind: PdfCrossReferenceEntryKind;\n readonly offset: number;\n}\n\n/** What the strict walk of the appended bytes found. */\ninterface PdfAppendedRegion {\n readonly objects: readonly PdfIndirectObject[];\n readonly crossReferences: readonly PdfCrossReferenceEntry[];\n /** Every trailer dictionary: a classic `trailer`, or a cross-reference stream's own dictionary. */\n readonly trailers: ReadonlyArray<{ readonly entries: Map<string, string>; readonly sectionOffset: number }>;\n /** The offset of every cross-reference section walked: an `xref` keyword, or a cross-reference stream's object. */\n readonly sectionOffsets: readonly number[];\n /** Every `startxref` value, in order. */\n readonly startxrefValues: readonly number[];\n}\n\n/** Thrown inside the walk; turned into an UNANALYSABLE refusal. */\nclass UnanalysableUpdate extends Error {}\n\n/**\n * Walk the bytes after the original STRICTLY, the way a reader meets them: indirect objects (each closed by `endobj`,\n * a stream's data delimited by its `/Length`), cross-reference sections, trailers, `startxref` and comments. Anything else\n * is refused, so no object can hide inside another's bytes (an object left without `endobj`, data between objects).\n */\nfunction walkAppendedRegion(text: string, from: number): PdfAppendedRegion {\n const objects: PdfIndirectObject[] = [];\n const crossReferences: PdfCrossReferenceEntry[] = [];\n const trailers: Array<{ entries: Map<string, string>; sectionOffset: number }> = [];\n const sectionOffsets: number[] = [];\n const startxrefValues: number[] = [];\n let lastTableOffset = -1;\n const tokens = new PdfTokenizer(text, from, text.length);\n for (;;) {\n tokens.skipWhitespace();\n if (tokens.position >= text.length) break;\n const at = tokens.position;\n const header = /^(\\d+)\\s+(\\d+)\\s+obj\\b/.exec(text.slice(at, at + 40));\n if (header) {\n tokens.position = at + header[0].length;\n const valueStart = tokens.position;\n if (tokens.readValue() === undefined) throw new UnanalysableUpdate(`object ${header[1]} at ${at} has no readable value`);\n const value = text.slice(valueStart, tokens.position).trim();\n tokens.skipWhitespace();\n let isStream = false;\n let streamData: string | undefined;\n if (text.startsWith('stream', tokens.position)) {\n isStream = true;\n let dataStart = tokens.position + 'stream'.length;\n if (text[dataStart] === '\\r' && text[dataStart + 1] === '\\n') dataStart += 2;\n else if (text[dataStart] === '\\n') dataStart += 1;\n else throw new UnanalysableUpdate(`object ${header[1]}: 'stream' is not followed by an end of line`);\n // Stated residual: a stream's data is not searched for text shaped like an object or a section. While a reader\n // follows the cross-reference sections (every one checked below) such text is inert; a reader that rebuilds a\n // damaged table by scanning the file could pick it up. Refusing on a pattern would refuse genuine DER data by chance.\n const length = streamLengthOf(text, parseDictionaryOrUndefined(value), from);\n streamData = text.slice(dataStart, dataStart + length);\n tokens.position = dataStart + length;\n tokens.skipWhitespace();\n if (!text.startsWith('endstream', tokens.position)) throw new UnanalysableUpdate(`object ${header[1]}: its stream does not end where its /Length says`);\n tokens.position += 'endstream'.length;\n tokens.skipWhitespace();\n }\n if (!text.startsWith('endobj', tokens.position)) throw new UnanalysableUpdate(`object ${header[1]} at ${at} is not closed by endobj`);\n tokens.position += 'endobj'.length;\n const object: PdfIndirectObject = { number: Number(header[1]), generation: Number(header[2]), offset: at, value, isStream, ...(streamData !== undefined ? { streamData } : {}) };\n objects.push(object);\n const dictionary = parseDictionaryOrUndefined(value);\n if (dictionary?.get('/Type') === '/XRef') {\n if (!isStream || streamData === undefined) throw new UnanalysableUpdate(`object ${header[1]} is a cross-reference stream without data`);\n crossReferences.push(...crossReferenceStreamEntries(dictionary, streamData));\n trailers.push({ entries: dictionary, sectionOffset: at });\n sectionOffsets.push(at);\n }\n continue;\n }\n if (text.startsWith('xref', at)) {\n tokens.position = at + 'xref'.length;\n crossReferences.push(...readCrossReferenceTable(text, tokens));\n sectionOffsets.push(at);\n lastTableOffset = at;\n continue;\n }\n if (text.startsWith('trailer', at)) {\n tokens.position = at + 'trailer'.length;\n const entries = tokens.readDictionaryEntries();\n if (!entries) throw new UnanalysableUpdate(`the trailer at ${at} is not a dictionary`);\n if (lastTableOffset < 0) throw new UnanalysableUpdate(`the trailer at ${at} follows no cross-reference table`);\n trailers.push({ entries, sectionOffset: lastTableOffset });\n lastTableOffset = -1;\n continue;\n }\n if (text.startsWith('startxref', at)) {\n tokens.position = at + 'startxref'.length;\n tokens.skipWhitespace();\n const number = /^\\d+/.exec(text.slice(tokens.position, tokens.position + 20));\n if (!number) throw new UnanalysableUpdate(`startxref at ${at} names no offset`);\n startxrefValues.push(Number(number[0]));\n tokens.position += number[0].length;\n continue;\n }\n throw new UnanalysableUpdate(`bytes at ${at} are neither an object, a cross-reference section nor a trailer`);\n }\n return { objects, crossReferences, trailers, sectionOffsets, startxrefValues };\n}\n\n/** A stream's `/Length`: direct, or an indirect integer object defined in the appended bytes. */\nfunction streamLengthOf(text: string, dictionary: Map<string, string> | undefined, from: number): number {\n const raw = dictionary?.get('/Length');\n if (raw === undefined) throw new UnanalysableUpdate('a stream declares no /Length');\n if (/^\\d+$/.test(raw)) return Number(raw);\n const reference = /^(\\d+) (\\d+) R$/.exec(raw);\n if (!reference) throw new UnanalysableUpdate(`a stream's /Length \"${raw}\" cannot be read`);\n const definition = new RegExp(`(?:^|[\\\\r\\\\n\\\\s])${reference[1]}\\\\s+${reference[2]}\\\\s+obj\\\\s+(\\\\d+)\\\\s+endobj`).exec(text.slice(from));\n if (!definition) throw new UnanalysableUpdate(`a stream's /Length ${raw} is not an integer object of the update`);\n return Number(definition[1]);\n}\n\n/** A classic cross-reference table: subsections of `start count`, then 20-byte entries, up to `trailer`. */\nfunction readCrossReferenceTable(text: string, tokens: PdfTokenizer): PdfCrossReferenceEntry[] {\n const entries: PdfCrossReferenceEntry[] = [];\n for (;;) {\n tokens.skipWhitespace();\n if (text.startsWith('trailer', tokens.position)) return entries;\n const subsection = /^(\\d+)\\s+(\\d+)[ \\t]*\\r?\\n/.exec(text.slice(tokens.position, tokens.position + 40));\n if (!subsection) throw new UnanalysableUpdate(`a cross-reference subsection at ${tokens.position} cannot be read`);\n tokens.position += subsection[0].length;\n const start = Number(subsection[1]);\n const count = Number(subsection[2]);\n for (let index = 0; index < count; index += 1) {\n const entry = /^(\\d{10}) (\\d{5}) ([nf])\\s{0,2}/.exec(text.slice(tokens.position, tokens.position + 22));\n if (!entry) throw new UnanalysableUpdate(`cross-reference entry ${start + index} cannot be read`);\n tokens.position += entry[0].length;\n entries.push({ number: start + index, generation: Number(entry[2]), kind: entry[3] === 'n' ? PdfCrossReferenceEntryKind.IN_USE : PdfCrossReferenceEntryKind.FREE, offset: Number(entry[1]) });\n }\n }\n}\n\n/** The entries of a cross-reference stream (FlateDecode with or without a PNG predictor, or no filter). */\nfunction crossReferenceStreamEntries(dictionary: Map<string, string>, data: string): PdfCrossReferenceEntry[] {\n const widths = (/^\\[\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s*\\]$/.exec(dictionary.get('/W') ?? '') ?? []).slice(1).map(Number);\n if (widths.length !== 3) throw new UnanalysableUpdate('a cross-reference stream has no readable /W');\n const filter = dictionary.get('/Filter');\n let bytes: Buffer = Buffer.from(data, 'latin1');\n if (filter === '/FlateDecode' || filter === '[/FlateDecode]' || filter === '[ /FlateDecode ]') bytes = inflateSync(bytes);\n else if (filter !== undefined) throw new UnanalysableUpdate(`a cross-reference stream uses ${filter}`);\n const rowLength = widths[0]! + widths[1]! + widths[2]!;\n const parameters = parseDictionaryOrUndefined(dictionary.get('/DecodeParms') ?? '');\n const predictor = Number(parameters?.get('/Predictor') ?? 1);\n if (predictor >= 10) bytes = undoPngPredictor(bytes, Number(parameters?.get('/Columns') ?? rowLength));\n else if (predictor !== 1) throw new UnanalysableUpdate(`a cross-reference stream uses predictor ${predictor}`);\n const size = Number(dictionary.get('/Size'));\n const index = (/^\\[([\\d\\s]+)\\]$/.exec(dictionary.get('/Index') ?? '')?.[1]?.trim().split(/\\s+/).map(Number)) ?? [0, size];\n const entries: PdfCrossReferenceEntry[] = [];\n let row = 0;\n for (let pair = 0; pair + 1 < index.length; pair += 2) {\n for (let number = index[pair]!; number < index[pair]! + index[pair + 1]!; number += 1, row += 1) {\n const at = row * rowLength;\n if (at + rowLength > bytes.length) throw new UnanalysableUpdate('a cross-reference stream is shorter than its /Index');\n const field = (start: number, width: number, fallback: number) => {\n if (width === 0) return fallback;\n let value = 0;\n for (let offset = 0; offset < width; offset += 1) value = value * 256 + bytes[at + start + offset]!;\n return value;\n };\n const type = field(0, widths[0]!, 1);\n const second = field(widths[0]!, widths[1]!, 0);\n const third = field(widths[0]! + widths[1]!, widths[2]!, 0);\n const kind = type === 1 ? PdfCrossReferenceEntryKind.IN_USE : type === 0 ? PdfCrossReferenceEntryKind.FREE : PdfCrossReferenceEntryKind.COMPRESSED;\n entries.push({ number, generation: type === 1 ? third : 0, kind, offset: second });\n }\n }\n return entries;\n}\n\n/** Undo the PNG predictors of a FlateDecode stream (ISO 32000-1 §7.4.4.4): one filter-type byte per row. */\nfunction undoPngPredictor(bytes: Buffer, columns: number): Buffer {\n const rows: Buffer[] = [];\n let previous = Buffer.alloc(columns);\n for (let at = 0; at + columns < bytes.length + 1 && at < bytes.length; at += columns + 1) {\n const type = bytes[at]!;\n const row = Buffer.from(bytes.subarray(at + 1, at + 1 + columns));\n for (let column = 0; column < columns; column += 1) {\n const left = column > 0 ? row[column - 1]! : 0;\n const up = previous[column]!;\n const upLeft = column > 0 ? previous[column - 1]! : 0;\n if (type === 1) row[column] = (row[column]! + left) & 0xff;\n else if (type === 2) row[column] = (row[column]! + up) & 0xff;\n else if (type === 3) row[column] = (row[column]! + Math.floor((left + up) / 2)) & 0xff;\n else if (type === 4) {\n const estimate = left + up - upLeft;\n const [pa, pb, pc] = [Math.abs(estimate - left), Math.abs(estimate - up), Math.abs(estimate - upLeft)];\n row[column] = (row[column]! + (pa <= pb && pa <= pc ? left : pb <= pc ? up : upLeft)) & 0xff;\n } else if (type !== 0) throw new UnanalysableUpdate(`a cross-reference stream row uses PNG filter ${type}`);\n }\n rows.push(row);\n previous = row;\n }\n return Buffer.concat(rows);\n}\n\n/**\n * The appended revisions, checked for permitted changes (module header, question 3). Answers a refusal, or `undefined`\n * when every appended object is a signing or validation addition and nothing unsigned follows the last signature but a\n * DSS update.\n */\nfunction analyseAppendedRevisions(text: string, originalLength: number, signatures: readonly PdfSignatureField[], lastCovered: number): PdfSignatureStructure | undefined {\n const original = text.slice(0, originalLength);\n const originalSize = lastNumberOf(original, /\\/Size\\s+(\\d+)/g);\n const originalRoot = lastMatchOf(original, /\\/Root\\s+(\\d+\\s+\\d+\\s+R)/g);\n const originalEncrypt = lastMatchOf(original, /\\/Encrypt\\s+(\\d+\\s+\\d+\\s+R)/g);\n if (originalSize === undefined || originalRoot === undefined) {\n return refuse(PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, 'The bytes sent declare no trailer /Size or /Root, so what was appended to them cannot be told apart.');\n }\n void signatures;\n let region: PdfAppendedRegion;\n try {\n region = walkAppendedRegion(text, originalLength);\n } catch (error) {\n return refuse(PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, `The bytes after the original cannot be read: ${describeCaughtError(error)}`);\n }\n\n // The trailers appended keep the catalog and the encryption the bytes sent named.\n // A reader finds the cross-reference sections through `startxref`, `/Prev` and `/XRefStm`: each must name a section\n // the walk READ (or, for the chain into the original, the original's own), so no section hidden in a stream's data, or\n // anywhere else the walk did not judge, can be the one a reader follows.\n // Into the original, a /Prev names the original's LAST section only: one naming an earlier section would make a reader\n // skip the original's own later updates, so render a version of the document other than the one sent.\n const walkedSections = new Set(region.sectionOffsets);\n const originalStartxrefs = allMatchesOf(original, /startxref\\s+(\\d+)/g).map(Number);\n const originalLastSection = originalStartxrefs[originalStartxrefs.length - 1];\n const originalCrossReferenceStreams = new Set(allMatchesOf(original, /\\/XRefStm\\s+(\\d+)/g).map(Number));\n if (region.startxrefValues.some((value) => !walkedSections.has(value))) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'An appended startxref names a cross-reference section the analysis did not read.');\n }\n const lastSection = region.sectionOffsets[region.sectionOffsets.length - 1];\n const lastStartxref = region.startxrefValues[region.startxrefValues.length - 1];\n if (region.sectionOffsets.length > 0 && lastStartxref !== lastSection) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'The file\\'s last startxref does not name its last cross-reference section.');\n }\n // Each appended section chains to the one immediately before it (the first to the original's last): a /Prev that skips\n // a revision would show a reader the document without, say, the signature that revision added. A hybrid file, whose\n // cross-reference stream is reached through /XRefStm and carries no /Prev of its own, is refused by this too: stated,\n // and fail-closed (the request stays open).\n let expectedPrev = originalLastSection;\n for (const { entries, sectionOffset } of region.trailers) {\n // An incremental update chains to what it updates: a section without /Prev would hide the whole original from a reader.\n if (entries.get('/Prev') === undefined || Number(entries.get('/Prev')) !== expectedPrev) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'An appended cross-reference section does not chain to the revision it updates.');\n }\n expectedPrev = sectionOffset;\n // A hybrid file's /XRefStm names a cross-reference stream: one the walk read, before this section, or the original's.\n const xrefStream = entries.get('/XRefStm');\n if (xrefStream !== undefined) {\n const offset = Number(xrefStream);\n const admitted = (walkedSections.has(offset) && offset < sectionOffset) || originalCrossReferenceStreams.has(offset);\n if (!/^\\d+$/.test(xrefStream) || !admitted) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'An appended trailer\\'s /XRefStm names a cross-reference stream the analysis did not read.');\n }\n }\n }\n for (const { entries: trailer } of region.trailers) {\n const root = trailer.get('/Root');\n if (root === undefined || normalizeReference(root) !== normalizeReference(originalRoot)) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'An appended trailer names another catalog than the bytes sent.');\n }\n const encrypt = trailer.get('/Encrypt');\n if ((encrypt ?? '') !== (originalEncrypt ?? '') && !(encrypt && originalEncrypt && normalizeReference(encrypt) === normalizeReference(originalEncrypt))) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'An appended trailer changes the document\\'s encryption.');\n }\n }\n\n // Every cross-reference entry appended points at an object this walk read, by its number and generation: a reader\n // finds objects through these entries, so none may point into another object's bytes or back into the bytes sent.\n const objectAt = new Map(region.objects.map((object) => [object.offset, object]));\n for (const entry of region.crossReferences) {\n if (entry.kind === PdfCrossReferenceEntryKind.COMPRESSED) {\n return refuse(PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, `Object ${entry.number} is placed in an object stream by an appended cross-reference stream.`);\n }\n if (entry.kind === PdfCrossReferenceEntryKind.FREE) {\n if (entry.number !== 0 && (entry.number < originalSize || region.objects.some((object) => object.number === entry.number))) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, `An appended cross-reference section frees object ${entry.number}.`);\n }\n continue;\n }\n const target = objectAt.get(entry.offset);\n if (!target || target.number !== entry.number || target.generation !== entry.generation) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, `An appended cross-reference entry for object ${entry.number} does not point at that object's definition in the update.`);\n }\n }\n\n const infoReference = lastMatchOf(original, /\\/Info\\s+(\\d+\\s+\\d+\\s+R)/g);\n const rootNumber = Number(originalRoot.split(/\\s+/)[0]);\n const infoNumber = infoReference ? Number(infoReference.split(/\\s+/)[0]) : undefined;\n const growableArrays = growableArrayNumbers(original, region.objects);\n\n for (const object of region.objects) {\n const dictionary = parseDictionaryOrUndefined(object.value);\n const type = dictionary?.get('/Type');\n const afterLastSignature = object.offset >= lastCovered;\n const previous = previousDefinition(text, object, originalLength, region.objects);\n const existedBefore = object.number < originalSize || previous !== undefined;\n\n if (existedBefore) {\n // A redefinition, whatever it calls itself: judged against what it replaces.\n if (!previous) {\n return refuse(PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, `Object ${object.number} is redefined, and its previous definition is not a plain object the analysis can compare.`);\n }\n if (afterLastSignature) {\n const refusal = object.number === rootNumber ? refusalOfCatalogChange(object, dictionary, previous, new Set(['/DSS'])) : `Object ${object.number} is changed after the last signature.`;\n if (refusal) return refuse(PdfSignatureStructureRefusal.UNSIGNED_BYTES_AFTER_LAST_SIGNATURE, refusal);\n continue;\n }\n const refusal = refusalOfRedefinition(object, dictionary, previous, { isCatalog: object.number === rootNumber, isInfo: object.number === infoNumber, growableArrays });\n if (refusal) return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, refusal);\n continue;\n }\n\n // A new object.\n if (type === '/ObjStm') {\n return refuse(PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, `Object ${object.number} is an object stream appended after the bytes sent; the objects in it cannot be checked.`);\n }\n if (type === '/XRef') continue;\n if (afterLastSignature) {\n if (!isDssAddition(object, dictionary)) {\n return refuse(PdfSignatureStructureRefusal.UNSIGNED_BYTES_AFTER_LAST_SIGNATURE, `Object ${object.number}, after the last signature, is not a document security store update.`);\n }\n continue;\n }\n const refusal = refusalOfNewObject(object, dictionary);\n if (refusal) return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, refusal);\n }\n return undefined;\n}\n\n/** The kinds of object signing and validation data add. Anything else new (a page, a free-text annotation) is refused. */\nconst NEW_OBJECT_TYPES: ReadonlySet<string> = new Set(['/Sig', '/DSS', '/VRI', '/XObject', '/Font', '/FontDescriptor', '/Annot', '/Encoding']);\nconst ANNOTATION_SUBTYPES_ADMITTED: ReadonlySet<string> = new Set(['/Widget']);\n/** Form keys that would change what the document shows or does when opened (XFA forms, regenerated appearances). */\nconst FORBIDDEN_FORM_KEYS: readonly string[] = ['/XFA', '/NeedAppearances'];\n\nfunction refusalOfNewObject(object: PdfIndirectObject, dictionary: Map<string, string> | undefined): string | undefined {\n if (!dictionary) return undefined; // An array or a simple value: reachable only through a key the checks below admit.\n const type = dictionary.get('/Type');\n const subtype = dictionary.get('/Subtype');\n if (type !== undefined && !NEW_OBJECT_TYPES.has(type)) return `Object ${object.number} adds a ${type} after the bytes sent.`;\n if (type === '/XObject' && subtype !== '/Form') return `Object ${object.number} adds an image or other XObject, not an appearance.`;\n if (type === '/Annot' || (subtype !== undefined && type === undefined && dictionary.has('/Rect'))) {\n if (!subtype || !ANNOTATION_SUBTYPES_ADMITTED.has(subtype)) return `Object ${object.number} adds a ${subtype ?? 'untyped'} annotation, which can cover the document's content.`;\n }\n if (subtype === '/Widget' && dictionary.get('/FT') !== '/Sig' && !dictionary.has('/Parent')) {\n return `Object ${object.number} adds a widget that is not a signature field.`;\n }\n // A form field that is not a signature field could change what the document shows when filled.\n if (dictionary.has('/FT') && dictionary.get('/FT') !== '/Sig') return `Object ${object.number} adds a ${dictionary.get('/FT')} form field.`;\n const forbidden = FORBIDDEN_FORM_KEYS.find((key) => dictionary.has(key));\n if (forbidden) return `Object ${object.number} adds a form carrying ${forbidden}.`;\n return undefined;\n}\n\n/** The keys a redefinition may change, per kind of object; every other key must keep its value. */\nconst CATALOG_CHANGEABLE_KEYS: ReadonlySet<string> = new Set(['/AcroForm', '/DSS']);\nconst PAGE_CHANGEABLE_KEYS: ReadonlySet<string> = new Set(['/Annots']);\nconst FORM_CHANGEABLE_KEYS: ReadonlySet<string> = new Set(['/Fields', '/SigFlags', '/DR', '/DA']);\n\nfunction refusalOfRedefinition(\n object: PdfIndirectObject,\n dictionary: Map<string, string> | undefined,\n previous: PdfIndirectObject,\n kind: { readonly isCatalog: boolean; readonly isInfo: boolean; readonly growableArrays: ReadonlySet<number> },\n): string | undefined {\n const previousDictionary = parseDictionaryOrUndefined(previous.value);\n // Document metadata, invisible on the page: the trailer's /Info dictionary, and an XMP stream that WAS one.\n if (kind.isInfo && !object.isStream && !previous.isStream && dictionary && previousDictionary) return undefined;\n if (object.isStream && previous.isStream && dictionary?.get('/Type') === '/Metadata' && previousDictionary?.get('/Type') === '/Metadata') return undefined;\n if (object.isStream || previous.isStream) return `Object ${object.number}, a stream, is replaced after the bytes sent.`;\n if (kind.isCatalog) return refusalOfCatalogChange(object, dictionary, previous, CATALOG_CHANGEABLE_KEYS);\n if (!dictionary) {\n // An indirect array may only grow, and only one a page's /Annots or a form's /Fields names.\n const before = referencesIn(previous.value);\n const after = referencesIn(object.value);\n if (!kind.growableArrays.has(object.number) || !previous.value.startsWith('[') || !object.value.startsWith('[') || before.some((reference) => !after.includes(reference))) {\n return `Object ${object.number} is replaced by a value that drops or changes what it held.`;\n }\n return undefined;\n }\n if (!previousDictionary) return `Object ${object.number} changes kind after the bytes sent.`;\n const type = previousDictionary.get('/Type');\n const changeable = type === '/Page' ? PAGE_CHANGEABLE_KEYS : previousDictionary.has('/Fields') ? FORM_CHANGEABLE_KEYS : undefined;\n if (!changeable) return `Object ${object.number}${type ? ` (${type})` : ''} is changed after the bytes sent.`;\n if (changeable === FORM_CHANGEABLE_KEYS) {\n const forbidden = FORBIDDEN_FORM_KEYS.find((key) => dictionary.has(key));\n if (forbidden) return `Object ${object.number}, the form, gains ${forbidden}.`;\n }\n return refusalOfChangedKeys(object, previousDictionary, dictionary, changeable, type);\n}\n\n/** A catalog redefinition: only `changeable` keys may differ, and an inline form may not gain XFA or regenerated appearances. */\nfunction refusalOfCatalogChange(object: PdfIndirectObject, dictionary: Map<string, string> | undefined, previous: PdfIndirectObject, changeable: ReadonlySet<string>): string | undefined {\n const previousDictionary = parseDictionaryOrUndefined(previous.value);\n if (object.isStream || !dictionary || !previousDictionary) return `Object ${object.number}, the catalog, changes kind.`;\n const form = dictionary.get('/AcroForm');\n const inlineForm = form?.startsWith('<<') ? parseDictionaryOrUndefined(form) : undefined;\n const forbidden = inlineForm ? FORBIDDEN_FORM_KEYS.find((key) => inlineForm.has(key)) : undefined;\n if (forbidden) return `The catalog's form gains ${forbidden}.`;\n return refusalOfChangedKeys(object, previousDictionary, dictionary, changeable, '/Catalog');\n}\n\nfunction refusalOfChangedKeys(object: PdfIndirectObject, before: Map<string, string>, after: Map<string, string>, changeable: ReadonlySet<string>, type: string | undefined): string | undefined {\n for (const key of new Set([...before.keys(), ...after.keys()])) {\n if (changeable.has(key)) continue;\n if (before.get(key) !== after.get(key)) return `Object ${object.number}${type ? ` (${type})` : ''} changes ${key} after the bytes sent.`;\n }\n return undefined;\n}\n\n/** Whether a NEW object appended after the last signature belongs to a document security store update. */\nfunction isDssAddition(object: PdfIndirectObject, dictionary: Map<string, string> | undefined): boolean {\n if (!dictionary) return object.value.startsWith('[');\n const type = dictionary.get('/Type');\n if (type === '/DSS' || type === '/VRI') return true;\n // The DSS's certificate, CRL and OCSP streams carry no type; an untyped dictionary or stream with no keys of a page,\n // an annotation or a form is data the DSS references.\n return type === undefined && !dictionary.has('/Subtype') && !dictionary.has('/FT') && !dictionary.has('/Rect') && !dictionary.has('/Contents');\n}\n\n/**\n * The definition `object` replaces: the last one before it in the update's walk, else the last plain one in the bytes sent\n * (`undefined` when the original keeps it only in a compressed object stream). By object NUMBER, whatever the generation:\n * a new generation of an object number is still a replacement of what that number held, and is judged as one.\n */\nfunction previousDefinition(text: string, object: PdfIndirectObject, originalLength: number, appended: readonly PdfIndirectObject[]): PdfIndirectObject | undefined {\n let found: PdfIndirectObject | undefined;\n for (const candidate of appended) {\n if (candidate.offset >= object.offset) break;\n if (candidate.number === object.number) found = candidate;\n }\n if (found) return found;\n const pattern = new RegExp(`(?:^|[\\\\r\\\\n\\\\s])${object.number}\\\\s+\\\\d+\\\\s+obj\\\\b`, 'g');\n for (let match = pattern.exec(text); match && match.index < originalLength; match = pattern.exec(text)) {\n const offset = match.index + match[0].indexOf(String(object.number));\n try {\n const walked = walkOneObject(text, offset, originalLength);\n if (walked) found = walked;\n } catch {\n // Not readable as a plain object here; an earlier or later definition may be.\n }\n }\n return found;\n}\n\n/** One plain object at `offset` in the bytes sent, delimited the way the walk delimits appended ones. */\nfunction walkOneObject(text: string, offset: number, limit: number): PdfIndirectObject | undefined {\n const header = /^(\\d+)\\s+(\\d+)\\s+obj\\b/.exec(text.slice(offset, offset + 40));\n if (!header) return undefined;\n const tokens = new PdfTokenizer(text, offset + header[0].length, limit);\n const valueStart = tokens.position;\n if (tokens.readValue() === undefined) return undefined;\n const value = text.slice(valueStart, tokens.position).trim();\n tokens.skipWhitespace();\n const isStream = text.startsWith('stream', tokens.position);\n return { number: Number(header[1]), generation: Number(header[2]), offset, value, isStream };\n}\n\n/**\n * The indirect arrays that may grow: those a PAGE's `/Annots` or a FORM's `/Fields` names, read from the original and\n * from the appended pages, catalog and forms (never from an arbitrary appended object, which could otherwise name any\n * array). An array the original names under any other key (a page's `/Contents`, `/Kids`) is never growable, whatever\n * else names it.\n */\nfunction growableArrayNumbers(original: string, appended: readonly PdfIndirectObject[]): ReadonlySet<number> {\n const named = (text: string) => [...text.matchAll(/\\/(?:Annots|Fields)\\s+(\\d+)\\s+\\d+\\s+R/g)].map((match) => Number(match[1]));\n const growable = new Set(named(original));\n for (const object of appended) {\n const dictionary = parseDictionaryOrUndefined(object.value);\n if (dictionary && (dictionary.get('/Type') === '/Page' || dictionary.get('/Type') === '/Catalog' || (dictionary.has('/Fields') && !dictionary.has('/Type')))) {\n for (const number of named(object.value)) growable.add(number);\n }\n }\n // Every other reference of the original, under any key (a name may carry digits: `/CS0`) or as an element of an array.\n for (const match of original.matchAll(/(\\/[^\\s/<>\\[\\]()]+\\s+)?(\\d+)\\s+\\d+\\s+R\\b/g)) {\n const key = match[1]?.trim();\n if (key !== '/Annots' && key !== '/Fields') growable.delete(Number(match[2]));\n }\n // The type filter above is defence in depth: an array the original references only through /Annots or /Fields is\n // growable from the original already, and every other reference removes it here.\n return growable;\n}\n\nfunction referencesIn(value: string): string[] {\n return [...value.matchAll(/(\\d+)\\s+(\\d+)\\s+R/g)].map((match) => `${match[1]} ${match[2]} R`);\n}\n\nfunction normalizeReference(reference: string): string {\n return reference.trim().split(/\\s+/).join(' ');\n}\n\nfunction lastNumberOf(text: string, pattern: RegExp): number | undefined {\n const value = lastMatchOf(text, pattern);\n return value === undefined ? undefined : Number(value);\n}\n\nfunction lastMatchOf(text: string, pattern: RegExp): string | undefined {\n const all = allMatchesOf(text, pattern);\n return all.length > 0 ? all[all.length - 1] : undefined;\n}\n\nfunction allMatchesOf(text: string, pattern: RegExp): string[] {\n return [...text.matchAll(pattern)].map((match) => match[1]!);\n}\n\n/** A PDF date (`D:YYYYMMDDHHmmSSOHH'mm`) as an instant; `undefined` when it does not read. */\nexport function parsePdfDate(value: string | undefined): Date | undefined {\n if (!value) return undefined;\n const match = /^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(Z|[+-]\\d{2}'?\\d{2}'?)?/.exec(value);\n if (!match) return undefined;\n const [, year, month = '01', day = '01', hour = '00', minute = '00', second = '00', zone] = match;\n let offset = 'Z';\n if (zone && zone !== 'Z') {\n const digits = zone.replace(/'/g, '');\n offset = `${digits.slice(0, 3)}:${digits.slice(3, 5) || '00'}`;\n }\n const date = new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}${offset}`);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * A PDF dictionary's top-level keys and their values, each value normalized to single spaces so two definitions can be\n * compared. `undefined` when `value` is not a dictionary.\n */\nexport function parseDictionaryOrUndefined(value: string): Map<string, string> | undefined {\n if (!value.startsWith('<<')) return undefined;\n const tokens = new PdfTokenizer(value, 0, value.length);\n const entries = tokens.readDictionaryEntries();\n return entries;\n}\n\n/** A minimal PDF tokenizer: enough to delimit values (nested dictionaries, arrays, strings, references). */\nclass PdfTokenizer {\n position: number;\n\n constructor(private readonly text: string, from: number, private readonly end: number) {\n this.position = from;\n }\n\n skipWhitespace(): void {\n while (this.position < this.end) {\n const character = this.text[this.position]!;\n if (character === '%') {\n while (this.position < this.end && this.text[this.position] !== '\\n' && this.text[this.position] !== '\\r') this.position += 1;\n continue;\n }\n if (!/[\\s\\0]/.test(character)) return;\n this.position += 1;\n }\n }\n\n /** The dictionary at the cursor as key → normalized value; `undefined` when it is not one or is unterminated. */\n readDictionaryEntries(): Map<string, string> | undefined {\n this.skipWhitespace();\n if (!this.text.startsWith('<<', this.position)) return undefined;\n this.position += 2;\n const entries = new Map<string, string>();\n for (;;) {\n this.skipWhitespace();\n if (this.position >= this.end) return undefined;\n if (this.text.startsWith('>>', this.position)) {\n this.position += 2;\n return entries;\n }\n const key = this.readName();\n if (key === undefined) return undefined;\n const start = this.position;\n if (this.readValue() === undefined) return undefined;\n entries.set(key, this.text.slice(start, this.position).trim().replace(/\\s+/g, ' '));\n }\n }\n\n private readName(): string | undefined {\n this.skipWhitespace();\n if (this.text[this.position] !== '/') return undefined;\n const start = this.position;\n this.position += 1;\n while (this.position < this.end && !/[\\s\\0/<>[\\]()%{}]/.test(this.text[this.position]!)) this.position += 1;\n return this.text.slice(start, this.position);\n }\n\n /** Skip one value (an indirect reference counts as one). Answers `true`, or `undefined` when it does not delimit. */\n readValue(): true | undefined {\n this.skipWhitespace();\n if (this.position >= this.end) return undefined;\n const character = this.text[this.position]!;\n if (this.text.startsWith('<<', this.position)) {\n return this.readDictionaryEntries() === undefined ? undefined : true;\n }\n if (character === '<') {\n const close = this.text.indexOf('>', this.position);\n if (close < 0 || close >= this.end) return undefined;\n this.position = close + 1;\n return true;\n }\n if (character === '[') {\n this.position += 1;\n for (;;) {\n this.skipWhitespace();\n if (this.position >= this.end) return undefined;\n if (this.text[this.position] === ']') {\n this.position += 1;\n return true;\n }\n if (this.readValue() === undefined) return undefined;\n }\n }\n if (character === '(') return this.readLiteralString();\n if (character === '/') return this.readName() === undefined ? undefined : true;\n // A number, which may begin an indirect reference `N G R`, or a keyword.\n const number = /^[+-]?(\\d+\\.?\\d*|\\.\\d+)/.exec(this.text.slice(this.position, Math.min(this.end, this.position + 32)));\n if (number) {\n this.position += number[0].length;\n const reference = /^\\s+\\d+\\s+R(?![A-Za-z])/.exec(this.text.slice(this.position, Math.min(this.end, this.position + 32)));\n if (reference && /^\\d+$/.test(number[0])) this.position += reference[0].length;\n return true;\n }\n const keyword = /^[A-Za-z]+/.exec(this.text.slice(this.position, Math.min(this.end, this.position + 16)));\n if (keyword) {\n this.position += keyword[0].length;\n return true;\n }\n return undefined;\n }\n\n private readLiteralString(): true | undefined {\n let depth = 0;\n while (this.position < this.end) {\n const character = this.text[this.position]!;\n if (character === '\\\\') {\n this.position += 2;\n continue;\n }\n if (character === '(') depth += 1;\n if (character === ')') {\n depth -= 1;\n if (depth === 0) {\n this.position += 1;\n return true;\n }\n }\n this.position += 1;\n }\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pdf-signature-structure.backend.js","sourceRoot":"","sources":["../../../../src/compliance/electronic-signatures/pdf-signature-structure.backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8EAA8E,CAAC;AAEnH,8FAA8F;AAC9F,MAAM,CAAN,IAAY,4BAaX;AAbD,WAAY,4BAA4B;IACtC,uEAAuE;IACvE,6DAA6B,CAAA;IAC7B,kHAAkH;IAClH,6EAA6C,CAAA;IAC7C,0EAA0E;IAC1E,2GAA2E,CAAA;IAC3E,0EAA0E;IAC1E,+EAA+C,CAAA;IAC/C,0FAA0F;IAC1F,iFAAiD,CAAA;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,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACnC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,iBAAiB;QACvB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAChC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAC;YAC5C,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;gBACvB,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;gBACnB,SAAS;YACX,CAAC;YACD,IAAI,SAAS,KAAK,GAAG;gBAAE,KAAK,IAAI,CAAC,CAAC;YAClC,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;gBACtB,KAAK,IAAI,CAAC,CAAC;gBACX,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;oBAChB,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;oBACnB,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;YACD,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACrB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/**\n * # The structure of a signed PDF (#2293): what the signatures cover, and what was added after the bytes sent\n *\n * The byte-level half of validating a signed deliverable. It reads no cryptography (the signed-document validator does)\n * and answers three questions about the file the vendor returned:\n *\n * 1. **Where are the signatures, and what do they cover?** Each signature dictionary names a `/ByteRange [0 a b c]`: the\n * signed bytes are `[0, a)` and `[b, b + c)`, and the gap `[a, b)` must be exactly the `/Contents` hex string, which holds\n * the CMS signature. A range that does not start at 0, whose gap is not that hex string, or that runs past the file is\n * refused.\n * 2. **Do the signatures extend the bytes that were sent?** An electronic signature is applied as an INCREMENTAL UPDATE:\n * the vendor appends to the file it was given. So the file must start with exactly the bytes the approver approved,\n * ending at one of their `%%EOF` markers, and that prefix must hash to the request's `originalContentSha256`. A vendor\n * that rewrites the file (re-saves it, flattens it) is refused: what was signed is then not provably what was sent.\n * 3. **Is everything appended after those bytes a PERMITTED change?** Signing adds a signature dictionary, a signature\n * field and its widget, an appearance, a form, a page's `/Annots` and the catalog's `/AcroForm`; a validation update\n * adds a `/DSS`. Anything else appended (a new page, changed page content, another kind of annotation over the text, a\n * catalog swapped through the trailer) is refused, and so is anything after the LAST signature that is not a DSS\n * update: nothing signed covers it.\n *\n * ## How the appended bytes are read, and the limits that are stated\n *\n * They are WALKED strictly, the way a reader meets them: indirect objects, each closed by `endobj` and a stream's data\n * delimited by its `/Length`; cross-reference sections (tables, and cross-reference streams decoded with FlateDecode and\n * the PNG predictors); trailers; `startxref`; comments. Any other byte is refused, so no object can hide inside another's\n * bytes. Every cross-reference entry appended must point at an object the walk read, by its number and generation, so a\n * reader cannot be sent to bytes the analysis did not judge; freeing an object of the original is refused. An object\n * whose number the original or an earlier revision defined is a REDEFINITION, whatever type it now claims, and is judged\n * against what it replaces: only the catalog's `/AcroForm` and `/DSS`, a page's `/Annots`, a form's fields, an indirect\n * array a page's `/Annots` or a form's `/Fields` names (which may only grow), the trailer's `/Info` dictionary and an XMP\n * stream that was already one may change. After the last signature only NEW `/DSS` data and the catalog's `/DSS` may\n * appear. A form may not gain `/XFA` or `/NeedAppearances`, and the appended trailers keep the original's catalog and\n * encryption.\n *\n * Refused as unreadable: an appended object stream (its objects cannot be read without decompressing it, and a\n * redefinition hidden in one would pass unseen), a cross-reference entry placing an object in one, and a redefinition\n * whose previous definition the original keeps only in a compressed object stream. Admitted without inspecting what it\n * draws: a new appearance stream (`/Type /XObject /Subtype /Form`), which renders only inside its own widget's\n * rectangle and is what every vendor adds to show a signature. A \"shadow\" drawn in a signature widget is therefore not\n * detected; that is this analysis's stated residual. A vendor whose updates this refuses leaves the request open, never\n * SIGNED.\n *\n * Why the residual stays (re-examined 2026-11-12). The published shadow attacks hide content in the document BEFORE it is\n * signed and reveal it in a later update; here the bytes before the signature are the operator's own approved original,\n * and every later update is confined above, so what remains is a widget whose own appearance paints over the page inside\n * its rectangle. Telling a legitimate signature image from one that covers text needs the page RENDERED with and without\n * the widget and compared, which is a PDF renderer in the engine; a rule on the rectangle's size or place would refuse\n * honest visible signatures and still admit a small overlay over one figure. The deliverable that was approved is kept as\n * its frozen original (#2900), so a reader can compare it with the signed copy.\n * Cross-reference updates written as a HYBRID file (a classic section naming a cross-reference stream through /XRefStm)\n * are admitted since 2026-11-12; see `analyseAppendedRevisions`.\n *\n * spec-cite: ISO 32000-1:2008 §7.5.6 (incremental updates), §12.8.1 (signature dictionary: `ByteRange`, `Contents`,\n * `SubFilter`, `M`) and ETSI EN 319 142-1 §5.4 (the DSS dictionary); paraphrased from the structure they define, not\n * quoted.\n */\nimport { createHash } from 'node:crypto';\nimport { inflateSync } from 'node:zlib';\n\nimport { describeCaughtError } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\n\n/** Why a signed PDF's structure was refused. Stable codes: a REJECTED verdict carries one. */\nexport enum PdfSignatureStructureRefusal {\n /** No signature dictionary with a well-formed byte range was found. */\n NO_SIGNATURE = 'no_signature',\n /** A byte range does not start at 0, runs past the file, or its gap is not exactly the `/Contents` hex string. */\n MALFORMED_BYTE_RANGE = 'malformed_byte_range',\n /** Bytes follow the last signature and are not a permitted DSS update. */\n UNSIGNED_BYTES_AFTER_LAST_SIGNATURE = 'unsigned_bytes_after_last_signature',\n /** No prefix of the file ending at a `%%EOF` hashes to the bytes sent. */\n ORIGINAL_NOT_A_PREFIX = 'original_not_a_prefix',\n /** The appended bytes change the document beyond what signing and validation data add. */\n NOT_A_PERMITTED_CHANGE = 'not_a_permitted_change',\n /** The appended bytes cannot be analysed (an object stream, a redefinition of a compressed object, an unreadable object). */\n UNANALYSABLE_UPDATE = 'unanalysable_update',\n}\n\n/** One signature found in the file. */\nexport interface PdfSignatureField {\n /** `[0, a, b, c]` as declared. */\n readonly byteRange: readonly [number, number, number, number];\n /** The DER of the CMS signature: the `/Contents` hex decoded, its zero padding left for the CMS parser to end on. */\n readonly contents: Uint8Array;\n /** The signature dictionary's `/SubFilter` name, without the slash. */\n readonly subFilter: string | undefined;\n /** The signing time the dictionary's `/M` CLAIMS. The vendor's word, never proof. */\n readonly claimedSigningTime: Date | undefined;\n /** The offset just past the last byte this signature covers. */\n readonly coveredEnd: number;\n}\n\n/** The SubFilters a PAdES / PDF signature validated here may declare: CMS detached signatures. */\nexport const PDF_ACCEPTED_SIGNATURE_SUBFILTERS: ReadonlySet<string> = new Set(['adbe.pkcs7.detached', 'ETSI.CAdES.detached']);\n\nexport type PdfSignatureStructure =\n | {\n readonly ok: true;\n /** The signatures, in the order they cover the file (the first covers the least). */\n readonly signatures: readonly PdfSignatureField[];\n /** The length of the original bytes the file starts with. */\n readonly originalLength: number;\n }\n | { readonly ok: false; readonly refusal: PdfSignatureStructureRefusal; readonly reason: string };\n\n/** Read a signed PDF's structure against the hash of the bytes sent (see the module header). Never throws. */\nexport function analysePdfSignatureStructure(file: Uint8Array, originalContentSha256: string): PdfSignatureStructure {\n try {\n return analyse(file, originalContentSha256);\n } catch (error) {\n return { ok: false, refusal: PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, reason: `The file could not be read: ${describeCaughtError(error)}` };\n }\n}\n\nfunction refuse(refusal: PdfSignatureStructureRefusal, reason: string): PdfSignatureStructure {\n return { ok: false, refusal, reason };\n}\n\nfunction analyse(file: Uint8Array, originalContentSha256: string): PdfSignatureStructure {\n // latin1: one character per byte, so every string offset is a byte offset.\n const text = Buffer.from(file.buffer, file.byteOffset, file.byteLength).toString('latin1');\n const signatures: PdfSignatureField[] = [];\n const byteRangePattern = /\\/ByteRange\\s*\\[\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s*\\]/g;\n for (let match = byteRangePattern.exec(text); match; match = byteRangePattern.exec(text)) {\n const [start, firstLength, secondStart, secondLength] = match.slice(1, 5).map((value) => Number(value)) as [number, number, number, number];\n if (start !== 0 || firstLength <= 0 || secondStart <= firstLength || secondStart + secondLength > file.byteLength) {\n return refuse(PdfSignatureStructureRefusal.MALFORMED_BYTE_RANGE, `A signature's byte range [${start} ${firstLength} ${secondStart} ${secondLength}] does not cover the file from its start within its length.`);\n }\n const gap = text.slice(firstLength, secondStart);\n if (!/^<[0-9A-Fa-f\\s]*>$/.test(gap)) {\n return refuse(PdfSignatureStructureRefusal.MALFORMED_BYTE_RANGE, `A signature's byte range leaves out bytes ${firstLength}–${secondStart} that are not its /Contents hex string.`);\n }\n // The dictionary the byte range sits in must be the one whose /Contents is the gap.\n const objectStart = text.lastIndexOf(' obj', match.index);\n const objectEnd = text.indexOf('endobj', match.index);\n if (objectStart < 0 || objectEnd < 0 || firstLength < objectStart || secondStart > objectEnd) {\n return refuse(PdfSignatureStructureRefusal.MALFORMED_BYTE_RANGE, 'A signature\\'s byte range does not leave out the /Contents of its own signature dictionary.');\n }\n const dictionary = text.slice(objectStart, firstLength) + text.slice(secondStart, objectEnd);\n const hex = gap.slice(1, -1).replace(/\\s+/g, '');\n signatures.push({\n byteRange: [start, firstLength, secondStart, secondLength],\n contents: new Uint8Array(Buffer.from(hex.length % 2 === 0 ? hex : `${hex}0`, 'hex')),\n subFilter: /\\/SubFilter\\s*\\/([^\\s/<>[\\]()]+)/.exec(dictionary)?.[1],\n claimedSigningTime: parsePdfDate(/\\/M\\s*\\((D:[^)]*)\\)/.exec(dictionary)?.[1]),\n coveredEnd: secondStart + secondLength,\n });\n }\n if (signatures.length === 0) return refuse(PdfSignatureStructureRefusal.NO_SIGNATURE, 'The file carries no signature.');\n signatures.sort((first, second) => first.coveredEnd - second.coveredEnd);\n\n // The bytes sent, as a prefix ending at one of their %%EOF markers.\n const firstSignatureStart = Math.min(...signatures.map((signature) => signature.byteRange[1]));\n const originalLength = originalPrefixLength(file, text, firstSignatureStart, originalContentSha256);\n if (originalLength === undefined) {\n return refuse(PdfSignatureStructureRefusal.ORIGINAL_NOT_A_PREFIX, 'The signed file does not start with the bytes that were sent: the vendor did not sign them as an incremental update.');\n }\n\n const lastCovered = signatures[signatures.length - 1]!.coveredEnd;\n const changes = analyseAppendedRevisions(text, originalLength, signatures, lastCovered);\n if (changes) return changes;\n return { ok: true, signatures, originalLength };\n}\n\n/**\n * The length of the prefix that hashes to the bytes sent: an offset just past a `%%EOF` marker (and its end-of-line, when\n * the original ended with one), before the first signature.\n */\nfunction originalPrefixLength(file: Uint8Array, text: string, before: number, sha256: string): number | undefined {\n for (let index = text.indexOf('%%EOF'); index >= 0 && index < before; index = text.indexOf('%%EOF', index + 1)) {\n const end = index + 5;\n const candidates = [end];\n if (text[end] === '\\r' && text[end + 1] === '\\n') candidates.push(end + 2);\n else if (text[end] === '\\n' || text[end] === '\\r') candidates.push(end + 1);\n for (const length of candidates) {\n if (length > before) continue;\n if (createHash('sha256').update(file.subarray(0, length)).digest('hex') === sha256) return length;\n }\n }\n return undefined;\n}\n\n/** One indirect object as written in the bytes. */\ninterface PdfIndirectObject {\n readonly number: number;\n readonly generation: number;\n /** The offset of the object's number: where a cross-reference entry must point. */\n readonly offset: number;\n /** The object's value up to `stream` or `endobj`: a dictionary, an array, or a simple value. */\n readonly value: string;\n readonly isStream: boolean;\n /** A stream's data, as written (undecoded). */\n readonly streamData?: string;\n}\n\n/** Where a cross-reference entry says an object is (ISO 32000-1 §7.5.4, §7.5.8.3). */\nenum PdfCrossReferenceEntryKind {\n /** In use, its definition at the entry's byte offset. */\n IN_USE = 'in_use',\n /** Free: the object is deleted. */\n FREE = 'free',\n /** Stored inside an object stream (refused: the analysis does not read object streams). */\n COMPRESSED = 'compressed',\n}\n\n/** A cross-reference entry an appended section declares. */\ninterface PdfCrossReferenceEntry {\n readonly number: number;\n readonly generation: number;\n readonly kind: PdfCrossReferenceEntryKind;\n readonly offset: number;\n}\n\n/** What the strict walk of the appended bytes found. */\ninterface PdfAppendedRegion {\n readonly objects: readonly PdfIndirectObject[];\n readonly crossReferences: readonly PdfCrossReferenceEntry[];\n /** Every trailer dictionary: a classic `trailer`, or a cross-reference stream's own dictionary. */\n readonly trailers: ReadonlyArray<{ readonly entries: Map<string, string>; readonly sectionOffset: number }>;\n /** The offset of every cross-reference section walked: an `xref` keyword, or a cross-reference stream's object. */\n readonly sectionOffsets: readonly number[];\n /** Every `startxref` value, in order. */\n readonly startxrefValues: readonly number[];\n}\n\n/** Thrown inside the walk; turned into an UNANALYSABLE refusal. */\nclass UnanalysableUpdate extends Error {}\n\n/**\n * Walk the bytes after the original STRICTLY, the way a reader meets them: indirect objects (each closed by `endobj`,\n * a stream's data delimited by its `/Length`), cross-reference sections, trailers, `startxref` and comments. Anything else\n * is refused, so no object can hide inside another's bytes (an object left without `endobj`, data between objects).\n */\nfunction walkAppendedRegion(text: string, from: number): PdfAppendedRegion {\n const objects: PdfIndirectObject[] = [];\n const crossReferences: PdfCrossReferenceEntry[] = [];\n const trailers: Array<{ entries: Map<string, string>; sectionOffset: number }> = [];\n const sectionOffsets: number[] = [];\n const startxrefValues: number[] = [];\n let lastTableOffset = -1;\n const tokens = new PdfTokenizer(text, from, text.length);\n for (;;) {\n tokens.skipWhitespace();\n if (tokens.position >= text.length) break;\n const at = tokens.position;\n const header = /^(\\d+)\\s+(\\d+)\\s+obj\\b/.exec(text.slice(at, at + 40));\n if (header) {\n tokens.position = at + header[0].length;\n const valueStart = tokens.position;\n if (tokens.readValue() === undefined) throw new UnanalysableUpdate(`object ${header[1]} at ${at} has no readable value`);\n const value = text.slice(valueStart, tokens.position).trim();\n tokens.skipWhitespace();\n let isStream = false;\n let streamData: string | undefined;\n if (text.startsWith('stream', tokens.position)) {\n isStream = true;\n let dataStart = tokens.position + 'stream'.length;\n if (text[dataStart] === '\\r' && text[dataStart + 1] === '\\n') dataStart += 2;\n else if (text[dataStart] === '\\n') dataStart += 1;\n else throw new UnanalysableUpdate(`object ${header[1]}: 'stream' is not followed by an end of line`);\n // Stated residual: a stream's data is not searched for text shaped like an object or a section. While a reader\n // follows the cross-reference sections (every one checked below) such text is inert; a reader that rebuilds a\n // damaged table by scanning the file could pick it up. Refusing on a pattern would refuse genuine DER data by chance.\n const length = streamLengthOf(text, parseDictionaryOrUndefined(value), from);\n streamData = text.slice(dataStart, dataStart + length);\n tokens.position = dataStart + length;\n tokens.skipWhitespace();\n if (!text.startsWith('endstream', tokens.position)) throw new UnanalysableUpdate(`object ${header[1]}: its stream does not end where its /Length says`);\n tokens.position += 'endstream'.length;\n tokens.skipWhitespace();\n }\n if (!text.startsWith('endobj', tokens.position)) throw new UnanalysableUpdate(`object ${header[1]} at ${at} is not closed by endobj`);\n tokens.position += 'endobj'.length;\n const object: PdfIndirectObject = { number: Number(header[1]), generation: Number(header[2]), offset: at, value, isStream, ...(streamData !== undefined ? { streamData } : {}) };\n objects.push(object);\n const dictionary = parseDictionaryOrUndefined(value);\n if (dictionary?.get('/Type') === '/XRef') {\n if (!isStream || streamData === undefined) throw new UnanalysableUpdate(`object ${header[1]} is a cross-reference stream without data`);\n crossReferences.push(...crossReferenceStreamEntries(dictionary, streamData));\n trailers.push({ entries: dictionary, sectionOffset: at });\n sectionOffsets.push(at);\n }\n continue;\n }\n if (text.startsWith('xref', at)) {\n tokens.position = at + 'xref'.length;\n crossReferences.push(...readCrossReferenceTable(text, tokens));\n sectionOffsets.push(at);\n lastTableOffset = at;\n continue;\n }\n if (text.startsWith('trailer', at)) {\n tokens.position = at + 'trailer'.length;\n const entries = tokens.readDictionaryEntries();\n if (!entries) throw new UnanalysableUpdate(`the trailer at ${at} is not a dictionary`);\n if (lastTableOffset < 0) throw new UnanalysableUpdate(`the trailer at ${at} follows no cross-reference table`);\n trailers.push({ entries, sectionOffset: lastTableOffset });\n lastTableOffset = -1;\n continue;\n }\n if (text.startsWith('startxref', at)) {\n tokens.position = at + 'startxref'.length;\n tokens.skipWhitespace();\n const number = /^\\d+/.exec(text.slice(tokens.position, tokens.position + 20));\n if (!number) throw new UnanalysableUpdate(`startxref at ${at} names no offset`);\n startxrefValues.push(Number(number[0]));\n tokens.position += number[0].length;\n continue;\n }\n throw new UnanalysableUpdate(`bytes at ${at} are neither an object, a cross-reference section nor a trailer`);\n }\n return { objects, crossReferences, trailers, sectionOffsets, startxrefValues };\n}\n\n/** A stream's `/Length`: direct, or an indirect integer object defined in the appended bytes. */\nfunction streamLengthOf(text: string, dictionary: Map<string, string> | undefined, from: number): number {\n const raw = dictionary?.get('/Length');\n if (raw === undefined) throw new UnanalysableUpdate('a stream declares no /Length');\n if (/^\\d+$/.test(raw)) return Number(raw);\n const reference = /^(\\d+) (\\d+) R$/.exec(raw);\n if (!reference) throw new UnanalysableUpdate(`a stream's /Length \"${raw}\" cannot be read`);\n const definition = new RegExp(`(?:^|[\\\\r\\\\n\\\\s])${reference[1]}\\\\s+${reference[2]}\\\\s+obj\\\\s+(\\\\d+)\\\\s+endobj`).exec(text.slice(from));\n if (!definition) throw new UnanalysableUpdate(`a stream's /Length ${raw} is not an integer object of the update`);\n return Number(definition[1]);\n}\n\n/** A classic cross-reference table: subsections of `start count`, then 20-byte entries, up to `trailer`. */\nfunction readCrossReferenceTable(text: string, tokens: PdfTokenizer): PdfCrossReferenceEntry[] {\n const entries: PdfCrossReferenceEntry[] = [];\n for (;;) {\n tokens.skipWhitespace();\n if (text.startsWith('trailer', tokens.position)) return entries;\n const subsection = /^(\\d+)\\s+(\\d+)[ \\t]*\\r?\\n/.exec(text.slice(tokens.position, tokens.position + 40));\n if (!subsection) throw new UnanalysableUpdate(`a cross-reference subsection at ${tokens.position} cannot be read`);\n tokens.position += subsection[0].length;\n const start = Number(subsection[1]);\n const count = Number(subsection[2]);\n for (let index = 0; index < count; index += 1) {\n const entry = /^(\\d{10}) (\\d{5}) ([nf])\\s{0,2}/.exec(text.slice(tokens.position, tokens.position + 22));\n if (!entry) throw new UnanalysableUpdate(`cross-reference entry ${start + index} cannot be read`);\n tokens.position += entry[0].length;\n entries.push({ number: start + index, generation: Number(entry[2]), kind: entry[3] === 'n' ? PdfCrossReferenceEntryKind.IN_USE : PdfCrossReferenceEntryKind.FREE, offset: Number(entry[1]) });\n }\n }\n}\n\n/** The entries of a cross-reference stream (FlateDecode with or without a PNG predictor, or no filter). */\nfunction crossReferenceStreamEntries(dictionary: Map<string, string>, data: string): PdfCrossReferenceEntry[] {\n const widths = (/^\\[\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s*\\]$/.exec(dictionary.get('/W') ?? '') ?? []).slice(1).map(Number);\n if (widths.length !== 3) throw new UnanalysableUpdate('a cross-reference stream has no readable /W');\n const filter = dictionary.get('/Filter');\n let bytes: Buffer = Buffer.from(data, 'latin1');\n if (filter === '/FlateDecode' || filter === '[/FlateDecode]' || filter === '[ /FlateDecode ]') bytes = inflateSync(bytes);\n else if (filter !== undefined) throw new UnanalysableUpdate(`a cross-reference stream uses ${filter}`);\n const rowLength = widths[0]! + widths[1]! + widths[2]!;\n const parameters = parseDictionaryOrUndefined(dictionary.get('/DecodeParms') ?? '');\n const predictor = Number(parameters?.get('/Predictor') ?? 1);\n if (predictor >= 10) bytes = undoPngPredictor(bytes, Number(parameters?.get('/Columns') ?? rowLength));\n else if (predictor !== 1) throw new UnanalysableUpdate(`a cross-reference stream uses predictor ${predictor}`);\n const size = Number(dictionary.get('/Size'));\n const index = (/^\\[([\\d\\s]+)\\]$/.exec(dictionary.get('/Index') ?? '')?.[1]?.trim().split(/\\s+/).map(Number)) ?? [0, size];\n const entries: PdfCrossReferenceEntry[] = [];\n let row = 0;\n for (let pair = 0; pair + 1 < index.length; pair += 2) {\n for (let number = index[pair]!; number < index[pair]! + index[pair + 1]!; number += 1, row += 1) {\n const at = row * rowLength;\n if (at + rowLength > bytes.length) throw new UnanalysableUpdate('a cross-reference stream is shorter than its /Index');\n const field = (start: number, width: number, fallback: number) => {\n if (width === 0) return fallback;\n let value = 0;\n for (let offset = 0; offset < width; offset += 1) value = value * 256 + bytes[at + start + offset]!;\n return value;\n };\n const type = field(0, widths[0]!, 1);\n const second = field(widths[0]!, widths[1]!, 0);\n const third = field(widths[0]! + widths[1]!, widths[2]!, 0);\n const kind = type === 1 ? PdfCrossReferenceEntryKind.IN_USE : type === 0 ? PdfCrossReferenceEntryKind.FREE : PdfCrossReferenceEntryKind.COMPRESSED;\n entries.push({ number, generation: type === 1 ? third : 0, kind, offset: second });\n }\n }\n return entries;\n}\n\n/** Undo the PNG predictors of a FlateDecode stream (ISO 32000-1 §7.4.4.4): one filter-type byte per row. */\nfunction undoPngPredictor(bytes: Buffer, columns: number): Buffer {\n const rows: Buffer[] = [];\n let previous = Buffer.alloc(columns);\n for (let at = 0; at + columns < bytes.length + 1 && at < bytes.length; at += columns + 1) {\n const type = bytes[at]!;\n const row = Buffer.from(bytes.subarray(at + 1, at + 1 + columns));\n for (let column = 0; column < columns; column += 1) {\n const left = column > 0 ? row[column - 1]! : 0;\n const up = previous[column]!;\n const upLeft = column > 0 ? previous[column - 1]! : 0;\n if (type === 1) row[column] = (row[column]! + left) & 0xff;\n else if (type === 2) row[column] = (row[column]! + up) & 0xff;\n else if (type === 3) row[column] = (row[column]! + Math.floor((left + up) / 2)) & 0xff;\n else if (type === 4) {\n const estimate = left + up - upLeft;\n const [pa, pb, pc] = [Math.abs(estimate - left), Math.abs(estimate - up), Math.abs(estimate - upLeft)];\n row[column] = (row[column]! + (pa <= pb && pa <= pc ? left : pb <= pc ? up : upLeft)) & 0xff;\n } else if (type !== 0) throw new UnanalysableUpdate(`a cross-reference stream row uses PNG filter ${type}`);\n }\n rows.push(row);\n previous = row;\n }\n return Buffer.concat(rows);\n}\n\n/**\n * The appended revisions, checked for permitted changes (module header, question 3). Answers a refusal, or `undefined`\n * when every appended object is a signing or validation addition and nothing unsigned follows the last signature but a\n * DSS update.\n */\nfunction analyseAppendedRevisions(text: string, originalLength: number, signatures: readonly PdfSignatureField[], lastCovered: number): PdfSignatureStructure | undefined {\n const original = text.slice(0, originalLength);\n const originalSize = lastNumberOf(original, /\\/Size\\s+(\\d+)/g);\n const originalRoot = lastMatchOf(original, /\\/Root\\s+(\\d+\\s+\\d+\\s+R)/g);\n const originalEncrypt = lastMatchOf(original, /\\/Encrypt\\s+(\\d+\\s+\\d+\\s+R)/g);\n if (originalSize === undefined || originalRoot === undefined) {\n return refuse(PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, 'The bytes sent declare no trailer /Size or /Root, so what was appended to them cannot be told apart.');\n }\n void signatures;\n let region: PdfAppendedRegion;\n try {\n region = walkAppendedRegion(text, originalLength);\n } catch (error) {\n return refuse(PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, `The bytes after the original cannot be read: ${describeCaughtError(error)}`);\n }\n\n // The trailers appended keep the catalog and the encryption the bytes sent named.\n // A reader finds the cross-reference sections through `startxref`, `/Prev` and `/XRefStm`: each must name a section\n // the walk READ (or, for the chain into the original, the original's own), so no section hidden in a stream's data, or\n // anywhere else the walk did not judge, can be the one a reader follows.\n // Into the original, a /Prev names the original's LAST section only: one naming an earlier section would make a reader\n // skip the original's own later updates, so render a version of the document other than the one sent.\n const walkedSections = new Set(region.sectionOffsets);\n const originalStartxrefs = allMatchesOf(original, /startxref\\s+(\\d+)/g).map(Number);\n const originalLastSection = originalStartxrefs[originalStartxrefs.length - 1];\n const originalCrossReferenceStreams = new Set(allMatchesOf(original, /\\/XRefStm\\s+(\\d+)/g).map(Number));\n if (region.startxrefValues.some((value) => !walkedSections.has(value))) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'An appended startxref names a cross-reference section the analysis did not read.');\n }\n const lastSection = region.sectionOffsets[region.sectionOffsets.length - 1];\n const lastStartxref = region.startxrefValues[region.startxrefValues.length - 1];\n if (region.sectionOffsets.length > 0 && lastStartxref !== lastSection) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'The file\\'s last startxref does not name its last cross-reference section.');\n }\n // Each appended section chains to the one immediately before it (the first to the original's last): a /Prev that skips\n // a revision would show a reader the document without, say, the signature that revision added.\n //\n // A HYBRID update is the one exception. Its cross-reference stream is not a revision of its own: the classic section of\n // the same update names it through /XRefStm, and a reader reaches it only from there, searching it before that section's\n // /Prev. ISO 32000-1 says a cross-reference stream's /Prev is \"not meaningful in hybrid-reference files\".\n // spec-cite: ISO 32000-1:2008 §7.5.8.2 Table 17 (the Prev row), and §7.5.8.4 (the XRefStm search order).\n // So a cross-reference stream that the VERY NEXT appended section names by /XRefStm is admitted without a /Prev of its\n // own (or with one equal to that section's, which changes nothing), and does not advance the chain. Its entries are\n // judged with every other appended entry below. Until 2026-11-12 every hybrid update was refused.\n const hybridCompanions = new Set<number>();\n let expectedPrev = originalLastSection;\n for (const [index, { entries, sectionOffset }] of region.trailers.entries()) {\n const namingSection = region.trailers[index + 1];\n const hybridCompanion = entries.get('/Type') === '/XRef'\n && namingSection?.entries.get('/XRefStm') !== undefined\n && Number(namingSection.entries.get('/XRefStm')) === sectionOffset\n && (entries.get('/Prev') === undefined || Number(entries.get('/Prev')) === expectedPrev);\n if (hybridCompanion) {\n hybridCompanions.add(sectionOffset);\n continue;\n }\n // An incremental update chains to what it updates: a section without /Prev would hide the whole original from a reader.\n if (entries.get('/Prev') === undefined || Number(entries.get('/Prev')) !== expectedPrev) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'An appended cross-reference section does not chain to the revision it updates.');\n }\n expectedPrev = sectionOffset;\n // A hybrid file's /XRefStm names a cross-reference stream: one the walk read, before this section, or the original's.\n const xrefStream = entries.get('/XRefStm');\n if (xrefStream !== undefined) {\n const offset = Number(xrefStream);\n const admitted = (walkedSections.has(offset) && offset < sectionOffset) || originalCrossReferenceStreams.has(offset);\n if (!/^\\d+$/.test(xrefStream) || !admitted) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'An appended trailer\\'s /XRefStm names a cross-reference stream the analysis did not read.');\n }\n }\n }\n for (const { entries: trailer, sectionOffset } of region.trailers) {\n const root = trailer.get('/Root');\n // A hybrid companion is read only through the section naming it, whose /Root a reader takes; it may name none.\n const rootOptional = hybridCompanions.has(sectionOffset);\n if ((root === undefined && !rootOptional) || (root !== undefined && normalizeReference(root) !== normalizeReference(originalRoot))) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'An appended trailer names another catalog than the bytes sent.');\n }\n const encrypt = trailer.get('/Encrypt');\n if ((encrypt ?? '') !== (originalEncrypt ?? '') && !(encrypt && originalEncrypt && normalizeReference(encrypt) === normalizeReference(originalEncrypt))) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, 'An appended trailer changes the document\\'s encryption.');\n }\n }\n\n // Every cross-reference entry appended points at an object this walk read, by its number and generation: a reader\n // finds objects through these entries, so none may point into another object's bytes or back into the bytes sent.\n const objectAt = new Map(region.objects.map((object) => [object.offset, object]));\n for (const entry of region.crossReferences) {\n if (entry.kind === PdfCrossReferenceEntryKind.COMPRESSED) {\n return refuse(PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, `Object ${entry.number} is placed in an object stream by an appended cross-reference stream.`);\n }\n if (entry.kind === PdfCrossReferenceEntryKind.FREE) {\n if (entry.number !== 0 && (entry.number < originalSize || region.objects.some((object) => object.number === entry.number))) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, `An appended cross-reference section frees object ${entry.number}.`);\n }\n continue;\n }\n const target = objectAt.get(entry.offset);\n if (!target || target.number !== entry.number || target.generation !== entry.generation) {\n return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, `An appended cross-reference entry for object ${entry.number} does not point at that object's definition in the update.`);\n }\n }\n\n const infoReference = lastMatchOf(original, /\\/Info\\s+(\\d+\\s+\\d+\\s+R)/g);\n const rootNumber = Number(originalRoot.split(/\\s+/)[0]);\n const infoNumber = infoReference ? Number(infoReference.split(/\\s+/)[0]) : undefined;\n const growableArrays = growableArrayNumbers(original, region.objects);\n\n for (const object of region.objects) {\n const dictionary = parseDictionaryOrUndefined(object.value);\n const type = dictionary?.get('/Type');\n const afterLastSignature = object.offset >= lastCovered;\n const previous = previousDefinition(text, object, originalLength, region.objects);\n const existedBefore = object.number < originalSize || previous !== undefined;\n\n if (existedBefore) {\n // A redefinition, whatever it calls itself: judged against what it replaces.\n if (!previous) {\n return refuse(PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, `Object ${object.number} is redefined, and its previous definition is not a plain object the analysis can compare.`);\n }\n if (afterLastSignature) {\n const refusal = object.number === rootNumber ? refusalOfCatalogChange(object, dictionary, previous, new Set(['/DSS'])) : `Object ${object.number} is changed after the last signature.`;\n if (refusal) return refuse(PdfSignatureStructureRefusal.UNSIGNED_BYTES_AFTER_LAST_SIGNATURE, refusal);\n continue;\n }\n const refusal = refusalOfRedefinition(object, dictionary, previous, { isCatalog: object.number === rootNumber, isInfo: object.number === infoNumber, growableArrays });\n if (refusal) return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, refusal);\n continue;\n }\n\n // A new object.\n if (type === '/ObjStm') {\n return refuse(PdfSignatureStructureRefusal.UNANALYSABLE_UPDATE, `Object ${object.number} is an object stream appended after the bytes sent; the objects in it cannot be checked.`);\n }\n if (type === '/XRef') continue;\n if (afterLastSignature) {\n if (!isDssAddition(object, dictionary)) {\n return refuse(PdfSignatureStructureRefusal.UNSIGNED_BYTES_AFTER_LAST_SIGNATURE, `Object ${object.number}, after the last signature, is not a document security store update.`);\n }\n continue;\n }\n const refusal = refusalOfNewObject(object, dictionary);\n if (refusal) return refuse(PdfSignatureStructureRefusal.NOT_A_PERMITTED_CHANGE, refusal);\n }\n return undefined;\n}\n\n/** The kinds of object signing and validation data add. Anything else new (a page, a free-text annotation) is refused. */\nconst NEW_OBJECT_TYPES: ReadonlySet<string> = new Set(['/Sig', '/DSS', '/VRI', '/XObject', '/Font', '/FontDescriptor', '/Annot', '/Encoding']);\nconst ANNOTATION_SUBTYPES_ADMITTED: ReadonlySet<string> = new Set(['/Widget']);\n/** Form keys that would change what the document shows or does when opened (XFA forms, regenerated appearances). */\nconst FORBIDDEN_FORM_KEYS: readonly string[] = ['/XFA', '/NeedAppearances'];\n\nfunction refusalOfNewObject(object: PdfIndirectObject, dictionary: Map<string, string> | undefined): string | undefined {\n if (!dictionary) return undefined; // An array or a simple value: reachable only through a key the checks below admit.\n const type = dictionary.get('/Type');\n const subtype = dictionary.get('/Subtype');\n if (type !== undefined && !NEW_OBJECT_TYPES.has(type)) return `Object ${object.number} adds a ${type} after the bytes sent.`;\n if (type === '/XObject' && subtype !== '/Form') return `Object ${object.number} adds an image or other XObject, not an appearance.`;\n if (type === '/Annot' || (subtype !== undefined && type === undefined && dictionary.has('/Rect'))) {\n if (!subtype || !ANNOTATION_SUBTYPES_ADMITTED.has(subtype)) return `Object ${object.number} adds a ${subtype ?? 'untyped'} annotation, which can cover the document's content.`;\n }\n if (subtype === '/Widget' && dictionary.get('/FT') !== '/Sig' && !dictionary.has('/Parent')) {\n return `Object ${object.number} adds a widget that is not a signature field.`;\n }\n // A form field that is not a signature field could change what the document shows when filled.\n if (dictionary.has('/FT') && dictionary.get('/FT') !== '/Sig') return `Object ${object.number} adds a ${dictionary.get('/FT')} form field.`;\n const forbidden = FORBIDDEN_FORM_KEYS.find((key) => dictionary.has(key));\n if (forbidden) return `Object ${object.number} adds a form carrying ${forbidden}.`;\n return undefined;\n}\n\n/** The keys a redefinition may change, per kind of object; every other key must keep its value. */\nconst CATALOG_CHANGEABLE_KEYS: ReadonlySet<string> = new Set(['/AcroForm', '/DSS']);\nconst PAGE_CHANGEABLE_KEYS: ReadonlySet<string> = new Set(['/Annots']);\nconst FORM_CHANGEABLE_KEYS: ReadonlySet<string> = new Set(['/Fields', '/SigFlags', '/DR', '/DA']);\n\nfunction refusalOfRedefinition(\n object: PdfIndirectObject,\n dictionary: Map<string, string> | undefined,\n previous: PdfIndirectObject,\n kind: { readonly isCatalog: boolean; readonly isInfo: boolean; readonly growableArrays: ReadonlySet<number> },\n): string | undefined {\n const previousDictionary = parseDictionaryOrUndefined(previous.value);\n // Document metadata, invisible on the page: the trailer's /Info dictionary, and an XMP stream that WAS one.\n if (kind.isInfo && !object.isStream && !previous.isStream && dictionary && previousDictionary) return undefined;\n if (object.isStream && previous.isStream && dictionary?.get('/Type') === '/Metadata' && previousDictionary?.get('/Type') === '/Metadata') return undefined;\n if (object.isStream || previous.isStream) return `Object ${object.number}, a stream, is replaced after the bytes sent.`;\n if (kind.isCatalog) return refusalOfCatalogChange(object, dictionary, previous, CATALOG_CHANGEABLE_KEYS);\n if (!dictionary) {\n // An indirect array may only grow, and only one a page's /Annots or a form's /Fields names.\n const before = referencesIn(previous.value);\n const after = referencesIn(object.value);\n if (!kind.growableArrays.has(object.number) || !previous.value.startsWith('[') || !object.value.startsWith('[') || before.some((reference) => !after.includes(reference))) {\n return `Object ${object.number} is replaced by a value that drops or changes what it held.`;\n }\n return undefined;\n }\n if (!previousDictionary) return `Object ${object.number} changes kind after the bytes sent.`;\n const type = previousDictionary.get('/Type');\n const changeable = type === '/Page' ? PAGE_CHANGEABLE_KEYS : previousDictionary.has('/Fields') ? FORM_CHANGEABLE_KEYS : undefined;\n if (!changeable) return `Object ${object.number}${type ? ` (${type})` : ''} is changed after the bytes sent.`;\n if (changeable === FORM_CHANGEABLE_KEYS) {\n const forbidden = FORBIDDEN_FORM_KEYS.find((key) => dictionary.has(key));\n if (forbidden) return `Object ${object.number}, the form, gains ${forbidden}.`;\n }\n return refusalOfChangedKeys(object, previousDictionary, dictionary, changeable, type);\n}\n\n/** A catalog redefinition: only `changeable` keys may differ, and an inline form may not gain XFA or regenerated appearances. */\nfunction refusalOfCatalogChange(object: PdfIndirectObject, dictionary: Map<string, string> | undefined, previous: PdfIndirectObject, changeable: ReadonlySet<string>): string | undefined {\n const previousDictionary = parseDictionaryOrUndefined(previous.value);\n if (object.isStream || !dictionary || !previousDictionary) return `Object ${object.number}, the catalog, changes kind.`;\n const form = dictionary.get('/AcroForm');\n const inlineForm = form?.startsWith('<<') ? parseDictionaryOrUndefined(form) : undefined;\n const forbidden = inlineForm ? FORBIDDEN_FORM_KEYS.find((key) => inlineForm.has(key)) : undefined;\n if (forbidden) return `The catalog's form gains ${forbidden}.`;\n return refusalOfChangedKeys(object, previousDictionary, dictionary, changeable, '/Catalog');\n}\n\nfunction refusalOfChangedKeys(object: PdfIndirectObject, before: Map<string, string>, after: Map<string, string>, changeable: ReadonlySet<string>, type: string | undefined): string | undefined {\n for (const key of new Set([...before.keys(), ...after.keys()])) {\n if (changeable.has(key)) continue;\n if (before.get(key) !== after.get(key)) return `Object ${object.number}${type ? ` (${type})` : ''} changes ${key} after the bytes sent.`;\n }\n return undefined;\n}\n\n/** Whether a NEW object appended after the last signature belongs to a document security store update. */\nfunction isDssAddition(object: PdfIndirectObject, dictionary: Map<string, string> | undefined): boolean {\n if (!dictionary) return object.value.startsWith('[');\n const type = dictionary.get('/Type');\n if (type === '/DSS' || type === '/VRI') return true;\n // The DSS's certificate, CRL and OCSP streams carry no type; an untyped dictionary or stream with no keys of a page,\n // an annotation or a form is data the DSS references.\n return type === undefined && !dictionary.has('/Subtype') && !dictionary.has('/FT') && !dictionary.has('/Rect') && !dictionary.has('/Contents');\n}\n\n/**\n * The definition `object` replaces: the last one before it in the update's walk, else the last plain one in the bytes sent\n * (`undefined` when the original keeps it only in a compressed object stream). By object NUMBER, whatever the generation:\n * a new generation of an object number is still a replacement of what that number held, and is judged as one.\n */\nfunction previousDefinition(text: string, object: PdfIndirectObject, originalLength: number, appended: readonly PdfIndirectObject[]): PdfIndirectObject | undefined {\n let found: PdfIndirectObject | undefined;\n for (const candidate of appended) {\n if (candidate.offset >= object.offset) break;\n if (candidate.number === object.number) found = candidate;\n }\n if (found) return found;\n const pattern = new RegExp(`(?:^|[\\\\r\\\\n\\\\s])${object.number}\\\\s+\\\\d+\\\\s+obj\\\\b`, 'g');\n for (let match = pattern.exec(text); match && match.index < originalLength; match = pattern.exec(text)) {\n const offset = match.index + match[0].indexOf(String(object.number));\n try {\n const walked = walkOneObject(text, offset, originalLength);\n if (walked) found = walked;\n } catch {\n // Not readable as a plain object here; an earlier or later definition may be.\n }\n }\n return found;\n}\n\n/** One plain object at `offset` in the bytes sent, delimited the way the walk delimits appended ones. */\nfunction walkOneObject(text: string, offset: number, limit: number): PdfIndirectObject | undefined {\n const header = /^(\\d+)\\s+(\\d+)\\s+obj\\b/.exec(text.slice(offset, offset + 40));\n if (!header) return undefined;\n const tokens = new PdfTokenizer(text, offset + header[0].length, limit);\n const valueStart = tokens.position;\n if (tokens.readValue() === undefined) return undefined;\n const value = text.slice(valueStart, tokens.position).trim();\n tokens.skipWhitespace();\n const isStream = text.startsWith('stream', tokens.position);\n return { number: Number(header[1]), generation: Number(header[2]), offset, value, isStream };\n}\n\n/**\n * The indirect arrays that may grow: those a PAGE's `/Annots` or a FORM's `/Fields` names, read from the original and\n * from the appended pages, catalog and forms (never from an arbitrary appended object, which could otherwise name any\n * array). An array the original names under any other key (a page's `/Contents`, `/Kids`) is never growable, whatever\n * else names it.\n */\nfunction growableArrayNumbers(original: string, appended: readonly PdfIndirectObject[]): ReadonlySet<number> {\n const named = (text: string) => [...text.matchAll(/\\/(?:Annots|Fields)\\s+(\\d+)\\s+\\d+\\s+R/g)].map((match) => Number(match[1]));\n const growable = new Set(named(original));\n for (const object of appended) {\n const dictionary = parseDictionaryOrUndefined(object.value);\n if (dictionary && (dictionary.get('/Type') === '/Page' || dictionary.get('/Type') === '/Catalog' || (dictionary.has('/Fields') && !dictionary.has('/Type')))) {\n for (const number of named(object.value)) growable.add(number);\n }\n }\n // Every other reference of the original, under any key (a name may carry digits: `/CS0`) or as an element of an array.\n for (const match of original.matchAll(/(\\/[^\\s/<>\\[\\]()]+\\s+)?(\\d+)\\s+\\d+\\s+R\\b/g)) {\n const key = match[1]?.trim();\n if (key !== '/Annots' && key !== '/Fields') growable.delete(Number(match[2]));\n }\n // The type filter above is defence in depth: an array the original references only through /Annots or /Fields is\n // growable from the original already, and every other reference removes it here.\n return growable;\n}\n\nfunction referencesIn(value: string): string[] {\n return [...value.matchAll(/(\\d+)\\s+(\\d+)\\s+R/g)].map((match) => `${match[1]} ${match[2]} R`);\n}\n\nfunction normalizeReference(reference: string): string {\n return reference.trim().split(/\\s+/).join(' ');\n}\n\nfunction lastNumberOf(text: string, pattern: RegExp): number | undefined {\n const value = lastMatchOf(text, pattern);\n return value === undefined ? undefined : Number(value);\n}\n\nfunction lastMatchOf(text: string, pattern: RegExp): string | undefined {\n const all = allMatchesOf(text, pattern);\n return all.length > 0 ? all[all.length - 1] : undefined;\n}\n\nfunction allMatchesOf(text: string, pattern: RegExp): string[] {\n return [...text.matchAll(pattern)].map((match) => match[1]!);\n}\n\n/** A PDF date (`D:YYYYMMDDHHmmSSOHH'mm`) as an instant; `undefined` when it does not read. */\nexport function parsePdfDate(value: string | undefined): Date | undefined {\n if (!value) return undefined;\n const match = /^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(Z|[+-]\\d{2}'?\\d{2}'?)?/.exec(value);\n if (!match) return undefined;\n const [, year, month = '01', day = '01', hour = '00', minute = '00', second = '00', zone] = match;\n let offset = 'Z';\n if (zone && zone !== 'Z') {\n const digits = zone.replace(/'/g, '');\n offset = `${digits.slice(0, 3)}:${digits.slice(3, 5) || '00'}`;\n }\n const date = new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}${offset}`);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * A PDF dictionary's top-level keys and their values, each value normalized to single spaces so two definitions can be\n * compared. `undefined` when `value` is not a dictionary.\n */\nexport function parseDictionaryOrUndefined(value: string): Map<string, string> | undefined {\n if (!value.startsWith('<<')) return undefined;\n const tokens = new PdfTokenizer(value, 0, value.length);\n const entries = tokens.readDictionaryEntries();\n return entries;\n}\n\n/** A minimal PDF tokenizer: enough to delimit values (nested dictionaries, arrays, strings, references). */\nclass PdfTokenizer {\n position: number;\n\n constructor(private readonly text: string, from: number, private readonly end: number) {\n this.position = from;\n }\n\n skipWhitespace(): void {\n while (this.position < this.end) {\n const character = this.text[this.position]!;\n if (character === '%') {\n while (this.position < this.end && this.text[this.position] !== '\\n' && this.text[this.position] !== '\\r') this.position += 1;\n continue;\n }\n if (!/[\\s\\0]/.test(character)) return;\n this.position += 1;\n }\n }\n\n /** The dictionary at the cursor as key → normalized value; `undefined` when it is not one or is unterminated. */\n readDictionaryEntries(): Map<string, string> | undefined {\n this.skipWhitespace();\n if (!this.text.startsWith('<<', this.position)) return undefined;\n this.position += 2;\n const entries = new Map<string, string>();\n for (;;) {\n this.skipWhitespace();\n if (this.position >= this.end) return undefined;\n if (this.text.startsWith('>>', this.position)) {\n this.position += 2;\n return entries;\n }\n const key = this.readName();\n if (key === undefined) return undefined;\n const start = this.position;\n if (this.readValue() === undefined) return undefined;\n entries.set(key, this.text.slice(start, this.position).trim().replace(/\\s+/g, ' '));\n }\n }\n\n private readName(): string | undefined {\n this.skipWhitespace();\n if (this.text[this.position] !== '/') return undefined;\n const start = this.position;\n this.position += 1;\n while (this.position < this.end && !/[\\s\\0/<>[\\]()%{}]/.test(this.text[this.position]!)) this.position += 1;\n return this.text.slice(start, this.position);\n }\n\n /** Skip one value (an indirect reference counts as one). Answers `true`, or `undefined` when it does not delimit. */\n readValue(): true | undefined {\n this.skipWhitespace();\n if (this.position >= this.end) return undefined;\n const character = this.text[this.position]!;\n if (this.text.startsWith('<<', this.position)) {\n return this.readDictionaryEntries() === undefined ? undefined : true;\n }\n if (character === '<') {\n const close = this.text.indexOf('>', this.position);\n if (close < 0 || close >= this.end) return undefined;\n this.position = close + 1;\n return true;\n }\n if (character === '[') {\n this.position += 1;\n for (;;) {\n this.skipWhitespace();\n if (this.position >= this.end) return undefined;\n if (this.text[this.position] === ']') {\n this.position += 1;\n return true;\n }\n if (this.readValue() === undefined) return undefined;\n }\n }\n if (character === '(') return this.readLiteralString();\n if (character === '/') return this.readName() === undefined ? undefined : true;\n // A number, which may begin an indirect reference `N G R`, or a keyword.\n const number = /^[+-]?(\\d+\\.?\\d*|\\.\\d+)/.exec(this.text.slice(this.position, Math.min(this.end, this.position + 32)));\n if (number) {\n this.position += number[0].length;\n const reference = /^\\s+\\d+\\s+R(?![A-Za-z])/.exec(this.text.slice(this.position, Math.min(this.end, this.position + 32)));\n if (reference && /^\\d+$/.test(number[0])) this.position += reference[0].length;\n return true;\n }\n const keyword = /^[A-Za-z]+/.exec(this.text.slice(this.position, Math.min(this.end, this.position + 16)));\n if (keyword) {\n this.position += keyword[0].length;\n return true;\n }\n return undefined;\n }\n\n private readLiteralString(): true | undefined {\n let depth = 0;\n while (this.position < this.end) {\n const character = this.text[this.position]!;\n if (character === '\\\\') {\n this.position += 2;\n continue;\n }\n if (character === '(') depth += 1;\n if (character === ')') {\n depth -= 1;\n if (depth === 0) {\n this.position += 1;\n return true;\n }\n }\n this.position += 1;\n }\n return undefined;\n }\n}\n"]}
|
package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.d.ts
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import type { LoggerService } from '../../monitoring/logger/services/logger.service';
|
|
2
2
|
import type { FilesBackendService } from '../../files/services/files.backend.service';
|
|
3
3
|
import type { ExecutionContextCreatorBackendService } from '../../runtime/services/execution-context-creator.backend.service';
|
|
4
|
+
import type { RepositoriesRegistryHandlerBackendService } from '../../base-classes/services/repositories/repositories-registry-handler.backend.service';
|
|
4
5
|
import type { ResourcesRegistryBackendService } from '../../resources/services/resources-registry.backend.service';
|
|
5
6
|
import { type ServerProducedFileWriterDependencies } from '../../files/services/server-produced-file-writer.backend';
|
|
6
|
-
/**
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* What one link of an evidence file to its SIGNED request did. Total over the file's states: the caller decides from it
|
|
9
|
+
* whether a later poll must try again.
|
|
10
|
+
*/
|
|
11
|
+
export declare enum SignatureRequestEvidenceLinkOutcome {
|
|
12
|
+
/** Linked now. */
|
|
13
|
+
LINKED = "linked",
|
|
14
|
+
/** Already linked to this request and field (a later poll's link, or an earlier one that succeeded). */
|
|
15
|
+
ALREADY_LINKED = "already_linked",
|
|
16
|
+
/** Not linkable yet: its scan (or its upload) has not ended. A later poll links it. */
|
|
17
|
+
NOT_YET_LINKABLE = "not_yet_linkable",
|
|
18
|
+
/** The link failed for a reason that may pass (the store could not be read or written). A later poll tries again. */
|
|
19
|
+
FAILED = "failed",
|
|
20
|
+
/**
|
|
21
|
+
* It can never be this request's: gone, or in a state no link leaves (infected, quarantined, failed, deleted, orphaned),
|
|
22
|
+
* or linked to another record. The request names evidence that is not kept.
|
|
23
|
+
*/
|
|
24
|
+
LOST = "lost"
|
|
25
|
+
}
|
|
26
|
+
/** The outcomes a later poll must link again. */
|
|
27
|
+
export declare const SIGNATURE_EVIDENCE_LINK_RETRIED: ReadonlySet<SignatureRequestEvidenceLinkOutcome>;
|
|
8
28
|
/** The request's two evidence fields. */
|
|
9
29
|
export declare enum SignatureRequestEvidenceField {
|
|
10
30
|
/** The signed document the vendor returned. */
|
|
@@ -22,8 +42,8 @@ export interface SignatureRequestEvidenceFiles {
|
|
|
22
42
|
readonly mimeType: string;
|
|
23
43
|
readonly filename: string;
|
|
24
44
|
}): Promise<string>;
|
|
25
|
-
/** Link a file the request names to it, so the teardown and the holds find it. Never throws. */
|
|
26
|
-
link(fileId: string, request: Readonly<Record<string, unknown>>, field: SignatureRequestEvidenceField): Promise<
|
|
45
|
+
/** Link a file the request names to it, so the teardown and the holds find it, and answer what happened. Never throws. */
|
|
46
|
+
link(fileId: string, request: Readonly<Record<string, unknown>>, field: SignatureRequestEvidenceField): Promise<SignatureRequestEvidenceLinkOutcome>;
|
|
27
47
|
/** Delete a file whose request move was lost. Never throws: an unlinked file is the cleanup's otherwise. */
|
|
28
48
|
discard(fileId: string): Promise<void>;
|
|
29
49
|
}
|
|
@@ -33,10 +53,14 @@ export declare class SignatureRequestEvidenceFilesBackendService implements Sign
|
|
|
33
53
|
private readonly fileWriter;
|
|
34
54
|
private readonly files;
|
|
35
55
|
private readonly contexts;
|
|
56
|
+
/** The file's state, read as the inbound-email receiver reads its stored files: the infrastructure read, no access check. */
|
|
57
|
+
private readonly repositories;
|
|
36
58
|
private readonly resources?;
|
|
37
|
-
constructor(logger: Pick<LoggerService, '
|
|
59
|
+
constructor(logger: Pick<LoggerService, 'warn'>, fileWriter: ServerProducedFileWriterDependencies, files: Pick<FilesBackendService, 'linkFileToResource' | 'deleteDetachedFile'>, contexts: Pick<ExecutionContextCreatorBackendService, 'createForInternalOperation'>,
|
|
60
|
+
/** The file's state, read as the inbound-email receiver reads its stored files: the infrastructure read, no access check. */
|
|
61
|
+
repositories: Pick<RepositoriesRegistryHandlerBackendService, 'readUnscopedByKey'>, resources?: Pick<ResourcesRegistryBackendService, 'getServiceOperationPathDefault'>);
|
|
38
62
|
write(input: Parameters<SignatureRequestEvidenceFiles['write']>[0]): Promise<string>;
|
|
39
|
-
link(fileId: string, request: Readonly<Record<string, unknown>>, field: SignatureRequestEvidenceField): Promise<
|
|
63
|
+
link(fileId: string, request: Readonly<Record<string, unknown>>, field: SignatureRequestEvidenceField): Promise<SignatureRequestEvidenceLinkOutcome>;
|
|
40
64
|
discard(fileId: string): Promise<void>;
|
|
41
65
|
/** The application's own context for these files, as a super-administrator would act (the relay's). */
|
|
42
66
|
private internalContext;
|
package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-request-evidence-files.backend.d.ts","sourceRoot":"","sources":["../../../../src/compliance/electronic-signatures/signature-request-evidence-files.backend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signature-request-evidence-files.backend.d.ts","sourceRoot":"","sources":["../../../../src/compliance/electronic-signatures/signature-request-evidence-files.backend.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yDAAyD,C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