@wildo-ai/platform-config-lib 1.1.10 → 1.1.12
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/_unimplemented/soft-warn.d.ts +24 -49
- package/dist/esm/_unimplemented/soft-warn.d.ts.map +1 -1
- package/dist/esm/_unimplemented/soft-warn.js +24 -49
- package/dist/esm/_unimplemented/soft-warn.js.map +1 -1
- package/dist/esm/blueprint/anchored-region.d.ts +83 -0
- package/dist/esm/blueprint/anchored-region.d.ts.map +1 -0
- package/dist/esm/blueprint/anchored-region.js +263 -0
- package/dist/esm/blueprint/anchored-region.js.map +1 -0
- package/dist/esm/blueprint/blueprint.schemas.d.ts +600 -0
- package/dist/esm/blueprint/blueprint.schemas.d.ts.map +1 -0
- package/dist/esm/blueprint/blueprint.schemas.js +638 -0
- package/dist/esm/blueprint/blueprint.schemas.js.map +1 -0
- package/dist/esm/bootstrap/application-backend-env.contracts.js.map +1 -1
- package/dist/esm/bootstrap/application-creation-verification-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/application-creation-verification-env.contracts.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap-planner.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts +13 -1
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.js +6 -0
- package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts +29 -4
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.js +29 -4
- package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +131 -2
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js +139 -2
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
- package/dist/esm/bootstrap/platform-store-preconnect.d.ts +21 -0
- package/dist/esm/bootstrap/platform-store-preconnect.d.ts.map +1 -1
- package/dist/esm/bootstrap/platform-store-preconnect.js +25 -0
- package/dist/esm/bootstrap/platform-store-preconnect.js.map +1 -1
- package/dist/esm/bootstrap/postgresql-owed-grants.contracts.d.ts +80 -0
- package/dist/esm/bootstrap/postgresql-owed-grants.contracts.d.ts.map +1 -0
- package/dist/esm/bootstrap/postgresql-owed-grants.contracts.js +81 -0
- package/dist/esm/bootstrap/postgresql-owed-grants.contracts.js.map +1 -0
- package/dist/esm/bootstrap/runtime-backing-service-access.d.ts +41 -9
- package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-backing-service-access.js +77 -28
- package/dist/esm/bootstrap/runtime-backing-service-access.js.map +1 -1
- package/dist/esm/bootstrap/runtime-network-policy.d.ts +117 -12
- package/dist/esm/bootstrap/runtime-network-policy.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-network-policy.js +222 -23
- package/dist/esm/bootstrap/runtime-network-policy.js.map +1 -1
- package/dist/esm/bootstrap/runtime-network-topology.d.ts +31 -4
- package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-network-topology.js +43 -2
- package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
- package/dist/esm/bootstrap/runtime-platform-access.js.map +1 -1
- package/dist/esm/bootstrap/runtime-principal.contracts.d.ts +40 -2
- package/dist/esm/bootstrap/runtime-principal.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-principal.contracts.js +66 -3
- package/dist/esm/bootstrap/runtime-principal.contracts.js.map +1 -1
- package/dist/esm/bootstrap/runtime-response-integrity.d.ts +249 -0
- package/dist/esm/bootstrap/runtime-response-integrity.d.ts.map +1 -0
- package/dist/esm/bootstrap/runtime-response-integrity.js +353 -0
- package/dist/esm/bootstrap/runtime-response-integrity.js.map +1 -0
- package/dist/esm/bootstrap/runtime-secret-env.contracts.d.ts +32 -0
- package/dist/esm/bootstrap/runtime-secret-env.contracts.d.ts.map +1 -0
- package/dist/esm/bootstrap/runtime-secret-env.contracts.js +43 -0
- package/dist/esm/bootstrap/runtime-secret-env.contracts.js.map +1 -0
- package/dist/esm/bootstrap/runtime-topology.contracts.js.map +1 -1
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.js.map +1 -1
- package/dist/esm/canonical-json/rfc8785-canonical-json.d.ts +51 -0
- package/dist/esm/canonical-json/rfc8785-canonical-json.d.ts.map +1 -0
- package/dist/esm/canonical-json/rfc8785-canonical-json.js +231 -0
- package/dist/esm/canonical-json/rfc8785-canonical-json.js.map +1 -0
- package/dist/esm/config-authoring.entry.js.map +1 -1
- package/dist/esm/credentials/credential-generator.service.d.ts.map +1 -1
- package/dist/esm/credentials/credential-generator.service.js.map +1 -1
- package/dist/esm/index.d.ts +20 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +20 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/key-management/application-legacy-envelope-key.contracts.d.ts +119 -0
- package/dist/esm/key-management/application-legacy-envelope-key.contracts.d.ts.map +1 -0
- package/dist/esm/key-management/application-legacy-envelope-key.contracts.js +109 -0
- package/dist/esm/key-management/application-legacy-envelope-key.contracts.js.map +1 -0
- package/dist/esm/key-management/application-signing-key-rotation.contracts.d.ts +182 -0
- package/dist/esm/key-management/application-signing-key-rotation.contracts.d.ts.map +1 -0
- package/dist/esm/key-management/application-signing-key-rotation.contracts.js +145 -0
- package/dist/esm/key-management/application-signing-key-rotation.contracts.js.map +1 -0
- package/dist/esm/key-management/approval-seal-manifested-copy.d.ts +156 -0
- package/dist/esm/key-management/approval-seal-manifested-copy.d.ts.map +1 -0
- package/dist/esm/key-management/approval-seal-manifested-copy.js +617 -0
- package/dist/esm/key-management/approval-seal-manifested-copy.js.map +1 -0
- package/dist/esm/key-management/approval-seal-verifier.d.ts +278 -0
- package/dist/esm/key-management/approval-seal-verifier.d.ts.map +1 -0
- package/dist/esm/key-management/approval-seal-verifier.js +355 -0
- package/dist/esm/key-management/approval-seal-verifier.js.map +1 -0
- package/dist/esm/key-management/approval-seal.contracts.d.ts +128 -0
- package/dist/esm/key-management/approval-seal.contracts.d.ts.map +1 -0
- package/dist/esm/key-management/approval-seal.contracts.js +135 -0
- package/dist/esm/key-management/approval-seal.contracts.js.map +1 -0
- package/dist/esm/key-management/data-key.contracts.d.ts +106 -0
- package/dist/esm/key-management/data-key.contracts.d.ts.map +1 -0
- package/dist/esm/key-management/data-key.contracts.js +54 -0
- package/dist/esm/key-management/data-key.contracts.js.map +1 -0
- package/dist/esm/key-management/es256-jws.d.ts +60 -0
- package/dist/esm/key-management/es256-jws.d.ts.map +1 -0
- package/dist/esm/key-management/es256-jws.js +135 -0
- package/dist/esm/key-management/es256-jws.js.map +1 -0
- package/dist/esm/key-management/key-provider.spi.d.ts +158 -0
- package/dist/esm/key-management/key-provider.spi.d.ts.map +1 -0
- package/dist/esm/key-management/key-provider.spi.js +38 -0
- package/dist/esm/key-management/key-provider.spi.js.map +1 -0
- package/dist/esm/key-management/keyring-rotation.contracts.d.ts +83 -0
- package/dist/esm/key-management/keyring-rotation.contracts.d.ts.map +1 -0
- package/dist/esm/key-management/keyring-rotation.contracts.js +101 -0
- package/dist/esm/key-management/keyring-rotation.contracts.js.map +1 -0
- package/dist/esm/key-management/keyring-status.contracts.d.ts +59 -0
- package/dist/esm/key-management/keyring-status.contracts.d.ts.map +1 -0
- package/dist/esm/key-management/keyring-status.contracts.js +45 -0
- package/dist/esm/key-management/keyring-status.contracts.js.map +1 -0
- package/dist/esm/key-management/pdf-incremental-update.d.ts +158 -0
- package/dist/esm/key-management/pdf-incremental-update.d.ts.map +1 -0
- package/dist/esm/key-management/pdf-incremental-update.js +730 -0
- package/dist/esm/key-management/pdf-incremental-update.js.map +1 -0
- package/dist/esm/key-management/pdf-truetype-font.d.ts +35 -0
- package/dist/esm/key-management/pdf-truetype-font.d.ts.map +1 -0
- package/dist/esm/key-management/pdf-truetype-font.js +152 -0
- package/dist/esm/key-management/pdf-truetype-font.js.map +1 -0
- package/dist/esm/key-management/qr-code.d.ts +38 -0
- package/dist/esm/key-management/qr-code.d.ts.map +1 -0
- package/dist/esm/key-management/qr-code.js +325 -0
- package/dist/esm/key-management/qr-code.js.map +1 -0
- package/dist/esm/key-management/signature-request.contracts.d.ts +91 -0
- package/dist/esm/key-management/signature-request.contracts.d.ts.map +1 -0
- package/dist/esm/key-management/signature-request.contracts.js +96 -0
- package/dist/esm/key-management/signature-request.contracts.js.map +1 -0
- package/dist/esm/key-management/signing-log-export.contracts.d.ts +215 -0
- package/dist/esm/key-management/signing-log-export.contracts.d.ts.map +1 -0
- package/dist/esm/key-management/signing-log-export.contracts.js +268 -0
- package/dist/esm/key-management/signing-log-export.contracts.js.map +1 -0
- package/dist/esm/key-management/vault-custody.contracts.d.ts +98 -0
- package/dist/esm/key-management/vault-custody.contracts.d.ts.map +1 -0
- package/dist/esm/key-management/vault-custody.contracts.js +154 -0
- package/dist/esm/key-management/vault-custody.contracts.js.map +1 -0
- package/dist/esm/lockfile/build-parallelism.d.ts.map +1 -1
- package/dist/esm/lockfile/build-parallelism.js.map +1 -1
- package/dist/esm/lockfile/canonical-json.d.ts +1 -1
- package/dist/esm/lockfile/canonical-json.d.ts.map +1 -1
- package/dist/esm/lockfile/canonical-json.js +1 -1
- package/dist/esm/lockfile/canonical-json.js.map +1 -1
- package/dist/esm/lockfile/file-lock-hold.d.ts.map +1 -1
- package/dist/esm/lockfile/file-lock-hold.js +2 -1
- package/dist/esm/lockfile/file-lock-hold.js.map +1 -1
- package/dist/esm/lockfile/lockfile-io.d.ts +13 -17
- package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -1
- package/dist/esm/lockfile/lockfile-io.js +29 -30
- package/dist/esm/lockfile/lockfile-io.js.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.d.ts +22 -20
- package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.js +13 -14
- package/dist/esm/lockfile/materialize-infra-section.js.map +1 -1
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts +27 -249
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js +28 -3
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
- package/dist/esm/pnpm-settings/application-pnpm-settings.d.ts +146 -0
- package/dist/esm/pnpm-settings/application-pnpm-settings.d.ts.map +1 -0
- package/dist/esm/pnpm-settings/application-pnpm-settings.js +573 -0
- package/dist/esm/pnpm-settings/application-pnpm-settings.js.map +1 -0
- package/dist/esm/project-config/application-public-pricing-catalog.loader.d.ts.map +1 -1
- package/dist/esm/project-config/application-public-pricing-catalog.loader.js +22 -3
- package/dist/esm/project-config/application-public-pricing-catalog.loader.js.map +1 -1
- package/dist/esm/project-config/application-served-public-documents.loader.d.ts +26 -0
- package/dist/esm/project-config/application-served-public-documents.loader.d.ts.map +1 -0
- package/dist/esm/project-config/application-served-public-documents.loader.js +86 -0
- package/dist/esm/project-config/application-served-public-documents.loader.js.map +1 -0
- package/dist/esm/project-config/backend-compliance-section.reader.d.ts +35 -0
- package/dist/esm/project-config/backend-compliance-section.reader.d.ts.map +1 -0
- package/dist/esm/project-config/backend-compliance-section.reader.js +123 -0
- package/dist/esm/project-config/backend-compliance-section.reader.js.map +1 -0
- package/dist/esm/project-config/backend-compliance-section.worker.d.ts +20 -0
- package/dist/esm/project-config/backend-compliance-section.worker.d.ts.map +1 -0
- package/dist/esm/project-config/backend-compliance-section.worker.js +78 -0
- package/dist/esm/project-config/backend-compliance-section.worker.js.map +1 -0
- package/dist/esm/project-config/config-module-resolution.d.ts +32 -0
- package/dist/esm/project-config/config-module-resolution.d.ts.map +1 -0
- package/dist/esm/project-config/config-module-resolution.js +33 -0
- package/dist/esm/project-config/config-module-resolution.js.map +1 -0
- package/dist/esm/project-config/define-framework-config.js.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.d.ts +344 -69
- package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.js +194 -143
- package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
- package/dist/esm/project-config/define-minion-config.d.ts +26 -36
- package/dist/esm/project-config/define-minion-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-minion-config.js +64 -25
- package/dist/esm/project-config/define-minion-config.js.map +1 -1
- package/dist/esm/project-config/define-saas-config.d.ts +82 -348
- package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-saas-config.js +262 -103
- package/dist/esm/project-config/define-saas-config.js.map +1 -1
- package/dist/esm/project-config/define-worker-config.d.ts +10 -20
- package/dist/esm/project-config/define-worker-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-worker-config.js +10 -12
- package/dist/esm/project-config/define-worker-config.js.map +1 -1
- package/dist/esm/project-config/hosted-infra-env-config.d.ts.map +1 -1
- package/dist/esm/project-config/hosted-infra-env-config.js +4 -1
- package/dist/esm/project-config/hosted-infra-env-config.js.map +1 -1
- package/dist/esm/project-config/index.d.ts +5 -0
- package/dist/esm/project-config/index.d.ts.map +1 -1
- package/dist/esm/project-config/index.js +5 -0
- package/dist/esm/project-config/index.js.map +1 -1
- package/dist/esm/project-config/loader-instances-zod.d.ts +19 -0
- package/dist/esm/project-config/loader-instances-zod.d.ts.map +1 -0
- package/dist/esm/project-config/loader-instances-zod.js +40 -0
- package/dist/esm/project-config/loader-instances-zod.js.map +1 -0
- package/dist/esm/project-config/loader.d.ts +131 -14
- package/dist/esm/project-config/loader.d.ts.map +1 -1
- package/dist/esm/project-config/loader.js +226 -12
- package/dist/esm/project-config/loader.js.map +1 -1
- package/dist/esm/project-config/minion-liveness.contracts.d.ts +131 -0
- package/dist/esm/project-config/minion-liveness.contracts.d.ts.map +1 -0
- package/dist/esm/project-config/minion-liveness.contracts.js +167 -0
- package/dist/esm/project-config/minion-liveness.contracts.js.map +1 -0
- package/dist/esm/project-config/minion-local-provider-registration.d.ts.map +1 -1
- package/dist/esm/project-config/minion-local-provider-registration.js.map +1 -1
- package/dist/esm/project-config/npm-version-range.d.ts.map +1 -1
- package/dist/esm/project-config/npm-version-range.js +39 -16
- package/dist/esm/project-config/npm-version-range.js.map +1 -1
- package/dist/esm/project-config/owning-package-tsconfig.d.ts +15 -0
- package/dist/esm/project-config/owning-package-tsconfig.d.ts.map +1 -0
- package/dist/esm/project-config/owning-package-tsconfig.js +29 -0
- package/dist/esm/project-config/owning-package-tsconfig.js.map +1 -0
- package/dist/esm/project-config/provider-catalog-types.js.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.d.ts +4 -4
- package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.js +16 -10
- package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts +103 -49
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.js +216 -16
- package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
- package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts +0 -2
- package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/application-creation-verification.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/application-modules.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/application-modules.utils.js.map +1 -1
- package/dist/esm/project-config/shared/auth.schemas.d.ts +0 -17
- package/dist/esm/project-config/shared/auth.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/auth.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/backing-service-servability.js.map +1 -1
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts +9 -10
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/backing-services.schemas.js +13 -15
- package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/cdn.schemas.d.ts +0 -51
- package/dist/esm/project-config/shared/cdn.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/cdn.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/csp-defaults.d.ts +36 -9
- package/dist/esm/project-config/shared/csp-defaults.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp-defaults.js +54 -11
- package/dist/esm/project-config/shared/csp-defaults.js.map +1 -1
- package/dist/esm/project-config/shared/csp-emit.d.ts +60 -13
- package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp-emit.js +77 -24
- package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
- package/dist/esm/project-config/shared/csp.schemas.d.ts +72 -85
- package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp.schemas.js +40 -13
- package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/data-services.schemas.d.ts +0 -8
- package/dist/esm/project-config/shared/data-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/data-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/env-example-defaults.d.ts.map +1 -1
- package/dist/esm/project-config/shared/env-example-defaults.js.map +1 -1
- package/dist/esm/project-config/shared/environment.schemas.d.ts +101 -8
- package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/environment.schemas.js +128 -9
- package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +10 -4
- package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infra-service.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts +2 -1
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js +4 -1
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
- package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
- package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts.map +1 -1
- package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -1
- package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts +24 -0
- package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts.map +1 -1
- package/dist/esm/project-config/shared/minion-resource-access.validation.js +25 -2
- package/dist/esm/project-config/shared/minion-resource-access.validation.js.map +1 -1
- package/dist/esm/project-config/shared/object-storage-session-policy.d.ts.map +1 -1
- package/dist/esm/project-config/shared/object-storage-session-policy.js.map +1 -1
- package/dist/esm/project-config/shared/platform-key-management.schemas.d.ts +276 -0
- package/dist/esm/project-config/shared/platform-key-management.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/platform-key-management.schemas.js +296 -0
- package/dist/esm/project-config/shared/platform-key-management.schemas.js.map +1 -0
- package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/platform-storage.schemas.d.ts +2 -2
- package/dist/esm/project-config/shared/platform-storage.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/platform-storage.schemas.js +16 -2
- package/dist/esm/project-config/shared/platform-storage.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/service-definitions.schemas.d.ts +21 -23
- package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/service-definitions.schemas.js +4 -5
- package/dist/esm/project-config/shared/service-definitions.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts +0 -18
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.js.map +1 -1
- package/dist/esm/project-config/static-asset-import-noop.d.ts +20 -3
- package/dist/esm/project-config/static-asset-import-noop.d.ts.map +1 -1
- package/dist/esm/project-config/static-asset-import-noop.js +36 -20
- package/dist/esm/project-config/static-asset-import-noop.js.map +1 -1
- package/dist/esm/registry/artifact-domain.schemas.d.ts +0 -5
- package/dist/esm/registry/artifact-domain.schemas.d.ts.map +1 -1
- package/dist/esm/registry/artifact-domain.schemas.js.map +1 -1
- package/dist/esm/registry/digest.schemas.js.map +1 -1
- package/dist/esm/registry/index.d.ts +3 -3
- package/dist/esm/registry/index.d.ts.map +1 -1
- package/dist/esm/registry/index.js +3 -3
- package/dist/esm/registry/index.js.map +1 -1
- package/dist/esm/registry/local-checkout-source.d.ts +22 -2
- package/dist/esm/registry/local-checkout-source.d.ts.map +1 -1
- package/dist/esm/registry/local-checkout-source.js +66 -3
- package/dist/esm/registry/local-checkout-source.js.map +1 -1
- package/dist/esm/registry/lockfile-modules-section.schemas.d.ts +11 -98
- package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -1
- package/dist/esm/registry/lockfile-modules-section.schemas.js +1 -2
- package/dist/esm/registry/lockfile-modules-section.schemas.js.map +1 -1
- package/dist/esm/registry/module-artifact.schemas.d.ts +40 -17
- package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-artifact.schemas.js.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.d.ts +324 -74
- package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.js +377 -19
- package/dist/esm/registry/module-manifest.schemas.js.map +1 -1
- package/dist/esm/registry/module-search.schemas.d.ts +2 -0
- package/dist/esm/registry/module-search.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-search.schemas.js +14 -1
- package/dist/esm/registry/module-search.schemas.js.map +1 -1
- package/dist/esm/registry/registry-config.schemas.d.ts +0 -18
- package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -1
- package/dist/esm/registry/registry-config.schemas.js.map +1 -1
- package/dist/esm/registry/registry-defaults.constants.d.ts.map +1 -1
- package/dist/esm/registry/registry-defaults.constants.js.map +1 -1
- package/dist/esm/registry/registry-errors.d.ts +103 -5
- package/dist/esm/registry/registry-errors.d.ts.map +1 -1
- package/dist/esm/registry/registry-errors.js +213 -6
- package/dist/esm/registry/registry-errors.js.map +1 -1
- package/dist/esm/registry/registry-keys.schemas.js.map +1 -1
- package/dist/esm/registry/registry-section-schemas.constants.d.ts +5 -0
- package/dist/esm/registry/registry-section-schemas.constants.d.ts.map +1 -1
- package/dist/esm/registry/registry-section-schemas.constants.js.map +1 -1
- package/dist/esm/registry/registry-url-resolution.d.ts +72 -0
- package/dist/esm/registry/registry-url-resolution.d.ts.map +1 -0
- package/dist/esm/registry/registry-url-resolution.js +157 -0
- package/dist/esm/registry/registry-url-resolution.js.map +1 -0
- package/dist/esm/release/framework-release.constants.d.ts.map +1 -1
- package/dist/esm/release/framework-release.constants.js.map +1 -1
- package/dist/esm/schemas/framework-info.schemas.js.map +1 -1
- package/dist/esm/schemas/framework-secrets.schemas.d.ts +48 -0
- package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/framework-secrets.schemas.js +53 -0
- package/dist/esm/schemas/framework-secrets.schemas.js.map +1 -1
- package/dist/esm/schemas/platform-application-config.schemas.d.ts +1 -1
- package/dist/esm/schemas/platform-application-config.schemas.js.map +1 -1
- package/dist/esm/schemas/platform-application-secrets.schemas.d.ts +1 -1
- package/dist/esm/schemas/platform-application-secrets.schemas.js.map +1 -1
- package/dist/esm/schemas/platform-config.schemas.d.ts +2 -2
- package/dist/esm/schemas/platform-config.schemas.js.map +1 -1
- package/dist/esm/workspace-scope/application-subject-manifest.js.map +1 -1
- package/dist/esm/workspace-scope/index.js.map +1 -1
- package/dist/esm/workspace-scope/resolve-homes.d.ts.map +1 -1
- package/dist/esm/workspace-scope/resolve-homes.js.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope-detector.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope-detector.js.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope.schemas.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/dist/esm/_unimplemented/index.d.ts +0 -3
- package/dist/esm/_unimplemented/index.d.ts.map +0 -1
- package/dist/esm/_unimplemented/index.js +0 -3
- package/dist/esm/_unimplemented/index.js.map +0 -1
- package/dist/esm/_unimplemented/unimplemented-field-warning.d.ts +0 -137
- package/dist/esm/_unimplemented/unimplemented-field-warning.d.ts.map +0 -1
- package/dist/esm/_unimplemented/unimplemented-field-warning.js +0 -153
- package/dist/esm/_unimplemented/unimplemented-field-warning.js.map +0 -1
- package/dist/esm/project-config/shared/cdn.example.d.ts +0 -14
- package/dist/esm/project-config/shared/cdn.example.d.ts.map +0 -1
- package/dist/esm/project-config/shared/cdn.example.js +0 -38
- package/dist/esm/project-config/shared/cdn.example.js.map +0 -1
- package/dist/esm/project-config/shared/schema-version.schemas.d.ts +0 -15
- package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +0 -1
- package/dist/esm/project-config/shared/schema-version.schemas.js +0 -40
- package/dist/esm/project-config/shared/schema-version.schemas.js.map +0 -1
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # A QR code, encoded deterministically (#2907)
|
|
3
|
+
*
|
|
4
|
+
* The manifested copy of an approved document prints a QR code linking to the application's public verification route
|
|
5
|
+
* with the seal's JWS. The copy's verifier rebuilds the copy byte for byte, so it has to rebuild the code as well, from
|
|
6
|
+
* the same input, with the same choices: this encoder is a pure function of its text and its error-correction level, and
|
|
7
|
+
* makes every choice the standard leaves to the encoder in a fixed way (byte mode, the smallest version that fits, the
|
|
8
|
+
* mask with the lowest penalty, the lowest such mask on a tie). A dependency would have tied every verifier to one
|
|
9
|
+
* release of a third party's choices; this one is ours and is pinned by its tests.
|
|
10
|
+
*
|
|
11
|
+
* The algorithm follows Project Nayuki's QR Code generator (MIT), reimplemented. The error-correction block tables are
|
|
12
|
+
* those of ISO/IEC 18004 as the `qrcode` package (MIT) lists them.
|
|
13
|
+
*
|
|
14
|
+
* spec-cite: ISO/IEC 18004:2015 §7.4.5 (byte mode), §7.5 (error correction, Tables 9), §7.7 (placement), §7.8 (masking
|
|
15
|
+
* and the penalty rules), §7.9 (format information), §7.10 (version information). Cited by section.
|
|
16
|
+
*/
|
|
17
|
+
/** The error-correction levels this encoder offers. */
|
|
18
|
+
export var QrErrorCorrection;
|
|
19
|
+
(function (QrErrorCorrection) {
|
|
20
|
+
/** About 7% of the codewords recoverable. */
|
|
21
|
+
QrErrorCorrection["LOW"] = "low";
|
|
22
|
+
/** About 15%: what a printed code usually takes. */
|
|
23
|
+
QrErrorCorrection["MEDIUM"] = "medium";
|
|
24
|
+
})(QrErrorCorrection || (QrErrorCorrection = {}));
|
|
25
|
+
/** Text too long for any version at the level asked for. */
|
|
26
|
+
export class QrCodeTooLongError extends Error {
|
|
27
|
+
bytes;
|
|
28
|
+
constructor(bytes) {
|
|
29
|
+
super(`A QR code cannot hold ${bytes} bytes at this error-correction level`);
|
|
30
|
+
this.bytes = bytes;
|
|
31
|
+
this.name = 'QrCodeTooLongError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const ECC_BLOCKS = {
|
|
35
|
+
[QrErrorCorrection.LOW]: [1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
|
36
|
+
[QrErrorCorrection.MEDIUM]: [1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
|
|
37
|
+
};
|
|
38
|
+
const ECC_TOTAL = {
|
|
39
|
+
[QrErrorCorrection.LOW]: [7, 10, 15, 20, 26, 36, 40, 48, 60, 72, 80, 96, 104, 120, 132, 144, 168, 180, 196, 224, 224, 252, 270, 300, 312, 336, 360, 390, 420, 450, 480, 510, 540, 570, 570, 600, 630, 660, 720, 750],
|
|
40
|
+
[QrErrorCorrection.MEDIUM]: [10, 16, 26, 36, 48, 64, 72, 88, 110, 130, 150, 176, 198, 216, 240, 280, 308, 338, 364, 416, 442, 476, 504, 560, 588, 644, 700, 728, 784, 812, 868, 924, 980, 1036, 1064, 1120, 1204, 1260, 1316, 1372],
|
|
41
|
+
};
|
|
42
|
+
/** The two format bits of each level (§7.9.1): L is 01, M is 00. */
|
|
43
|
+
const FORMAT_BITS = { [QrErrorCorrection.LOW]: 1, [QrErrorCorrection.MEDIUM]: 0 };
|
|
44
|
+
/** Modules a version leaves for data and error correction, after every function pattern. */
|
|
45
|
+
function rawDataModules(version) {
|
|
46
|
+
let result = (16 * version + 128) * version + 64;
|
|
47
|
+
if (version >= 2) {
|
|
48
|
+
const alignments = Math.floor(version / 7) + 2;
|
|
49
|
+
result -= (25 * alignments - 10) * alignments - 55;
|
|
50
|
+
if (version >= 7)
|
|
51
|
+
result -= 36;
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
function dataCodewords(version, level) {
|
|
56
|
+
return Math.floor(rawDataModules(version) / 8) - ECC_TOTAL[level][version - 1];
|
|
57
|
+
}
|
|
58
|
+
/** The centres of the alignment patterns along one axis. */
|
|
59
|
+
function alignmentPositions(version) {
|
|
60
|
+
if (version === 1)
|
|
61
|
+
return [];
|
|
62
|
+
const count = Math.floor(version / 7) + 2;
|
|
63
|
+
const step = Math.floor((version * 8 + count * 3 + 5) / (count * 4 - 4)) * 2;
|
|
64
|
+
const positions = [6];
|
|
65
|
+
for (let position = version * 4 + 17 - 7; positions.length < count; position -= step)
|
|
66
|
+
positions.splice(1, 0, position);
|
|
67
|
+
return positions;
|
|
68
|
+
}
|
|
69
|
+
/** GF(256) with the QR polynomial 0x11D. */
|
|
70
|
+
function gfMultiply(x, y) {
|
|
71
|
+
let result = 0;
|
|
72
|
+
for (let bit = 7; bit >= 0; bit -= 1) {
|
|
73
|
+
result = (result << 1) ^ ((result >>> 7) * 0x11d);
|
|
74
|
+
result ^= ((y >>> bit) & 1) * x;
|
|
75
|
+
}
|
|
76
|
+
return result & 0xff;
|
|
77
|
+
}
|
|
78
|
+
function reedSolomonDivisor(degree) {
|
|
79
|
+
const result = new Array(degree).fill(0);
|
|
80
|
+
result[degree - 1] = 1;
|
|
81
|
+
let root = 1;
|
|
82
|
+
for (let index = 0; index < degree; index += 1) {
|
|
83
|
+
for (let term = 0; term < degree; term += 1) {
|
|
84
|
+
result[term] = gfMultiply(result[term], root);
|
|
85
|
+
if (term + 1 < degree)
|
|
86
|
+
result[term] ^= result[term + 1];
|
|
87
|
+
}
|
|
88
|
+
root = gfMultiply(root, 0x02);
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
function reedSolomonRemainder(data, divisor) {
|
|
93
|
+
const result = divisor.map(() => 0);
|
|
94
|
+
for (const byte of data) {
|
|
95
|
+
const factor = byte ^ result.shift();
|
|
96
|
+
result.push(0);
|
|
97
|
+
divisor.forEach((coefficient, index) => { result[index] ^= gfMultiply(coefficient, factor); });
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
/** Encode `text` (UTF-8, byte mode) at `level`. Throws {@link QrCodeTooLongError}. */
|
|
102
|
+
export function encodeQrCode(text, level) {
|
|
103
|
+
const bytes = Buffer.from(text, 'utf8');
|
|
104
|
+
let version = 1;
|
|
105
|
+
for (; version <= 40; version += 1) {
|
|
106
|
+
const countBits = version <= 9 ? 8 : 16;
|
|
107
|
+
if (4 + countBits + bytes.length * 8 <= dataCodewords(version, level) * 8)
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
if (version > 40)
|
|
111
|
+
throw new QrCodeTooLongError(bytes.length);
|
|
112
|
+
// The bit stream: mode, count, data, terminator, padding.
|
|
113
|
+
const bits = [];
|
|
114
|
+
const append = (value, length) => { for (let bit = length - 1; bit >= 0; bit -= 1)
|
|
115
|
+
bits.push((value >>> bit) & 1); };
|
|
116
|
+
append(0b0100, 4);
|
|
117
|
+
append(bytes.length, version <= 9 ? 8 : 16);
|
|
118
|
+
for (const byte of bytes)
|
|
119
|
+
append(byte, 8);
|
|
120
|
+
const capacity = dataCodewords(version, level) * 8;
|
|
121
|
+
append(0, Math.min(4, capacity - bits.length));
|
|
122
|
+
append(0, (8 - (bits.length % 8)) % 8);
|
|
123
|
+
for (let pad = 0xec; bits.length < capacity; pad ^= 0xec ^ 0x11)
|
|
124
|
+
append(pad, 8);
|
|
125
|
+
const data = [];
|
|
126
|
+
for (let index = 0; index < bits.length; index += 8)
|
|
127
|
+
data.push(bits.slice(index, index + 8).reduce((byte, bit) => (byte << 1) | bit, 0));
|
|
128
|
+
// Blocks, each with its error correction, interleaved (§7.6).
|
|
129
|
+
const blocks = ECC_BLOCKS[level][version - 1];
|
|
130
|
+
const eccPerBlock = ECC_TOTAL[level][version - 1] / blocks;
|
|
131
|
+
const raw = Math.floor(rawDataModules(version) / 8);
|
|
132
|
+
const shortBlocks = blocks - (raw % blocks);
|
|
133
|
+
const shortLength = Math.floor(raw / blocks);
|
|
134
|
+
const divisor = reedSolomonDivisor(eccPerBlock);
|
|
135
|
+
const blockData = [];
|
|
136
|
+
for (let block = 0, at = 0; block < blocks; block += 1) {
|
|
137
|
+
const dataLength = shortLength - eccPerBlock + (block < shortBlocks ? 0 : 1);
|
|
138
|
+
const slice = data.slice(at, at + dataLength);
|
|
139
|
+
at += dataLength;
|
|
140
|
+
const ecc = reedSolomonRemainder(slice, divisor);
|
|
141
|
+
if (block < shortBlocks)
|
|
142
|
+
slice.push(-1);
|
|
143
|
+
blockData.push([...slice, ...ecc]);
|
|
144
|
+
}
|
|
145
|
+
const codewords = [];
|
|
146
|
+
for (let index = 0; index < blockData[0].length; index += 1) {
|
|
147
|
+
blockData.forEach((block, blockIndex) => {
|
|
148
|
+
if (index !== shortLength - eccPerBlock || blockIndex >= shortBlocks)
|
|
149
|
+
codewords.push(block[index]);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const size = version * 4 + 17;
|
|
153
|
+
const modules = Array.from({ length: size }, () => new Array(size).fill(false));
|
|
154
|
+
const isFunction = Array.from({ length: size }, () => new Array(size).fill(false));
|
|
155
|
+
const set = (x, y, dark) => { modules[y][x] = dark; isFunction[y][x] = true; };
|
|
156
|
+
// Function patterns.
|
|
157
|
+
for (let index = 0; index < size; index += 1) {
|
|
158
|
+
set(6, index, index % 2 === 0);
|
|
159
|
+
set(index, 6, index % 2 === 0);
|
|
160
|
+
}
|
|
161
|
+
const finder = (cx, cy) => {
|
|
162
|
+
for (let dy = -4; dy <= 4; dy += 1)
|
|
163
|
+
for (let dx = -4; dx <= 4; dx += 1) {
|
|
164
|
+
const distance = Math.max(Math.abs(dx), Math.abs(dy));
|
|
165
|
+
const x = cx + dx;
|
|
166
|
+
const y = cy + dy;
|
|
167
|
+
if (x >= 0 && x < size && y >= 0 && y < size)
|
|
168
|
+
set(x, y, distance !== 2 && distance !== 4);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
finder(3, 3);
|
|
172
|
+
finder(size - 4, 3);
|
|
173
|
+
finder(3, size - 4);
|
|
174
|
+
const positions = alignmentPositions(version);
|
|
175
|
+
positions.forEach((ax, i) => positions.forEach((ay, j) => {
|
|
176
|
+
if ((i === 0 && j === 0) || (i === 0 && j === positions.length - 1) || (i === positions.length - 1 && j === 0))
|
|
177
|
+
return;
|
|
178
|
+
for (let dy = -2; dy <= 2; dy += 1)
|
|
179
|
+
for (let dx = -2; dx <= 2; dx += 1)
|
|
180
|
+
set(ax + dx, ay + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
|
|
181
|
+
}));
|
|
182
|
+
const drawFormat = (mask) => {
|
|
183
|
+
const formatData = (FORMAT_BITS[level] << 3) | mask;
|
|
184
|
+
let remainder = formatData;
|
|
185
|
+
for (let index = 0; index < 10; index += 1)
|
|
186
|
+
remainder = (remainder << 1) ^ ((remainder >>> 9) * 0x537);
|
|
187
|
+
const formatBits = ((formatData << 10) | remainder) ^ 0x5412;
|
|
188
|
+
const bit = (index) => ((formatBits >>> index) & 1) !== 0;
|
|
189
|
+
for (let index = 0; index <= 5; index += 1)
|
|
190
|
+
set(8, index, bit(index));
|
|
191
|
+
set(8, 7, bit(6));
|
|
192
|
+
set(8, 8, bit(7));
|
|
193
|
+
set(7, 8, bit(8));
|
|
194
|
+
for (let index = 9; index < 15; index += 1)
|
|
195
|
+
set(14 - index, 8, bit(index));
|
|
196
|
+
for (let index = 0; index < 8; index += 1)
|
|
197
|
+
set(size - 1 - index, 8, bit(index));
|
|
198
|
+
for (let index = 8; index < 15; index += 1)
|
|
199
|
+
set(8, size - 15 + index, bit(index));
|
|
200
|
+
set(8, size - 8, true);
|
|
201
|
+
};
|
|
202
|
+
drawFormat(0);
|
|
203
|
+
if (version >= 7) {
|
|
204
|
+
let remainder = version;
|
|
205
|
+
for (let index = 0; index < 12; index += 1)
|
|
206
|
+
remainder = (remainder << 1) ^ ((remainder >>> 11) * 0x1f25);
|
|
207
|
+
const versionBits = (version << 12) | remainder;
|
|
208
|
+
for (let index = 0; index < 18; index += 1) {
|
|
209
|
+
const dark = ((versionBits >>> index) & 1) !== 0;
|
|
210
|
+
const a = size - 11 + (index % 3);
|
|
211
|
+
const b = Math.floor(index / 3);
|
|
212
|
+
set(a, b, dark);
|
|
213
|
+
set(b, a, dark);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Codeword placement, zigzag from the bottom right (§7.7.3).
|
|
217
|
+
let bitIndex = 0;
|
|
218
|
+
for (let right = size - 1; right >= 1; right -= 2) {
|
|
219
|
+
if (right === 6)
|
|
220
|
+
right = 5;
|
|
221
|
+
for (let vertical = 0; vertical < size; vertical += 1) {
|
|
222
|
+
for (let column = 0; column < 2; column += 1) {
|
|
223
|
+
const x = right - column;
|
|
224
|
+
const upward = ((right + 1) & 2) === 0;
|
|
225
|
+
const y = upward ? size - 1 - vertical : vertical;
|
|
226
|
+
if (!isFunction[y][x] && bitIndex < codewords.length * 8) {
|
|
227
|
+
modules[y][x] = ((codewords[bitIndex >>> 3] >>> (7 - (bitIndex & 7))) & 1) !== 0;
|
|
228
|
+
bitIndex += 1;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const applyMask = (mask) => {
|
|
234
|
+
for (let y = 0; y < size; y += 1)
|
|
235
|
+
for (let x = 0; x < size; x += 1) {
|
|
236
|
+
if (isFunction[y][x])
|
|
237
|
+
continue;
|
|
238
|
+
const invert = [
|
|
239
|
+
(x + y) % 2 === 0, y % 2 === 0, x % 3 === 0, (x + y) % 3 === 0,
|
|
240
|
+
(Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0, ((x * y) % 2) + ((x * y) % 3) === 0,
|
|
241
|
+
(((x * y) % 2) + ((x * y) % 3)) % 2 === 0, (((x + y) % 2) + ((x * y) % 3)) % 2 === 0,
|
|
242
|
+
][mask];
|
|
243
|
+
if (invert)
|
|
244
|
+
modules[y][x] = !modules[y][x];
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
let best = 0;
|
|
248
|
+
let bestPenalty = Infinity;
|
|
249
|
+
for (let mask = 0; mask < 8; mask += 1) {
|
|
250
|
+
applyMask(mask);
|
|
251
|
+
drawFormat(mask);
|
|
252
|
+
const penalty = penaltyOf(modules, size);
|
|
253
|
+
if (penalty < bestPenalty) {
|
|
254
|
+
best = mask;
|
|
255
|
+
bestPenalty = penalty;
|
|
256
|
+
}
|
|
257
|
+
applyMask(mask);
|
|
258
|
+
}
|
|
259
|
+
applyMask(best);
|
|
260
|
+
drawFormat(best);
|
|
261
|
+
return { version, size, mask: best, dark: (x, y) => modules[y][x] };
|
|
262
|
+
}
|
|
263
|
+
/** The mask penalty of §7.8.3: runs, 2×2 blocks, finder-like patterns, dark balance. */
|
|
264
|
+
function penaltyOf(modules, size) {
|
|
265
|
+
let result = 0;
|
|
266
|
+
const addHistory = (length, history) => {
|
|
267
|
+
if (history[0] === 0)
|
|
268
|
+
length += size;
|
|
269
|
+
history.pop();
|
|
270
|
+
history.unshift(length);
|
|
271
|
+
};
|
|
272
|
+
const countPatterns = (history) => {
|
|
273
|
+
const n = history[1];
|
|
274
|
+
const core = n > 0 && history[2] === n && history[3] === n * 3 && history[4] === n && history[5] === n;
|
|
275
|
+
return (core && history[0] >= n * 4 && history[6] >= n ? 1 : 0) + (core && history[6] >= n * 4 && history[0] >= n ? 1 : 0);
|
|
276
|
+
};
|
|
277
|
+
const terminate = (color, length, history) => {
|
|
278
|
+
if (color) {
|
|
279
|
+
addHistory(length, history);
|
|
280
|
+
length = 0;
|
|
281
|
+
}
|
|
282
|
+
addHistory(length + size, history);
|
|
283
|
+
return countPatterns(history);
|
|
284
|
+
};
|
|
285
|
+
for (const horizontal of [true, false]) {
|
|
286
|
+
for (let line = 0; line < size; line += 1) {
|
|
287
|
+
let color = false;
|
|
288
|
+
let run = 0;
|
|
289
|
+
const history = [0, 0, 0, 0, 0, 0, 0];
|
|
290
|
+
for (let along = 0; along < size; along += 1) {
|
|
291
|
+
const module = horizontal ? modules[line][along] : modules[along][line];
|
|
292
|
+
if (module === color) {
|
|
293
|
+
run += 1;
|
|
294
|
+
if (run === 5)
|
|
295
|
+
result += 3;
|
|
296
|
+
else if (run > 5)
|
|
297
|
+
result += 1;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
addHistory(run, history);
|
|
301
|
+
if (!color)
|
|
302
|
+
result += countPatterns(history) * 40;
|
|
303
|
+
color = module;
|
|
304
|
+
run = 1;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
result += terminate(color, run, history) * 40;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
let dark = 0;
|
|
311
|
+
for (let y = 0; y < size; y += 1)
|
|
312
|
+
for (let x = 0; x < size; x += 1) {
|
|
313
|
+
if (modules[y][x])
|
|
314
|
+
dark += 1;
|
|
315
|
+
if (x < size - 1 && y < size - 1) {
|
|
316
|
+
const color = modules[y][x];
|
|
317
|
+
if (color === modules[y][x + 1] && color === modules[y + 1][x] && color === modules[y + 1][x + 1])
|
|
318
|
+
result += 3;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const total = size * size;
|
|
322
|
+
result += (Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1) * 10;
|
|
323
|
+
return result;
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=qr-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-code.js","sourceRoot":"","sources":["../../../src/key-management/qr-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,uDAAuD;AACvD,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,6CAA6C;IAC7C,gCAAW,CAAA;IACX,oDAAoD;IACpD,sCAAiB,CAAA;AACnB,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AAUD,4DAA4D;AAC5D,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACtB;IAArB,YAAqB,KAAa;QAChC,KAAK,CAAC,yBAAyB,KAAK,uCAAuC,CAAC,CAAC;QAD1D,UAAK,GAAL,KAAK,CAAQ;QAEhC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CA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,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;QAChD,CAAC;IACH,CAAC;IACD,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC;QAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACnE,IAAI,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC;gBAAE,IAAI,IAAI,CAAC,CAAC;YAC9B,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;gBACjC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC;gBAC7B,IAAI,KAAK,KAAK,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,GAAG,CAAC,CAAC;oBAAE,MAAM,IAAI,CAAC,CAAC;YACpH,CAAC;QACH,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,KAAK,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACzE,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * # A QR code, encoded deterministically (#2907)\n *\n * The manifested copy of an approved document prints a QR code linking to the application's public verification route\n * with the seal's JWS. The copy's verifier rebuilds the copy byte for byte, so it has to rebuild the code as well, from\n * the same input, with the same choices: this encoder is a pure function of its text and its error-correction level, and\n * makes every choice the standard leaves to the encoder in a fixed way (byte mode, the smallest version that fits, the\n * mask with the lowest penalty, the lowest such mask on a tie). A dependency would have tied every verifier to one\n * release of a third party's choices; this one is ours and is pinned by its tests.\n *\n * The algorithm follows Project Nayuki's QR Code generator (MIT), reimplemented. The error-correction block tables are\n * those of ISO/IEC 18004 as the `qrcode` package (MIT) lists them.\n *\n * spec-cite: ISO/IEC 18004:2015 §7.4.5 (byte mode), §7.5 (error correction, Tables 9), §7.7 (placement), §7.8 (masking\n * and the penalty rules), §7.9 (format information), §7.10 (version information). Cited by section.\n */\n\n/** The error-correction levels this encoder offers. */\nexport enum QrErrorCorrection {\n /** About 7% of the codewords recoverable. */\n LOW = 'low',\n /** About 15%: what a printed code usually takes. */\n MEDIUM = 'medium',\n}\n\n/** A QR code: `size` × `size` modules, `dark(x, y)` true for a dark module. */\nexport interface QrCode {\n readonly version: number;\n readonly size: number;\n readonly mask: number;\n dark(x: number, y: number): boolean;\n}\n\n/** Text too long for any version at the level asked for. */\nexport class QrCodeTooLongError extends Error {\n constructor(readonly bytes: number) {\n super(`A QR code cannot hold ${bytes} bytes at this error-correction level`);\n this.name = 'QrCodeTooLongError';\n }\n}\n\nconst ECC_BLOCKS: Record<QrErrorCorrection, readonly number[]> = {\n [QrErrorCorrection.LOW]: [1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],\n [QrErrorCorrection.MEDIUM]: [1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],\n};\nconst ECC_TOTAL: Record<QrErrorCorrection, readonly number[]> = {\n [QrErrorCorrection.LOW]: [7, 10, 15, 20, 26, 36, 40, 48, 60, 72, 80, 96, 104, 120, 132, 144, 168, 180, 196, 224, 224, 252, 270, 300, 312, 336, 360, 390, 420, 450, 480, 510, 540, 570, 570, 600, 630, 660, 720, 750],\n [QrErrorCorrection.MEDIUM]: [10, 16, 26, 36, 48, 64, 72, 88, 110, 130, 150, 176, 198, 216, 240, 280, 308, 338, 364, 416, 442, 476, 504, 560, 588, 644, 700, 728, 784, 812, 868, 924, 980, 1036, 1064, 1120, 1204, 1260, 1316, 1372],\n};\n/** The two format bits of each level (§7.9.1): L is 01, M is 00. */\nconst FORMAT_BITS: Record<QrErrorCorrection, number> = { [QrErrorCorrection.LOW]: 1, [QrErrorCorrection.MEDIUM]: 0 };\n\n/** Modules a version leaves for data and error correction, after every function pattern. */\nfunction rawDataModules(version: number): number {\n let result = (16 * version + 128) * version + 64;\n if (version >= 2) {\n const alignments = Math.floor(version / 7) + 2;\n result -= (25 * alignments - 10) * alignments - 55;\n if (version >= 7) result -= 36;\n }\n return result;\n}\n\nfunction dataCodewords(version: number, level: QrErrorCorrection): number {\n return Math.floor(rawDataModules(version) / 8) - ECC_TOTAL[level][version - 1]!;\n}\n\n/** The centres of the alignment patterns along one axis. */\nfunction alignmentPositions(version: number): number[] {\n if (version === 1) return [];\n const count = Math.floor(version / 7) + 2;\n const step = Math.floor((version * 8 + count * 3 + 5) / (count * 4 - 4)) * 2;\n const positions = [6];\n for (let position = version * 4 + 17 - 7; positions.length < count; position -= step) positions.splice(1, 0, position);\n return positions;\n}\n\n/** GF(256) with the QR polynomial 0x11D. */\nfunction gfMultiply(x: number, y: number): number {\n let result = 0;\n for (let bit = 7; bit >= 0; bit -= 1) {\n result = (result << 1) ^ ((result >>> 7) * 0x11d);\n result ^= ((y >>> bit) & 1) * x;\n }\n return result & 0xff;\n}\n\nfunction reedSolomonDivisor(degree: number): number[] {\n const result = new Array<number>(degree).fill(0);\n result[degree - 1] = 1;\n let root = 1;\n for (let index = 0; index < degree; index += 1) {\n for (let term = 0; term < degree; term += 1) {\n result[term] = gfMultiply(result[term]!, root);\n if (term + 1 < degree) result[term] ^= result[term + 1]!;\n }\n root = gfMultiply(root, 0x02);\n }\n return result;\n}\n\nfunction reedSolomonRemainder(data: readonly number[], divisor: readonly number[]): number[] {\n const result = divisor.map(() => 0);\n for (const byte of data) {\n const factor = byte ^ result.shift()!;\n result.push(0);\n divisor.forEach((coefficient, index) => { result[index] ^= gfMultiply(coefficient, factor); });\n }\n return result;\n}\n\n/** Encode `text` (UTF-8, byte mode) at `level`. Throws {@link QrCodeTooLongError}. */\nexport function encodeQrCode(text: string, level: QrErrorCorrection): QrCode {\n const bytes = Buffer.from(text, 'utf8');\n let version = 1;\n for (; version <= 40; version += 1) {\n const countBits = version <= 9 ? 8 : 16;\n if (4 + countBits + bytes.length * 8 <= dataCodewords(version, level) * 8) break;\n }\n if (version > 40) throw new QrCodeTooLongError(bytes.length);\n\n // The bit stream: mode, count, data, terminator, padding.\n const bits: number[] = [];\n const append = (value: number, length: number) => { for (let bit = length - 1; bit >= 0; bit -= 1) bits.push((value >>> bit) & 1); };\n append(0b0100, 4);\n append(bytes.length, version <= 9 ? 8 : 16);\n for (const byte of bytes) append(byte, 8);\n const capacity = dataCodewords(version, level) * 8;\n append(0, Math.min(4, capacity - bits.length));\n append(0, (8 - (bits.length % 8)) % 8);\n for (let pad = 0xec; bits.length < capacity; pad ^= 0xec ^ 0x11) append(pad, 8);\n const data: number[] = [];\n for (let index = 0; index < bits.length; index += 8) data.push(bits.slice(index, index + 8).reduce((byte, bit) => (byte << 1) | bit, 0));\n\n // Blocks, each with its error correction, interleaved (§7.6).\n const blocks = ECC_BLOCKS[level][version - 1]!;\n const eccPerBlock = ECC_TOTAL[level][version - 1]! / blocks;\n const raw = Math.floor(rawDataModules(version) / 8);\n const shortBlocks = blocks - (raw % blocks);\n const shortLength = Math.floor(raw / blocks);\n const divisor = reedSolomonDivisor(eccPerBlock);\n const blockData: number[][] = [];\n for (let block = 0, at = 0; block < blocks; block += 1) {\n const dataLength = shortLength - eccPerBlock + (block < shortBlocks ? 0 : 1);\n const slice = data.slice(at, at + dataLength);\n at += dataLength;\n const ecc = reedSolomonRemainder(slice, divisor);\n if (block < shortBlocks) slice.push(-1);\n blockData.push([...slice, ...ecc]);\n }\n const codewords: number[] = [];\n for (let index = 0; index < blockData[0]!.length; index += 1) {\n blockData.forEach((block, blockIndex) => {\n if (index !== shortLength - eccPerBlock || blockIndex >= shortBlocks) codewords.push(block[index]!);\n });\n }\n\n const size = version * 4 + 17;\n const modules: boolean[][] = Array.from({ length: size }, () => new Array<boolean>(size).fill(false));\n const isFunction: boolean[][] = Array.from({ length: size }, () => new Array<boolean>(size).fill(false));\n const set = (x: number, y: number, dark: boolean) => { modules[y]![x] = dark; isFunction[y]![x] = true; };\n\n // Function patterns.\n for (let index = 0; index < size; index += 1) { set(6, index, index % 2 === 0); set(index, 6, index % 2 === 0); }\n const finder = (cx: number, cy: number) => {\n for (let dy = -4; dy <= 4; dy += 1) for (let dx = -4; dx <= 4; dx += 1) {\n const distance = Math.max(Math.abs(dx), Math.abs(dy));\n const x = cx + dx;\n const y = cy + dy;\n if (x >= 0 && x < size && y >= 0 && y < size) set(x, y, distance !== 2 && distance !== 4);\n }\n };\n finder(3, 3); finder(size - 4, 3); finder(3, size - 4);\n const positions = alignmentPositions(version);\n positions.forEach((ax, i) => positions.forEach((ay, j) => {\n if ((i === 0 && j === 0) || (i === 0 && j === positions.length - 1) || (i === positions.length - 1 && j === 0)) return;\n for (let dy = -2; dy <= 2; dy += 1) for (let dx = -2; dx <= 2; dx += 1) set(ax + dx, ay + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);\n }));\n const drawFormat = (mask: number) => {\n const formatData = (FORMAT_BITS[level] << 3) | mask;\n let remainder = formatData;\n for (let index = 0; index < 10; index += 1) remainder = (remainder << 1) ^ ((remainder >>> 9) * 0x537);\n const formatBits = ((formatData << 10) | remainder) ^ 0x5412;\n const bit = (index: number) => ((formatBits >>> index) & 1) !== 0;\n for (let index = 0; index <= 5; index += 1) set(8, index, bit(index));\n set(8, 7, bit(6)); set(8, 8, bit(7)); set(7, 8, bit(8));\n for (let index = 9; index < 15; index += 1) set(14 - index, 8, bit(index));\n for (let index = 0; index < 8; index += 1) set(size - 1 - index, 8, bit(index));\n for (let index = 8; index < 15; index += 1) set(8, size - 15 + index, bit(index));\n set(8, size - 8, true);\n };\n drawFormat(0);\n if (version >= 7) {\n let remainder = version;\n for (let index = 0; index < 12; index += 1) remainder = (remainder << 1) ^ ((remainder >>> 11) * 0x1f25);\n const versionBits = (version << 12) | remainder;\n for (let index = 0; index < 18; index += 1) {\n const dark = ((versionBits >>> index) & 1) !== 0;\n const a = size - 11 + (index % 3);\n const b = Math.floor(index / 3);\n set(a, b, dark); set(b, a, dark);\n }\n }\n\n // Codeword placement, zigzag from the bottom right (§7.7.3).\n let bitIndex = 0;\n for (let right = size - 1; right >= 1; right -= 2) {\n if (right === 6) right = 5;\n for (let vertical = 0; vertical < size; vertical += 1) {\n for (let column = 0; column < 2; column += 1) {\n const x = right - column;\n const upward = ((right + 1) & 2) === 0;\n const y = upward ? size - 1 - vertical : vertical;\n if (!isFunction[y]![x] && bitIndex < codewords.length * 8) {\n modules[y]![x] = ((codewords[bitIndex >>> 3]! >>> (7 - (bitIndex & 7))) & 1) !== 0;\n bitIndex += 1;\n }\n }\n }\n }\n\n const applyMask = (mask: number) => {\n for (let y = 0; y < size; y += 1) for (let x = 0; x < size; x += 1) {\n if (isFunction[y]![x]) continue;\n const invert = [\n (x + y) % 2 === 0, y % 2 === 0, x % 3 === 0, (x + y) % 3 === 0,\n (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0, ((x * y) % 2) + ((x * y) % 3) === 0,\n (((x * y) % 2) + ((x * y) % 3)) % 2 === 0, (((x + y) % 2) + ((x * y) % 3)) % 2 === 0,\n ][mask]!;\n if (invert) modules[y]![x] = !modules[y]![x];\n }\n };\n let best = 0;\n let bestPenalty = Infinity;\n for (let mask = 0; mask < 8; mask += 1) {\n applyMask(mask);\n drawFormat(mask);\n const penalty = penaltyOf(modules, size);\n if (penalty < bestPenalty) { best = mask; bestPenalty = penalty; }\n applyMask(mask);\n }\n applyMask(best);\n drawFormat(best);\n return { version, size, mask: best, dark: (x, y) => modules[y]![x]! };\n}\n\n/** The mask penalty of §7.8.3: runs, 2×2 blocks, finder-like patterns, dark balance. */\nfunction penaltyOf(modules: readonly boolean[][], size: number): number {\n let result = 0;\n const addHistory = (length: number, history: number[]) => {\n if (history[0] === 0) length += size;\n history.pop();\n history.unshift(length);\n };\n const countPatterns = (history: readonly number[]) => {\n const n = history[1]!;\n const core = n > 0 && history[2] === n && history[3] === n * 3 && history[4] === n && history[5] === n;\n return (core && history[0]! >= n * 4 && history[6]! >= n ? 1 : 0) + (core && history[6]! >= n * 4 && history[0]! >= n ? 1 : 0);\n };\n const terminate = (color: boolean, length: number, history: number[]) => {\n if (color) { addHistory(length, history); length = 0; }\n addHistory(length + size, history);\n return countPatterns(history);\n };\n for (const horizontal of [true, false]) {\n for (let line = 0; line < size; line += 1) {\n let color = false;\n let run = 0;\n const history = [0, 0, 0, 0, 0, 0, 0];\n for (let along = 0; along < size; along += 1) {\n const module = horizontal ? modules[line]![along]! : modules[along]![line]!;\n if (module === color) {\n run += 1;\n if (run === 5) result += 3;\n else if (run > 5) result += 1;\n } else {\n addHistory(run, history);\n if (!color) result += countPatterns(history) * 40;\n color = module;\n run = 1;\n }\n }\n result += terminate(color, run, history) * 40;\n }\n }\n let dark = 0;\n for (let y = 0; y < size; y += 1) for (let x = 0; x < size; x += 1) {\n if (modules[y]![x]) dark += 1;\n if (x < size - 1 && y < size - 1) {\n const color = modules[y]![x];\n if (color === modules[y]![x + 1] && color === modules[y + 1]![x] && color === modules[y + 1]![x + 1]) result += 3;\n }\n }\n const total = size * size;\n result += (Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1) * 10;\n return result;\n}\n"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CryptoKey_Purpose, type RateLimitConfiguration } from '@wildo-ai/saas-models';
|
|
3
|
+
/**
|
|
4
|
+
* # Asking the platform custodian for a signature (#2891)
|
|
5
|
+
*
|
|
6
|
+
* An application backend never holds a platform-custody key. It asks apps-manager, the custodian, to sign claims for a
|
|
7
|
+
* purpose, and apps-manager decides everything that makes the signature mean something: the issuer (from the
|
|
8
|
+
* application's own record), the key version (`kid`), the media type (`typ`) and the signing instant (`iat`). The request
|
|
9
|
+
* carries only what the application decided, the CLAIMS, and the digest of them it recorded when the decision committed.
|
|
10
|
+
*
|
|
11
|
+
* Both sides import this module, so the digest the application records at commit and the one the custodian recomputes
|
|
12
|
+
* are the same function.
|
|
13
|
+
*/
|
|
14
|
+
/** The media type of an approval seal's JWS (`typ` header, RFC 7515 §4.1.9): its purpose's, from the descriptor. */
|
|
15
|
+
export declare const APPROVAL_SEAL_JWS_TYPE: string;
|
|
16
|
+
/**
|
|
17
|
+
* The claims the custodian sets itself, which a request may never carry: an application that could set `iss` could
|
|
18
|
+
* issue in another application's name, and one that could set `iat` could date its own seals. Refused rather than
|
|
19
|
+
* overwritten, so a caller that tries learns it.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CUSTODIAN_SET_CLAIMS: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* How far a decision may be dated AFTER the signing instant: the two clocks are different machines. Five minutes, the
|
|
24
|
+
* customary leeway for JWT time claims (RFC 7519 §4.1.4 leaves it to the implementer; five minutes is what major JWT
|
|
25
|
+
* libraries and identity providers default to).
|
|
26
|
+
*/
|
|
27
|
+
export declare const SIGNATURE_CLOCK_SKEW_TOLERANCE_SECONDS: number;
|
|
28
|
+
/**
|
|
29
|
+
* How long a request may be retried as the SAME request: the outbox that relays seals (#2903) gives up on a row after
|
|
30
|
+
* this age and marks it DEAD. Within it, the same claims get the signature already made back; past it, a re-drive is
|
|
31
|
+
* signed anew. Also the grace a retired key version keeps its private material for.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SIGNATURE_REQUEST_MAXIMUM_RETRY_AGE_SECONDS: number;
|
|
34
|
+
/** The longest apps-manager outage the platform is designed to absorb without an operator. */
|
|
35
|
+
export declare const LONGEST_SUPPORTED_CUSTODIAN_OUTAGE_SECONDS: number;
|
|
36
|
+
/**
|
|
37
|
+
* A decision older than this when it is signed is sealed with `lateSeal: true`, which the verifier shows. Longer than
|
|
38
|
+
* the retry age plus the longest supported outage, so no seal the normal path produces is late; a late seal is a
|
|
39
|
+
* re-driven DEAD one. An old decision is never refused: refusing would leave it with no seal at all.
|
|
40
|
+
*/
|
|
41
|
+
export declare const LATE_SEAL_BOUND_SECONDS: number;
|
|
42
|
+
/**
|
|
43
|
+
* How often one application runtime may ask: per application and principal. A ceiling against a runaway loop, set well
|
|
44
|
+
* above any decision volume a person produces; bulk decisions are one seal over a list (#2903). A refusal for rate is
|
|
45
|
+
* retryable, never DEAD.
|
|
46
|
+
*/
|
|
47
|
+
export declare const SIGNATURE_REQUEST_RATE_LIMIT: RateLimitConfiguration;
|
|
48
|
+
/**
|
|
49
|
+
* The approval seal's request claims, as far as the custodian checks them (#2891). The full seal shape is #2903's
|
|
50
|
+
* `ApprovalSealClaims`; the custodian needs only what it decides on: the seal's id, when the decision was taken, and
|
|
51
|
+
* the tenant (which selects an organization-scoped key). Other members pass through unchanged, and are covered by the
|
|
52
|
+
* decision-payload digest.
|
|
53
|
+
*/
|
|
54
|
+
export declare const ApprovalSealRequestClaimsSchema: z.ZodObject<{
|
|
55
|
+
jti: z.ZodString;
|
|
56
|
+
decidedAt: z.ZodNumber;
|
|
57
|
+
tenant: z.ZodString;
|
|
58
|
+
}, z.core.$loose>;
|
|
59
|
+
export type ApprovalSealRequestClaims = z.infer<typeof ApprovalSealRequestClaimsSchema>;
|
|
60
|
+
/** The claims schema of each purpose that may be requested. */
|
|
61
|
+
export declare const SIGNATURE_REQUEST_CLAIMS_SCHEMA_BY_PURPOSE: Readonly<Partial<Record<CryptoKey_Purpose, typeof ApprovalSealRequestClaimsSchema>>>;
|
|
62
|
+
/** The request body. */
|
|
63
|
+
export declare const SignatureRequestSchema: z.ZodObject<{
|
|
64
|
+
purpose: z.ZodEnum<typeof CryptoKey_Purpose>;
|
|
65
|
+
claims: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
66
|
+
decisionPayloadDigest: z.ZodString;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
export type SignatureRequest = z.infer<typeof SignatureRequestSchema>;
|
|
69
|
+
/** The answer: the compact JWS and what the custodian decided in it. */
|
|
70
|
+
export interface SignatureResponse {
|
|
71
|
+
readonly jws: string;
|
|
72
|
+
readonly kid: string;
|
|
73
|
+
readonly iss: string;
|
|
74
|
+
readonly iat: number;
|
|
75
|
+
/** {@link sealClaimsDigestOf} the signed claims: with `iss` and `jti`, the seal's identity (never the JWS bytes). */
|
|
76
|
+
readonly claimsDigest: string;
|
|
77
|
+
readonly lateSeal: boolean;
|
|
78
|
+
/** True when the same claims had been signed already, and that signature is returned. */
|
|
79
|
+
readonly replayed: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The decision-payload digest: over every claim the APPLICATION decided, i.e. the request claims (the custodian-set
|
|
83
|
+
* claims are excluded by construction, since a request may not carry them). Recorded at commit, recomputed by the
|
|
84
|
+
* custodian, and a mismatch is refused.
|
|
85
|
+
*/
|
|
86
|
+
export declare function decisionPayloadDigestOf(claims: Readonly<Record<string, unknown>>): string;
|
|
87
|
+
/** The signed claims' digest, custodian-set claims included: the seal's identity with (`iss`, `jti`). */
|
|
88
|
+
export declare function sealClaimsDigestOf(signedClaims: Readonly<Record<string, unknown>>): string;
|
|
89
|
+
/** The issuer the custodian sets for an application: a URN of its slug, which is stable and names no person. */
|
|
90
|
+
export declare function signatureIssuerOf(appSlug: string): string;
|
|
91
|
+
//# sourceMappingURL=signature-request.contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature-request.contracts.d.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AC,GAAG,EAAE,MAAM,CAAC;IACrB,qHAAqH;IACrH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAOD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAEzF;AAED,yGAAyG;AACzG,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAE1F;AAED,gHAAgH;AAChH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { singleJwsTypeOf, CryptoKey_Purpose } from '@wildo-ai/saas-models';
|
|
4
|
+
import { canonicalizeJson } from '../canonical-json/rfc8785-canonical-json.js';
|
|
5
|
+
import { base64url } from './es256-jws.js';
|
|
6
|
+
/**
|
|
7
|
+
* # Asking the platform custodian for a signature (#2891)
|
|
8
|
+
*
|
|
9
|
+
* An application backend never holds a platform-custody key. It asks apps-manager, the custodian, to sign claims for a
|
|
10
|
+
* purpose, and apps-manager decides everything that makes the signature mean something: the issuer (from the
|
|
11
|
+
* application's own record), the key version (`kid`), the media type (`typ`) and the signing instant (`iat`). The request
|
|
12
|
+
* carries only what the application decided, the CLAIMS, and the digest of them it recorded when the decision committed.
|
|
13
|
+
*
|
|
14
|
+
* Both sides import this module, so the digest the application records at commit and the one the custodian recomputes
|
|
15
|
+
* are the same function.
|
|
16
|
+
*/
|
|
17
|
+
/** The media type of an approval seal's JWS (`typ` header, RFC 7515 §4.1.9): its purpose's, from the descriptor. */
|
|
18
|
+
export const APPROVAL_SEAL_JWS_TYPE = singleJwsTypeOf(CryptoKey_Purpose.APPROVAL_SEAL);
|
|
19
|
+
/**
|
|
20
|
+
* The claims the custodian sets itself, which a request may never carry: an application that could set `iss` could
|
|
21
|
+
* issue in another application's name, and one that could set `iat` could date its own seals. Refused rather than
|
|
22
|
+
* overwritten, so a caller that tries learns it.
|
|
23
|
+
*/
|
|
24
|
+
export const CUSTODIAN_SET_CLAIMS = ['iss', 'iat', 'kid', 'typ', 'lateSeal'];
|
|
25
|
+
/**
|
|
26
|
+
* How far a decision may be dated AFTER the signing instant: the two clocks are different machines. Five minutes, the
|
|
27
|
+
* customary leeway for JWT time claims (RFC 7519 §4.1.4 leaves it to the implementer; five minutes is what major JWT
|
|
28
|
+
* libraries and identity providers default to).
|
|
29
|
+
*/
|
|
30
|
+
export const SIGNATURE_CLOCK_SKEW_TOLERANCE_SECONDS = 5 * 60;
|
|
31
|
+
/**
|
|
32
|
+
* How long a request may be retried as the SAME request: the outbox that relays seals (#2903) gives up on a row after
|
|
33
|
+
* this age and marks it DEAD. Within it, the same claims get the signature already made back; past it, a re-drive is
|
|
34
|
+
* signed anew. Also the grace a retired key version keeps its private material for.
|
|
35
|
+
*/
|
|
36
|
+
export const SIGNATURE_REQUEST_MAXIMUM_RETRY_AGE_SECONDS = 7 * 24 * 60 * 60;
|
|
37
|
+
/** The longest apps-manager outage the platform is designed to absorb without an operator. */
|
|
38
|
+
export const LONGEST_SUPPORTED_CUSTODIAN_OUTAGE_SECONDS = 3 * 24 * 60 * 60;
|
|
39
|
+
/**
|
|
40
|
+
* A decision older than this when it is signed is sealed with `lateSeal: true`, which the verifier shows. Longer than
|
|
41
|
+
* the retry age plus the longest supported outage, so no seal the normal path produces is late; a late seal is a
|
|
42
|
+
* re-driven DEAD one. An old decision is never refused: refusing would leave it with no seal at all.
|
|
43
|
+
*/
|
|
44
|
+
export const LATE_SEAL_BOUND_SECONDS = SIGNATURE_REQUEST_MAXIMUM_RETRY_AGE_SECONDS + LONGEST_SUPPORTED_CUSTODIAN_OUTAGE_SECONDS + 24 * 60 * 60;
|
|
45
|
+
/**
|
|
46
|
+
* How often one application runtime may ask: per application and principal. A ceiling against a runaway loop, set well
|
|
47
|
+
* above any decision volume a person produces; bulk decisions are one seal over a list (#2903). A refusal for rate is
|
|
48
|
+
* retryable, never DEAD.
|
|
49
|
+
*/
|
|
50
|
+
export const SIGNATURE_REQUEST_RATE_LIMIT = { requestsPerMinute: 600, requestsPerHour: 20_000 };
|
|
51
|
+
/**
|
|
52
|
+
* The approval seal's request claims, as far as the custodian checks them (#2891). The full seal shape is #2903's
|
|
53
|
+
* `ApprovalSealClaims`; the custodian needs only what it decides on: the seal's id, when the decision was taken, and
|
|
54
|
+
* the tenant (which selects an organization-scoped key). Other members pass through unchanged, and are covered by the
|
|
55
|
+
* decision-payload digest.
|
|
56
|
+
*/
|
|
57
|
+
export const ApprovalSealRequestClaimsSchema = z.looseObject({
|
|
58
|
+
/** The seal's id, minted at commit: at least 128 bits, base64url. With `iss` it is the idempotency key. */
|
|
59
|
+
jti: z.string().regex(/^[A-Za-z0-9_-]{22,}$/),
|
|
60
|
+
/** When the decision was taken, in seconds since the epoch. Distinct from `iat`, when it was signed. */
|
|
61
|
+
decidedAt: z.number().int().positive(),
|
|
62
|
+
/** The organization the decision was taken in. */
|
|
63
|
+
tenant: z.string().min(1),
|
|
64
|
+
});
|
|
65
|
+
/** The claims schema of each purpose that may be requested. */
|
|
66
|
+
export const SIGNATURE_REQUEST_CLAIMS_SCHEMA_BY_PURPOSE = {
|
|
67
|
+
[CryptoKey_Purpose.APPROVAL_SEAL]: ApprovalSealRequestClaimsSchema,
|
|
68
|
+
};
|
|
69
|
+
/** The request body. */
|
|
70
|
+
export const SignatureRequestSchema = z.strictObject({
|
|
71
|
+
purpose: z.enum(CryptoKey_Purpose),
|
|
72
|
+
claims: z.record(z.string(), z.unknown()),
|
|
73
|
+
/** {@link decisionPayloadDigestOf} the claims, as the application recorded it when the decision committed. */
|
|
74
|
+
decisionPayloadDigest: z.string().min(1),
|
|
75
|
+
});
|
|
76
|
+
/** SHA-256, base64url, over the RFC 8785 serialization of a JSON value. */
|
|
77
|
+
function jcsSha256(value) {
|
|
78
|
+
return base64url(createHash('sha256').update(canonicalizeJson(value), 'utf8').digest());
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The decision-payload digest: over every claim the APPLICATION decided, i.e. the request claims (the custodian-set
|
|
82
|
+
* claims are excluded by construction, since a request may not carry them). Recorded at commit, recomputed by the
|
|
83
|
+
* custodian, and a mismatch is refused.
|
|
84
|
+
*/
|
|
85
|
+
export function decisionPayloadDigestOf(claims) {
|
|
86
|
+
return jcsSha256(claims);
|
|
87
|
+
}
|
|
88
|
+
/** The signed claims' digest, custodian-set claims included: the seal's identity with (`iss`, `jti`). */
|
|
89
|
+
export function sealClaimsDigestOf(signedClaims) {
|
|
90
|
+
return jcsSha256(signedClaims);
|
|
91
|
+
}
|
|
92
|
+
/** The issuer the custodian sets for an application: a URN of its slug, which is stable and names no person. */
|
|
93
|
+
export function signatureIssuerOf(appSlug) {
|
|
94
|
+
return `urn:wildo:application:${appSlug}`;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=signature-request.contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature-request.contracts.js","sourceRoot":"","sources":["../../../src/key-management/signature-request.contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAA+B,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;GAUG;AAEH,oHAAoH;AACpH,MAAM,CAAC,MAA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C,MAAM,sBAAsB,GAAG,CAAC,CAAC,YAAY,CAAC;IACnD,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACzC,8GAA8G;IAC9G,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACzC,CAAC,CAAC;AAgBH,2EAA2E;AAC3E,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAC1F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAyC;IAC/E,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,kBAAkB,CAAC,YAA+C;IAChF,OAAO,SAAS,CAAC,YAAY,CAAC,CAAC;AACjC,CAAC;AAED,gHAAgH;AAChH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,yBAAyB,OAAO,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\nimport { z } from 'zod';\nimport { singleJwsTypeOf, CryptoKey_Purpose, type RateLimitConfiguration } from '@wildo-ai/saas-models';\nimport { canonicalizeJson } from '../canonical-json/rfc8785-canonical-json';\nimport { base64url } from './es256-jws';\n\n/**\n * # Asking the platform custodian for a signature (#2891)\n *\n * An application backend never holds a platform-custody key. It asks apps-manager, the custodian, to sign claims for a\n * purpose, and apps-manager decides everything that makes the signature mean something: the issuer (from the\n * application's own record), the key version (`kid`), the media type (`typ`) and the signing instant (`iat`). The request\n * carries only what the application decided, the CLAIMS, and the digest of them it recorded when the decision committed.\n *\n * Both sides import this module, so the digest the application records at commit and the one the custodian recomputes\n * are the same function.\n */\n\n/** The media type of an approval seal's JWS (`typ` header, RFC 7515 §4.1.9): its purpose's, from the descriptor. */\nexport const APPROVAL_SEAL_JWS_TYPE: string = singleJwsTypeOf(CryptoKey_Purpose.APPROVAL_SEAL);\n\n/**\n * The claims the custodian sets itself, which a request may never carry: an application that could set `iss` could\n * issue in another application's name, and one that could set `iat` could date its own seals. Refused rather than\n * overwritten, so a caller that tries learns it.\n */\nexport const CUSTODIAN_SET_CLAIMS: readonly string[] = ['iss', 'iat', 'kid', 'typ', 'lateSeal'];\n\n/**\n * How far a decision may be dated AFTER the signing instant: the two clocks are different machines. Five minutes, the\n * customary leeway for JWT time claims (RFC 7519 §4.1.4 leaves it to the implementer; five minutes is what major JWT\n * libraries and identity providers default to).\n */\nexport const SIGNATURE_CLOCK_SKEW_TOLERANCE_SECONDS = 5 * 60;\n\n/**\n * How long a request may be retried as the SAME request: the outbox that relays seals (#2903) gives up on a row after\n * this age and marks it DEAD. Within it, the same claims get the signature already made back; past it, a re-drive is\n * signed anew. Also the grace a retired key version keeps its private material for.\n */\nexport const SIGNATURE_REQUEST_MAXIMUM_RETRY_AGE_SECONDS = 7 * 24 * 60 * 60;\n\n/** The longest apps-manager outage the platform is designed to absorb without an operator. */\nexport const LONGEST_SUPPORTED_CUSTODIAN_OUTAGE_SECONDS = 3 * 24 * 60 * 60;\n\n/**\n * A decision older than this when it is signed is sealed with `lateSeal: true`, which the verifier shows. Longer than\n * the retry age plus the longest supported outage, so no seal the normal path produces is late; a late seal is a\n * re-driven DEAD one. An old decision is never refused: refusing would leave it with no seal at all.\n */\nexport const LATE_SEAL_BOUND_SECONDS = SIGNATURE_REQUEST_MAXIMUM_RETRY_AGE_SECONDS + LONGEST_SUPPORTED_CUSTODIAN_OUTAGE_SECONDS + 24 * 60 * 60;\n\n/**\n * How often one application runtime may ask: per application and principal. A ceiling against a runaway loop, set well\n * above any decision volume a person produces; bulk decisions are one seal over a list (#2903). A refusal for rate is\n * retryable, never DEAD.\n */\nexport const SIGNATURE_REQUEST_RATE_LIMIT: RateLimitConfiguration = { requestsPerMinute: 600, requestsPerHour: 20_000 };\n\n/**\n * The approval seal's request claims, as far as the custodian checks them (#2891). The full seal shape is #2903's\n * `ApprovalSealClaims`; the custodian needs only what it decides on: the seal's id, when the decision was taken, and\n * the tenant (which selects an organization-scoped key). Other members pass through unchanged, and are covered by the\n * decision-payload digest.\n */\nexport const ApprovalSealRequestClaimsSchema = z.looseObject({\n /** The seal's id, minted at commit: at least 128 bits, base64url. With `iss` it is the idempotency key. */\n jti: z.string().regex(/^[A-Za-z0-9_-]{22,}$/),\n /** When the decision was taken, in seconds since the epoch. Distinct from `iat`, when it was signed. */\n decidedAt: z.number().int().positive(),\n /** The organization the decision was taken in. */\n tenant: z.string().min(1),\n});\nexport type ApprovalSealRequestClaims = z.infer<typeof ApprovalSealRequestClaimsSchema>;\n\n/** The claims schema of each purpose that may be requested. */\nexport const SIGNATURE_REQUEST_CLAIMS_SCHEMA_BY_PURPOSE: Readonly<Partial<Record<CryptoKey_Purpose, typeof ApprovalSealRequestClaimsSchema>>> = {\n [CryptoKey_Purpose.APPROVAL_SEAL]: ApprovalSealRequestClaimsSchema,\n};\n\n/** The request body. */\nexport const SignatureRequestSchema = z.strictObject({\n purpose: z.enum(CryptoKey_Purpose),\n claims: z.record(z.string(), z.unknown()),\n /** {@link decisionPayloadDigestOf} the claims, as the application recorded it when the decision committed. */\n decisionPayloadDigest: z.string().min(1),\n});\nexport type SignatureRequest = z.infer<typeof SignatureRequestSchema>;\n\n/** The answer: the compact JWS and what the custodian decided in it. */\nexport interface SignatureResponse {\n readonly jws: string;\n readonly kid: string;\n readonly iss: string;\n readonly iat: number;\n /** {@link sealClaimsDigestOf} the signed claims: with `iss` and `jti`, the seal's identity (never the JWS bytes). */\n readonly claimsDigest: string;\n readonly lateSeal: boolean;\n /** True when the same claims had been signed already, and that signature is returned. */\n readonly replayed: boolean;\n}\n\n/** SHA-256, base64url, over the RFC 8785 serialization of a JSON value. */\nfunction jcsSha256(value: unknown): string {\n return base64url(createHash('sha256').update(canonicalizeJson(value), 'utf8').digest());\n}\n\n/**\n * The decision-payload digest: over every claim the APPLICATION decided, i.e. the request claims (the custodian-set\n * claims are excluded by construction, since a request may not carry them). Recorded at commit, recomputed by the\n * custodian, and a mismatch is refused.\n */\nexport function decisionPayloadDigestOf(claims: Readonly<Record<string, unknown>>): string {\n return jcsSha256(claims);\n}\n\n/** The signed claims' digest, custodian-set claims included: the seal's identity with (`iss`, `jti`). */\nexport function sealClaimsDigestOf(signedClaims: Readonly<Record<string, unknown>>): string {\n return jcsSha256(signedClaims);\n}\n\n/** The issuer the custodian sets for an application: a URN of its slug, which is stable and names no person. */\nexport function signatureIssuerOf(appSlug: string): string {\n return `urn:wildo:application:${appSlug}`;\n}\n"]}
|